source: rtems/cpukit/score/cpu/i386/rtems/score/i386.h @ 1b502424

4.104.114.95
Last change on this file since 1b502424 was 1b502424, checked in by Ralf Corsepius <ralf.corsepius@…>, on 08/16/08 at 05:46:28

Add missing prototypes.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/**
2 * @file rtems/score/i386.h
3 */
4
5/*
6 *  This include file contains information pertaining to the Intel
7 *  i386 processor.
8 *
9 *  COPYRIGHT (c) 1989-1999.
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
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_SCORE_I386_H
20#define _RTEMS_SCORE_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
40 *    pentiumpro
41 *
42 *  CPU Model Feature Flags:
43 *
44 *  I386_HAS_BSWAP:  Defined to "1" if the instruction for endian swapping
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
52#if defined(_SOFT_FLOAT)
53#define I386_HAS_FPU 0
54#else
55#define I386_HAS_FPU 1
56#endif
57
58#if defined(__pentiumpro__)
59
60#define CPU_MODEL_NAME  "Pentium Pro"
61
62#elif defined(__i586__)
63
64# if defined(__pentium__)
65# define CPU_MODEL_NAME  "Pentium"
66# elif defined(__k6__)
67# define CPU_MODEL_NAME "K6"
68# else
69# define CPU_MODEL_NAME "i586"
70# endif
71
72#elif defined(__i486__)
73
74# if !defined(_SOFT_FLOAT)
75# define CPU_MODEL_NAME  "i486dx"
76# else
77# define CPU_MODEL_NAME  "i486sx"
78# endif
79
80#elif defined(__i386__)
81
82#define I386_HAS_BSWAP  0
83
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
89
90#else
91#error "Unknown CPU Model"
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
121static inline uint32_t i386_swap_u32(
122  uint32_t value
123)
124{
125  uint32_t 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
137static inline uint16_t i386_swap_u16(
138  uint16_t value
139)
140{
141    unsigned short      sout;
142
143    __asm__ volatile( "rorw $8,%0" : "=r"  (sout) : "0"   (value));
144    return (sout);
145}
146
147
148/*
149 * Added for pagination management
150 */
151
152static inline unsigned int i386_get_cr0(void)
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(void)
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(void)
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
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 */
219
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()
226
227#define CPU_swap_u32( _value )  i386_swap_u32( _value )
228#define CPU_swap_u16( _value )  i386_swap_u16( _value )
229
230/* i80x86 I/O instructions */
231
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 )
238
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif /* !ASM */
245
246#endif
Note: See TracBrowser for help on using the repository browser.