RTEMS CPU Kit with SuperCore  4.11.3
cpu.h
Go to the documentation of this file.
1 
7 /*
8  * This include file contains information pertaining to the XXX
9  * processor.
10  *
11  * @note This file is part of a porting template that is intended
12  * to be used as the starting point when porting RTEMS to a new
13  * CPU family. The following needs to be done when using this as
14  * the starting point for a new port:
15  *
16  * + Anywhere there is an XXX, it should be replaced
17  * with information about the CPU family being ported to.
18  *
19  * + At the end of each comment section, there is a heading which
20  * says "Port Specific Information:". When porting to RTEMS,
21  * add CPU family specific information in this section
22  */
23 
24 /*
25  * COPYRIGHT (c) 1989-2008.
26  * On-Line Applications Research Corporation (OAR).
27  *
28  * The license and distribution terms for this file may be
29  * found in the file LICENSE in this distribution or at
30  * http://www.rtems.org/license/LICENSE.
31  */
32 
33 #ifndef _RTEMS_SCORE_CPU_H
34 #define _RTEMS_SCORE_CPU_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <rtems/score/types.h>
41 #include <rtems/score/m32c.h>
42 
43 /* conditional compilation parameters */
44 
45 #define RTEMS_USE_16_BIT_OBJECT
46 
68 #define CPU_INLINE_ENABLE_DISPATCH FALSE
69 
97 #define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE
98 
110 #define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
111 
130 #define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE
131 
144 #define CPU_ALLOCATE_INTERRUPT_STACK TRUE
145 
155 #define CPU_ISR_PASSES_FRAME_POINTER 0
156 
192 #if ( M32C_HAS_FPU == 1 )
193 #define CPU_HARDWARE_FP TRUE
194 #else
195 #define CPU_HARDWARE_FP FALSE
196 #endif
197 #define CPU_SOFTWARE_FP FALSE
198 
199 #define CPU_CONTEXT_FP_SIZE 0
200 
225 #define CPU_ALL_TASKS_ARE_FP TRUE
226 
242 #define CPU_IDLE_TASK_IS_FP FALSE
243 
273 #define CPU_USE_DEFERRED_FP_SWITCH TRUE
274 
299 #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE
300 
312 #define CPU_STACK_GROWS_UP TRUE
313 
337 #define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (2)))
338 
339 #define CPU_TIMESTAMP_USE_STRUCT_TIMESPEC TRUE
340 
362 #define CPU_BIG_ENDIAN TRUE
363 
377 #define CPU_LITTLE_ENDIAN FALSE
378 
392 #define CPU_MODES_INTERRUPT_MASK 0x00000001
393 
394 #define CPU_PER_CPU_CONTROL_SIZE 0
395 
396 /*
397  * Processor defined structures required for cpukit/score.
398  *
399  * Port Specific Information:
400  *
401  * XXX document implementation including references if appropriate
402  */
403 
404 /* may need to put some structures here. */
405 
456 typedef struct {
458  uint32_t sp;
460  uint32_t fb;
462 
472 #define _CPU_Context_Get_SP( _context ) \
473  (_context)->sp
474 
482 typedef struct {
488  uint32_t special_interrupt_register;
490 
514 /*
515  * Nothing prevents the porter from declaring more CPU specific variables.
516  *
517  * Port Specific Information:
518  *
519  * XXX document implementation including references if appropriate
520  */
521 
522 /* XXX: if needed, put more variables here */
523 
533 #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
534 
543 #define CPU_INTERRUPT_NUMBER_OF_VECTORS 32
544 
546 #define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
547 
552 #define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
553 
566 #define CPU_STACK_MINIMUM_SIZE (2048L)
567 
568 #ifdef __m32cm_cpu__
569  #define CPU_SIZEOF_POINTER 4
570 #else
571  #define CPU_SIZEOF_POINTER 2
572 #endif
573 
582 #define CPU_ALIGNMENT 2
583 
607 #define CPU_HEAP_ALIGNMENT 4
608 
625 #define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT
626 
640 #define CPU_STACK_ALIGNMENT 0
641 
642 /*
643  * ISR handler macros
644  */
645 
655 #define _CPU_Initialize_vectors()
656 
669 #define _CPU_ISR_Disable( _isr_cookie ) \
670  do { \
671  int _flg; \
672  m32c_get_flg( _flg ); \
673  _isr_cookie = _flg; \
674  __asm__ volatile( "fclr I" ); \
675  } while(0)
676 
690 #define _CPU_ISR_Enable(_isr_cookie) \
691  do { \
692  int _flg = (int) (_isr_cookie); \
693  m32c_set_flg( _flg ); \
694  } while(0)
695 
710 #define _CPU_ISR_Flash( _isr_cookie ) \
711  do { \
712  int _flg = (int) (_isr_cookie); \
713  m32c_set_flg( _flg ); \
714  __asm__ volatile( "fclr I" ); \
715  } while(0)
716 
734 #define _CPU_ISR_Set_level( _new_level ) \
735  do { \
736  if (_new_level) __asm__ volatile( "fclr I" ); \
737  else __asm__ volatile( "fset I" ); \
738  } while(0)
739 
752 uint32_t _CPU_ISR_Get_level( void );
753 
754 /* end of ISR handler macros */
755 
756 /* Context handler macros */
757 
792  Context_Control *the_context,
793  uint32_t *stack_base,
794  size_t size,
795  uint32_t new_level,
796  void *entry_point,
797  bool is_fp,
798  void *tls_area
799 );
800 
817  Context_Control *the_context
819 
843 #define _CPU_Context_Fp_start( _base, _offset ) \
844  ( (void *) _Addresses_Add_offset( (_base), (_offset) ) )
845 
864 #define _CPU_Context_Initialize_fp( _destination ) \
865  { \
866  *(*(_destination)) = _CPU_Null_fp_context; \
867  }
868 
869 /* end of Context handler macros */
870 
871 /* Fatal Error manager macros */
872 
882 #define _CPU_Fatal_halt( _source, _error ) \
883  { \
884  }
885 
886 /* end of Fatal Error manager macros */
887 
888 /* Bitfield handler macros */
889 
902 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
903 
912 #define CPU_USE_GENERIC_BITFIELD_DATA TRUE
913 
978 #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
979 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \
980  { \
981  (_output) = 0; /* do something to prevent warnings */ \
982  }
983 #endif
984 
985 /* end of Bitfield handler macros */
986 
996 #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
997 
998 #define _CPU_Priority_Mask( _bit_number ) \
999  ( 1 << (_bit_number) )
1000 
1001 #endif
1002 
1015 #if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
1016 
1017 #define _CPU_Priority_bits_index( _priority ) \
1018  (_priority)
1019 
1020 #endif
1021 
1024 /* end of Priority handler macros */
1025 
1026 /* functions */
1027 
1035 void _CPU_Initialize(void);
1036 
1052  uint32_t vector,
1053  proc_ptr new_handler,
1054  proc_ptr *old_handler
1055 );
1056 
1071  uint32_t vector,
1072  proc_ptr new_handler,
1073  proc_ptr *old_handler
1074 );
1075 
1088 void _CPU_Install_interrupt_stack( void );
1089 
1100 void *_CPU_Thread_Idle_body( uintptr_t ignored );
1101 
1114 void _CPU_Context_switch(
1115  Context_Control *run,
1116  Context_Control *heir
1117 );
1118 
1134  Context_Control *new_context
1136 
1137 static inline void _CPU_Context_volatile_clobber( uintptr_t pattern )
1138 {
1139  /* TODO */
1140 }
1141 
1142 static inline void _CPU_Context_validate( uintptr_t pattern )
1143 {
1144  while (1) {
1145  /* TODO */
1146  }
1147 }
1148 
1149 /* FIXME */
1150 typedef CPU_Interrupt_frame CPU_Exception_frame;
1151 
1152 void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
1153 
1183 static inline uint32_t CPU_swap_u32(
1184  uint32_t value
1185 )
1186 {
1187  uint32_t byte1, byte2, byte3, byte4, swapped;
1188 
1189  byte4 = (value >> 24) & 0xff;
1190  byte3 = (value >> 16) & 0xff;
1191  byte2 = (value >> 8) & 0xff;
1192  byte1 = value & 0xff;
1193 
1194  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
1195  return swapped;
1196 }
1197 
1206 #define CPU_swap_u16( value ) \
1207  (((value&0xff) << 8) | ((value >> 8)&0xff))
1208 
1209 typedef uint32_t CPU_Counter_ticks;
1210 
1211 CPU_Counter_ticks _CPU_Counter_read( void );
1212 
1213 static inline CPU_Counter_ticks _CPU_Counter_difference(
1214  CPU_Counter_ticks second,
1215  CPU_Counter_ticks first
1216 )
1217 {
1218  return second - first;
1219 }
1220 
1221 #ifdef __cplusplus
1222 }
1223 #endif
1224 
1225 #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
uint32_t fb
This will contain the frame base pointer.
Definition: cpu.h:460
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
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_Restart_self(Context_Control *the_context)
This routine is responsible for somehow restarting the currently executing task.
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
M32C Set up Basic CPU Dependency Settings Based on Compiler Settings.
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
#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
void * proc_ptr
XXX: Eventually proc_ptr needs to disappear!!!
Definition: basedefs.h:329