source: rtems/cpukit/score/cpu/sparc/rtems/score/cpu.h @ f8ad6c6f

4.115
Last change on this file since f8ad6c6f was f8ad6c6f, checked in by Sebastian Huber <sebastian.huber@…>, on 08/02/13 at 12:12:55

sparc: Make _CPU_ISR_Dispatch_disable per-CPU

This variable must be available for each processor in the system.

  • Property mode set to 100644
File size: 45.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief SPARC CPU Department Source
5 *
6 * This include file contains information pertaining to the port of
7 * the executive to the SPARC processor.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2011.
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.com/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_CPU_H
20#define _RTEMS_SCORE_CPU_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <rtems/score/types.h>
27#include <rtems/score/sparc.h>
28
29/* conditional compilation parameters */
30
31/**
32 * Should the calls to _Thread_Enable_dispatch be inlined?
33 *
34 * - If TRUE, then they are inlined.
35 * - If FALSE, then a subroutine call is made.
36 *
37 * On this port, it is faster to inline _Thread_Enable_dispatch.
38 */
39#define CPU_INLINE_ENABLE_DISPATCH       TRUE
40
41/**
42 * Should the body of the search loops in _Thread_queue_Enqueue_priority
43 * be unrolled one time?  In unrolled each iteration of the loop examines
44 * two "nodes" on the chain being searched.  Otherwise, only one node
45 * is examined per iteration.
46 *
47 * - If TRUE, then the loops are unrolled.
48 * - If FALSE, then the loops are not unrolled.
49 *
50 * This parameter could go either way on the SPARC.  The interrupt flash
51 * code is relatively lengthy given the requirements for nops following
52 * writes to the psr.  But if the clock speed were high enough, this would
53 * not represent a great deal of time.
54 */
55#define CPU_UNROLL_ENQUEUE_PRIORITY      TRUE
56
57/**
58 * Does the executive manage a dedicated interrupt stack in software?
59 *
60 * If TRUE, then a stack is allocated in _ISR_Handler_initialization.
61 * If FALSE, nothing is done.
62 *
63 * The SPARC does not have a dedicated HW interrupt stack and one has
64 * been implemented in SW.
65 */
66#define CPU_HAS_SOFTWARE_INTERRUPT_STACK   TRUE
67
68/**
69 * Does the CPU follow the simple vectored interrupt model?
70 *
71 * - If TRUE, then RTEMS allocates the vector table it internally manages.
72 * - If FALSE, then the BSP is assumed to allocate and manage the vector
73 *   table
74 *
75 * THe SPARC is a simple vectored architecture.  Usually there is no
76 * PIC and the CPU directly vectors the interrupts.
77 */
78#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
79
80/**
81 * Does this CPU have hardware support for a dedicated interrupt stack?
82 *
83 * - If TRUE, then it must be installed during initialization.
84 * - If FALSE, then no installation is performed.
85 *
86 * The SPARC does not have a dedicated HW interrupt stack.
87 */
88#define CPU_HAS_HARDWARE_INTERRUPT_STACK  FALSE
89
90/**
91 * Do we allocate a dedicated interrupt stack in the Interrupt Manager?
92 *
93 * - If TRUE, then the memory is allocated during initialization.
94 * - If FALSE, then the memory is allocated during initialization.
95 *
96 * The SPARC does not have hardware support for switching to a
97 * dedicated interrupt stack.  The port includes support for doing this
98 * in software.
99 *
100 */
101#define CPU_ALLOCATE_INTERRUPT_STACK      TRUE
102
103/**
104 * Does the RTEMS invoke the user's ISR with the vector number and
105 * a pointer to the saved interrupt frame (1) or just the vector
106 * number (0)?
107 *
108 * The SPARC port does not pass an Interrupt Stack Frame pointer to
109 * interrupt handlers.
110 */
111#define CPU_ISR_PASSES_FRAME_POINTER 0
112
113/**
114 * Does the CPU have hardware floating point?
115 *
116 * - If TRUE, then the FLOATING_POINT task attribute is supported.
117 * - If FALSE, then the FLOATING_POINT task attribute is ignored.
118 *
119 * This is set based upon the multilib settings.
120 */
121#if ( SPARC_HAS_FPU == 1 )
122  #define CPU_HARDWARE_FP     TRUE
123#else
124  #define CPU_HARDWARE_FP     FALSE
125#endif
126
127/**
128 * The SPARC GCC port does not have a software floating point library
129 * that requires RTEMS assistance.
130 */
131#define CPU_SOFTWARE_FP     FALSE
132
133/**
134 * Are all tasks FLOATING_POINT tasks implicitly?
135 *
136 * - If TRUE, then the FLOATING_POINT task attribute is assumed.
137 * - If FALSE, then the FLOATING_POINT task attribute is followed.
138 *
139 * The SPARC GCC port does not implicitly use floating point registers.
140 */
141#define CPU_ALL_TASKS_ARE_FP     FALSE
142
143/**
144 * Should the IDLE task have a floating point context?
145 *
146 * - If TRUE, then the IDLE task is created as a FLOATING_POINT task
147 *   and it has a floating point context which is switched in and out.
148 * - If FALSE, then the IDLE task does not have a floating point context.
149 *
150 * The IDLE task does not have to be floating point on the SPARC.
151 */
152#define CPU_IDLE_TASK_IS_FP      FALSE
153
154/**
155 * Should the saving of the floating point registers be deferred
156 * until a context switch is made to another different floating point
157 * task?
158 *
159 * - If TRUE, then the floating point context will not be stored until
160 * necessary.  It will remain in the floating point registers and not
161 * disturned until another floating point task is switched to.
162 *
163 * - If FALSE, then the floating point context is saved when a floating
164 * point task is switched out and restored when the next floating point
165 * task is restored.  The state of the floating point registers between
166 * those two operations is not specified.
167 *
168 * On the SPARC, we can disable the FPU for integer only tasks so
169 * it is safe to defer floating point context switches.
170 */
171#if defined(RTEMS_SMP)
172  #define CPU_USE_DEFERRED_FP_SWITCH FALSE
173#else
174  #define CPU_USE_DEFERRED_FP_SWITCH TRUE
175#endif
176
177/**
178 * Does this port provide a CPU dependent IDLE task implementation?
179 *
180 * - If TRUE, then the routine _CPU_Thread_Idle_body
181 * must be provided and is the default IDLE thread body instead of
182 * _CPU_Thread_Idle_body.
183 *
184 * - If FALSE, then use the generic IDLE thread body if the BSP does
185 * not provide one.
186 *
187 * The SPARC architecture does not have a low power or halt instruction.
188 * It is left to the BSP and/or CPU specific code to provide an IDLE
189 * thread body which is aware of low power modes.
190 */
191#define CPU_PROVIDES_IDLE_THREAD_BODY    FALSE
192
193/**
194 * Does the stack grow up (toward higher addresses) or down
195 * (toward lower addresses)?
196 *
197 * - If TRUE, then the grows upward.
198 * - If FALSE, then the grows toward smaller addresses.
199 *
200 * The stack grows to lower addresses on the SPARC.
201 */
202#define CPU_STACK_GROWS_UP               FALSE
203
204/**
205 * The following is the variable attribute used to force alignment
206 * of critical data structures.  On some processors it may make
207 * sense to have these aligned on tighter boundaries than
208 * the minimum requirements of the compiler in order to have as
209 * much of the critical data area as possible in a cache line.
210 *
211 * The SPARC does not appear to have particularly strict alignment
212 * requirements.  This value was chosen to take advantages of caches.
213 */
214#define CPU_STRUCTURE_ALIGNMENT          __attribute__ ((aligned (16)))
215
216#define CPU_TIMESTAMP_USE_INT64_INLINE TRUE
217
218/**
219 * Define what is required to specify how the network to host conversion
220 * routines are handled.
221 *
222 * The SPARC is big endian.
223 */
224#define CPU_BIG_ENDIAN                           TRUE
225
226/**
227 * Define what is required to specify how the network to host conversion
228 * routines are handled.
229 *
230 * The SPARC is NOT little endian.
231 */
232#define CPU_LITTLE_ENDIAN                        FALSE
233
234/**
235 * The following defines the number of bits actually used in the
236 * interrupt field of the task mode.  How those bits map to the
237 * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
238 *
239 * The SPARC has 16 interrupt levels in the PIL field of the PSR.
240 */
241#define CPU_MODES_INTERRUPT_MASK   0x0000000F
242
243#ifndef ASM
244/**
245 * This structure represents the organization of the minimum stack frame
246 * for the SPARC.  More framing information is required in certain situaions
247 * such as when there are a large number of out parameters or when the callee
248 * must save floating point registers.
249 */
250typedef struct {
251  /** This is the offset of the l0 register. */
252  uint32_t    l0;
253  /** This is the offset of the l1 register. */
254  uint32_t    l1;
255  /** This is the offset of the l2 register. */
256  uint32_t    l2;
257  /** This is the offset of the l3 register. */
258  uint32_t    l3;
259  /** This is the offset of the l4 register. */
260  uint32_t    l4;
261  /** This is the offset of the l5 register. */
262  uint32_t    l5;
263  /** This is the offset of the l6 register. */
264  uint32_t    l6;
265  /** This is the offset of the l7 register. */
266  uint32_t    l7;
267  /** This is the offset of the l0 register. */
268  uint32_t    i0;
269  /** This is the offset of the i1 register. */
270  uint32_t    i1;
271  /** This is the offset of the i2 register. */
272  uint32_t    i2;
273  /** This is the offset of the i3 register. */
274  uint32_t    i3;
275  /** This is the offset of the i4 register. */
276  uint32_t    i4;
277  /** This is the offset of the i5 register. */
278  uint32_t    i5;
279  /** This is the offset of the i6 register. */
280  uint32_t    i6_fp;
281  /** This is the offset of the i7 register. */
282  uint32_t    i7;
283  /** This is the offset of the register used to return structures. */
284  void       *structure_return_address;
285
286  /*
287   * The following are for the callee to save the register arguments in
288   * should this be necessary.
289   */
290  /** This is the offset of the register for saved argument 0. */
291  uint32_t    saved_arg0;
292  /** This is the offset of the register for saved argument 1. */
293  uint32_t    saved_arg1;
294  /** This is the offset of the register for saved argument 2. */
295  uint32_t    saved_arg2;
296  /** This is the offset of the register for saved argument 3. */
297  uint32_t    saved_arg3;
298  /** This is the offset of the register for saved argument 4. */
299  uint32_t    saved_arg4;
300  /** This is the offset of the register for saved argument 5. */
301  uint32_t    saved_arg5;
302  /** This field pads the structure so ldd and std instructions can be used. */
303  uint32_t    pad0;
304}  CPU_Minimum_stack_frame;
305
306#endif /* ASM */
307
308/** This macro defines an offset into the stack frame for use in assembly. */
309#define CPU_STACK_FRAME_L0_OFFSET             0x00
310/** This macro defines an offset into the stack frame for use in assembly. */
311#define CPU_STACK_FRAME_L1_OFFSET             0x04
312/** This macro defines an offset into the stack frame for use in assembly. */
313#define CPU_STACK_FRAME_L2_OFFSET             0x08
314/** This macro defines an offset into the stack frame for use in assembly. */
315#define CPU_STACK_FRAME_L3_OFFSET             0x0c
316/** This macro defines an offset into the stack frame for use in assembly. */
317#define CPU_STACK_FRAME_L4_OFFSET             0x10
318/** This macro defines an offset into the stack frame for use in assembly. */
319#define CPU_STACK_FRAME_L5_OFFSET             0x14
320/** This macro defines an offset into the stack frame for use in assembly. */
321#define CPU_STACK_FRAME_L6_OFFSET             0x18
322/** This macro defines an offset into the stack frame for use in assembly. */
323#define CPU_STACK_FRAME_L7_OFFSET             0x1c
324/** This macro defines an offset into the stack frame for use in assembly. */
325#define CPU_STACK_FRAME_I0_OFFSET             0x20
326/** This macro defines an offset into the stack frame for use in assembly. */
327#define CPU_STACK_FRAME_I1_OFFSET             0x24
328/** This macro defines an offset into the stack frame for use in assembly. */
329#define CPU_STACK_FRAME_I2_OFFSET             0x28
330/** This macro defines an offset into the stack frame for use in assembly. */
331#define CPU_STACK_FRAME_I3_OFFSET             0x2c
332/** This macro defines an offset into the stack frame for use in assembly. */
333#define CPU_STACK_FRAME_I4_OFFSET             0x30
334/** This macro defines an offset into the stack frame for use in assembly. */
335#define CPU_STACK_FRAME_I5_OFFSET             0x34
336/** This macro defines an offset into the stack frame for use in assembly. */
337#define CPU_STACK_FRAME_I6_FP_OFFSET          0x38
338/** This macro defines an offset into the stack frame for use in assembly. */
339#define CPU_STACK_FRAME_I7_OFFSET             0x3c
340/** This macro defines an offset into the stack frame for use in assembly. */
341#define CPU_STRUCTURE_RETURN_ADDRESS_OFFSET   0x40
342/** This macro defines an offset into the stack frame for use in assembly. */
343#define CPU_STACK_FRAME_SAVED_ARG0_OFFSET     0x44
344/** This macro defines an offset into the stack frame for use in assembly. */
345#define CPU_STACK_FRAME_SAVED_ARG1_OFFSET     0x48
346/** This macro defines an offset into the stack frame for use in assembly. */
347#define CPU_STACK_FRAME_SAVED_ARG2_OFFSET     0x4c
348/** This macro defines an offset into the stack frame for use in assembly. */
349#define CPU_STACK_FRAME_SAVED_ARG3_OFFSET     0x50
350/** This macro defines an offset into the stack frame for use in assembly. */
351#define CPU_STACK_FRAME_SAVED_ARG4_OFFSET     0x54
352/** This macro defines an offset into the stack frame for use in assembly. */
353#define CPU_STACK_FRAME_SAVED_ARG5_OFFSET     0x58
354/** This macro defines an offset into the stack frame for use in assembly. */
355#define CPU_STACK_FRAME_PAD0_OFFSET           0x5c
356
357/** This defines the size of the minimum stack frame. */
358#define CPU_MINIMUM_STACK_FRAME_SIZE          0x60
359
360#define CPU_PER_CPU_CONTROL_SIZE 4
361
362/**
363 * @brief Offset of the CPU_Per_CPU_control::isr_dispatch_disable field
364 * relative to the Per_CPU_Control begin.
365 */
366#define SPARC_PER_CPU_ISR_DISPATCH_DISABLE 0
367
368/**
369 * @defgroup Contexts SPARC Context Structures
370 *
371 * @ingroup Score
372 *
373 * Generally there are 2 types of context to save.
374 *    + Interrupt registers to save
375 *    + Task level registers to save
376 *
377 * This means we have the following 3 context items:
378 *    + task level context stuff::  Context_Control
379 *    + floating point task stuff:: Context_Control_fp
380 *    + special interrupt level context :: Context_Control_interrupt
381 *
382 * On the SPARC, we are relatively conservative in that we save most
383 * of the CPU state in the context area.  The ET (enable trap) bit and
384 * the CWP (current window pointer) fields of the PSR are considered
385 * system wide resources and are not maintained on a per-thread basis.
386 */
387/**@{**/
388
389#ifndef ASM
390
391typedef struct {
392  /**
393   * This flag is context switched with each thread.  It indicates
394   * that THIS thread has an _ISR_Dispatch stack frame on its stack.
395   * By using this flag, we can avoid nesting more interrupt dispatching
396   * attempts on a previously interrupted thread's stack.
397   */
398  uint32_t isr_dispatch_disable;
399} CPU_Per_CPU_control;
400
401/**
402 * @brief SPARC basic context.
403 *
404 * This structure defines the basic integer and processor state context
405 * for the SPARC architecture.
406 */
407typedef struct {
408  /**
409   * Using a double g0_g1 will put everything in this structure on a
410   * double word boundary which allows us to use double word loads
411   * and stores safely in the context switch.
412   */
413  double     g0_g1;
414  /** This will contain the contents of the g2 register. */
415  uint32_t   g2;
416  /** This will contain the contents of the g3 register. */
417  uint32_t   g3;
418  /** This will contain the contents of the g4 register. */
419  uint32_t   g4;
420  /** This will contain the contents of the g5 register. */
421  uint32_t   g5;
422  /** This will contain the contents of the g6 register. */
423  uint32_t   g6;
424  /** This will contain the contents of the g7 register. */
425  uint32_t   g7;
426
427  /** This will contain the contents of the l0 register. */
428  uint32_t   l0;
429  /** This will contain the contents of the l1 register. */
430  uint32_t   l1;
431  /** This will contain the contents of the l2 register. */
432  uint32_t   l2;
433  /** This will contain the contents of the l3 register. */
434  uint32_t   l3;
435  /** This will contain the contents of the l4 register. */
436  uint32_t   l4;
437  /** This will contain the contents of the l5 registeer.*/
438  uint32_t   l5;
439  /** This will contain the contents of the l6 register. */
440  uint32_t   l6;
441  /** This will contain the contents of the l7 register. */
442  uint32_t   l7;
443
444  /** This will contain the contents of the i0 register. */
445  uint32_t   i0;
446  /** This will contain the contents of the i1 register. */
447  uint32_t   i1;
448  /** This will contain the contents of the i2 register. */
449  uint32_t   i2;
450  /** This will contain the contents of the i3 register. */
451  uint32_t   i3;
452  /** This will contain the contents of the i4 register. */
453  uint32_t   i4;
454  /** This will contain the contents of the i5 register. */
455  uint32_t   i5;
456  /** This will contain the contents of the i6 (e.g. frame pointer) register. */
457  uint32_t   i6_fp;
458  /** This will contain the contents of the i7 register. */
459  uint32_t   i7;
460
461  /** This will contain the contents of the o0 register. */
462  uint32_t   o0;
463  /** This will contain the contents of the o1 register. */
464  uint32_t   o1;
465  /** This will contain the contents of the o2 register. */
466  uint32_t   o2;
467  /** This will contain the contents of the o3 register. */
468  uint32_t   o3;
469  /** This will contain the contents of the o4 register. */
470  uint32_t   o4;
471  /** This will contain the contents of the o5 register. */
472  uint32_t   o5;
473  /** This will contain the contents of the o6 (e.g. frame pointer) register. */
474  uint32_t   o6_sp;
475  /** This will contain the contents of the o7 register. */
476  uint32_t   o7;
477
478  /** This will contain the contents of the processor status register. */
479  uint32_t   psr;
480  /**
481   * This field is used to prevent heavy nesting of calls to _Thread_Dispatch
482   * on an interrupted  task's stack.  This is problematic on the slower
483   * SPARC CPU models at high interrupt rates.
484   */
485  uint32_t   isr_dispatch_disable;
486} Context_Control;
487
488/**
489 * This macro provides a CPU independent way for RTEMS to access the
490 * stack pointer in a context structure. The actual name and offset is
491 * CPU architecture dependent.
492 */
493#define _CPU_Context_Get_SP( _context ) \
494  (_context)->o6_sp
495
496#endif /* ASM */
497
498/*
499 *  Offsets of fields with Context_Control for assembly routines.
500 */
501
502/** This macro defines an offset into the context for use in assembly. */
503#define G0_OFFSET    0x00
504/** This macro defines an offset into the context for use in assembly. */
505#define G1_OFFSET    0x04
506/** This macro defines an offset into the context for use in assembly. */
507#define G2_OFFSET    0x08
508/** This macro defines an offset into the context for use in assembly. */
509#define G3_OFFSET    0x0C
510/** This macro defines an offset into the context for use in assembly. */
511#define G4_OFFSET    0x10
512/** This macro defines an offset into the context for use in assembly. */
513#define G5_OFFSET    0x14
514/** This macro defines an offset into the context for use in assembly. */
515#define G6_OFFSET    0x18
516/** This macro defines an offset into the context for use in assembly. */
517#define G7_OFFSET    0x1C
518
519/** This macro defines an offset into the context for use in assembly. */
520#define L0_OFFSET    0x20
521/** This macro defines an offset into the context for use in assembly. */
522#define L1_OFFSET    0x24
523/** This macro defines an offset into the context for use in assembly. */
524#define L2_OFFSET    0x28
525/** This macro defines an offset into the context for use in assembly. */
526#define L3_OFFSET    0x2C
527/** This macro defines an offset into the context for use in assembly. */
528#define L4_OFFSET    0x30
529/** This macro defines an offset into the context for use in assembly. */
530#define L5_OFFSET    0x34
531/** This macro defines an offset into the context for use in assembly. */
532#define L6_OFFSET    0x38
533/** This macro defines an offset into the context for use in assembly. */
534#define L7_OFFSET    0x3C
535
536/** This macro defines an offset into the context for use in assembly. */
537#define I0_OFFSET    0x40
538/** This macro defines an offset into the context for use in assembly. */
539#define I1_OFFSET    0x44
540/** This macro defines an offset into the context for use in assembly. */
541#define I2_OFFSET    0x48
542/** This macro defines an offset into the context for use in assembly. */
543#define I3_OFFSET    0x4C
544/** This macro defines an offset into the context for use in assembly. */
545#define I4_OFFSET    0x50
546/** This macro defines an offset into the context for use in assembly. */
547#define I5_OFFSET    0x54
548/** This macro defines an offset into the context for use in assembly. */
549#define I6_FP_OFFSET 0x58
550/** This macro defines an offset into the context for use in assembly. */
551#define I7_OFFSET    0x5C
552
553/** This macro defines an offset into the context for use in assembly. */
554#define O0_OFFSET    0x60
555/** This macro defines an offset into the context for use in assembly. */
556#define O1_OFFSET    0x64
557/** This macro defines an offset into the context for use in assembly. */
558#define O2_OFFSET    0x68
559/** This macro defines an offset into the context for use in assembly. */
560#define O3_OFFSET    0x6C
561/** This macro defines an offset into the context for use in assembly. */
562#define O4_OFFSET    0x70
563/** This macro defines an offset into the context for use in assembly. */
564#define O5_OFFSET    0x74
565/** This macro defines an offset into the context for use in assembly. */
566#define O6_SP_OFFSET 0x78
567/** This macro defines an offset into the context for use in assembly. */
568#define O7_OFFSET    0x7C
569
570/** This macro defines an offset into the context for use in assembly. */
571#define PSR_OFFSET   0x80
572/** This macro defines an offset into the context for use in assembly. */
573#define ISR_DISPATCH_DISABLE_STACK_OFFSET 0x84
574
575/** This defines the size of the context area for use in assembly. */
576#define CONTEXT_CONTROL_SIZE 0x88
577
578#ifndef ASM
579/**
580 * @brief SPARC basic context.
581 *
582 * This structure defines floating point context area.
583 */
584typedef struct {
585  /** This will contain the contents of the f0 and f1 register. */
586  double      f0_f1;
587  /** This will contain the contents of the f2 and f3 register. */
588  double      f2_f3;
589  /** This will contain the contents of the f4 and f5 register. */
590  double      f4_f5;
591  /** This will contain the contents of the f6 and f7 register. */
592  double      f6_f7;
593  /** This will contain the contents of the f8 and f9 register. */
594  double      f8_f9;
595  /** This will contain the contents of the f10 and f11 register. */
596  double      f10_f11;
597  /** This will contain the contents of the f12 and f13 register. */
598  double      f12_f13;
599  /** This will contain the contents of the f14 and f15 register. */
600  double      f14_f15;
601  /** This will contain the contents of the f16 and f17 register. */
602  double      f16_f17;
603  /** This will contain the contents of the f18 and f19 register. */
604  double      f18_f19;
605  /** This will contain the contents of the f20 and f21 register. */
606  double      f20_f21;
607  /** This will contain the contents of the f22 and f23 register. */
608  double      f22_f23;
609  /** This will contain the contents of the f24 and f25 register. */
610  double      f24_f25;
611  /** This will contain the contents of the f26 and f27 register. */
612  double      f26_f27;
613  /** This will contain the contents of the f28 and f29 register. */
614  double      f28_f29;
615  /** This will contain the contents of the f30 and f31 register. */
616  double      f30_f31;
617  /** This will contain the contents of the floating point status register. */
618  uint32_t    fsr;
619} Context_Control_fp;
620
621#endif /* ASM */
622
623/*
624 *  Offsets of fields with Context_Control_fp for assembly routines.
625 */
626
627/** This macro defines an offset into the FPU context for use in assembly. */
628#define FO_F1_OFFSET     0x00
629/** This macro defines an offset into the FPU context for use in assembly. */
630#define F2_F3_OFFSET     0x08
631/** This macro defines an offset into the FPU context for use in assembly. */
632#define F4_F5_OFFSET     0x10
633/** This macro defines an offset into the FPU context for use in assembly. */
634#define F6_F7_OFFSET     0x18
635/** This macro defines an offset into the FPU context for use in assembly. */
636#define F8_F9_OFFSET     0x20
637/** This macro defines an offset into the FPU context for use in assembly. */
638#define F1O_F11_OFFSET   0x28
639/** This macro defines an offset into the FPU context for use in assembly. */
640#define F12_F13_OFFSET   0x30
641/** This macro defines an offset into the FPU context for use in assembly. */
642#define F14_F15_OFFSET   0x38
643/** This macro defines an offset into the FPU context for use in assembly. */
644#define F16_F17_OFFSET   0x40
645/** This macro defines an offset into the FPU context for use in assembly. */
646#define F18_F19_OFFSET   0x48
647/** This macro defines an offset into the FPU context for use in assembly. */
648#define F2O_F21_OFFSET   0x50
649/** This macro defines an offset into the FPU context for use in assembly. */
650#define F22_F23_OFFSET   0x58
651/** This macro defines an offset into the FPU context for use in assembly. */
652#define F24_F25_OFFSET   0x60
653/** This macro defines an offset into the FPU context for use in assembly. */
654#define F26_F27_OFFSET   0x68
655/** This macro defines an offset into the FPU context for use in assembly. */
656#define F28_F29_OFFSET   0x70
657/** This macro defines an offset into the FPU context for use in assembly. */
658#define F3O_F31_OFFSET   0x78
659/** This macro defines an offset into the FPU context for use in assembly. */
660#define FSR_OFFSET       0x80
661
662/** This defines the size of the FPU context area for use in assembly. */
663#define CONTEXT_CONTROL_FP_SIZE 0x84
664
665#ifndef ASM
666
667/** @} */
668
669/**
670 * @brief Interrupt stack frame (ISF).
671 *
672 * Context saved on stack for an interrupt.
673 *
674 * NOTE: The PSR, PC, and NPC are only saved in this structure for the
675 *       benefit of the user's handler.
676 */
677typedef struct {
678  /** On an interrupt, we must save the minimum stack frame. */
679  CPU_Minimum_stack_frame  Stack_frame;
680  /** This is the offset of the PSR on an ISF. */
681  uint32_t                 psr;
682  /** This is the offset of the XXX on an ISF. */
683  uint32_t                 pc;
684  /** This is the offset of the XXX on an ISF. */
685  uint32_t                 npc;
686  /** This is the offset of the g1 register on an ISF. */
687  uint32_t                 g1;
688  /** This is the offset of the g2 register on an ISF. */
689  uint32_t                 g2;
690  /** This is the offset of the g3 register on an ISF. */
691  uint32_t                 g3;
692  /** This is the offset of the g4 register on an ISF. */
693  uint32_t                 g4;
694  /** This is the offset of the g5 register on an ISF. */
695  uint32_t                 g5;
696  /** This is the offset of the g6 register on an ISF. */
697  uint32_t                 g6;
698  /** This is the offset of the g7 register on an ISF. */
699  uint32_t                 g7;
700  /** This is the offset of the i0 register on an ISF. */
701  uint32_t                 i0;
702  /** This is the offset of the i1 register on an ISF. */
703  uint32_t                 i1;
704  /** This is the offset of the i2 register on an ISF. */
705  uint32_t                 i2;
706  /** This is the offset of the i3 register on an ISF. */
707  uint32_t                 i3;
708  /** This is the offset of the i4 register on an ISF. */
709  uint32_t                 i4;
710  /** This is the offset of the i5 register on an ISF. */
711  uint32_t                 i5;
712  /** This is the offset of the i6 register on an ISF. */
713  uint32_t                 i6_fp;
714  /** This is the offset of the i7 register on an ISF. */
715  uint32_t                 i7;
716  /** This is the offset of the y register on an ISF. */
717  uint32_t                 y;
718  /** This is the offset of the tpc register on an ISF. */
719  uint32_t                 tpc;
720} CPU_Interrupt_frame;
721
722#endif /* ASM */
723
724/*
725 *  Offsets of fields with CPU_Interrupt_frame for assembly routines.
726 */
727
728/** This macro defines an offset into the ISF for use in assembly. */
729#define ISF_STACK_FRAME_OFFSET 0x00
730/** This macro defines an offset into the ISF for use in assembly. */
731#define ISF_PSR_OFFSET         CPU_MINIMUM_STACK_FRAME_SIZE + 0x00
732/** This macro defines an offset into the ISF for use in assembly. */
733#define ISF_PC_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x04
734/** This macro defines an offset into the ISF for use in assembly. */
735#define ISF_NPC_OFFSET         CPU_MINIMUM_STACK_FRAME_SIZE + 0x08
736/** This macro defines an offset into the ISF for use in assembly. */
737#define ISF_G1_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x0c
738/** This macro defines an offset into the ISF for use in assembly. */
739#define ISF_G2_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x10
740/** This macro defines an offset into the ISF for use in assembly. */
741#define ISF_G3_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x14
742/** This macro defines an offset into the ISF for use in assembly. */
743#define ISF_G4_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x18
744/** This macro defines an offset into the ISF for use in assembly. */
745#define ISF_G5_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x1c
746/** This macro defines an offset into the ISF for use in assembly. */
747#define ISF_G6_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x20
748/** This macro defines an offset into the ISF for use in assembly. */
749#define ISF_G7_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x24
750/** This macro defines an offset into the ISF for use in assembly. */
751#define ISF_I0_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x28
752/** This macro defines an offset into the ISF for use in assembly. */
753#define ISF_I1_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x2c
754/** This macro defines an offset into the ISF for use in assembly. */
755#define ISF_I2_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x30
756/** This macro defines an offset into the ISF for use in assembly. */
757#define ISF_I3_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x34
758/** This macro defines an offset into the ISF for use in assembly. */
759#define ISF_I4_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x38
760/** This macro defines an offset into the ISF for use in assembly. */
761#define ISF_I5_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x3c
762/** This macro defines an offset into the ISF for use in assembly. */
763#define ISF_I6_FP_OFFSET       CPU_MINIMUM_STACK_FRAME_SIZE + 0x40
764/** This macro defines an offset into the ISF for use in assembly. */
765#define ISF_I7_OFFSET          CPU_MINIMUM_STACK_FRAME_SIZE + 0x44
766/** This macro defines an offset into the ISF for use in assembly. */
767#define ISF_Y_OFFSET           CPU_MINIMUM_STACK_FRAME_SIZE + 0x48
768/** This macro defines an offset into the ISF for use in assembly. */
769#define ISF_TPC_OFFSET         CPU_MINIMUM_STACK_FRAME_SIZE + 0x4c
770
771/** This defines the size of the ISF area for use in assembly. */
772#define CONTEXT_CONTROL_INTERRUPT_FRAME_SIZE \
773        CPU_MINIMUM_STACK_FRAME_SIZE + 0x50
774
775#ifndef ASM
776/**
777 * This variable is contains the initialize context for the FP unit.
778 * It is filled in by _CPU_Initialize and copied into the task's FP
779 * context area during _CPU_Context_Initialize.
780 */
781SCORE_EXTERN Context_Control_fp  _CPU_Null_fp_context CPU_STRUCTURE_ALIGNMENT;
782
783/**
784 * The following type defines an entry in the SPARC's trap table.
785 *
786 * NOTE: The instructions chosen are RTEMS dependent although one is
787 *       obligated to use two of the four instructions to perform a
788 *       long jump.  The other instructions load one register with the
789 *       trap type (a.k.a. vector) and another with the psr.
790 */
791typedef struct {
792  /** This will contain a "mov %psr, %l0" instruction. */
793  uint32_t     mov_psr_l0;
794  /** This will contain a "sethi %hi(_handler), %l4" instruction. */
795  uint32_t     sethi_of_handler_to_l4;
796  /** This will contain a "jmp %l4 + %lo(_handler)" instruction. */
797  uint32_t     jmp_to_low_of_handler_plus_l4;
798  /** This will contain a " mov _vector, %l3" instruction. */
799  uint32_t     mov_vector_l3;
800} CPU_Trap_table_entry;
801
802/**
803 * This is the set of opcodes for the instructions loaded into a trap
804 * table entry.  The routine which installs a handler is responsible
805 * for filling in the fields for the _handler address and the _vector
806 * trap type.
807 *
808 * The constants following this structure are masks for the fields which
809 * must be filled in when the handler is installed.
810 */
811extern const CPU_Trap_table_entry _CPU_Trap_slot_template;
812
813/**
814 * The size of the floating point context area.
815 */
816#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
817
818#endif
819
820/**
821 * Amount of extra stack (above minimum stack size) required by
822 * MPCI receive server thread.  Remember that in a multiprocessor
823 * system this thread must exist and be able to process all directives.
824 */
825#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024
826
827/**
828 * This defines the number of entries in the ISR_Vector_table managed
829 * by the executive.
830 *
831 * On the SPARC, there are really only 256 vectors.  However, the executive
832 * has no easy, fast, reliable way to determine which traps are synchronous
833 * and which are asynchronous.  By default, synchronous traps return to the
834 * instruction which caused the interrupt.  So if you install a software
835 * trap handler as an executive interrupt handler (which is desirable since
836 * RTEMS takes care of window and register issues), then the executive needs
837 * to know that the return address is to the trap rather than the instruction
838 * following the trap.
839 *
840 * So vectors 0 through 255 are treated as regular asynchronous traps which
841 * provide the "correct" return address.  Vectors 256 through 512 are assumed
842 * by the executive to be synchronous and to require that the return address
843 * be fudged.
844 *
845 * If you use this mechanism to install a trap handler which must reexecute
846 * the instruction which caused the trap, then it should be installed as
847 * an asynchronous trap.  This will avoid the executive changing the return
848 * address.
849 */
850#define CPU_INTERRUPT_NUMBER_OF_VECTORS     256
851
852/**
853 * The SPARC has 256 vectors but the port treats 256-512 as synchronous
854 * traps.
855 */
856#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER 511
857
858/**
859 * This is the bit step in a vector number to indicate it is being installed
860 * as a synchronous trap.
861 */
862#define SPARC_SYNCHRONOUS_TRAP_BIT_MASK     0x100
863
864/**
865 * This macro indicates that @a _trap as an asynchronous trap.
866 */
867#define SPARC_ASYNCHRONOUS_TRAP( _trap )    (_trap)
868
869/**
870 * This macro indicates that @a _trap as a synchronous trap.
871 */
872#define SPARC_SYNCHRONOUS_TRAP( _trap )     ((_trap) + 256 )
873
874/**
875 * This macro returns the real hardware vector number associated with @a _trap.
876 */
877#define SPARC_REAL_TRAP_NUMBER( _trap )     ((_trap) % 256)
878
879/**
880 * This is defined if the port has a special way to report the ISR nesting
881 * level.  Most ports maintain the variable _ISR_Nest_level.
882 */
883#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
884
885/**
886 * Should be large enough to run all tests.  This ensures
887 * that a "reasonable" small application should not have any problems.
888 *
889 * This appears to be a fairly generous number for the SPARC since
890 * represents a call depth of about 20 routines based on the minimum
891 * stack frame.
892 */
893#define CPU_STACK_MINIMUM_SIZE  (1024*4)
894
895/**
896 * What is the size of a pointer on this architecture?
897 */
898#define CPU_SIZEOF_POINTER 4
899
900/**
901 * CPU's worst alignment requirement for data types on a byte boundary.  This
902 * alignment does not take into account the requirements for the stack.
903 *
904 * On the SPARC, this is required for double word loads and stores.
905 */
906#define CPU_ALIGNMENT      8
907
908/**
909 * This number corresponds to the byte alignment requirement for the
910 * heap handler.  This alignment requirement may be stricter than that
911 * for the data types alignment specified by CPU_ALIGNMENT.  It is
912 * common for the heap to follow the same alignment requirement as
913 * CPU_ALIGNMENT.  If the CPU_ALIGNMENT is strict enough for the heap,
914 * then this should be set to CPU_ALIGNMENT.
915 *
916 * NOTE:  This does not have to be a power of 2.  It does have to
917 *        be greater or equal to than CPU_ALIGNMENT.
918 */
919#define CPU_HEAP_ALIGNMENT         CPU_ALIGNMENT
920
921/**
922 * This number corresponds to the byte alignment requirement for memory
923 * buffers allocated by the partition manager.  This alignment requirement
924 * may be stricter than that for the data types alignment specified by
925 * CPU_ALIGNMENT.  It is common for the partition to follow the same
926 * alignment requirement as CPU_ALIGNMENT.  If the CPU_ALIGNMENT is strict
927 * enough for the partition, then this should be set to CPU_ALIGNMENT.
928 *
929 * NOTE:  This does not have to be a power of 2.  It does have to
930 *        be greater or equal to than CPU_ALIGNMENT.
931 */
932#define CPU_PARTITION_ALIGNMENT    CPU_ALIGNMENT
933
934/**
935 * This number corresponds to the byte alignment requirement for the
936 * stack.  This alignment requirement may be stricter than that for the
937 * data types alignment specified by CPU_ALIGNMENT.  If the CPU_ALIGNMENT
938 * is strict enough for the stack, then this should be set to 0.
939 *
940 * NOTE:  This must be a power of 2 either 0 or greater than CPU_ALIGNMENT.
941 *
942 * The alignment restrictions for the SPARC are not that strict but this
943 * should unsure that the stack is always sufficiently alignment that the
944 * window overflow, underflow, and flush routines can use double word loads
945 * and stores.
946 */
947#define CPU_STACK_ALIGNMENT        16
948
949#ifndef ASM
950
951/*
952 *  ISR handler macros
953 */
954
955/**
956 * Support routine to initialize the RTEMS vector table after it is allocated.
957 */
958#define _CPU_Initialize_vectors()
959
960/**
961 * Disable all interrupts for a critical section.  The previous
962 * level is returned in _level.
963 */
964#define _CPU_ISR_Disable( _level ) \
965  (_level) = sparc_disable_interrupts()
966
967/**
968 * Enable interrupts to the previous level (returned by _CPU_ISR_Disable).
969 * This indicates the end of a critical section.  The parameter
970 * _level is not modified.
971 */
972#define _CPU_ISR_Enable( _level ) \
973  sparc_enable_interrupts( _level )
974
975/**
976 * This temporarily restores the interrupt to _level before immediately
977 * disabling them again.  This is used to divide long critical
978 * sections into two or more parts.  The parameter _level is not
979 * modified.
980 */
981#define _CPU_ISR_Flash( _level ) \
982  sparc_flash_interrupts( _level )
983
984/**
985 * Map interrupt level in task mode onto the hardware that the CPU
986 * actually provides.  Currently, interrupt levels which do not
987 * map onto the CPU in a straight fashion are undefined.
988 */
989#define _CPU_ISR_Set_level( _newlevel ) \
990   sparc_enable_interrupts( _newlevel << 8)
991
992/**
993 * @brief Obtain the current interrupt disable level.
994 *
995 * This method is invoked to return the current interrupt disable level.
996 *
997 * @return This method returns the current interrupt disable level.
998 */
999uint32_t   _CPU_ISR_Get_level( void );
1000
1001/* end of ISR handler macros */
1002
1003/* Context handler macros */
1004
1005/**
1006 * Initialize the context to a state suitable for starting a
1007 * task after a context restore operation.  Generally, this
1008 * involves:
1009 *
1010 * - setting a starting address
1011 * - preparing the stack
1012 * - preparing the stack and frame pointers
1013 * - setting the proper interrupt level in the context
1014 * - initializing the floating point context
1015 *
1016 * @param[in] the_context points to the context area
1017 * @param[in] stack_base is the low address of the allocated stack area
1018 * @param[in] size is the size of the stack area in bytes
1019 * @param[in] new_level is the interrupt level for the task
1020 * @param[in] entry_point is the task's entry point
1021 * @param[in] is_fp is set to TRUE if the task is a floating point task
1022 *
1023 * NOTE:  Implemented as a subroutine for the SPARC port.
1024 */
1025void _CPU_Context_Initialize(
1026  Context_Control  *the_context,
1027  uint32_t         *stack_base,
1028  uint32_t          size,
1029  uint32_t          new_level,
1030  void             *entry_point,
1031  bool              is_fp
1032);
1033
1034/**
1035 * This macro is invoked from _Thread_Handler to do whatever CPU
1036 * specific magic is required that must be done in the context of
1037 * the thread when it starts.
1038 *
1039 * On the SPARC, this is setting the frame pointer so GDB is happy.
1040 * Make GDB stop unwinding at _Thread_Handler, previous register window
1041 * Frame pointer is 0 and calling address must be a function with starting
1042 * with a SAVE instruction. If return address is leaf-function (no SAVE)
1043 * GDB will not look at prev reg window fp.
1044 *
1045 * _Thread_Handler is known to start with SAVE.
1046 */
1047#define _CPU_Context_Initialization_at_thread_begin() \
1048  do { \
1049    __asm__ volatile ("set _Thread_Handler,%%i7\n"::); \
1050  } while (0)
1051
1052/**
1053 * This routine is responsible for somehow restarting the currently
1054 * executing task.
1055 *
1056 * On the SPARC, this is is relatively painless but requires a small
1057 * amount of wrapper code before using the regular restore code in
1058 * of the context switch.
1059 */
1060#define _CPU_Context_Restart_self( _the_context ) \
1061   _CPU_Context_restore( (_the_context) );
1062
1063/**
1064 * The FP context area for the SPARC is a simple structure and nothing
1065 * special is required to find the "starting load point"
1066 */
1067#define _CPU_Context_Fp_start( _base, _offset ) \
1068   ( (void *) _Addresses_Add_offset( (_base), (_offset) ) )
1069
1070/**
1071 * This routine initializes the FP context area passed to it to.
1072 *
1073 * The SPARC allows us to use the simple initialization model
1074 * in which an "initial" FP context was saved into _CPU_Null_fp_context
1075 * at CPU initialization and it is simply copied into the destination
1076 * context.
1077 */
1078#define _CPU_Context_Initialize_fp( _destination ) \
1079  do { \
1080   *(*(_destination)) = _CPU_Null_fp_context; \
1081  } while (0)
1082
1083/* end of Context handler macros */
1084
1085/* Fatal Error manager macros */
1086
1087/**
1088 * This routine copies _error into a known place -- typically a stack
1089 * location or a register, optionally disables interrupts, and
1090 * halts/stops the CPU.
1091 */
1092#define _CPU_Fatal_halt( _error ) \
1093  do { \
1094    uint32_t   level; \
1095    \
1096    level = sparc_disable_interrupts(); \
1097    __asm__ volatile ( "mov  %0, %%g1 " : "=r" (level) : "0" (level) ); \
1098    while (1); /* loop forever */ \
1099  } while (0)
1100
1101/* end of Fatal Error manager macros */
1102
1103/* Bitfield handler macros */
1104
1105#if ( SPARC_HAS_BITSCAN == 0 )
1106  /**
1107   * The SPARC port uses the generic C algorithm for bitfield scan if the
1108   * CPU model does not have a scan instruction.
1109   */
1110  #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
1111  /**
1112   * The SPARC port uses the generic C algorithm for bitfield scan if the
1113   * CPU model does not have a scan instruction.  Thus is needs the generic
1114   * data table used by that algorithm.
1115   */
1116  #define CPU_USE_GENERIC_BITFIELD_DATA TRUE
1117#else
1118  #error "scan instruction not currently supported by RTEMS!!"
1119#endif
1120
1121/* end of Bitfield handler macros */
1122
1123/* functions */
1124
1125/**
1126 * @brief SPARC specific initialization.
1127 *
1128 * This routine performs CPU dependent initialization.
1129 */
1130void _CPU_Initialize(void);
1131
1132/**
1133 * @brief SPARC specific raw ISR installer.
1134 *
1135 * This routine installs @a new_handler to be directly called from the trap
1136 * table.
1137 *
1138 * @param[in] vector is the vector number
1139 * @param[in] new_handler is the new ISR handler
1140 * @param[in] old_handler will contain the old ISR handler
1141 */
1142void _CPU_ISR_install_raw_handler(
1143  uint32_t    vector,
1144  proc_ptr    new_handler,
1145  proc_ptr   *old_handler
1146);
1147
1148/**
1149 * @brief SPARC specific RTEMS ISR installer.
1150 *
1151 * This routine installs an interrupt vector.
1152 *
1153 * @param[in] vector is the vector number
1154 * @param[in] new_handler is the new ISR handler
1155 * @param[in] old_handler will contain the old ISR handler
1156 */
1157
1158void _CPU_ISR_install_vector(
1159  uint32_t    vector,
1160  proc_ptr    new_handler,
1161  proc_ptr   *old_handler
1162);
1163
1164/**
1165 * @brief SPARC specific context switch.
1166 *
1167 * This routine switches from the run context to the heir context.
1168 *
1169 * @param[in] run is the currently executing thread
1170 * @param[in] heir will become the currently executing thread
1171 */
1172void _CPU_Context_switch(
1173  Context_Control  *run,
1174  Context_Control  *heir
1175);
1176
1177/**
1178 * @brief SPARC specific context restore.
1179 *
1180 * This routine is generally used only to restart self in an
1181 * efficient manner.
1182 *
1183 * @param[in] new_context is the context to restore
1184 */
1185void _CPU_Context_restore(
1186  Context_Control *new_context
1187) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
1188
1189#if defined(RTEMS_SMP)
1190  /**
1191   * @brief SPARC specific method to switch to first task.
1192   *
1193   * This routine is only used to switch to the first task on a
1194   * secondary core in an SMP configuration.  We do not need to
1195   * flush all the windows and, in fact, this can be dangerous
1196   * as they may or may not be initialized properly.
1197   *
1198   * @param[in] new_context is the context to restore
1199   */
1200  void _CPU_Context_switch_to_first_task_smp(
1201    Context_Control *new_context
1202  );
1203
1204  RTEMS_COMPILER_PURE_ATTRIBUTE uint32_t _CPU_SMP_Get_current_processor( void );
1205
1206  void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
1207
1208  static inline void _CPU_SMP_Processor_event_broadcast( void )
1209  {
1210    __asm__ volatile ( "" : : : "memory" );
1211  }
1212
1213  static inline void _CPU_SMP_Processor_event_receive( void )
1214  {
1215    __asm__ volatile ( "" : : : "memory" );
1216  }
1217#endif
1218
1219/**
1220 * @brief SPARC specific save FPU method.
1221 *
1222 * This routine saves the floating point context passed to it.
1223 *
1224 * @param[in] fp_context_ptr is the area to save into
1225 */
1226void _CPU_Context_save_fp(
1227  Context_Control_fp **fp_context_ptr
1228);
1229
1230/**
1231 * @brief SPARC specific restore FPU method.
1232 *
1233 * This routine restores the floating point context passed to it.
1234 *
1235 * @param[in] fp_context_ptr is the area to restore from
1236 */
1237void _CPU_Context_restore_fp(
1238  Context_Control_fp **fp_context_ptr
1239);
1240
1241static inline void _CPU_Context_volatile_clobber( uintptr_t pattern )
1242{
1243  /* TODO */
1244}
1245
1246static inline void _CPU_Context_validate( uintptr_t pattern )
1247{
1248  while (1) {
1249    /* TODO */
1250  }
1251}
1252
1253typedef struct {
1254  uint32_t trap;
1255  CPU_Interrupt_frame *isf;
1256} CPU_Exception_frame;
1257
1258void _BSP_Exception_frame_print( const CPU_Exception_frame *frame );
1259
1260static inline void _CPU_Exception_frame_print(
1261  const CPU_Exception_frame *frame
1262)
1263{
1264  _BSP_Exception_frame_print( frame );
1265}
1266
1267/**
1268 * @brief SPARC specific method to endian swap an uint32_t.
1269 *
1270 * The following routine swaps the endian format of an unsigned int.
1271 * It must be static because it is referenced indirectly.
1272 *
1273 * @param[in] value is the value to endian swap
1274 *
1275 * This version will work on any processor, but if you come across a better
1276 * way for the SPARC PLEASE use it.  The most common way to swap a 32-bit
1277 * entity as shown below is not any more efficient on the SPARC.
1278 *
1279 *    - swap least significant two bytes with 16-bit rotate
1280 *    - swap upper and lower 16-bits
1281 *    - swap most significant two bytes with 16-bit rotate
1282 *
1283 * It is not obvious how the SPARC can do significantly better than the
1284 * generic code.  gcc 2.7.0 only generates about 12 instructions for the
1285 * following code at optimization level four (i.e. -O4).
1286 */
1287static inline uint32_t CPU_swap_u32(
1288  uint32_t value
1289)
1290{
1291  uint32_t   byte1, byte2, byte3, byte4, swapped;
1292
1293  byte4 = (value >> 24) & 0xff;
1294  byte3 = (value >> 16) & 0xff;
1295  byte2 = (value >> 8)  & 0xff;
1296  byte1 =  value        & 0xff;
1297
1298  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
1299  return( swapped );
1300}
1301
1302/**
1303 * @brief SPARC specific method to endian swap an uint16_t.
1304 *
1305 * The following routine swaps the endian format of a uint16_t.
1306 *
1307 * @param[in] value is the value to endian swap
1308 */
1309#define CPU_swap_u16( value ) \
1310  (((value&0xff) << 8) | ((value >> 8)&0xff))
1311
1312#endif /* ASM */
1313
1314#ifdef __cplusplus
1315}
1316#endif
1317
1318#endif
Note: See TracBrowser for help on using the repository browser.