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

5
Last change on this file since 42f2fdfd was 42f2fdfd, checked in by Sebastian Huber <sebastian.huber@…>, on 07/20/18 at 05:56:43

score: Move context validation declarations

The context validation support functions _CPU_Context_validate() and
_CPU_Context_volatile_clobber() are used only by one test program
(spcontext01). Move the function declarations to the CPU port
implementation header file.

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