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

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on 09/19/95 at 14:53:29

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

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