source: rtems/cpukit/score/cpu/moxie/rtems/score/cpu.h @ 18e29faf

5
Last change on this file since 18e29faf was 18e29faf, checked in by Sebastian Huber <sebastian.huber@…>, on 06/08/16 at 08:10:40

score: Delete CPU_USE_GENERIC_BITFIELD_DATA

Rename log2table into _Bitfield_Leading_zeros since it acually returns
the count of leading zeros of an 8-bit integer. The value for zero is a
bit odd. Provide it unconditionally.

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