source: rtems/cpukit/score/cpu/i386/rtems/score/i386.h @ 8adc214

4.104.114.84.95
Last change on this file since 8adc214 was 8adc214, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/21/04 at 11:35:50

Cosmetics.

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