1 | /* i386.h |
---|
2 | * |
---|
3 | * This include file contains information pertaining to the Intel |
---|
4 | * i386 processor. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1998. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * Copyright assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef __i386_h |
---|
18 | #define __i386_h |
---|
19 | |
---|
20 | #ifdef __cplusplus |
---|
21 | extern "C" { |
---|
22 | #endif |
---|
23 | |
---|
24 | /* |
---|
25 | * This section contains the information required to build |
---|
26 | * RTEMS for a particular member of the Intel i386 |
---|
27 | * family when executing in protected mode. It does |
---|
28 | * this by setting variables to indicate which implementation |
---|
29 | * dependent features are present in a particular member |
---|
30 | * of the family. |
---|
31 | * |
---|
32 | * Currently recognized: |
---|
33 | * i386_fp (i386 DX or SX w/i387) |
---|
34 | * i386_nofp (i386 DX or SX w/o i387) |
---|
35 | * i486dx |
---|
36 | * i486sx |
---|
37 | * pentium |
---|
38 | * |
---|
39 | * CPU Model Feature Flags: |
---|
40 | * |
---|
41 | * I386_HAS_BSWAP: Defined to "1" if the instruction for endian swapping |
---|
42 | * (bswap) should be used. This instruction appears to |
---|
43 | * be present in all i486's and above. |
---|
44 | * |
---|
45 | * I386_HAS_FPU: Defined to "1" if the CPU has an FPU. |
---|
46 | * |
---|
47 | */ |
---|
48 | |
---|
49 | #if defined(i386_fp) |
---|
50 | |
---|
51 | #define CPU_MODEL_NAME "i386 with i387" |
---|
52 | #define I386_HAS_BSWAP 0 |
---|
53 | |
---|
54 | #elif defined(i386_nofp) |
---|
55 | |
---|
56 | #define CPU_MODEL_NAME "i386 w/o i387" |
---|
57 | #define I386_HAS_FPU 0 |
---|
58 | #define I386_HAS_BSWAP 0 |
---|
59 | |
---|
60 | #elif defined(i486dx) |
---|
61 | |
---|
62 | #define CPU_MODEL_NAME "i486dx" |
---|
63 | |
---|
64 | #elif defined(i486sx) |
---|
65 | |
---|
66 | #define CPU_MODEL_NAME "i486sx" |
---|
67 | #define I386_HAS_FPU 0 |
---|
68 | |
---|
69 | #elif defined(pentium) |
---|
70 | |
---|
71 | #define CPU_MODEL_NAME "Pentium" |
---|
72 | |
---|
73 | #else |
---|
74 | |
---|
75 | #error "Unsupported CPU Model" |
---|
76 | |
---|
77 | #endif |
---|
78 | |
---|
79 | /* |
---|
80 | * Set default values for CPU model feature flags |
---|
81 | * |
---|
82 | * NOTE: These settings are chosen to reflect most of the family members. |
---|
83 | */ |
---|
84 | |
---|
85 | #ifndef I386_HAS_FPU |
---|
86 | #define I386_HAS_FPU 1 |
---|
87 | #endif |
---|
88 | |
---|
89 | #ifndef I386_HAS_BSWAP |
---|
90 | #define I386_HAS_BSWAP 1 |
---|
91 | #endif |
---|
92 | |
---|
93 | /* |
---|
94 | * Define the name of the CPU family. |
---|
95 | */ |
---|
96 | |
---|
97 | #define CPU_NAME "Intel i386" |
---|
98 | |
---|
99 | #ifndef ASM |
---|
100 | |
---|
101 | /* |
---|
102 | * The following routine swaps the endian format of an unsigned int. |
---|
103 | * It must be static so it can be referenced indirectly. |
---|
104 | */ |
---|
105 | |
---|
106 | static inline unsigned int i386_swap_U32( |
---|
107 | unsigned int value |
---|
108 | ) |
---|
109 | { |
---|
110 | unsigned long lout; |
---|
111 | |
---|
112 | #if (I386_HAS_BSWAP == 0) |
---|
113 | asm volatile( "rorw $8,%%ax;" |
---|
114 | "rorl $16,%0;" |
---|
115 | "rorw $8,%%ax" : "=a" (lout) : "0" (value) ); |
---|
116 | #else |
---|
117 | __asm__ volatile( "bswap %0" : "=r" (lout) : "0" (value)); |
---|
118 | #endif |
---|
119 | return( lout ); |
---|
120 | } |
---|
121 | |
---|
122 | static inline unsigned int i386_swap_U16( |
---|
123 | unsigned int value |
---|
124 | ) |
---|
125 | { |
---|
126 | unsigned short sout; |
---|
127 | |
---|
128 | __asm__ volatile( "rorw $8,%0" : "=r" (sout) : "0" (value)); |
---|
129 | return (sout); |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | /* routines */ |
---|
134 | |
---|
135 | /* |
---|
136 | * i386_Logical_to_physical |
---|
137 | * |
---|
138 | * Converts logical address to physical address. |
---|
139 | */ |
---|
140 | |
---|
141 | void *i386_Logical_to_physical( |
---|
142 | unsigned short segment, |
---|
143 | void *address |
---|
144 | ); |
---|
145 | |
---|
146 | /* |
---|
147 | * i386_Physical_to_logical |
---|
148 | * |
---|
149 | * Converts physical address to logical address. |
---|
150 | */ |
---|
151 | |
---|
152 | void *i386_Physical_to_logical( |
---|
153 | unsigned short segment, |
---|
154 | void *address |
---|
155 | ); |
---|
156 | |
---|
157 | |
---|
158 | /* |
---|
159 | * "Simpler" names for a lot of the things defined in this file |
---|
160 | */ |
---|
161 | |
---|
162 | /* segment access routines */ |
---|
163 | |
---|
164 | #define get_cs() i386_get_cs() |
---|
165 | #define get_ds() i386_get_ds() |
---|
166 | #define get_es() i386_get_es() |
---|
167 | #define get_ss() i386_get_ss() |
---|
168 | #define get_fs() i386_get_fs() |
---|
169 | #define get_gs() i386_get_gs() |
---|
170 | |
---|
171 | #define CPU_swap_u32( _value ) i386_swap_U32( _value ) |
---|
172 | #define CPU_swap_u16( _value ) i386_swap_U16( _value ) |
---|
173 | |
---|
174 | /* i80x86 I/O instructions */ |
---|
175 | |
---|
176 | #define outport_byte( _port, _value ) i386_outport_byte( _port, _value ) |
---|
177 | #define outport_word( _port, _value ) i386_outport_word( _port, _value ) |
---|
178 | #define outport_long( _port, _value ) i386_outport_long( _port, _value ) |
---|
179 | #define inport_byte( _port, _value ) i386_inport_byte( _port, _value ) |
---|
180 | #define inport_word( _port, _value ) i386_inport_word( _port, _value ) |
---|
181 | #define inport_long( _port, _value ) i386_inport_long( _port, _value ) |
---|
182 | |
---|
183 | |
---|
184 | #ifdef __cplusplus |
---|
185 | } |
---|
186 | #endif |
---|
187 | |
---|
188 | #endif /* !ASM */ |
---|
189 | |
---|
190 | #endif |
---|
191 | /* end of include file */ |
---|