source: rtems/cpukit/score/cpu/moxie/include/rtems/score/cpu.h @ c8df844

5
Last change on this file since c8df844 was c8df844, checked in by Sebastian Huber <sebastian.huber@…>, on 06/19/18 at 12:59:51

score: Add CPU_INTERRUPT_STACK_ALIGNMENT

Add CPU port define for the interrupt stack alignment. The alignment
should take the stack ABI and the cache line size into account.

Update #3459.

  • Property mode set to 100644
File size: 24.3 KB
Line 
1/**
2 * @file rtems/score/cpu.h
3 */
4
5/*
6 *  This include file contains information pertaining to the Moxie
7 *  processor.
8 *
9 *  Copyright (c) 2013  Anthony Green
10 *
11 *  Based on code with the following copyright..
12 *  COPYRIGHT (c) 1989-2006, 2010.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _RTEMS_SCORE_CPU_H
21#define _RTEMS_SCORE_CPU_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <rtems/score/basedefs.h>
28#include <rtems/score/moxie.h>  /* pick up machine definitions */
29
30#include <rtems/bspIo.h>        /* printk */
31
32/* conditional compilation parameters */
33
34/*
35 *  Should this target use 16 or 32 bit object Ids?
36 *
37 */
38#define RTEMS_USE_32_BIT_OBJECT
39
40/*
41 *  Does RTEMS manage a dedicated interrupt stack in software?
42 *
43 *  If TRUE, then a stack is allocated in _ISR_Handler_initialization.
44 *  If FALSE, nothing is done.
45 *
46 *  If the CPU supports a dedicated interrupt stack in hardware,
47 *  then it is generally the responsibility of the BSP to allocate it
48 *  and set it up.
49 *
50 *  If the CPU does not support a dedicated interrupt stack, then
51 *  the porter has two options: (1) execute interrupts on the
52 *  stack of the interrupted task, and (2) have RTEMS manage a dedicated
53 *  interrupt stack.
54 *
55 *  If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE.
56 *
57 *  Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and
58 *  CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE.  It is
59 *  possible that both are FALSE for a particular CPU.  Although it
60 *  is unclear what that would imply about the interrupt processing
61 *  procedure on that CPU.
62 *
63 *  MOXIE Specific Information:
64 *
65 *  XXX
66 */
67#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE
68
69/*
70 *  Does the CPU follow the simple vectored interrupt model?
71 *
72 *  If TRUE, then RTEMS allocates the vector table it internally manages.
73 *  If FALSE, then the BSP is assumed to allocate and manage the vector
74 *  table
75 *
76 *  MOXIE Specific Information:
77 *
78 *  XXX document implementation including references if appropriate
79 */
80#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
81
82/*
83 *  Does this CPU have hardware support for a dedicated interrupt stack?
84 *
85 *  If TRUE, then it must be installed during initialization.
86 *  If FALSE, then no installation is performed.
87 *
88 *  If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE.
89 *
90 *  Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and
91 *  CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE.  It is
92 *  possible that both are FALSE for a particular CPU.  Although it
93 *  is unclear what that would imply about the interrupt processing
94 *  procedure on that CPU.
95 *
96 *  MOXIE Specific Information:
97 *
98 *  XXX
99 */
100#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
101
102/*
103 *  Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager?
104 *
105 *  If TRUE, then the memory is allocated during initialization.
106 *  If FALSE, then the memory is allocated during initialization.
107 *
108 *  This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE.
109 *
110 *  MOXIE Specific Information:
111 *
112 *  XXX
113 */
114#define CPU_ALLOCATE_INTERRUPT_STACK TRUE
115
116/*
117 *  Does the CPU have hardware floating point?
118 *
119 *  If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported.
120 *  If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored.
121 *
122 *  If there is a FP coprocessor such as the i387 or mc68881, then
123 *  the answer is TRUE.
124 *
125 *  The macro name "MOXIE_HAS_FPU" should be made CPU specific.
126 *  It indicates whether or not this CPU model has FP support.  For
127 *  example, it would be possible to have an i386_nofp CPU model
128 *  which set this to false to indicate that you have an i386 without
129 *  an i387 and wish to leave floating point support out of RTEMS.
130 *
131 *  MOXIE Specific Information:
132 *
133 *  XXX
134 */
135#define CPU_HARDWARE_FP     FALSE
136
137/*
138 *  Are all tasks RTEMS_FLOATING_POINT tasks implicitly?
139 *
140 *  If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed.
141 *  If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed.
142 *
143 *  If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well.
144 *
145 *  MOXIE Specific Information:
146 *
147 *  XXX
148 */
149#define CPU_ALL_TASKS_ARE_FP     FALSE
150
151/*
152 *  Should the IDLE task have a floating point context?
153 *
154 *  If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task
155 *  and it has a floating point context which is switched in and out.
156 *  If FALSE, then the IDLE task does not have a floating point context.
157 *
158 *  Setting this to TRUE negatively impacts the time required to preempt
159 *  the IDLE task from an interrupt because the floating point context
160 *  must be saved as part of the preemption.
161 *
162 *  MOXIE Specific Information:
163 *
164 *  XXX
165 */
166#define CPU_IDLE_TASK_IS_FP      FALSE
167
168/*
169 *  Should the saving of the floating point registers be deferred
170 *  until a context switch is made to another different floating point
171 *  task?
172 *
173 *  If TRUE, then the floating point context will not be stored until
174 *  necessary.  It will remain in the floating point registers and not
175 *  disturned until another floating point task is switched to.
176 *
177 *  If FALSE, then the floating point context is saved when a floating
178 *  point task is switched out and restored when the next floating point
179 *  task is restored.  The state of the floating point registers between
180 *  those two operations is not specified.
181 *
182 *  If the floating point context does NOT have to be saved as part of
183 *  interrupt dispatching, then it should be safe to set this to TRUE.
184 *
185 *  Setting this flag to TRUE results in using a different algorithm
186 *  for deciding when to save and restore the floating point context.
187 *  The deferred FP switch algorithm minimizes the number of times
188 *  the FP context is saved and restored.  The FP context is not saved
189 *  until a context switch is made to another, different FP task.
190 *  Thus in a system with only one FP task, the FP context will never
191 *  be saved or restored.
192 *
193 *  MOXIE Specific Information:
194 *
195 *  XXX
196 */
197#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
198
199#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE
200
201/*
202 *  Does this port provide a CPU dependent IDLE task implementation?
203 *
204 *  If TRUE, then the routine _CPU_Internal_threads_Idle_thread_body
205 *  must be provided and is the default IDLE thread body instead of
206 *  _Internal_threads_Idle_thread_body.
207 *
208 *  If FALSE, then use the generic IDLE thread body if the BSP does
209 *  not provide one.
210 *
211 *  This is intended to allow for supporting processors which have
212 *  a low power or idle mode.  When the IDLE thread is executed, then
213 *  the CPU can be powered down.
214 *
215 *  The order of precedence for selecting the IDLE thread body is:
216 *
217 *    1.  BSP provided
218 *    2.  CPU dependent (if provided)
219 *    3.  generic (if no BSP and no CPU dependent)
220 *
221 *  MOXIE Specific Information:
222 *
223 *  XXX
224 *  The port initially called a BSP dependent routine called
225 *  IDLE_Monitor.  The idle task body can be overridden by
226 *  the BSP in newer versions of RTEMS.
227 */
228#define CPU_PROVIDES_IDLE_THREAD_BODY    FALSE
229
230/*
231 *  Does the stack grow up (toward higher addresses) or down
232 *  (toward lower addresses)?
233 *
234 *  If TRUE, then the grows upward.
235 *  If FALSE, then the grows toward smaller addresses.
236 *
237 *  MOXIE Specific Information:
238 *
239 *  XXX
240 */
241#define CPU_STACK_GROWS_UP               FALSE
242
243/* FIXME: Is this the right value? */
244#define CPU_CACHE_LINE_BYTES 32
245
246#define CPU_STRUCTURE_ALIGNMENT
247
248/*
249 *  The following defines the number of bits actually used in the
250 *  interrupt field of the task mode.  How those bits map to the
251 *  CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
252 *
253 *  MOXIE Specific Information:
254 *
255 *  XXX
256 */
257#define CPU_MODES_INTERRUPT_MASK   0x00000001
258
259#define CPU_MAXIMUM_PROCESSORS 32
260
261/*
262 *  Processor defined structures required for cpukit/score.
263 *
264 *  MOXIE Specific Information:
265 *
266 *  XXX
267 */
268
269/* may need to put some structures here.  */
270
271/*
272 * Contexts
273 *
274 *  Generally there are 2 types of context to save.
275 *     1. Interrupt registers to save
276 *     2. Task level registers to save
277 *
278 *  This means we have the following 3 context items:
279 *     1. task level context stuff::  Context_Control
280 *     2. floating point task stuff:: Context_Control_fp
281 *     3. special interrupt level context :: Context_Control_interrupt
282 *
283 *  On some processors, it is cost-effective to save only the callee
284 *  preserved registers during a task context switch.  This means
285 *  that the ISR code needs to save those registers which do not
286 *  persist across function calls.  It is not mandatory to make this
287 *  distinctions between the caller/callee saves registers for the
288 *  purpose of minimizing context saved during task switch and on interrupts.
289 *  If the cost of saving extra registers is minimal, simplicity is the
290 *  choice.  Save the same context on interrupt entry as for tasks in
291 *  this case.
292 *
293 *  Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then
294 *  care should be used in designing the context area.
295 *
296 *  On some CPUs with hardware floating point support, the Context_Control_fp
297 *  structure will not be used or it simply consist of an array of a
298 *  fixed number of bytes.   This is done when the floating point context
299 *  is dumped by a "FP save context" type instruction and the format
300 *  is not really defined by the CPU.  In this case, there is no need
301 *  to figure out the exact format -- only the size.  Of course, although
302 *  this is enough information for RTEMS, it is probably not enough for
303 *  a debugger such as gdb.  But that is another problem.
304 *
305 *  MOXIE Specific Information:
306 *
307 *  XXX
308 */
309
310#define nogap __attribute__ ((packed))
311
312typedef struct {
313    void        *fp nogap;
314    void        *sp nogap;
315    uint32_t    r0 nogap;
316    uint32_t    r1 nogap;
317    uint32_t    r2 nogap;
318    uint32_t    r3 nogap;
319    uint32_t    r4 nogap;
320    uint32_t    r5 nogap;
321    uint32_t    r6 nogap;
322    uint32_t    r7 nogap;
323    uint32_t    r8 nogap;
324    uint32_t    r9 nogap;
325    uint32_t    r10 nogap;
326    uint32_t    r11 nogap;
327    uint32_t    r12 nogap;
328    uint32_t    r13 nogap;
329} Context_Control;
330
331#define _CPU_Context_Get_SP( _context ) \
332  (_context)->sp
333
334typedef struct {
335    double      some_float_register[2];
336} Context_Control_fp;
337
338typedef struct {
339    uint32_t   special_interrupt_register;
340} CPU_Interrupt_frame;
341
342/*
343 *  Nothing prevents the porter from declaring more CPU specific variables.
344 *
345 *  MOXIE Specific Information:
346 *
347 *  XXX
348 */
349
350/*
351 *  The size of the floating point context area.  On some CPUs this
352 *  will not be a "sizeof" because the format of the floating point
353 *  area is not defined -- only the size is.  This is usually on
354 *  CPUs with a "floating point save context" instruction.
355 *
356 *  MOXIE Specific Information:
357 *
358 *  XXX
359 */
360#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
361
362/*
363 *  Amount of extra stack (above minimum stack size) required by
364 *  system initialization thread.  Remember that in a multiprocessor
365 *  system the system intialization thread becomes the MP server thread.
366 *
367 *  MOXIE Specific Information:
368 *
369 *  It is highly unlikely the MOXIE will get used in a multiprocessor system.
370 */
371#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
372
373/*
374 *  This defines the number of entries in the ISR_Vector_table managed
375 *  by RTEMS.
376 *
377 *  MOXIE Specific Information:
378 *
379 *  XXX
380 */
381#define CPU_INTERRUPT_NUMBER_OF_VECTORS      64
382#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER \
383    (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
384
385/*
386 *  This is defined if the port has a special way to report the ISR nesting
387 *  level.  Most ports maintain the variable _ISR_Nest_level.
388 */
389#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
390
391/*
392 *  Should be large enough to run all RTEMS tests.  This ensures
393 *  that a "reasonable" small application should not have any problems.
394 *
395 *  MOXIE Specific Information:
396 *
397 *  XXX
398 */
399#define CPU_STACK_MINIMUM_SIZE          (1536)
400
401/**
402 * Size of a pointer.
403 *
404 * This must be an integer literal that can be used by the assembler.  This
405 * value will be used to calculate offsets of structure members.  These
406 * offsets will be used in assembler code.
407 */
408#define CPU_SIZEOF_POINTER         4
409
410/*
411 *  CPU's worst alignment requirement for data types on a byte boundary.  This
412 *  alignment does not take into account the requirements for the stack.
413 *
414 *  MOXIE Specific Information:
415 *
416 *  XXX
417 */
418#define CPU_ALIGNMENT              8
419
420/*
421 *  This number corresponds to the byte alignment requirement for the
422 *  heap handler.  This alignment requirement may be stricter than that
423 *  for the data types alignment specified by CPU_ALIGNMENT.  It is
424 *  common for the heap to follow the same alignment requirement as
425 *  CPU_ALIGNMENT.  If the CPU_ALIGNMENT is strict enough for the heap,
426 *  then this should be set to CPU_ALIGNMENT.
427 *
428 *  NOTE:  This does not have to be a power of 2.  It does have to
429 *         be greater or equal to than CPU_ALIGNMENT.
430 *
431 *  MOXIE Specific Information:
432 *
433 *  XXX
434 */
435#define CPU_HEAP_ALIGNMENT         CPU_ALIGNMENT
436
437/*
438 *  This number corresponds to the byte alignment requirement for memory
439 *  buffers allocated by the partition manager.  This alignment requirement
440 *  may be stricter than that for the data types alignment specified by
441 *  CPU_ALIGNMENT.  It is common for the partition to follow the same
442 *  alignment requirement as CPU_ALIGNMENT.  If the CPU_ALIGNMENT is strict
443 *  enough for the partition, then this should be set to CPU_ALIGNMENT.
444 *
445 *  NOTE:  This does not have to be a power of 2.  It does have to
446 *         be greater or equal to than CPU_ALIGNMENT.
447 *
448 *  MOXIE Specific Information:
449 *
450 *  XXX
451 */
452#define CPU_PARTITION_ALIGNMENT    CPU_ALIGNMENT
453
454/*
455 *  This number corresponds to the byte alignment requirement for the
456 *  stack.  This alignment requirement may be stricter than that for the
457 *  data types alignment specified by CPU_ALIGNMENT.  If the CPU_ALIGNMENT
458 *  is strict enough for the stack, then this should be set to 0.
459 *
460 *  NOTE:  This must be a power of 2 either 0 or greater than CPU_ALIGNMENT.
461 *
462 *  MOXIE Specific Information:
463 *
464 *  XXX
465 */
466#define CPU_STACK_ALIGNMENT        0
467
468#define CPU_INTERRUPT_STACK_ALIGNMENT CPU_CACHE_LINE_BYTES
469
470/*
471 *  ISR handler macros
472 */
473
474/*
475 *  Support routine to initialize the RTEMS vector table after it is allocated.
476 */
477#define _CPU_Initialize_vectors()
478
479/*
480 *  Disable all interrupts for an RTEMS critical section.  The previous
481 *  level is returned in _level.
482 *
483 *  MOXIE Specific Information:
484 *
485 *  TODO: As of 7 October 2014, this method is not implemented.
486 */
487#define _CPU_ISR_Disable( _isr_cookie ) \
488  do { \
489    (_isr_cookie) = 0; \
490  } while (0)
491
492/*
493 *  Enable interrupts to the previous level (returned by _CPU_ISR_Disable).
494 *  This indicates the end of an RTEMS critical section.  The parameter
495 *  _level is not modified.
496 *
497 *  MOXIE Specific Information:
498 *
499 *  TODO: As of 7 October 2014, this method is not implemented.
500 */
501#define _CPU_ISR_Enable( _isr_cookie ) \
502  do { \
503    (_isr_cookie) = (_isr_cookie); \
504  } while (0)
505
506/*
507 *  This temporarily restores the interrupt to _level before immediately
508 *  disabling them again.  This is used to divide long RTEMS critical
509 *  sections into two or more parts.  The parameter _level is not
510 *  modified.
511 *
512 *  MOXIE Specific Information:
513 *
514 *  TODO: As of 7 October 2014, this method is not implemented.
515 */
516#define _CPU_ISR_Flash( _isr_cookie ) \
517  do { \
518    _CPU_ISR_Enable( _isr_cookie ); \
519    _CPU_ISR_Disable( _isr_cookie ); \
520  } while (0)
521
522RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
523{
524  return true;
525}
526
527/*
528 *  Map interrupt level in task mode onto the hardware that the CPU
529 *  actually provides.  Currently, interrupt levels which do not
530 *  map onto the CPU in a generic fashion are undefined.  Someday,
531 *  it would be nice if these were "mapped" by the application
532 *  via a callout.  For example, m68k has 8 levels 0 - 7, levels
533 *  8 - 255 would be available for bsp/application specific meaning.
534 *  This could be used to manage a programmable interrupt controller
535 *  via the rtems_task_mode directive.
536 *
537 *  MOXIE Specific Information:
538 *
539 *  TODO: As of 7 October 2014, this method is not implemented.
540 */
541#define _CPU_ISR_Set_level( _new_level )        \
542  {                                                     \
543    if (_new_level)   asm volatile ( "nop\n" );         \
544    else              asm volatile ( "nop\n" );         \
545  }
546
547uint32_t   _CPU_ISR_Get_level( void );
548
549/* end of ISR handler macros */
550
551/* Context handler macros */
552
553/*
554 *  Initialize the context to a state suitable for starting a
555 *  task after a context restore operation.  Generally, this
556 *  involves:
557 *
558 *     - setting a starting address
559 *     - preparing the stack
560 *     - preparing the stack and frame pointers
561 *     - setting the proper interrupt level in the context
562 *     - initializing the floating point context
563 *
564 *  This routine generally does not set any unnecessary register
565 *  in the context.  The state of the "general data" registers is
566 *  undefined at task start time.
567 *
568 *  NOTE: This is_fp parameter is TRUE if the thread is to be a floating
569 *        point thread.  This is typically only used on CPUs where the
570 *        FPU may be easily disabled by software such as on the SPARC
571 *        where the PSR contains an enable FPU bit.
572 *
573 *  MOXIE Specific Information:
574 *
575 *  TODO: As of 7 October 2014, this method does not ensure that the context
576 *  is set up with interrupts disabled/enabled as requested.
577 */
578#define CPU_CCR_INTERRUPTS_ON  0x80
579#define CPU_CCR_INTERRUPTS_OFF 0x00
580
581#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
582                                 _isr, _entry_point, _is_fp, _tls_area ) \
583  /* Locate Me */                                                  \
584  do {                                                             \
585    uintptr_t   _stack;                                            \
586                                                                   \
587    (void) _is_fp; /* avoid warning for being unused */            \
588    (void) _isr;   /* avoid warning for being unused */            \
589    _stack = ((uintptr_t)(_stack_base)) + (_size) - 8;             \
590    *((proc_ptr *)(_stack)) = (_entry_point);                      \
591    _stack -= 4;                                                   \
592    (_the_context)->fp = (void *)_stack;                           \
593    (_the_context)->sp = (void *)_stack;                           \
594  } while (0)
595
596
597/*
598 *  This routine is responsible for somehow restarting the currently
599 *  executing task.  If you are lucky, then all that is necessary
600 *  is restoring the context.  Otherwise, there will need to be
601 *  a special assembly routine which does something special in this
602 *  case.  Context_Restore should work most of the time.  It will
603 *  not work if restarting self conflicts with the stack frame
604 *  assumptions of restoring a context.
605 *
606 *  MOXIE Specific Information:
607 *
608 *  XXX
609 */
610#define _CPU_Context_Restart_self( _the_context ) \
611   _CPU_Context_restore( (_the_context) );
612
613#define _CPU_Context_Initialize_fp( _destination ) \
614  memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE );
615
616/* end of Context handler macros */
617
618/* Fatal Error manager macros */
619
620/*
621 *  This routine copies _error into a known place -- typically a stack
622 *  location or a register, optionally disables interrupts, and
623 *  halts/stops the CPU.
624 *
625 *  MOXIE Specific Information:
626 *
627 *  XXX
628 */
629#define _CPU_Fatal_halt( _source, _error ) \
630        printk("Fatal Error %d.%lu Halted\n",_source,_error); \
631        for(;;)
632
633/* end of Fatal Error manager macros */
634
635#define CPU_USE_GENERIC_BITFIELD_CODE TRUE
636
637/* functions */
638
639/*
640 *  _CPU_Initialize
641 *
642 *  This routine performs CPU dependent initialization.
643 *
644 *  MOXIE Specific Information:
645 *
646 *  XXX
647 */
648void _CPU_Initialize(void);
649
650/*
651 *  _CPU_ISR_install_raw_handler
652 *
653 *  This routine installs a "raw" interrupt handler directly into the
654 *  processor's vector table.
655 *
656 *  MOXIE Specific Information:
657 *
658 *  XXX
659 */
660void _CPU_ISR_install_raw_handler(
661  uint32_t    vector,
662  proc_ptr    new_handler,
663  proc_ptr   *old_handler
664);
665
666/*
667 *  _CPU_ISR_install_vector
668 *
669 *  This routine installs an interrupt vector.
670 *
671 *  MOXIE Specific Information:
672 *
673 *  XXX
674 */
675void _CPU_ISR_install_vector(
676  uint32_t    vector,
677  proc_ptr    new_handler,
678  proc_ptr   *old_handler
679);
680
681/*
682 *  _CPU_Install_interrupt_stack
683 *
684 *  This routine installs the hardware interrupt stack pointer.
685 *
686 *  NOTE:  It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK
687 *         is TRUE.
688 *
689 *  MOXIE Specific Information:
690 *
691 *  XXX
692 */
693void _CPU_Install_interrupt_stack( void );
694
695/*
696 *  _CPU_Internal_threads_Idle_thread_body
697 *
698 *  This routine is the CPU dependent IDLE thread body.
699 *
700 *  NOTE:  It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY
701 *         is TRUE.
702 *
703 *  MOXIE Specific Information:
704 *
705 *  XXX
706 */
707void *_CPU_Thread_Idle_body( uint32_t );
708
709/*
710 *  _CPU_Context_switch
711 *
712 *  This routine switches from the run context to the heir context.
713 *
714 *  MOXIE Specific Information:
715 *
716 *  XXX
717 */
718void _CPU_Context_switch(
719  Context_Control  *run,
720  Context_Control  *heir
721);
722
723/*
724 *  _CPU_Context_restore
725 *
726 *  This routine is generallu used only to restart self in an
727 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
728 *
729 *  NOTE: May be unnecessary to reload some registers.
730 *
731 *  MOXIE Specific Information:
732 *
733 *  XXX
734 */
735void _CPU_Context_restore(
736  Context_Control *new_context
737) RTEMS_NO_RETURN;
738
739/*
740 *  _CPU_Context_save_fp
741 *
742 *  This routine saves the floating point context passed to it.
743 *
744 *  MOXIE Specific Information:
745 *
746 *  XXX
747 */
748void _CPU_Context_save_fp(
749  Context_Control_fp **fp_context_ptr
750);
751
752/*
753 *  _CPU_Context_restore_fp
754 *
755 *  This routine restores the floating point context passed to it.
756 *
757 *  MOXIE Specific Information:
758 *
759 *  XXX
760 */
761void _CPU_Context_restore_fp(
762  Context_Control_fp **fp_context_ptr
763);
764
765static inline void _CPU_Context_volatile_clobber( uintptr_t pattern )
766{
767  /* TODO */
768}
769
770static inline void _CPU_Context_validate( uintptr_t pattern )
771{
772  while (1) {
773    /* TODO */
774  }
775}
776
777/**
778 * @brief The set of registers that specifies the complete processor state.
779 *
780 * The CPU exception frame may be available in fatal error conditions like for
781 * example illegal opcodes, instruction fetch errors, or data access errors.
782 *
783 * @see rtems_fatal(), RTEMS_FATAL_SOURCE_EXCEPTION, and
784 * rtems_exception_frame_print().
785 */
786typedef struct {
787  uint32_t integer_registers [16];
788} CPU_Exception_frame;
789
790/**
791 * @brief Prints the exception frame via printk().
792 *
793 * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION.
794 */
795void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
796
797/*  The following routine swaps the endian format of an unsigned int.
798 *  It must be static because it is referenced indirectly.
799 *
800 *  This version will work on any processor, but if there is a better
801 *  way for your CPU PLEASE use it.  The most common way to do this is to:
802 *
803 *     swap least significant two bytes with 16-bit rotate
804 *     swap upper and lower 16-bits
805 *     swap most significant two bytes with 16-bit rotate
806 *
807 *  Some CPUs have special instructions which swap a 32-bit quantity in
808 *  a single instruction (e.g. i486).  It is probably best to avoid
809 *  an "endian swapping control bit" in the CPU.  One good reason is
810 *  that interrupts would probably have to be disabled to ensure that
811 *  an interrupt does not try to access the same "chunk" with the wrong
812 *  endian.  Another good reason is that on some CPUs, the endian bit
813 *  endianness for ALL fetches -- both code and data -- so the code
814 *  will be fetched incorrectly.
815 *
816 *  MOXIE Specific Information:
817 *
818 *  This is the generic implementation.
819 */
820static inline uint32_t   CPU_swap_u32(
821  uint32_t   value
822)
823{
824  uint32_t   byte1, byte2, byte3, byte4, swapped;
825
826  byte4 = (value >> 24) & 0xff;
827  byte3 = (value >> 16) & 0xff;
828  byte2 = (value >> 8)  & 0xff;
829  byte1 =  value        & 0xff;
830
831  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
832  return( swapped );
833}
834
835#define CPU_swap_u16( value ) \
836  (((value&0xff) << 8) | ((value >> 8)&0xff))
837
838typedef uint32_t CPU_Counter_ticks;
839
840uint32_t _CPU_Counter_frequency( void );
841
842CPU_Counter_ticks _CPU_Counter_read( void );
843
844static inline CPU_Counter_ticks _CPU_Counter_difference(
845  CPU_Counter_ticks second,
846  CPU_Counter_ticks first
847)
848{
849  return second - first;
850}
851
852/** Type that can store a 32-bit integer or a pointer. */
853typedef uintptr_t CPU_Uint32ptr;
854
855#ifdef __cplusplus
856}
857#endif
858
859#endif
Note: See TracBrowser for help on using the repository browser.