source: rtems/c/src/exec/score/cpu/i386/i386.h @ 67a2288

4.104.114.84.95
Last change on this file since 67a2288 was 67a2288, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 23, 1998 at 10:02:34 PM

Patch from Eric VALETTE <valette@…>:

Here is a enhanced version of my previous patch. This patch enables
to potentially share the new interrupt management code for all Intel targets
(pc386, go32 and force386) bsp.

Note : this patch is complete only for pc386. It still needs to

be completed for go32 and force386. I carrefully checked
that anything needed is in for force386 (only some function
name changes for IDT manipulation and GDT segment
manipulation). But anyway I will not be able to test any
of theses targets...

  • Property mode set to 100644
File size: 5.9 KB
Line 
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
21extern "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
106static 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
122static 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 *  IO Port Access Routines
134 */
135
136#define i386_outport_byte( _port, _value ) \
137   { register unsigned short __port  = _port; \
138     register unsigned char  __value = _value; \
139     \
140     asm volatile ( "outb %0,%1" : "=a" (__value), "=d" (__port) \
141                                 : "0"   (__value), "1"  (__port) \
142                  ); \
143   }
144
145#define i386_outport_word( _port, _value ) \
146   { register unsigned short __port  = _port; \
147     register unsigned short __value = _value; \
148     \
149     asm volatile ( "outw %0,%1" : "=a" (__value), "=d" (__port) \
150                                 : "0"   (__value), "1"  (__port) \
151                  ); \
152   }
153
154#define i386_outport_long( _port, _value ) \
155   { register unsigned short __port  = _port; \
156     register unsigned int  __value = _value; \
157     \
158     asm volatile ( "outl %0,%1" : "=a" (__value), "=d" (__port) \
159                                 : "0"   (__value), "1"  (__port) \
160                  ); \
161   }
162
163#define i386_inport_byte( _port, _value ) \
164   { register unsigned short __port  = _port; \
165     register unsigned char  __value = 0; \
166     \
167     asm volatile ( "inb %1,%0" : "=a" (__value), "=d" (__port) \
168                                : "0"   (__value), "1"  (__port) \
169                  ); \
170     _value = __value; \
171   }
172
173#define i386_inport_word( _port, _value ) \
174   { register unsigned short __port  = _port; \
175     register unsigned short __value = 0; \
176     \
177     asm volatile ( "inw %1,%0" : "=a" (__value), "=d" (__port) \
178                                : "0"   (__value), "1"  (__port) \
179                  ); \
180     _value = __value; \
181   }
182
183#define i386_inport_long( _port, _value ) \
184   { register unsigned short __port  = _port; \
185     register unsigned int  __value = 0; \
186     \
187     asm volatile ( "inl %1,%0" : "=a" (__value), "=d" (__port) \
188                                : "0"   (__value), "1"  (__port) \
189                  ); \
190     _value = __value; \
191   }
192
193
194/* routines */
195
196/*
197 *  i386_Logical_to_physical
198 *
199 *  Converts logical address to physical address.
200 */
201
202void *i386_Logical_to_physical(
203  unsigned short  segment,
204  void           *address
205);
206
207/*
208 *  i386_Physical_to_logical
209 *
210 *  Converts physical address to logical address.
211 */
212
213void *i386_Physical_to_logical(
214  unsigned short  segment,
215  void           *address
216);
217
218
219/*
220 *  "Simpler" names for a lot of the things defined in this file
221 */
222
223/* segment access routines */
224 
225#define get_cs()   i386_get_cs()
226#define get_ds()   i386_get_ds()
227#define get_es()   i386_get_es()
228#define get_ss()   i386_get_ss()
229#define get_fs()   i386_get_fs()
230#define get_gs()   i386_get_gs()
231 
232#define CPU_swap_u32( _value )  i386_swap_U32( _value )
233#define CPU_swap_u16( _value )  i386_swap_U16( _value )
234 
235/* i80x86 I/O instructions */
236 
237#define outport_byte( _port, _value ) i386_outport_byte( _port, _value )
238#define outport_word( _port, _value ) i386_outport_word( _port, _value )
239#define outport_long( _port, _value ) i386_outport_long( _port, _value )
240#define inport_byte( _port, _value )  i386_inport_byte( _port, _value )
241#define inport_word( _port, _value )  i386_inport_word( _port, _value )
242#define inport_long( _port, _value )  i386_inport_long( _port, _value )
243 
244
245#ifdef __cplusplus
246}
247#endif
248
249#endif /* !ASM */
250
251#endif
252/* end of include file */
Note: See TracBrowser for help on using the repository browser.