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

Last change on this file since 328bd35 was d885b2b2, checked in by Jan Dolezal <dolezj21@…>, on Nov 20, 2014 at 2:00:28 PM

i386: GDTR manipulation functions parameters changed to use explicit width types

  • Property mode set to 100644
File size: 2.9 KB
Line 
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
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13#include <rtems/asm.h>
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)
27
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 */
53SYM (i386_set_IDTR):
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                                     uint16_t* limit);
73 */
74
75SYM (i386_get_info_from_GDTR):
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        movw    ax, (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*, uint16_t limit);
97 */
98SYM (i386_set_GDTR):
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
112
113END_CODE
114
115END
Note: See TracBrowser for help on using the repository browser.