[67a2288] | 1 | /* cpu_asm.S |
---|
| 2 | * |
---|
| 3 | * This file contains all assembly code for the Intel i386 IDT |
---|
| 4 | * manipulation. |
---|
| 5 | * |
---|
| 6 | * COPYRIGHT (c) 1998 valette@crf.canon.fr |
---|
| 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 10 | * http://www.rtems.org/license/LICENSE. |
---|
[67a2288] | 11 | */ |
---|
| 12 | |
---|
[6caf92f8] | 13 | #include <rtems/asm.h> |
---|
[67a2288] | 14 | |
---|
| 15 | BEGIN_CODE |
---|
| 16 | /* |
---|
| 17 | * C callable function enabling to get easilly usable info from |
---|
| 18 | * the actual value of IDT register. |
---|
| 19 | * |
---|
| 20 | extern void i386_get_info_from_IDTR (interrupt_gate_descriptor** table, |
---|
| 21 | unsigned* limit); |
---|
| 22 | */ |
---|
| 23 | PUBLIC (i386_get_info_from_IDTR) |
---|
| 24 | PUBLIC (i386_set_IDTR) |
---|
| 25 | PUBLIC (i386_get_info_from_GDTR) |
---|
| 26 | PUBLIC (i386_set_GDTR) |
---|
[42e243e] | 27 | |
---|
[67a2288] | 28 | SYM (i386_get_info_from_IDTR): |
---|
| 29 | movl 4(esp), ecx /* get location where table address */ |
---|
| 30 | /* must be stored */ |
---|
| 31 | movl 8(esp), edx /* get location table size must be stored */ |
---|
| 32 | |
---|
| 33 | subl $6, esp /* let room to prepare 48 bit IDTR */ |
---|
| 34 | |
---|
| 35 | sidt (esp) /* get 48 bit IDTR value */ |
---|
| 36 | |
---|
| 37 | movl 2(esp), eax /* get base */ |
---|
| 38 | movl eax, (ecx) |
---|
| 39 | |
---|
| 40 | movzwl (esp), eax /* get limit */ |
---|
| 41 | movl eax, (edx) |
---|
| 42 | |
---|
| 43 | addl $6, esp /* restore %esp */ |
---|
| 44 | ret |
---|
| 45 | |
---|
| 46 | /* |
---|
| 47 | * C callable function enabling to change the value of IDT register. Must be called |
---|
| 48 | * with inmterrupt masked at processor level!!!. |
---|
| 49 | * |
---|
| 50 | extern void i386_set_IDTR (interrupt_gate_descriptor* table, |
---|
| 51 | unsigned limit); |
---|
| 52 | */ |
---|
[42e243e] | 53 | SYM (i386_set_IDTR): |
---|
[67a2288] | 54 | |
---|
| 55 | leal 4(esp), edx /* load in edx address of input */ |
---|
| 56 | /* parameter "table" */ |
---|
| 57 | |
---|
| 58 | movl (edx), eax /* load base into eax */ |
---|
| 59 | movl 4(edx), ecx /* load limit into ecx */ |
---|
| 60 | |
---|
| 61 | movw cx, (edx) /* prepare 48 bit pointer */ |
---|
| 62 | movl eax, 2(edx) |
---|
| 63 | |
---|
| 64 | lidt (edx) |
---|
| 65 | |
---|
| 66 | ret |
---|
| 67 | /* |
---|
| 68 | * |
---|
| 69 | * C callable function enabling to get easilly usable info from |
---|
| 70 | * the actual value of GDT register. |
---|
| 71 | extern void i386_get_info_from_GDTR (segment_descriptors** table, |
---|
[d885b2b2] | 72 | uint16_t* limit); |
---|
[67a2288] | 73 | */ |
---|
[42e243e] | 74 | |
---|
| 75 | SYM (i386_get_info_from_GDTR): |
---|
[67a2288] | 76 | movl 4(esp), ecx /* get location where table address */ |
---|
| 77 | /* must be stored */ |
---|
| 78 | movl 8(esp), edx /* get location table size must be stored */ |
---|
| 79 | |
---|
| 80 | subl $6, esp /* let room to prepare 48 bit GDTR */ |
---|
| 81 | |
---|
| 82 | sgdt (esp) /* get 48 bit GDTR value */ |
---|
| 83 | |
---|
| 84 | movl 2(esp), eax /* get base */ |
---|
| 85 | movl eax, (ecx) |
---|
| 86 | |
---|
| 87 | movzwl (esp), eax /* get limit */ |
---|
[d885b2b2] | 88 | movw ax, (edx) |
---|
[67a2288] | 89 | |
---|
| 90 | addl $6, esp /* restore %esp */ |
---|
| 91 | ret |
---|
| 92 | |
---|
| 93 | /* |
---|
| 94 | * C callable function enabling to change the value of GDT register. |
---|
| 95 | * Must be called with interrupts masked at processor level!!!. |
---|
[d885b2b2] | 96 | * extern void i386_set_GDTR (segment_descriptors*, uint16_t limit); |
---|
[67a2288] | 97 | */ |
---|
[42e243e] | 98 | SYM (i386_set_GDTR): |
---|
[67a2288] | 99 | |
---|
| 100 | leal 4(esp), edx /* load in edx address of input */ |
---|
| 101 | /* parameter "table" */ |
---|
| 102 | |
---|
| 103 | movl (edx), eax /* load base into eax */ |
---|
| 104 | movl 4(edx), ecx /* load limit into ecx */ |
---|
| 105 | |
---|
| 106 | movw cx, (edx) /* prepare 48 bit pointer */ |
---|
| 107 | movl eax, 2(edx) |
---|
| 108 | |
---|
| 109 | lgdt (edx) |
---|
| 110 | |
---|
| 111 | ret |
---|
[42e243e] | 112 | |
---|
[67a2288] | 113 | END_CODE |
---|
| 114 | |
---|
| 115 | END |
---|