RTEMS  5.0.0
cpu.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2011 embedded brains GmbH
11  *
12  * Copyright (c) 2006 Kolja Waschk (rtemsdev/ixo.de)
13  *
14  * COPYRIGHT (c) 1989-2004.
15  * On-Line Applications Research Corporation (OAR).
16  *
17  * The license and distribution terms for this file may be
18  * found in the file LICENSE in this distribution or at
19  * http://www.rtems.org/license/LICENSE.
20  */
21 
22 #ifndef _RTEMS_SCORE_CPU_H
23 #define _RTEMS_SCORE_CPU_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <rtems/score/basedefs.h>
30 #include <rtems/score/nios2.h>
31 
32 #define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
33 
34 #define CPU_INTERRUPT_NUMBER_OF_VECTORS 32
35 
36 #define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
37 
38 #define CPU_PROVIDES_ISR_IS_IN_PROGRESS TRUE
39 
40 #define CPU_ISR_PASSES_FRAME_POINTER FALSE
41 
42 #define CPU_HARDWARE_FP FALSE
43 
44 #define CPU_SOFTWARE_FP FALSE
45 
46 #define CPU_CONTEXT_FP_SIZE 0
47 
48 #define CPU_ALL_TASKS_ARE_FP FALSE
49 
50 #define CPU_IDLE_TASK_IS_FP FALSE
51 
52 #define CPU_USE_DEFERRED_FP_SWITCH FALSE
53 
54 #define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE
55 
56 #define CPU_STACK_GROWS_UP FALSE
57 
58 /* FIXME: Is this the right value? */
59 #define CPU_CACHE_LINE_BYTES 32
60 
61 #define CPU_STRUCTURE_ALIGNMENT \
62  RTEMS_SECTION( ".sdata" ) RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
63 
64 #define CPU_STACK_MINIMUM_SIZE (4 * 1024)
65 
66 #define CPU_SIZEOF_POINTER 4
67 
68 /*
69  * Alignment value according to "Nios II Processor Reference" chapter 7
70  * "Application Binary Interface" section "Memory Alignment".
71  */
72 #define CPU_ALIGNMENT 4
73 
74 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
75 
76 /*
77  * Alignment value according to "Nios II Processor Reference" chapter 7
78  * "Application Binary Interface" section "Stacks".
79  */
80 #define CPU_STACK_ALIGNMENT 4
81 
82 #define CPU_INTERRUPT_STACK_ALIGNMENT CPU_CACHE_LINE_BYTES
83 
84 /*
85  * A Nios II configuration with an external interrupt controller (EIC) supports
86  * up to 64 interrupt levels. A Nios II configuration with an internal
87  * interrupt controller (IIC) has only two interrupt levels (enabled and
88  * disabled). The _CPU_ISR_Get_level() and _CPU_ISR_Set_level() functions will
89  * take care about configuration specific mappings.
90  */
91 #define CPU_MODES_INTERRUPT_MASK 0x3f
92 
93 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
94 
95 #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
96 
97 #define CPU_MAXIMUM_PROCESSORS 32
98 
99 #ifndef ASM
100 
115 typedef struct {
116  uint32_t r16;
117  uint32_t r17;
118  uint32_t r18;
119  uint32_t r19;
120  uint32_t r20;
121  uint32_t r21;
122  uint32_t r22;
123  uint32_t r23;
124  uint32_t fp;
125  uint32_t status;
126  uint32_t sp;
127  uint32_t ra;
128  uint32_t thread_dispatch_disabled;
129  uint32_t stack_mpubase;
130  uint32_t stack_mpuacc;
132 
133 #define _CPU_Context_Get_SP( _context ) \
134  (_context)->sp
135 
136 typedef void CPU_Interrupt_frame;
137 
138 typedef struct {
139  uint32_t r1;
140  uint32_t r2;
141  uint32_t r3;
142  uint32_t r4;
143  uint32_t r5;
144  uint32_t r6;
145  uint32_t r7;
146  uint32_t r8;
147  uint32_t r9;
148  uint32_t r10;
149  uint32_t r11;
150  uint32_t r12;
151  uint32_t r13;
152  uint32_t r14;
153  uint32_t r15;
154  uint32_t r16;
155  uint32_t r17;
156  uint32_t r18;
157  uint32_t r19;
158  uint32_t r20;
159  uint32_t r21;
160  uint32_t r22;
161  uint32_t r23;
162  uint32_t gp;
163  uint32_t fp;
164  uint32_t sp;
165  uint32_t ra;
166  uint32_t et;
167  uint32_t ea;
168  uint32_t status;
169  uint32_t ienable;
170  uint32_t ipending;
172 
173 #define _CPU_Initialize_vectors()
174 
195 #define _CPU_ISR_Disable( _isr_cookie ) \
196  do { \
197  int _tmp; \
198  __asm__ volatile ( \
199  "rdctl %0, status\n" \
200  "movhi %1, %%hiadj(_Nios2_ISR_Status_mask)\n" \
201  "addi %1, %1, %%lo(_Nios2_ISR_Status_mask)\n" \
202  "and %1, %0, %1\n" \
203  "ori %1, %1, %%lo(_Nios2_ISR_Status_bits)\n" \
204  "wrctl status, %1" \
205  : "=&r" (_isr_cookie), "=&r" (_tmp) \
206  ); \
207  } while ( 0 )
208 
215 #define _CPU_ISR_Enable( _isr_cookie ) \
216  __builtin_wrctl( 0, (int) _isr_cookie )
217 
229 #define _CPU_ISR_Flash( _isr_cookie ) \
230  do { \
231  int _status = __builtin_rdctl( 0 ); \
232  __builtin_wrctl( 0, (int) _isr_cookie ); \
233  __builtin_wrctl( 0, _status ); \
234  } while ( 0 )
235 
236 bool _CPU_ISR_Is_enabled( uint32_t level );
237 
246 void _CPU_ISR_Set_level( uint32_t new_level );
247 
261 uint32_t _CPU_ISR_Get_level( void );
262 
282  void *stack_area_begin,
283  size_t stack_area_size,
284  uint32_t new_level,
285  void (*entry_point)( void ),
286  bool is_fp,
287  void *tls_area
288 );
289 
290 #define _CPU_Context_Restart_self( _the_context ) \
291  _CPU_Context_restore( (_the_context) );
292 
293 void _CPU_Fatal_halt( uint32_t _source, uint32_t _error )
295 
299 void _CPU_Initialize( void );
300 
301 typedef void ( *CPU_ISR_handler )( uint32_t );
302 
304  uint32_t vector,
305  CPU_ISR_handler new_handler,
306  CPU_ISR_handler *old_handler
307 );
308 
309 void *_CPU_Thread_Idle_body( uintptr_t ignored );
310 
312 
314  Context_Control *new_context
316 
318 
319 static inline uint32_t CPU_swap_u32( uint32_t value )
320 {
321  uint32_t byte1, byte2, byte3, byte4, swapped;
322 
323  byte4 = (value >> 24) & 0xff;
324  byte3 = (value >> 16) & 0xff;
325  byte2 = (value >> 8) & 0xff;
326  byte1 = value & 0xff;
327 
328  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
329 
330  return swapped;
331 }
332 
333 #define CPU_swap_u16( value ) \
334  (((value&0xff) << 8) | ((value >> 8)&0xff))
335 
336 typedef uint32_t CPU_Counter_ticks;
337 
338 uint32_t _CPU_Counter_frequency( void );
339 
340 CPU_Counter_ticks _CPU_Counter_read( void );
341 
342 static inline CPU_Counter_ticks _CPU_Counter_difference(
343  CPU_Counter_ticks second,
344  CPU_Counter_ticks first
345 )
346 {
347  return second - first;
348 }
349 
351 typedef uintptr_t CPU_Uint32ptr;
352 
353 #endif /* ASM */
354 
355 #ifdef __cplusplus
356 }
357 #endif
358 
359 #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
void _CPU_ISR_Set_level(uint32_t level)
Sets the hardware interrupt level by the level value.
Definition: cpu.c:57
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
Interrupt stack frame (ISF).
Definition: cpu.h:306
#define fp
frame-pointer */
Definition: regs.h:65
void _CPU_Context_Initialize(Context_Control *context, void *stack_area_begin, size_t stack_area_size, uint32_t new_level, void(*entry_point)(void), bool is_fp, void *tls_area)
Initializes the CPU context.
Definition: epiphany-context-initialize.c:40
void _CPU_Context_switch(Context_Control *run, Context_Control *heir)
CPU switch context.
Definition: cpu_asm.c:91
NIOS II Set up Basic CPU Dependency Settings Based on Compiler Settings.
void _CPU_Initialize(void)
CPU initialization.
Definition: cpu.c:45
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
unsigned context
Definition: tlb.h:108
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
void _CPU_Fatal_halt(uint32_t source, uint32_t error) RTEMS_NO_RETURN
Definition: bsp_fatal_halt.c:12
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
The set of registers that specifies the complete processor state.
Definition: cpu.h:635
#define gp
global data pointer */
Definition: regs.h:63