RTEMS CPU Kit with SuperCore  4.11.2
cpu.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2006.
12  * On-Line Applications Research Corporation (OAR).
13  * adapted to Blackfin by Alain Schaefer <alain.schaefer@easc.ch>
14  * and Antonio Giovanini <antonio@atos.com.br>
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #ifndef _RTEMS_SCORE_CPU_H
22 #define _RTEMS_SCORE_CPU_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <rtems/score/types.h>
29 #include <rtems/score/bfin.h>
30 
31 /* conditional compilation parameters */
32 
54 #define CPU_INLINE_ENABLE_DISPATCH FALSE
55 
83 #define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE
84 
85 /*
86  * Does the CPU follow the simple vectored interrupt model?
87  *
88  * If TRUE, then RTEMS allocates the vector table it internally manages.
89  * If FALSE, then the BSP is assumed to allocate and manage the vector
90  * table
91  *
92  * BFIN Specific Information:
93  *
94  * XXX document implementation including references if appropriate
95  */
96 #define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
97 
116 #define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
117 
130 #define CPU_ALLOCATE_INTERRUPT_STACK TRUE
131 
141 #define CPU_ISR_PASSES_FRAME_POINTER 1
142 
178 #if ( BLACKFIN_CPU_HAS_FPU == 1 )
179 #define CPU_HARDWARE_FP TRUE
180 #else
181 #define CPU_HARDWARE_FP FALSE
182 #endif
183 #define CPU_SOFTWARE_FP FALSE
184 
209 #define CPU_ALL_TASKS_ARE_FP FALSE
210 
226 #define CPU_IDLE_TASK_IS_FP FALSE
227 
257 #define CPU_USE_DEFERRED_FP_SWITCH TRUE
258 
283 #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE
284 
296 #define CPU_STACK_GROWS_UP FALSE
297 
321 #define CPU_STRUCTURE_ALIGNMENT
322 
323 #define CPU_TIMESTAMP_USE_INT64_INLINE TRUE
324 
346 #define CPU_BIG_ENDIAN FALSE
347 
361 #define CPU_LITTLE_ENDIAN TRUE
362 
375 #define CPU_MODES_INTERRUPT_MASK 0x00000001
376 
377 #define CPU_PER_CPU_CONTROL_SIZE 0
378 
379 /*
380  * Processor defined structures required for cpukit/score.
381  *
382  * Port Specific Information:
383  *
384  * XXX document implementation including references if appropriate
385  */
386 
387 /* may need to put some structures here. */
388 
389 #ifndef ASM
390 
440 /* make sure this stays in sync with the assembly function
441  __CPU_Context_switch in cpu_asm.S */
442 typedef struct {
443  uint32_t register_r4;
444  uint32_t register_r5;
445  uint32_t register_r6;
446  uint32_t register_r7;
447 
448  uint32_t register_p3;
449  uint32_t register_p4;
450  uint32_t register_p5;
451  uint32_t register_fp;
452  uint32_t register_sp;
453 
454  uint32_t register_rets;
455 
456  uint32_t imask;
458 
459 #define _CPU_Context_Get_SP( _context ) \
460  (_context)->register_sp
461 
466 typedef struct {
467  /* FPU registers are listed here */
468  /* Blackfin has no Floating Point */
470 
476 typedef struct {
481  /*uint32_t special_interrupt_register;*/
483 
495 
518 /*
519  * Nothing prevents the porter from declaring more CPU specific variables.
520  *
521  * Port Specific Information:
522  *
523  * XXX document implementation including references if appropriate
524  */
525 
526 /* XXX: if needed, put more variables here */
527 
539 #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
540 
541 #endif /* ASM */
542 
552 #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
553 
563 #define CPU_INTERRUPT_NUMBER_OF_VECTORS 16
564 
569 #define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
570 
576 #define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
577 
589 #define CPU_STACK_MINIMUM_SIZE (1024*8)
590 
591 #define CPU_SIZEOF_POINTER 4
592 
601 #define CPU_ALIGNMENT 8
602 
626 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
627 
644 #define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT
645 
659 #define CPU_STACK_ALIGNMENT 8
660 
661 /*
662  * ISR handler macros
663  */
664 
677 #define _CPU_Initialize_vectors()
678 
689 #define _CPU_ISR_Disable( _level ) \
690  { \
691  __asm__ volatile ("cli %0; csync \n" : "=d" (_level) ); \
692  }
693 
694 
706 #define _CPU_ISR_Enable( _level ) { \
707  __asm__ __volatile__ ("sti %0; csync \n" : : "d" (_level) ); \
708  }
709 
722 #define _CPU_ISR_Flash( _level ) { \
723  __asm__ __volatile__ ("sti %0; csync; cli r0; csync" \
724  : : "d"(_level) : "R0" ); \
725  }
726 
742 #define _CPU_ISR_Set_level( _new_level ) \
743  { \
744  __asm__ __volatile__ ( "sti %0; csync" : : "d"(_new_level ? 0 : 0xffff) ); \
745  }
746 
747 #ifndef ASM
748 
759 uint32_t _CPU_ISR_Get_level( void );
760 
761 /* end of ISR handler macros */
762 
765 /* Context handler macros */
766 
800  Context_Control *the_context,
801  uint32_t *stack_base,
802  uint32_t size,
803  uint32_t new_level,
804  void *entry_point,
805  bool is_fp,
806  void *tls_area
807 );
808 
824 #define _CPU_Context_Restart_self( _the_context ) \
825  _CPU_Context_restore( (_the_context) );
826 
849 #define _CPU_Context_Fp_start( _base, _offset ) \
850  ( (void *) _Addresses_Add_offset( (_base), (_offset) ) )
851 
870 #define _CPU_Context_Initialize_fp( _destination ) \
871  { \
872  *(*(_destination)) = _CPU_Null_fp_context; \
873  }
874 
875 /* end of Context handler macros */
876 
877 /* Fatal Error manager macros */
878 
888 #define _CPU_Fatal_halt( _source, _error ) \
889  { \
890  __asm__ volatile ( "cli R1; \
891  R1 = %0; \
892  _halt: \
893  idle; \
894  jump _halt;"\
895  : : "r" (_error) ); \
896  }
897 
898 /* end of Fatal Error manager macros */
899 
900 /* Bitfield handler macros */
901 
914 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
915 
924 #define CPU_USE_GENERIC_BITFIELD_DATA TRUE
925 
990 #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
991 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \
992  { \
993  __asm__ ("bit(1);"):
994  (_output) = 0; /* do something to prevent warnings */ \
995  }
996 #endif
997 
998 /* end of Bitfield handler macros */
999 
1011 #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
1012 
1013 #define _CPU_Priority_Mask( _bit_number ) \
1014  ( 1 << (_bit_number) )
1015 
1016 #endif
1017 
1031 #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
1032 
1033 #define _CPU_Priority_bits_index( _priority ) \
1034  (_priority)
1035 
1036 #endif
1037 
1038 /* end of Priority handler macros */
1039 
1040 /* functions */
1041 
1050 void _CPU_Initialize(void);
1051 
1066  uint32_t vector,
1067  proc_ptr new_handler,
1068  proc_ptr *old_handler
1069 );
1070 
1084  uint32_t vector,
1085  proc_ptr new_handler,
1086  proc_ptr *old_handler
1087 );
1088 
1100 void _CPU_Install_interrupt_stack( void );
1101 
1112 void *_CPU_Thread_Idle_body( uintptr_t ignored );
1113 
1129 void _CPU_Context_switch(
1130  Context_Control *run,
1131  Context_Control *heir
1132 );
1133 
1147  Context_Control *new_context
1149 
1164  Context_Control_fp **fp_context_ptr
1165 );
1166 
1181  Context_Control_fp **fp_context_ptr
1182 );
1183 
1184 static inline void _CPU_Context_volatile_clobber( uintptr_t pattern )
1185 {
1186  /* TODO */
1187 }
1188 
1189 static inline void _CPU_Context_validate( uintptr_t pattern )
1190 {
1191  while (1) {
1192  /* TODO */
1193  }
1194 }
1195 
1198 /* FIXME */
1199 typedef CPU_Interrupt_frame CPU_Exception_frame;
1200 
1201 void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
1202 
1231 static inline uint32_t CPU_swap_u32(
1232  uint32_t value
1233 )
1234 {
1235  uint32_t byte1, byte2, byte3, byte4, swapped;
1236 
1237  byte4 = (value >> 24) & 0xff;
1238  byte3 = (value >> 16) & 0xff;
1239  byte2 = (value >> 8) & 0xff;
1240  byte1 = value & 0xff;
1241 
1242  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
1243  return( swapped );
1244 }
1245 
1253 #define CPU_swap_u16( value ) \
1254  (((value&0xff) << 8) | ((value >> 8)&0xff))
1255 
1256 typedef uint32_t CPU_Counter_ticks;
1257 
1258 CPU_Counter_ticks _CPU_Counter_read( void );
1259 
1260 static inline CPU_Counter_ticks _CPU_Counter_difference(
1261  CPU_Counter_ticks second,
1262  CPU_Counter_ticks first
1263 )
1264 {
1265  return second - first;
1266 }
1267 
1268 #endif /* ASM */
1269 
1270 #ifdef __cplusplus
1271 }
1272 #endif
1273 
1274 #endif
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
void _CPU_Install_interrupt_stack(void)
This routine installs the hardware interrupt stack pointer.
Definition: cpu.c:101
Blackfin Set up Basic CPU Dependency Settings Based on Compiler Settings.
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
This defines the set of integer and processor state registers that must be saved during an interrupt...
Definition: cpu.h:425
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&#39;s vector table...
Definition: cpu.c:57
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
void _CPU_Context_Initialize(Context_Control *the_context, uint32_t *stack_base, uint32_t size, uint32_t new_level, void *entry_point, bool is_fp, void *tls_area)
Initialize the context to a state suitable for starting a task after a context restore operation...
Definition: cpu.c:183
CPU_Counter_ticks _CPU_Counter_read(void)
Returns the current CPU counter value.
Definition: cpu.c:96
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
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
#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
#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