source: rtems/cpukit/score/cpu/nios2/rtems/score/cpu.h @ 2a5880f1

4.115
Last change on this file since 2a5880f1 was 2a5880f1, checked in by Sebastian Huber <sebastian.huber@…>, on 08/10/11 at 15:00:53

2011-08-10 Sebastian Huber <sebastian.huber@…>

  • rtems/score/cpu.h: Removed superfluous comments. Format. Include by assembler support. Removed superfluous floating-point support. Stack alignment is now 4.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 *  Copyright (c) 2011 embedded brains GmbH
3 *
4 *  Copyright (c) 2006 Kolja Waschk (rtemsdev/ixo.de)
5 *
6 *  COPYRIGHT (c) 1989-2004.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef _RTEMS_SCORE_CPU_H
17#define _RTEMS_SCORE_CPU_H
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <rtems/score/types.h>
24#include <rtems/score/nios2.h>
25
26/*
27 * TODO: Run the timing tests and figure out what is better.
28 */
29#define CPU_INLINE_ENABLE_DISPATCH FALSE
30
31/*
32 * TODO: Run the timing tests and figure out what is better.
33 */
34#define CPU_UNROLL_ENQUEUE_PRIORITY TRUE
35
36#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE
37
38#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
39
40#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32
41
42#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
43
44#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
45
46#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
47
48#define CPU_ALLOCATE_INTERRUPT_STACK TRUE
49
50#define CPU_ISR_PASSES_FRAME_POINTER 1
51
52#define CPU_HARDWARE_FP FALSE
53
54#define CPU_SOFTWARE_FP FALSE
55
56#define CPU_CONTEXT_FP_SIZE 0
57
58#define CPU_ALL_TASKS_ARE_FP FALSE
59
60#define CPU_IDLE_TASK_IS_FP FALSE
61
62#define CPU_USE_DEFERRED_FP_SWITCH FALSE
63
64#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE
65
66#define CPU_STACK_GROWS_UP FALSE
67
68/*
69 * TODO: Run the timing tests and figure out if we profit from cache alignment.
70 */
71#define CPU_STRUCTURE_ALIGNMENT
72
73#define CPU_BIG_ENDIAN FALSE
74
75#define CPU_LITTLE_ENDIAN TRUE
76
77#define CPU_STACK_MINIMUM_SIZE (4 * 1024)
78
79/*
80 * Alignment value according to "Nios II Processor Reference" chapter 7
81 * "Application Binary Interface" section "Memory Alignment".
82 */
83#define CPU_ALIGNMENT 4
84
85#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
86
87#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT
88
89#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT
90
91#define CPU_MODES_INTERRUPT_MASK 0x1
92
93#define CPU_USE_GENERIC_BITFIELD_CODE TRUE
94
95#define CPU_USE_GENERIC_BITFIELD_DATA TRUE
96
97#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
98
99#ifndef ASM
100
101/**
102 * @brief Thread register context.
103 *
104 * The thread register context covers the non-volatile registers, the thread
105 * stack pointer, the return address, and the processor status.
106 *
107 * There is no need to save the global pointer (gp) since it is a system wide
108 * constant and set-up with the C runtime environment.
109 */
110typedef struct {
111  uint32_t r16;
112  uint32_t r17;
113  uint32_t r18;
114  uint32_t r19;
115  uint32_t r20;
116  uint32_t r21;
117  uint32_t r22;
118  uint32_t r23;
119  uint32_t fp;
120  uint32_t sp;
121  uint32_t ra;
122  uint32_t status;
123} Context_Control;
124
125#define _CPU_Context_Get_SP( _context ) \
126  (_context)->sp
127
128typedef struct {
129  uint32_t r1;
130  uint32_t r2;
131  uint32_t r3;
132  uint32_t r4;
133  uint32_t r5;
134  uint32_t r6;
135  uint32_t r7;
136  uint32_t r8;
137  uint32_t r9;
138  uint32_t r10;
139  uint32_t r11;
140  uint32_t r12;
141  uint32_t r13;
142  uint32_t r14;
143  uint32_t r15;
144  uint32_t ra;
145  uint32_t gp;
146  uint32_t et;
147  uint32_t ea;
148} CPU_Interrupt_frame;
149
150typedef struct {
151  uint32_t r1;
152  uint32_t r2;
153  uint32_t r3;
154  uint32_t r4;
155  uint32_t r5;
156  uint32_t r6;
157  uint32_t r7;
158  uint32_t r8;
159  uint32_t r9;
160  uint32_t r10;
161  uint32_t r11;
162  uint32_t r12;
163  uint32_t r13;
164  uint32_t r14;
165  uint32_t r15;
166  uint32_t r16;
167  uint32_t r17;
168  uint32_t r18;
169  uint32_t r19;
170  uint32_t r20;
171  uint32_t r21;
172  uint32_t r22;
173  uint32_t r23;
174  uint32_t gp;
175  uint32_t fp;
176  uint32_t sp;
177  uint32_t ra;
178  uint32_t et;
179  uint32_t ea;
180  uint32_t status;
181  uint32_t ienable;
182  uint32_t ipending;
183} CPU_Exception_frame;
184
185#define _CPU_Initialize_vectors()
186
187#define _CPU_ISR_Disable( _isr_cookie ) \
188  do { \
189    _isr_cookie = __builtin_rdctl( 0 ); \
190    __builtin_wrctl( 0, 0 ); \
191  } while ( 0 )
192
193#define _CPU_ISR_Enable( _isr_cookie ) \
194  do { \
195    __builtin_wrctl( 0, (int) _isr_cookie ); \
196  } while ( 0 )
197
198#define _CPU_ISR_Flash( _isr_cookie ) \
199  do { \
200    __builtin_wrctl( 0, (int) _isr_cookie ); \
201    __builtin_wrctl( 0, 0 ); \
202  } while ( 0 )
203
204#define _CPU_ISR_Set_level( new_level ) \
205  _CPU_ISR_Enable( new_level == 0 ? 1 : 0 );
206
207uint32_t _CPU_ISR_Get_level( void );
208
209/*
210 * FIXME: Evaluate interrupt level.
211 */
212#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
213                                 _isr, _entry_point, _is_fp ) \
214  do { \
215    uint32_t _stack = (uint32_t)(_stack_base) + (_size) - 4; \
216    (_the_context)->fp = (void *)_stack; \
217    (_the_context)->sp = (void *)_stack; \
218    (_the_context)->ra = (void *)(_entry_point); \
219    (_the_context)->status  = 0x1; /* IRQs enabled */ \
220  } while ( 0 )
221
222#define _CPU_Context_Restart_self( _the_context ) \
223  _CPU_Context_restore( (_the_context) );
224
225#define _CPU_Fatal_halt( _error ) \
226  do { \
227    __builtin_wrctl(0, 0); /* write 0 to status register (disable interrupts) */ \
228    __asm volatile ("mov et, %z0" : : "rM" (_error)); /* write error code to ET register */ \
229    for (;;); \
230  } while ( 0 )
231
232void _CPU_Initialize( void );
233
234void _CPU_ISR_install_raw_handler(
235  uint32_t vector,
236  proc_ptr new_handler,
237  proc_ptr *old_handler
238);
239
240void _CPU_ISR_install_vector(
241  uint32_t vector,
242  proc_ptr new_handler,
243  proc_ptr *old_handler
244);
245
246void _CPU_Context_switch( Context_Control *run, Context_Control *heir );
247
248void _CPU_Context_restore(
249  Context_Control *new_context
250) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
251
252static inline uint32_t CPU_swap_u32( uint32_t value )
253{
254  uint32_t byte1, byte2, byte3, byte4, swapped;
255
256  byte4 = (value >> 24) & 0xff;
257  byte3 = (value >> 16) & 0xff;
258  byte2 = (value >> 8)  & 0xff;
259  byte1 =  value        & 0xff;
260
261  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
262
263  return swapped;
264}
265
266#define CPU_swap_u16( value ) \
267  (((value&0xff) << 8) | ((value >> 8)&0xff))
268
269#endif /* ASM */
270
271#ifdef __cplusplus
272}
273#endif
274
275#endif
Note: See TracBrowser for help on using the repository browser.