19 #ifndef _RTEMS_SCORE_CPU_H 20 #define _RTEMS_SCORE_CPU_H 30 #include <rtems/score/types.h> 40 #define CPU_INLINE_ENABLE_DISPATCH TRUE 54 #define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE 60 #define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE 61 #define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE 62 #define CPU_ALLOCATE_INTERRUPT_STACK TRUE 70 #define CPU_ISR_PASSES_FRAME_POINTER 0 78 #define CPU_HARDWARE_FP TRUE 79 #define CPU_SOFTWARE_FP FALSE 81 #define CPU_ALL_TASKS_ARE_FP TRUE 82 #define CPU_IDLE_TASK_IS_FP TRUE 83 #define CPU_USE_DEFERRED_FP_SWITCH FALSE 86 #if ( I386_HAS_FPU == 1 ) 87 #define CPU_HARDWARE_FP TRUE 89 #define CPU_HARDWARE_FP FALSE 91 #define CPU_SOFTWARE_FP FALSE 93 #define CPU_ALL_TASKS_ARE_FP FALSE 94 #define CPU_IDLE_TASK_IS_FP FALSE 95 #if defined(RTEMS_SMP) 96 #define CPU_USE_DEFERRED_FP_SWITCH FALSE 98 #define CPU_USE_DEFERRED_FP_SWITCH TRUE 102 #define CPU_STACK_GROWS_UP FALSE 103 #define CPU_STRUCTURE_ALIGNMENT 105 #define CPU_TIMESTAMP_USE_INT64_INLINE TRUE 118 #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE 125 #define CPU_BIG_ENDIAN FALSE 126 #define CPU_LITTLE_ENDIAN TRUE 128 #define CPU_PER_CPU_CONTROL_SIZE 0 130 #define I386_CONTEXT_CONTROL_EFLAGS_OFFSET 0 131 #define I386_CONTEXT_CONTROL_ESP_OFFSET 4 132 #define I386_CONTEXT_CONTROL_EBP_OFFSET 8 133 #define I386_CONTEXT_CONTROL_EBX_OFFSET 12 134 #define I386_CONTEXT_CONTROL_ESI_OFFSET 16 135 #define I386_CONTEXT_CONTROL_EDI_OFFSET 20 138 #define I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 24 157 volatile bool is_executing;
161 #define _CPU_Context_Get_SP( _context ) \ 165 static inline bool _CPU_Context_Get_is_executing(
169 return context->is_executing;
172 static inline void _CPU_Context_Set_is_executing(
177 context->is_executing = is_executing;
210 uint8_t fp_save_area[108];
271 uint8_t xmmregs[8][16];
274 __attribute__((aligned(16)))
279 extern cpuExcHandlerType _currentExcHandler;
280 extern void rtems_exception_init_mngt(
void);
287 typedef void CPU_Interrupt_frame;
290 I386_EXCEPTION_DIVIDE_BY_ZERO = 0,
291 I386_EXCEPTION_DEBUG = 1,
292 I386_EXCEPTION_NMI = 2,
293 I386_EXCEPTION_BREAKPOINT = 3,
294 I386_EXCEPTION_OVERFLOW = 4,
295 I386_EXCEPTION_BOUND = 5,
296 I386_EXCEPTION_ILLEGAL_INSTR = 6,
297 I386_EXCEPTION_MATH_COPROC_UNAVAIL = 7,
298 I386_EXCEPTION_DOUBLE_FAULT = 8,
299 I386_EXCEPTION_I386_COPROC_SEG_ERR = 9,
300 I386_EXCEPTION_INVALID_TSS = 10,
301 I386_EXCEPTION_SEGMENT_NOT_PRESENT = 11,
302 I386_EXCEPTION_STACK_SEGMENT_FAULT = 12,
303 I386_EXCEPTION_GENERAL_PROT_ERR = 13,
304 I386_EXCEPTION_PAGE_FAULT = 14,
305 I386_EXCEPTION_INTEL_RES15 = 15,
306 I386_EXCEPTION_FLOAT_ERROR = 16,
307 I386_EXCEPTION_ALIGN_CHECK = 17,
308 I386_EXCEPTION_MACHINE_CHECK = 18,
309 I386_EXCEPTION_ENTER_RDBG = 50
311 } Intel_symbolic_exception_name;
320 #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) 335 #define CPU_MODES_INTERRUPT_LEVEL 0x00000001 336 #define CPU_MODES_INTERRUPT_MASK 0x00000001 342 #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 349 #define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE 355 #define CPU_STACK_MINIMUM_SIZE 4096 357 #define CPU_SIZEOF_POINTER 4 363 #define CPU_ALIGNMENT 4 364 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT 365 #define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT 376 #define CPU_STACK_ALIGNMENT 16 392 #define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level ) 394 #define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level ) 396 #define _CPU_ISR_Flash( _level ) i386_flash_interrupts( _level ) 398 #define _CPU_ISR_Set_level( _new_level ) \ 400 if ( _new_level ) __asm__ volatile ( "cli" ); \ 401 else __asm__ volatile ( "sti" ); \ 411 #define _CPU_Interrupt_stack_setup( _lo, _hi ) \ 413 _hi = (void*)(((uintptr_t)(_hi) - 4) & ~ (CPU_STACK_ALIGNMENT - 1)); \ 430 #define CPU_EFLAGS_INTERRUPTS_ON 0x00003202 431 #define CPU_EFLAGS_INTERRUPTS_OFF 0x00003002 465 #define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ 466 _isr, _entry_point, _is_fp, _tls_area ) \ 471 if ( (_isr) ) (_the_context)->eflags = CPU_EFLAGS_INTERRUPTS_OFF; \ 472 else (_the_context)->eflags = CPU_EFLAGS_INTERRUPTS_ON; \ 474 _stack = ((uint32_t)(_stack_base)) + (_size); \ 475 _stack &= ~ (CPU_STACK_ALIGNMENT - 1); \ 476 _stack -= 2*sizeof(proc_ptr*); \ 477 *((proc_ptr *)(_stack)) = (_entry_point); \ 478 (_the_context)->ebp = (void *) 0; \ 479 (_the_context)->esp = (void *) _stack; \ 482 #define _CPU_Context_Restart_self( _the_context ) \ 483 _CPU_Context_restore( (_the_context) ); 485 #if defined(RTEMS_SMP) 486 uint32_t _CPU_SMP_Initialize(
void );
488 bool _CPU_SMP_Start_processor( uint32_t cpu_index );
490 void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
492 void _CPU_SMP_Prepare_start_multitasking(
void );
494 uint32_t _CPU_SMP_Get_current_processor(
void );
496 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
498 static inline void _CPU_SMP_Processor_event_broadcast(
void )
500 __asm__ volatile (
"" : : :
"memory" );
503 static inline void _CPU_SMP_Processor_event_receive(
void )
505 __asm__ volatile (
"" : : :
"memory" );
509 #define _CPU_Context_Fp_start( _base, _offset ) \ 510 ( (void *) _Addresses_Add_offset( (_base), (_offset) ) ) 512 #define _CPU_Context_Initialize_fp( _fp_area ) \ 514 memcpy( *_fp_area, &_CPU_Null_fp_context, CPU_CONTEXT_FP_SIZE ); \ 526 #define _CPU_Fatal_halt( _source, _error ) \ 528 uint32_t _error_lvalue = ( _error ); \ 529 __asm__ volatile ( "cli ; \ 532 : "=r" ((_error_lvalue)) : "0" ((_error_lvalue)) \ 547 #define CPU_USE_GENERIC_BITFIELD_CODE FALSE 548 #define CPU_USE_GENERIC_BITFIELD_DATA FALSE 550 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ 552 register uint16_t __value_in_register = (_value); \ 556 __asm__ volatile ( "bsfw %0,%1 " \ 557 : "=r" (__value_in_register), "=r" (_output) \ 558 : "0" (__value_in_register), "1" (_output) \ 574 #define _CPU_Priority_Mask( _bit_number ) \ 575 ( 1 << (_bit_number) ) 577 #define _CPU_Priority_bits_index( _priority ) \ 622 #if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) 657 #define _CPU_Context_save_fp(fp_context_pp) \ 659 __asm__ __volatile__( \ 661 :"=m"((*(fp_context_pp))->fpucw) \ 663 __asm__ __volatile__( \ 665 :"=m"((*(fp_context_pp))->mxcsr) \ 680 #define _CPU_Context_restore_fp(fp_context_pp) \ 682 __asm__ __volatile__( \ 684 ::"m"((*(fp_context_pp))->fpucw) \ 687 __builtin_ia32_ldmxcsr(_Thread_Executing->fp_context->mxcsr); \ 696 #define _CPU_Context_Initialization_at_thread_begin() \ 698 __asm__ __volatile__( \ 702 :"st","st(1)","st(2)","st(3)", \ 703 "st(4)","st(5)","st(6)","st(7)", \ 706 if ( _Thread_Executing->fp_context ) { \ 707 _CPU_Context_restore_fp(&_Thread_Executing->fp_context); \ 731 CPU_Counter_ticks second,
732 CPU_Counter_ticks first
735 return second - first;
void _CPU_ISR_install_vector(uint32_t vector, proc_ptr new_handler, proc_ptr *old_handler)
This routine installs an interrupt vector.
Definition: cpu.c:69
void _CPU_Context_validate(uintptr_t pattern)
Initializes and validates the CPU context with values derived from the pattern parameter.
Definition: cpu.h:1109
uint32_t _CPU_ISR_Get_level(void)
Return the current interrupt disable level for this task in the format used by the interrupt level po...
Definition: cpu.c:39
void _CPU_Context_restore(Context_Control *new_context)
This routine is generally used only to restart self in an efficient manner.
Definition: cpu_asm.c:112
void _CPU_Context_switch(Context_Control *run, Context_Control *heir)
CPU switch context.
Definition: cpu_asm.c:92
void _CPU_Context_volatile_clobber(uintptr_t pattern)
Clobbers all volatile registers with values derived from the pattern parameter.
Definition: cpu.h:1104
This defines the minimal set of integer and processor state registers that must be saved during a vol...
Definition: cpu.h:248
void _CPU_Initialize(void)
CPU initialization.
Definition: cpu.c:26
SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context
This variable is optional.
Definition: cpu.h:494
uint32_t CPU_Counter_ticks
Unsigned integer type for CPU counter values.
Definition: cpu.h:1461
void _CPU_ISR_install_raw_handler(uint32_t vector, proc_ptr new_handler, proc_ptr *old_handler)
This routine installs a "raw" interrupt handler directly into the processor's vector table...
Definition: cpu.c:57
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.
void _CPU_Context_restore_fp(Context_Control_fp **fp_context_ptr)
This routine restores the floating point context passed to it.
Definition: cpu.c:176
Intel I386 CPU Dependent Source.
CPU_Counter_ticks _CPU_Counter_read(void)
Returns the current CPU counter value.
Definition: cpu.c:96
Intel I386 Interrupt Macros.
CPU_Counter_ticks _CPU_Counter_difference(CPU_Counter_ticks second, CPU_Counter_ticks first)
Returns the difference between the second and first CPU counter value.
Definition: cpu.h:1160
Intel CPU Constants and Definitions.
This defines the complete set of floating point registers that must be saved during any context switc...
Definition: cpu.h:294
void _CPU_Context_save_fp(Context_Control_fp **fp_context_ptr)
This routine saves the floating point context passed to it.
Definition: cpu.c:167
Definition: sse_test.c:126
#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE
The following macro is a compiler specific way to indicate that the method will NOT return to the cal...
Definition: basedefs.h:162
void _CPU_Exception_frame_print(const CPU_Exception_frame *frame)
Prints the exception frame via printk().
Definition: arm-exception-frame-print.c:46
void * _CPU_Thread_Idle_body(uintptr_t ignored)
This routine is the CPU dependent IDLE thread body.
Definition: cpu.c:125
The set of registers that specifies the complete processor state.
Definition: cpu.h:671
#define SCORE_EXTERN
The following ensures that all data is declared in the space of the initialization routine for either...
Definition: basedefs.h:81
void * proc_ptr
XXX: Eventually proc_ptr needs to disappear!!!
Definition: basedefs.h:329