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

4.104.114.84.95
Last change on this file since 73452854 was 937a6f3c, checked in by Joel Sherrill <joel.sherrill@…>, on 06/03/98 at 19:00:17

Added CPU_ISR_PASSES_FRAME_POINTER so some ports could pass just the
vector number to user ISR's and other ports could pass both the vector
number and a pointer to the ISF.

  • Property mode set to 100644
File size: 9.9 KB
Line 
1/*  cpu.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 __CPU_h
18#define __CPU_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/score/i386.h>              /* pick up machine definitions */
25#ifndef ASM
26#include <rtems/score/i386types.h>
27#endif
28
29/* conditional compilation parameters */
30
31#define CPU_INLINE_ENABLE_DISPATCH       TRUE
32#define CPU_UNROLL_ENQUEUE_PRIORITY      FALSE
33
34/*
35 *  i386 has an RTEMS allocated and managed interrupt stack.
36 */
37
38#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE
39#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
40#define CPU_ALLOCATE_INTERRUPT_STACK     TRUE
41
42/*
43 *  Does the RTEMS invoke the user's ISR with the vector number and
44 *  a pointer to the saved interrupt frame (1) or just the vector
45 *  number (0)?
46 */
47
48#define CPU_ISR_PASSES_FRAME_POINTER 0
49
50/*
51 *  Some family members have no FP, some have an FPU such as the i387
52 *  for the i386, others have it built in (i486DX, Pentium).
53 */
54
55#if ( I386_HAS_FPU == 1 )
56#define CPU_HARDWARE_FP     TRUE    /* i387 for i386 */
57#else
58#define CPU_HARDWARE_FP     FALSE
59#endif
60
61#define CPU_ALL_TASKS_ARE_FP             FALSE
62#define CPU_IDLE_TASK_IS_FP              FALSE
63#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
64
65#define CPU_PROVIDES_IDLE_THREAD_BODY    FALSE
66#define CPU_STACK_GROWS_UP               FALSE
67#define CPU_STRUCTURE_ALIGNMENT
68
69/*
70 *  Define what is required to specify how the network to host conversion
71 *  routines are handled.
72 */
73
74#define CPU_CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE
75#define CPU_BIG_ENDIAN                           FALSE
76#define CPU_LITTLE_ENDIAN                        TRUE
77
78/* structures */
79
80/*
81 *  Basic integer context for the i386 family.
82 */
83
84typedef struct {
85  unsigned32  eflags;   /* extended flags register                   */
86  void       *esp;      /* extended stack pointer register           */
87  void       *ebp;      /* extended base pointer register            */
88  unsigned32  ebx;      /* extended bx register                      */
89  unsigned32  esi;      /* extended source index register            */
90  unsigned32  edi;      /* extended destination index flags register */
91}   Context_Control;
92
93/*
94 *  FP context save area for the i387 numeric coprocessors.
95 */
96
97typedef struct {
98  unsigned8   fp_save_area[108];    /* context size area for I80387 */
99                                    /*  28 bytes for environment    */
100} Context_Control_fp;
101
102/*
103 *  The following structure defines the set of information saved
104 *  on the current stack by RTEMS upon receipt of each interrupt.
105 */
106
107typedef struct {
108  unsigned32   TBD;   /* XXX Fix for this CPU */
109} CPU_Interrupt_frame;
110
111/*
112 *  The following table contains the information required to configure
113 *  the i386 specific parameters.
114 */
115
116typedef struct {
117  void       (*pretasking_hook)( void );
118  void       (*predriver_hook)( void );
119  void       (*postdriver_hook)( void );
120  void       (*idle_task)( void );
121  boolean      do_zero_of_workspace;
122  unsigned32   interrupt_stack_size;
123  unsigned32   extra_mpci_receive_server_stack;
124  void *     (*stack_allocate_hook)( unsigned32 );
125  void       (*stack_free_hook)( void* );
126  /* end of fields required on all CPUs */
127
128  unsigned32   interrupt_table_segment;
129  void        *interrupt_table_offset;
130}   rtems_cpu_table;
131
132/*
133 *  context size area for floating point
134 *
135 *  NOTE:  This is out of place on the i386 to avoid a forward reference.
136 */
137
138#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
139
140/* variables */
141
142SCORE_EXTERN Context_Control_fp  _CPU_Null_fp_context;
143SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
144SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
145
146/* constants */
147
148/*
149 *  This defines the number of levels and the mask used to pick those
150 *  bits out of a thread mode.
151 */
152
153#define CPU_MODES_INTERRUPT_LEVEL  0x00000001 /* interrupt level in mode */
154#define CPU_MODES_INTERRUPT_MASK   0x00000001 /* interrupt level in mode */
155
156/*
157 *  extra stack required by the MPCI receive server thread
158 */
159
160#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024
161
162/*
163 *  i386 family supports 256 distinct vectors.
164 */
165
166#define CPU_INTERRUPT_NUMBER_OF_VECTORS      256
167#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER  (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
168
169/*
170 *  Minimum size of a thread's stack.
171 */
172
173#define CPU_STACK_MINIMUM_SIZE          1024
174
175/*
176 *  i386 is pretty tolerant of alignment.  Just put things on 4 byte boundaries.
177 */
178
179#define CPU_ALIGNMENT                    4
180#define CPU_HEAP_ALIGNMENT               CPU_ALIGNMENT
181#define CPU_PARTITION_ALIGNMENT          CPU_ALIGNMENT
182
183/*
184 *  On i386 thread stacks require no further alignment after allocation
185 *  from the Workspace.
186 */
187
188#define CPU_STACK_ALIGNMENT             0
189
190/* macros */
191
192/*
193 *  ISR handler macros
194 *
195 *  These macros perform the following functions:
196 *     + disable all maskable CPU interrupts
197 *     + restore previous interrupt level (enable)
198 *     + temporarily restore interrupts (flash)
199 *     + set a particular level
200 */
201
202#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
203
204#define _CPU_ISR_Enable( _level )  i386_enable_interrupts( _level )
205
206#define _CPU_ISR_Flash( _level )   i386_flash_interrupts( _level )
207
208#define _CPU_ISR_Set_level( _new_level ) \
209  { \
210    if ( _new_level ) asm volatile ( "cli" ); \
211    else              asm volatile ( "sti" ); \
212  }
213
214unsigned32 _CPU_ISR_Get_level( void );
215
216/* end of ISR handler macros */
217
218/*
219 *  Context handler macros
220 *
221 *  These macros perform the following functions:
222 *     + initialize a context area
223 *     + restart the current thread
224 *     + calculate the initial pointer into a FP context area
225 *     + initialize an FP context area
226 */
227
228#define CPU_EFLAGS_INTERRUPTS_ON  0x00003202
229#define CPU_EFLAGS_INTERRUPTS_OFF 0x00003002
230
231#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
232                                   _isr, _entry_point, _is_fp ) \
233  do { \
234    unsigned32 _stack; \
235    \
236    if ( (_isr) ) (_the_context)->eflags = CPU_EFLAGS_INTERRUPTS_OFF; \
237    else          (_the_context)->eflags = CPU_EFLAGS_INTERRUPTS_ON; \
238    \
239    _stack = ((unsigned32)(_stack_base)) + (_size) - 4; \
240    \
241    *((proc_ptr *)(_stack)) = (_entry_point); \
242    (_the_context)->ebp     = (void *) _stack; \
243    (_the_context)->esp     = (void *) _stack; \
244  } while (0)
245
246#define _CPU_Context_Restart_self( _the_context ) \
247   _CPU_Context_restore( (_the_context) );
248
249#define _CPU_Context_Fp_start( _base, _offset ) \
250   ( (void *) _Addresses_Add_offset( (_base), (_offset) ) )
251
252#define _CPU_Context_Initialize_fp( _fp_area ) \
253  { \
254    unsigned32 *_source      = (unsigned32 *) &_CPU_Null_fp_context; \
255    unsigned32 *_destination = *(_fp_area); \
256    unsigned32  _index; \
257    \
258    for ( _index=0 ; _index < CPU_CONTEXT_FP_SIZE/4 ; _index++ ) \
259      *_destination++ = *_source++; \
260  }
261
262/* end of Context handler macros */
263
264/*
265 *  Fatal Error manager macros
266 *
267 *  These macros perform the following functions:
268 *    + disable interrupts and halt the CPU
269 */
270
271#define _CPU_Fatal_halt( _error ) \
272  { \
273    asm volatile ( "cli ; \
274                    movl %0,%%eax ; \
275                    hlt" \
276                    : "=r" ((_error)) : "0" ((_error)) \
277    ); \
278  }
279
280/* end of Fatal Error manager macros */
281
282/*
283 *  Bitfield handler macros
284 *
285 *  These macros perform the following functions:
286 *     + scan for the highest numbered (MSB) set in a 16 bit bitfield
287 */
288
289#define CPU_USE_GENERIC_BITFIELD_CODE FALSE
290#define CPU_USE_GENERIC_BITFIELD_DATA FALSE
291
292#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
293  { \
294    register unsigned16 __value_in_register = (_value); \
295    \
296    _output = 0; \
297    \
298    asm volatile ( "bsfw    %0,%1 " \
299                    : "=r" (__value_in_register), "=r" (_output) \
300                    : "0"  (__value_in_register), "1"  (_output) \
301    ); \
302  }
303
304/* end of Bitfield handler macros */
305
306/*
307 *  Priority handler macros
308 *
309 *  These macros perform the following functions:
310 *    + return a mask with the bit for this major/minor portion of
311 *      of thread priority set.
312 *    + translate the bit number returned by "Bitfield_find_first_bit"
313 *      into an index into the thread ready chain bit maps
314 */
315
316#define _CPU_Priority_Mask( _bit_number ) \
317  ( 1 << (_bit_number) )
318
319#define _CPU_Priority_bits_index( _priority ) \
320  (_priority)
321
322/* functions */
323
324/*
325 *  _CPU_Initialize
326 *
327 *  This routine performs CPU dependent initialization.
328 */
329
330void _CPU_Initialize(
331  rtems_cpu_table  *cpu_table,
332  void      (*thread_dispatch)
333);
334
335/*
336 *  _CPU_ISR_install_raw_handler
337 *
338 *  This routine installs a "raw" interrupt handler directly into the
339 *  processor's vector table.
340 */
341 
342void _CPU_ISR_install_raw_handler(
343  unsigned32  vector,
344  proc_ptr    new_handler,
345  proc_ptr   *old_handler
346);
347
348/*
349 *  _CPU_ISR_install_vector
350 *
351 *  This routine installs an interrupt vector.
352 */
353
354void _CPU_ISR_install_vector(
355  unsigned32  vector,
356  proc_ptr    new_handler,
357  proc_ptr   *old_handler
358);
359
360/*
361 *  _CPU_Context_switch
362 *
363 *  This routine switches from the run context to the heir context.
364 */
365
366void _CPU_Context_switch(
367  Context_Control  *run,
368  Context_Control  *heir
369);
370
371/*
372 *  _CPU_Context_restore
373 *
374 *  This routine is generally used only to restart self in an
375 *  efficient manner and avoid stack conflicts.
376 */
377
378void _CPU_Context_restore(
379  Context_Control *new_context
380);
381
382/*
383 *  _CPU_Context_save_fp
384 *
385 *  This routine saves the floating point context passed to it.
386 */
387
388void _CPU_Context_save_fp(
389  void **fp_context_ptr
390);
391
392/*
393 *  _CPU_Context_restore_fp
394 *
395 *  This routine restores the floating point context passed to it.
396 */
397
398void _CPU_Context_restore_fp(
399  void **fp_context_ptr
400);
401
402#ifdef __cplusplus
403}
404#endif
405
406#endif
407/* end of include file */
Note: See TracBrowser for help on using the repository browser.