RTEMS  5.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cpu.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2008.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_CPU_H
20 #define _RTEMS_SCORE_CPU_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <rtems/score/basedefs.h>
27 #include <rtems/score/lm32.h>
28 
29 /* conditional compilation parameters */
30 
42 #define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
43 
53 #define CPU_ISR_PASSES_FRAME_POINTER TRUE
54 
90 #define CPU_HARDWARE_FP FALSE
91 #define CPU_SOFTWARE_FP FALSE
92 
117 #define CPU_ALL_TASKS_ARE_FP FALSE
118 
134 #define CPU_IDLE_TASK_IS_FP FALSE
135 
165 #define CPU_USE_DEFERRED_FP_SWITCH TRUE
166 
167 #define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE
168 
180 #define CPU_STACK_GROWS_UP FALSE
181 
182 /* L2 cache lines are 32 bytes in Milkymist SoC */
183 #define CPU_CACHE_LINE_BYTES 32
184 
185 #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
186 
197 #define CPU_MODES_INTERRUPT_MASK 0x00000001
198 
199 #define CPU_MAXIMUM_PROCESSORS 32
200 
201 /*
202  * Processor defined structures required for cpukit/score.
203  *
204  * Port Specific Information:
205  *
206  * XXX document implementation including references if appropriate
207  */
208 
209 /* may need to put some structures here. */
210 
261 typedef struct {
262  uint32_t r11;
263  uint32_t r12;
264  uint32_t r13;
265  uint32_t r14;
266  uint32_t r15;
267  uint32_t r16;
268  uint32_t r17;
269  uint32_t r18;
270  uint32_t r19;
271  uint32_t r20;
272  uint32_t r21;
273  uint32_t r22;
274  uint32_t r23;
275  uint32_t r24;
276  uint32_t r25;
277  uint32_t gp;
278  uint32_t fp;
279  uint32_t sp;
280  uint32_t ra;
281  uint32_t ie;
282  uint32_t epc;
284 
293 #define _CPU_Context_Get_SP( _context ) \
294  (_context)->sp
295 
300 typedef struct {
302 
308 typedef struct {
309  uint32_t r1;
310  uint32_t r2;
311  uint32_t r3;
312  uint32_t r4;
313  uint32_t r5;
314  uint32_t r6;
315  uint32_t r7;
316  uint32_t r8;
317  uint32_t r9;
318  uint32_t r10;
319  uint32_t ra;
320  uint32_t ba;
321  uint32_t ea;
323 
334 #if 0
335 extern Context_Control_fp _CPU_Null_fp_context;
336 #endif
337 
348 /*
349  * Nothing prevents the porter from declaring more CPU specific variables.
350  *
351  * Port Specific Information:
352  *
353  * XXX document implementation including references if appropriate
354  */
355 
356 /* XXX: if needed, put more variables here */
357 
369 #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
370 
381 #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
382 
392 #define CPU_INTERRUPT_NUMBER_OF_VECTORS 32
393 
398 #define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
399 
405 #define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
406 
407 
417 #define CPU_STACK_MINIMUM_SIZE (1024*4)
418 
419 #define CPU_SIZEOF_POINTER 4
420 
431 #define CPU_ALIGNMENT 4
432 
456 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
457 
468 #define CPU_STACK_ALIGNMENT CPU_ALIGNMENT
469 
470 #define CPU_INTERRUPT_STACK_ALIGNMENT CPU_CACHE_LINE_BYTES
471 
472 /*
473  * ISR handler macros
474  */
475 
488 #define _CPU_Initialize_vectors()
489 
500 #define _CPU_ISR_Disable( _isr_cookie ) \
501  lm32_disable_interrupts( _isr_cookie );
502 
514 #define _CPU_ISR_Enable( _isr_cookie ) \
515  lm32_enable_interrupts( _isr_cookie );
516 
529 #define _CPU_ISR_Flash( _isr_cookie ) \
530  lm32_flash_interrupts( _isr_cookie );
531 
532 RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
533 {
534  return ( level & 0x0001 ) != 0;
535 }
536 
552 #define _CPU_ISR_Set_level( new_level ) \
553  { \
554  _CPU_ISR_Enable( ( new_level==0 ) ? 1 : 0 ); \
555  }
556 
567 uint32_t _CPU_ISR_Get_level( void );
568 
569 /* end of ISR handler macros */
570 
573 /* Context handler macros */
574 
606 extern char _gp[];
607 
608 #define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
609  _isr, _entry_point, _is_fp, _tls_area ) \
610  do { \
611  uint32_t _stack = (uint32_t)(_stack_base) + (_size) - 4; \
612  \
613  (void) _is_fp; /* avoid warning for being unused */ \
614  (void) _isr; /* avoid warning for being unused */ \
615  (_the_context)->gp = (uint32_t)_gp; \
616  (_the_context)->fp = (uint32_t)_stack; \
617  (_the_context)->sp = (uint32_t)_stack; \
618  (_the_context)->ra = (uint32_t)(_entry_point); \
619  } while ( 0 )
620 
636 #define _CPU_Context_Restart_self( _the_context ) \
637  _CPU_Context_restore( (_the_context) );
638 
657 #define _CPU_Context_Initialize_fp( _destination )
658 #if 0
659  { \
660  *(*(_destination)) = _CPU_Null_fp_context; \
661  }
662 #endif
663 
664 /* end of Context handler macros */
665 
666 /* Fatal Error manager macros */
667 
677 #define _CPU_Fatal_halt( _source, _error ) \
678  { \
679  }
680 
681 /* end of Fatal Error manager macros */
682 
683 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
684 
685 /* functions */
686 
694 void _CPU_Initialize(void);
695 
701 typedef void ( *CPU_ISR_raw_handler )( void );
702 
704  uint32_t vector,
705  CPU_ISR_raw_handler new_handler,
706  CPU_ISR_raw_handler *old_handler
707 )
708 {
709  /* TODO */
710 }
711 
712 typedef void ( *CPU_ISR_handler )( uint32_t );
713 
715  uint32_t vector,
716  CPU_ISR_handler new_handler,
717  CPU_ISR_handler *old_handler
718 );
719 
722 void *_CPU_Thread_Idle_body( uintptr_t ignored );
723 
736  Context_Control *run,
737  Context_Control *heir
738 );
739 
758  Context_Control *new_context
760 
775  Context_Control_fp **fp_context_ptr
776 );
777 
792  Context_Control_fp **fp_context_ptr
793 );
794 
797 /* FIXME */
799 
800 void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
801 
838 static inline uint32_t CPU_swap_u32(
839  uint32_t value
840 )
841 {
842  uint32_t byte1, byte2, byte3, byte4, swapped;
843 
844  byte4 = (value >> 24) & 0xff;
845  byte3 = (value >> 16) & 0xff;
846  byte2 = (value >> 8) & 0xff;
847  byte1 = value & 0xff;
848 
849  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
850  return swapped;
851 }
852 
859 static inline uint16_t CPU_swap_u16(uint16_t v)
860 {
861  return v << 8 | v >> 8;
862 }
863 
866 typedef uint32_t CPU_Counter_ticks;
867 
868 uint32_t _CPU_Counter_frequency( void );
869 
870 CPU_Counter_ticks _CPU_Counter_read( void );
871 
872 static inline CPU_Counter_ticks _CPU_Counter_difference(
873  CPU_Counter_ticks second,
874  CPU_Counter_ticks first
875 )
876 {
877  return second - first;
878 }
879 
881 typedef uintptr_t CPU_Uint32ptr;
882 
883 #ifdef __cplusplus
884 }
885 #endif
886 
887 #endif
#define sp
stack-pointer */
Definition: regs.h:64
void _CPU_Exception_frame_print(const CPU_Exception_frame *frame)
Prints the exception frame via printk().
Definition: vectorexceptions.c:45
CPU_Counter_ticks _CPU_Counter_read(void)
Returns the current CPU counter value.
Definition: system-clocks.c:117
Thread register context.
Definition: cpu.h:196
void * _CPU_Thread_Idle_body(uintptr_t ignored)
Definition: idle-mcf5272.c:20
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
unsigned ie
Definition: tte.h:76
LM32 Set up Basic CPU Dependency Settings Based on Compiler Settings.
void _CPU_Context_restore_fp(Context_Control_fp **fp_context_ptr)
Definition: cpu.c:207
Interrupt stack frame (ISF).
Definition: cpu.h:306
#define fp
frame-pointer */
Definition: regs.h:65
void _CPU_Context_switch(Context_Control *run, Context_Control *heir)
CPU switch context.
Definition: cpu_asm.c:91
void _CPU_Initialize(void)
CPU initialization.
Definition: cpu.c:45
#define CPU_swap_u16(value)
Definition: cpu.h:817
SPARC basic context.
Definition: cpu.h:242
uint32_t CPU_Counter_ticks
Unsigned integer type for CPU counter values.
Definition: cpu.h:1202
#define RTEMS_NO_RETURN
Definition: basedefs.h:101
uint32_t _CPU_ISR_Get_level(void)
Definition: cpu.c:88
RTEMS_INLINE_ROUTINE void _CPU_ISR_install_raw_handler(uint32_t vector, CPU_ISR_raw_handler new_handler, CPU_ISR_raw_handler *old_handler)
SPARC specific raw ISR installer.
Definition: cpu.h:703
bool _CPU_ISR_Is_enabled(uint32_t level)
Returns true if interrupts are enabled in the specified ISR level, otherwise returns false...
Definition: cpu.h:381
void _CPU_Context_restore(Context_Control *new_context) RTEMS_NO_RETURN
Definition: cpu_asm.c:111
uintptr_t CPU_Uint32ptr
Definition: cpu.h:668
uint32_t _CPU_Counter_frequency(void)
Returns the current CPU counter frequency in Hz.
Definition: system-clocks.c:112
Basic Definitions.
#define ra
return address */
Definition: regs.h:66
RTEMS_INLINE_ROUTINE void _CPU_ISR_install_vector(uint32_t vector, CPU_ISR_handler new_handler, CPU_ISR_handler *old_handler)
SPARC specific RTEMS ISR installer.
Definition: cpu.h:605
unsigned v
Definition: tte.h:73
void _CPU_Context_save_fp(Context_Control_fp **fp_context_ptr)
Definition: cpu.c:198
The set of registers that specifies the complete processor state.
Definition: cpu.h:635
Context_Control_fp _CPU_Null_fp_context
Definition: cpu.c:45
#define gp
global data pointer */
Definition: regs.h:63