source: rtems/c/src/exec/score/cpu/i386/rtems/score/i386.h @ 95990b57

4.104.114.84.95
Last change on this file since 95990b57 was 95990b57, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 25, 2000 at 5:30:13 PM

2000-08-17 Ralf Corsepius <corsepiu@…>

  • rtems/score/i386.h: cpu-variant define handling Rewrite due to introduction of multilib defines.
  • asm.h: include cpuopts.h instead of targopts.h
  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*  i386.h
2 *
3 *  This include file contains information pertaining to the Intel
4 *  i386 processor.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __i386_h
17#define __i386_h
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*
24 *  This section contains the information required to build
25 *  RTEMS for a particular member of the Intel i386
26 *  family when executing in protected mode.  It does
27 *  this by setting variables to indicate which implementation
28 *  dependent features are present in a particular member
29 *  of the family.
30 *
31 *  Currently recognized:
32 *    i386_fp    (i386 DX or SX w/i387)
33 *    i386_nofp  (i386 DX or SX w/o i387)
34 *    i486dx
35 *    i486sx
36 *    pentium
37 *    pentiumpro
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(_SOFT_FLOAT)
50#define I386_HAS_FPU 0
51#else
52#define I386_HAS_FPU 1
53#endif
54
55#if defined(__pentiumpro__)
56
57#define CPU_MODEL_NAME  "Pentium Pro"
58
59#elif defined(__i586__)
60
61# if defined(__pentium__)
62# define CPU_MODEL_NAME  "Pentium"
63# elsif defined(__k6__)
64# define CPU_MODEL_NAME "K6"
65# else
66# define CPU_MODEL_NAME "i586"
67# endif
68
69#elif defined(__i486__)
70
71# if !defined(_SOFT_FLOAT)
72# define CPU_MODEL_NAME  "i486dx"
73# else
74# define CPU_MODEL_NAME  "i486sx"
75# endif
76
77#elif defined(__i386__)
78
79#define I386_HAS_BSWAP  0
80
81# if !defined(_SOFT_FLOAT)
82# define CPU_MODEL_NAME "i386 with i387"
83# else
84# define CPU_MODEL_NAME "i386 w/o i387"
85# endif
86
87#else
88#error "Unknown CPU Model"
89#endif
90
91/*
92 *  Set default values for CPU model feature flags
93 *
94 *  NOTE: These settings are chosen to reflect most of the family members.
95 */
96
97#ifndef I386_HAS_FPU
98#define I386_HAS_FPU 1
99#endif
100
101#ifndef I386_HAS_BSWAP
102#define I386_HAS_BSWAP 1
103#endif
104
105/*
106 *  Define the name of the CPU family.
107 */
108
109#define CPU_NAME "Intel i386"
110
111#ifndef ASM
112
113/*
114 *  The following routine swaps the endian format of an unsigned int.
115 *  It must be static so it can be referenced indirectly.
116 */
117
118static inline unsigned int i386_swap_U32(
119  unsigned int value
120)
121{
122  unsigned long lout;
123
124#if (I386_HAS_BSWAP == 0)
125  asm volatile( "rorw  $8,%%ax;"
126                "rorl  $16,%0;"
127                "rorw  $8,%%ax" : "=a" (lout) : "0" (value) );
128#else
129    __asm__ volatile( "bswap %0" : "=r"  (lout) : "0"   (value));
130#endif
131  return( lout );
132}
133
134static inline unsigned int i386_swap_U16(
135  unsigned int value
136)
137{
138    unsigned short      sout;
139
140    __asm__ volatile( "rorw $8,%0" : "=r"  (sout) : "0"   (value));
141    return (sout);
142}
143
144
145/*
146 * Added for pagination management
147 */
148 
149static inline unsigned int i386_get_cr0()
150{
151  register unsigned int segment = 0;
152
153  asm volatile ( "movl %%cr0,%0" : "=r" (segment) : "0" (segment) );
154
155  return segment;
156}
157
158static inline void i386_set_cr0(unsigned int segment)
159{
160  asm volatile ( "movl %0,%%cr0" : "=r" (segment) : "0" (segment) );
161}
162
163static inline unsigned int i386_get_cr2()
164{
165  register unsigned int segment = 0;
166
167  asm volatile ( "movl %%cr2,%0" : "=r" (segment) : "0" (segment) );
168
169  return segment;
170}
171
172static inline unsigned int i386_get_cr3()
173{
174  register unsigned int segment = 0;
175
176  asm volatile ( "movl %%cr3,%0" : "=r" (segment) : "0" (segment) );
177
178  return segment;
179}
180
181static inline void i386_set_cr3(unsigned int segment)
182{
183  asm volatile ( "movl %0,%%cr3" : "=r" (segment) : "0" (segment) );
184}
185
186/* routines */
187
188/*
189 *  i386_Logical_to_physical
190 *
191 *  Converts logical address to physical address.
192 */
193
194void *i386_Logical_to_physical(
195  unsigned short  segment,
196  void           *address
197);
198
199/*
200 *  i386_Physical_to_logical
201 *
202 *  Converts physical address to logical address.
203 */
204
205void *i386_Physical_to_logical(
206  unsigned short  segment,
207  void           *address
208);
209
210
211/*
212 *  "Simpler" names for a lot of the things defined in this file
213 */
214
215/* segment access routines */
216 
217#define get_cs()   i386_get_cs()
218#define get_ds()   i386_get_ds()
219#define get_es()   i386_get_es()
220#define get_ss()   i386_get_ss()
221#define get_fs()   i386_get_fs()
222#define get_gs()   i386_get_gs()
223 
224#define CPU_swap_u32( _value )  i386_swap_U32( _value )
225#define CPU_swap_u16( _value )  i386_swap_U16( _value )
226 
227/* i80x86 I/O instructions */
228 
229#define outport_byte( _port, _value ) i386_outport_byte( _port, _value )
230#define outport_word( _port, _value ) i386_outport_word( _port, _value )
231#define outport_long( _port, _value ) i386_outport_long( _port, _value )
232#define inport_byte( _port, _value )  i386_inport_byte( _port, _value )
233#define inport_word( _port, _value )  i386_inport_word( _port, _value )
234#define inport_long( _port, _value )  i386_inport_long( _port, _value )
235 
236
237#ifdef __cplusplus
238}
239#endif
240
241#endif /* !ASM */
242
243#endif
244/* end of include file */
Note: See TracBrowser for help on using the repository browser.