source: rtems/c/src/lib/libcpu/i386/idtr.S @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[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
15BEGIN_CODE
16/*
17 * C callable function enabling to get easilly usable info from
18 * the actual value of IDT register.
19 *
20extern void i386_get_info_from_IDTR (interrupt_gate_descriptor** table,
21                                     unsigned* limit);
22 */
23PUBLIC (i386_get_info_from_IDTR)
24PUBLIC (i386_set_IDTR)
25PUBLIC (i386_get_info_from_GDTR)
26PUBLIC (i386_set_GDTR)
[42e243e]27
[67a2288]28SYM (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 *
50extern void i386_set_IDTR (interrupt_gate_descriptor* table,
51                           unsigned limit);
52 */
[42e243e]53SYM (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.
71extern void i386_get_info_from_GDTR (segment_descriptors** table,
72                                     unsigned* limit);
73 */
[42e243e]74
75SYM (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 */
88        movl    eax, (edx)
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!!!.
96 *   extern void i386_set_GDTR (segment_descriptors*, unsigned limit);
97 */
[42e243e]98SYM (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]113END_CODE
114
115END
Note: See TracBrowser for help on using the repository browser.