source: rtems/cpukit/score/cpu/no_cpu/rtems/score/cpu.h @ 27bfcd8

5
Last change on this file since 27bfcd8 was 27bfcd8, checked in by Sebastian Huber <sebastian.huber@…>, on Jan 25, 2017 at 1:32:02 PM

score: Delete _CPU_Context_Fp_start()

Since the FP area pointer is passed by reference in
_CPU_Context_Initialize_fp() the optional FP area adjustment via
_CPU_Context_Fp_start() is superfluous. It is also wrong with respect
to memory management, e.g. pointer passed to _Workspace_Free() may be
not the one returned by _Workspace_Allocate().

Close #1400.

  • Property mode set to 100644
File size: 46.2 KB
Line 
1/**
2 * @file rtems/score/cpu.h
3 *
4 * @brief NO_CPU Department Source
5 *
6 * This include file contains information pertaining to the NO_CPU
7 * processor.
8 */
9
10/*
11 *  This include file contains information pertaining to the XXX
12 *  processor.
13 *
14 *  @note This file is part of a porting template that is intended
15 *  to be used as the starting point when porting RTEMS to a new
16 *  CPU family.  The following needs to be done when using this as
17 *  the starting point for a new port:
18 *
19 *  + Anywhere there is an XXX, it should be replaced
20 *    with information about the CPU family being ported to.
21 *
22 *  + At the end of each comment section, there is a heading which
23 *    says "Port Specific Information:".  When porting to RTEMS,
24 *    add CPU family specific information in this section
25 */
26
27/*
28 *  COPYRIGHT (c) 1989-2008.
29 *  On-Line Applications Research Corporation (OAR).
30 *
31 *  The license and distribution terms for this file may be
32 *  found in the file LICENSE in this distribution or at
33 *  http://www.rtems.org/license/LICENSE.
34 */
35
36#ifndef _RTEMS_SCORE_CPU_H
37#define _RTEMS_SCORE_CPU_H
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#include <rtems/score/types.h>
44#include <rtems/score/no_cpu.h>
45
46/* conditional compilation parameters */
47
48/**
49 * Does RTEMS manage a dedicated interrupt stack in software?
50 *
51 * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization.
52 * If FALSE, nothing is done.
53 *
54 * If the CPU supports a dedicated interrupt stack in hardware,
55 * then it is generally the responsibility of the BSP to allocate it
56 * and set it up.
57 *
58 * If the CPU does not support a dedicated interrupt stack, then
59 * the porter has two options: (1) execute interrupts on the
60 * stack of the interrupted task, and (2) have RTEMS manage a dedicated
61 * interrupt stack.
62 *
63 * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE.
64 *
65 * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and
66 * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE.  It is
67 * possible that both are FALSE for a particular CPU.  Although it
68 * is unclear what that would imply about the interrupt processing
69 * procedure on that CPU.
70 *
71 * Port Specific Information:
72 *
73 * XXX document implementation including references if appropriate
74 */
75#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE
76
77/**
78 * Does the CPU follow the simple vectored interrupt model?
79 *
80 * If TRUE, then RTEMS allocates the vector table it internally manages.
81 * If FALSE, then the BSP is assumed to allocate and manage the vector
82 * table
83 *
84 * Port Specific Information:
85 *
86 * XXX document implementation including references if appropriate
87 */
88#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
89
90/**
91 * Does this CPU have hardware support for a dedicated interrupt stack?
92 *
93 * If TRUE, then it must be installed during initialization.
94 * If FALSE, then no installation is performed.
95 *
96 * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE.
97 *
98 * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and
99 * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE.  It is
100 * possible that both are FALSE for a particular CPU.  Although it
101 * is unclear what that would imply about the interrupt processing
102 * procedure on that CPU.
103 *
104 * Port Specific Information:
105 *
106 * XXX document implementation including references if appropriate
107 */
108#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE
109
110/**
111 * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager?
112 *
113 * If TRUE, then the memory is allocated during initialization.
114 * If FALSE, then the memory is allocated during initialization.
115 *
116 * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE.
117 *
118 * Port Specific Information:
119 *
120 * XXX document implementation including references if appropriate
121 */
122#define CPU_ALLOCATE_INTERRUPT_STACK TRUE
123
124/**
125 * Does the RTEMS invoke the user's ISR with the vector number and
126 * a pointer to the saved interrupt frame (1) or just the vector
127 * number (0)?
128 *
129 * Port Specific Information:
130 *
131 * XXX document implementation including references if appropriate
132 */
133#define CPU_ISR_PASSES_FRAME_POINTER FALSE
134
135/**
136 * @def CPU_HARDWARE_FP
137 *
138 * Does the CPU have hardware floating point?
139 *
140 * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported.
141 * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored.
142 *
143 * If there is a FP coprocessor such as the i387 or mc68881, then
144 * the answer is TRUE.
145 *
146 * The macro name "NO_CPU_HAS_FPU" should be made CPU specific.
147 * It indicates whether or not this CPU model has FP support.  For
148 * example, it would be possible to have an i386_nofp CPU model
149 * which set this to false to indicate that you have an i386 without
150 * an i387 and wish to leave floating point support out of RTEMS.
151 */
152
153/**
154 * @def CPU_SOFTWARE_FP
155 *
156 * Does the CPU have no hardware floating point and GCC provides a
157 * software floating point implementation which must be context
158 * switched?
159 *
160 * This feature conditional is used to indicate whether or not there
161 * is software implemented floating point that must be context
162 * switched.  The determination of whether or not this applies
163 * is very tool specific and the state saved/restored is also
164 * compiler specific.
165 *
166 * Port Specific Information:
167 *
168 * XXX document implementation including references if appropriate
169 */
170#if ( NO_CPU_HAS_FPU == 1 )
171#define CPU_HARDWARE_FP     TRUE
172#else
173#define CPU_HARDWARE_FP     FALSE
174#endif
175#define CPU_SOFTWARE_FP     FALSE
176
177/**
178 * Are all tasks RTEMS_FLOATING_POINT tasks implicitly?
179 *
180 * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed.
181 * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed.
182 *
183 * So far, the only CPUs in which this option has been used are the
184 * HP PA-RISC and PowerPC.  On the PA-RISC, The HP C compiler and
185 * gcc both implicitly used the floating point registers to perform
186 * integer multiplies.  Similarly, the PowerPC port of gcc has been
187 * seen to allocate floating point local variables and touch the FPU
188 * even when the flow through a subroutine (like vfprintf()) might
189 * not use floating point formats.
190 *
191 * If a function which you would not think utilize the FP unit DOES,
192 * then one can not easily predict which tasks will use the FP hardware.
193 * In this case, this option should be TRUE.
194 *
195 * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well.
196 *
197 * Port Specific Information:
198 *
199 * XXX document implementation including references if appropriate
200 */
201#define CPU_ALL_TASKS_ARE_FP     TRUE
202
203/**
204 * Should the IDLE task have a floating point context?
205 *
206 * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task
207 * and it has a floating point context which is switched in and out.
208 * If FALSE, then the IDLE task does not have a floating point context.
209 *
210 * Setting this to TRUE negatively impacts the time required to preempt
211 * the IDLE task from an interrupt because the floating point context
212 * must be saved as part of the preemption.
213 *
214 * Port Specific Information:
215 *
216 * XXX document implementation including references if appropriate
217 */
218#define CPU_IDLE_TASK_IS_FP      FALSE
219
220/**
221 * Should the saving of the floating point registers be deferred
222 * until a context switch is made to another different floating point
223 * task?
224 *
225 * If TRUE, then the floating point context will not be stored until
226 * necessary.  It will remain in the floating point registers and not
227 * disturned until another floating point task is switched to.
228 *
229 * If FALSE, then the floating point context is saved when a floating
230 * point task is switched out and restored when the next floating point
231 * task is restored.  The state of the floating point registers between
232 * those two operations is not specified.
233 *
234 * If the floating point context does NOT have to be saved as part of
235 * interrupt dispatching, then it should be safe to set this to TRUE.
236 *
237 * Setting this flag to TRUE results in using a different algorithm
238 * for deciding when to save and restore the floating point context.
239 * The deferred FP switch algorithm minimizes the number of times
240 * the FP context is saved and restored.  The FP context is not saved
241 * until a context switch is made to another, different FP task.
242 * Thus in a system with only one FP task, the FP context will never
243 * be saved or restored.
244 *
245 * Port Specific Information:
246 *
247 * XXX document implementation including references if appropriate
248 */
249#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
250
251/**
252 * @brief Enables a robust thread dispatch if set to TRUE.
253 *
254 * In general, it is an application bug to call blocking operating system
255 * services with interrupts disabled.  In most situations this only increases
256 * the interrupt latency.  However, on SMP configurations or on some CPU port
257 * like ARM Cortex-M it leads to undefined system behaviour.  It order to ease
258 * the application development, this error condition is checked at run-time in
259 * case this CPU port option is defined to TRUE.
260 */
261#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE
262
263/**
264 * Does this port provide a CPU dependent IDLE task implementation?
265 *
266 * If TRUE, then the routine @ref _CPU_Thread_Idle_body
267 * must be provided and is the default IDLE thread body instead of
268 * @ref _CPU_Thread_Idle_body.
269 *
270 * If FALSE, then use the generic IDLE thread body if the BSP does
271 * not provide one.
272 *
273 * This is intended to allow for supporting processors which have
274 * a low power or idle mode.  When the IDLE thread is executed, then
275 * the CPU can be powered down.
276 *
277 * The order of precedence for selecting the IDLE thread body is:
278 *
279 *   -#  BSP provided
280 *   -#  CPU dependent (if provided)
281 *   -#  generic (if no BSP and no CPU dependent)
282 *
283 * Port Specific Information:
284 *
285 * XXX document implementation including references if appropriate
286 */
287#define CPU_PROVIDES_IDLE_THREAD_BODY    TRUE
288
289/**
290 * Does the stack grow up (toward higher addresses) or down
291 * (toward lower addresses)?
292 *
293 * If TRUE, then the grows upward.
294 * If FALSE, then the grows toward smaller addresses.
295 *
296 * Port Specific Information:
297 *
298 * XXX document implementation including references if appropriate
299 */
300#define CPU_STACK_GROWS_UP               TRUE
301
302/**
303 * The maximum cache line size in bytes.
304 *
305 * The actual processor may use no cache or a smaller cache line size.
306 */
307#define CPU_CACHE_LINE_BYTES 32
308
309/**
310 * The following is the variable attribute used to force alignment
311 * of critical RTEMS structures.  On some processors it may make
312 * sense to have these aligned on tighter boundaries than
313 * the minimum requirements of the compiler in order to have as
314 * much of the critical data area as possible in a cache line.
315 *
316 * Port Specific Information:
317 *
318 * XXX document implementation including references if appropriate
319 */
320#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
321
322/**
323 * @ingroup CPUInterrupt
324 *
325 * The following defines the number of bits actually used in the
326 * interrupt field of the task mode.  How those bits map to the
327 * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level.
328 *
329 * Port Specific Information:
330 *
331 * XXX document implementation including references if appropriate
332 */
333#define CPU_MODES_INTERRUPT_MASK   0x00000001
334
335/**
336 * @brief Maximum number of processors of all systems supported by this CPU
337 * port.
338 */
339#define CPU_MAXIMUM_PROCESSORS 32
340
341/*
342 *  Processor defined structures required for cpukit/score.
343 *
344 *  Port Specific Information:
345 *
346 *  XXX document implementation including references if appropriate
347 */
348
349/* may need to put some structures here.  */
350
351/**
352 * @defgroup CPUContext Processor Dependent Context Management
353 *
354 * From the highest level viewpoint, there are 2 types of context to save.
355 *
356 *    -# Interrupt registers to save
357 *    -# Task level registers to save
358 *
359 * Since RTEMS handles integer and floating point contexts separately, this
360 * means we have the following 3 context items:
361 *
362 *    -# task level context stuff::  Context_Control
363 *    -# floating point task stuff:: Context_Control_fp
364 *    -# special interrupt level context :: CPU_Interrupt_frame
365 *
366 * On some processors, it is cost-effective to save only the callee
367 * preserved registers during a task context switch.  This means
368 * that the ISR code needs to save those registers which do not
369 * persist across function calls.  It is not mandatory to make this
370 * distinctions between the caller/callee saves registers for the
371 * purpose of minimizing context saved during task switch and on interrupts.
372 * If the cost of saving extra registers is minimal, simplicity is the
373 * choice.  Save the same context on interrupt entry as for tasks in
374 * this case.
375 *
376 * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then
377 * care should be used in designing the context area.
378 *
379 * On some CPUs with hardware floating point support, the Context_Control_fp
380 * structure will not be used or it simply consist of an array of a
381 * fixed number of bytes.   This is done when the floating point context
382 * is dumped by a "FP save context" type instruction and the format
383 * is not really defined by the CPU.  In this case, there is no need
384 * to figure out the exact format -- only the size.  Of course, although
385 * this is enough information for RTEMS, it is probably not enough for
386 * a debugger such as gdb.  But that is another problem.
387 *
388 * Port Specific Information:
389 *
390 * XXX document implementation including references if appropriate
391 *
392 */
393/**@{**/
394
395/**
396 * @ingroup Management
397 * This defines the minimal set of integer and processor state registers
398 * that must be saved during a voluntary context switch from one thread
399 * to another.
400 */
401typedef struct {
402    /**
403     * This field is a hint that a port will have a number of integer
404     * registers that need to be saved at a context switch.
405     */
406    uint32_t   some_integer_register;
407    /**
408     * This field is a hint that a port will have a number of system
409     * registers that need to be saved at a context switch.
410     */
411    uint32_t   some_system_register;
412
413    /**
414     * This field is a hint that a port will have a register that
415     * is the stack pointer.
416     */
417    uint32_t   stack_pointer;
418
419#ifdef RTEMS_SMP
420    /**
421     * @brief On SMP configurations the thread context must contain a boolean
422     * indicator to signal if this context is executing on a processor.
423     *
424     * This field must be updated during a context switch.  The context switch
425     * to the heir must wait until the heir context indicates that it is no
426     * longer executing on a processor.  This indicator must be updated using
427     * an atomic test and set operation to ensure that at most one processor
428     * uses the heir context at the same time.  The context switch must also
429     * check for a potential new heir thread for this processor in case the
430     * heir context is not immediately available.  Update the executing thread
431     * for this processor only if necessary to avoid a cache line
432     * monopolization.
433     *
434     * @code
435     * void _CPU_Context_switch(
436     *   Context_Control *executing_context,
437     *   Context_Control *heir_context
438     * )
439     * {
440     *   save( executing_context );
441     *
442     *   executing_context->is_executing = false;
443     *   memory_barrier();
444     *
445     *   if ( test_and_set( &heir_context->is_executing ) ) {
446     *     do {
447     *       Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot();
448     *       Thread_Control *executing = cpu_self->executing;
449     *       Thread_Control *heir = cpu_self->heir;
450     *
451     *       if ( heir != executing ) {
452     *         cpu_self->executing = heir;
453     *         heir_context = (Context_Control *)
454     *           ((uintptr_t) heir + (uintptr_t) executing_context
455     *             - (uintptr_t) executing)
456     *       }
457     *     } while ( test_and_set( &heir_context->is_executing ) );
458     *   }
459     *
460     *   restore( heir_context );
461     * }
462     * @endcode
463     */
464    volatile bool is_executing;
465#endif
466} Context_Control;
467
468/**
469 * @ingroup Management
470 *
471 * This macro returns the stack pointer associated with @a _context.
472 *
473 * @param[in] _context is the thread context area to access
474 *
475 * @return This method returns the stack pointer.
476 */
477#define _CPU_Context_Get_SP( _context ) \
478  (_context)->stack_pointer
479
480/**
481 * @ingroup Management
482 *
483 * This defines the complete set of floating point registers that must
484 * be saved during any context switch from one thread to another.
485 */
486typedef struct {
487    /** FPU registers are listed here */
488    double      some_float_register;
489} Context_Control_fp;
490
491/**
492 * @ingroup Management
493 *
494 * This defines the set of integer and processor state registers that must
495 * be saved during an interrupt.  This set does not include any which are
496 * in @ref Context_Control.
497 */
498typedef struct {
499    /**
500     * This field is a hint that a port will have a number of integer
501     * registers that need to be saved when an interrupt occurs or
502     * when a context switch occurs at the end of an ISR.
503     */
504    uint32_t   special_interrupt_register;
505} CPU_Interrupt_frame;
506
507/**
508 * This variable is optional.  It is used on CPUs on which it is difficult
509 * to generate an "uninitialized" FP context.  It is filled in by
510 * @ref _CPU_Initialize and copied into the task's FP context area during
511 * @ref _CPU_Context_Initialize.
512 *
513 * Port Specific Information:
514 *
515 * XXX document implementation including references if appropriate
516 */
517extern Context_Control_fp _CPU_Null_fp_context;
518
519/** @} */
520
521/**
522 * @defgroup CPUInterrupt Processor Dependent Interrupt Management
523 *
524 * On some CPUs, RTEMS supports a software managed interrupt stack.
525 * This stack is allocated by the Interrupt Manager and the switch
526 * is performed in @ref _ISR_Handler.  These variables contain pointers
527 * to the lowest and highest addresses in the chunk of memory allocated
528 * for the interrupt stack.  Since it is unknown whether the stack
529 * grows up or down (in general), this give the CPU dependent
530 * code the option of picking the version it wants to use.
531 *
532 * NOTE: These two variables are required if the macro
533 *       @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE.
534 *
535 * Port Specific Information:
536 *
537 * XXX document implementation including references if appropriate
538 */
539
540/*
541 *  Nothing prevents the porter from declaring more CPU specific variables.
542 *
543 *  Port Specific Information:
544 *
545 *  XXX document implementation including references if appropriate
546 */
547
548/* XXX: if needed, put more variables here */
549
550/**
551 * @ingroup CPUContext
552 *
553 * The size of the floating point context area.  On some CPUs this
554 * will not be a "sizeof" because the format of the floating point
555 * area is not defined -- only the size is.  This is usually on
556 * CPUs with a "floating point save context" instruction.
557 *
558 * Port Specific Information:
559 *
560 * XXX document implementation including references if appropriate
561 */
562#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
563
564/**
565 * Amount of extra stack (above minimum stack size) required by
566 * MPCI receive server thread.  Remember that in a multiprocessor
567 * system this thread must exist and be able to process all directives.
568 *
569 * Port Specific Information:
570 *
571 * XXX document implementation including references if appropriate
572 */
573#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
574
575/**
576 * @ingroup CPUInterrupt
577 *
578 * This defines the number of entries in the _ISR_Vector_table managed by RTEMS
579 * in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to TRUE.  It must be a
580 * compile-time constant.
581 *
582 * It must be undefined in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to
583 * FALSE.
584 */
585#define CPU_INTERRUPT_NUMBER_OF_VECTORS      32
586
587/**
588 * @ingroup CPUInterrupt
589 *
590 * This defines the highest interrupt vector number for this port in case
591 * CPU_SIMPLE_VECTORED_INTERRUPTS is defined to TRUE.  It must be less than
592 * CPU_INTERRUPT_NUMBER_OF_VECTORS.  It may be not a compile-time constant.
593 *
594 * It must be undefined in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to
595 * FALSE.
596 */
597#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER  (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
598
599/**
600 * @ingroup CPUInterrupt
601 *
602 * This is defined if the port has a special way to report the ISR nesting
603 * level.  Most ports maintain the variable @a _ISR_Nest_level.
604 */
605#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
606
607/**
608 * @ingroup CPUContext
609 *
610 * Should be large enough to run all RTEMS tests.  This ensures
611 * that a "reasonable" small application should not have any problems.
612 *
613 * Port Specific Information:
614 *
615 * XXX document implementation including references if appropriate
616 */
617#define CPU_STACK_MINIMUM_SIZE          (1024*4)
618
619/**
620 * Size of a pointer.
621 *
622 * This must be an integer literal that can be used by the assembler.  This
623 * value will be used to calculate offsets of structure members.  These
624 * offsets will be used in assembler code.
625 */
626#define CPU_SIZEOF_POINTER         4
627
628/**
629 * CPU's worst alignment requirement for data types on a byte boundary.  This
630 * alignment does not take into account the requirements for the stack.  It
631 * must be a power of two greater than or equal to two.  The power of two
632 * requirement makes it possible to align values easily using simple bit
633 * operations.
634 *
635 * Port Specific Information:
636 *
637 * XXX document implementation including references if appropriate
638 */
639#define CPU_ALIGNMENT              8
640
641/**
642 * This number corresponds to the byte alignment requirement for the
643 * heap handler.  This alignment requirement may be stricter than that
644 * for the data types alignment specified by @ref CPU_ALIGNMENT.  It is
645 * common for the heap to follow the same alignment requirement as
646 * @ref CPU_ALIGNMENT.  If the @ref CPU_ALIGNMENT is strict enough for
647 * the heap, then this should be set to @ref CPU_ALIGNMENT.
648 *
649 * NOTE:  It must be a power of two greater than or equal to two.  The
650 *        requirement to be a multiple of two is because the heap uses the
651 *        least significant field of the front and back flags to indicate that
652 *        a block is in use or free.  So you do not want any odd length blocks
653 *        really putting length data in that bit.
654 *
655 *        On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will
656 *        have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that
657 *        elements allocated from the heap meet all restrictions.
658 *
659 * Port Specific Information:
660 *
661 * XXX document implementation including references if appropriate
662 */
663#define CPU_HEAP_ALIGNMENT         CPU_ALIGNMENT
664
665/**
666 * This number corresponds to the byte alignment requirement for memory
667 * buffers allocated by the partition manager.  This alignment requirement
668 * may be stricter than that for the data types alignment specified by
669 * @ref CPU_ALIGNMENT.  It is common for the partition to follow the same
670 * alignment requirement as @ref CPU_ALIGNMENT.  If the @ref CPU_ALIGNMENT is
671 * strict enough for the partition, then this should be set to
672 * @ref CPU_ALIGNMENT.
673 *
674 * NOTE:  This does not have to be a power of 2.  It does have to
675 *        be greater or equal to than @ref CPU_ALIGNMENT.
676 *
677 * Port Specific Information:
678 *
679 * XXX document implementation including references if appropriate
680 */
681#define CPU_PARTITION_ALIGNMENT    CPU_ALIGNMENT
682
683/**
684 * This number corresponds to the byte alignment requirement for the
685 * stack.  This alignment requirement may be stricter than that for the
686 * data types alignment specified by @ref CPU_ALIGNMENT.  If the
687 * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be
688 * set to 0.
689 *
690 * NOTE: This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT.
691 *
692 * Port Specific Information:
693 *
694 * XXX document implementation including references if appropriate
695 */
696#define CPU_STACK_ALIGNMENT        0
697
698/*
699 *  ISR handler macros
700 */
701
702/**
703 * @ingroup CPUInterrupt
704 *
705 * Support routine to initialize the RTEMS vector table after it is allocated.
706 *
707 * Port Specific Information:
708 *
709 * XXX document implementation including references if appropriate
710 */
711#define _CPU_Initialize_vectors()
712
713/**
714 * @ingroup CPUInterrupt
715 *
716 * Disable all interrupts for an RTEMS critical section.  The previous
717 * level is returned in @a _isr_cookie.
718 *
719 * @param[out] _isr_cookie will contain the previous level cookie
720 *
721 * Port Specific Information:
722 *
723 * XXX document implementation including references if appropriate
724 */
725#define _CPU_ISR_Disable( _isr_cookie ) \
726  { \
727    (_isr_cookie) = 0;   /* do something to prevent warnings */ \
728  }
729
730/**
731 * @ingroup CPUInterrupt
732 *
733 * Enable interrupts to the previous level (returned by _CPU_ISR_Disable).
734 * This indicates the end of an RTEMS critical section.  The parameter
735 * @a _isr_cookie is not modified.
736 *
737 * @param[in] _isr_cookie contain the previous level cookie
738 *
739 * Port Specific Information:
740 *
741 * XXX document implementation including references if appropriate
742 */
743#define _CPU_ISR_Enable( _isr_cookie )  \
744  { \
745  }
746
747/**
748 * @ingroup CPUInterrupt
749 *
750 * This temporarily restores the interrupt to @a _isr_cookie before immediately
751 * disabling them again.  This is used to divide long RTEMS critical
752 * sections into two or more parts.  The parameter @a _isr_cookie is not
753 * modified.
754 *
755 * @param[in] _isr_cookie contain the previous level cookie
756 *
757 * Port Specific Information:
758 *
759 * XXX document implementation including references if appropriate
760 */
761#define _CPU_ISR_Flash( _isr_cookie ) \
762  { \
763  }
764
765/**
766 * @brief Returns true if interrupts are enabled in the specified ISR level,
767 * otherwise returns false.
768 *
769 * @param[in] level The ISR level.
770 *
771 * @retval true Interrupts are enabled in the ISR level.
772 * @retval false Otherwise.
773 */
774RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
775{
776  return false;
777}
778
779/**
780 * @ingroup CPUInterrupt
781 *
782 * This routine and @ref _CPU_ISR_Get_level
783 * Map the interrupt level in task mode onto the hardware that the CPU
784 * actually provides.  Currently, interrupt levels which do not
785 * map onto the CPU in a generic fashion are undefined.  Someday,
786 * it would be nice if these were "mapped" by the application
787 * via a callout.  For example, m68k has 8 levels 0 - 7, levels
788 * 8 - 255 would be available for bsp/application specific meaning.
789 * This could be used to manage a programmable interrupt controller
790 * via the rtems_task_mode directive.
791 *
792 * Port Specific Information:
793 *
794 * XXX document implementation including references if appropriate
795 */
796#define _CPU_ISR_Set_level( new_level ) \
797  { \
798  }
799
800/**
801 * @ingroup CPUInterrupt
802 *
803 * Return the current interrupt disable level for this task in
804 * the format used by the interrupt level portion of the task mode.
805 *
806 * NOTE: This routine usually must be implemented as a subroutine.
807 *
808 * Port Specific Information:
809 *
810 * XXX document implementation including references if appropriate
811 */
812uint32_t   _CPU_ISR_Get_level( void );
813
814/* end of ISR handler macros */
815
816/* Context handler macros */
817
818/**
819 *  @ingroup CPUContext
820 *
821 * Initialize the context to a state suitable for starting a
822 * task after a context restore operation.  Generally, this
823 * involves:
824 *
825 *    - setting a starting address
826 *    - preparing the stack
827 *    - preparing the stack and frame pointers
828 *    - setting the proper interrupt level in the context
829 *    - initializing the floating point context
830 *
831 * This routine generally does not set any unnecessary register
832 * in the context.  The state of the "general data" registers is
833 * undefined at task start time.
834 *
835 * The ISR dispatch disable field of the context must be cleared to zero if it
836 * is used by the CPU port.  Otherwise, a thread restart results in
837 * unpredictable behaviour.
838 *
839 * @param[in] _the_context is the context structure to be initialized
840 * @param[in] _stack_base is the lowest physical address of this task's stack
841 * @param[in] _size is the size of this task's stack
842 * @param[in] _isr is the interrupt disable level
843 * @param[in] _entry_point is the thread's entry point.  This is
844 *        always @a _Thread_Handler
845 * @param[in] _is_fp is TRUE if the thread is to be a floating
846 *       point thread.  This is typically only used on CPUs where the
847 *       FPU may be easily disabled by software such as on the SPARC
848 *       where the PSR contains an enable FPU bit.
849 * @param[in] _tls_area The thread-local storage (TLS) area.
850 *
851 * Port Specific Information:
852 *
853 * XXX document implementation including references if appropriate
854 */
855#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
856                                 _isr, _entry_point, _is_fp, _tls_area ) \
857  { \
858  }
859
860/**
861 * This routine is responsible for somehow restarting the currently
862 * executing task.  If you are lucky, then all that is necessary
863 * is restoring the context.  Otherwise, there will need to be
864 * a special assembly routine which does something special in this
865 * case.  For many ports, simply adding a label to the restore path
866 * of @ref _CPU_Context_switch will work.  On other ports, it may be
867 * possibly to load a few arguments and jump to the restore path. It will
868 * not work if restarting self conflicts with the stack frame
869 * assumptions of restoring a context.
870 *
871 * Port Specific Information:
872 *
873 * XXX document implementation including references if appropriate
874 */
875#define _CPU_Context_Restart_self( _the_context ) \
876   _CPU_Context_restore( (_the_context) );
877
878/**
879 * This routine initializes the FP context area passed to it to.
880 * There are a few standard ways in which to initialize the
881 * floating point context.  The code included for this macro assumes
882 * that this is a CPU in which a "initial" FP context was saved into
883 * @a _CPU_Null_fp_context and it simply copies it to the destination
884 * context passed to it.
885 *
886 * Other floating point context save/restore models include:
887 *   -# not doing anything, and
888 *   -# putting a "null FP status word" in the correct place in the FP context.
889 *
890 * @param[in] _destination is the floating point context area
891 *
892 * Port Specific Information:
893 *
894 * XXX document implementation including references if appropriate
895 */
896#define _CPU_Context_Initialize_fp( _destination ) \
897  { \
898   *(*(_destination)) = _CPU_Null_fp_context; \
899  }
900
901/* end of Context handler macros */
902
903/* Fatal Error manager macros */
904
905/**
906 * This routine copies _error into a known place -- typically a stack
907 * location or a register, optionally disables interrupts, and
908 * halts/stops the CPU.
909 *
910 * Port Specific Information:
911 *
912 * XXX document implementation including references if appropriate
913 */
914#define _CPU_Fatal_halt( _source, _error ) \
915  { \
916  }
917
918/* end of Fatal Error manager macros */
919
920/* Bitfield handler macros */
921
922/**
923 * @defgroup CPUBitfield Processor Dependent Bitfield Manipulation
924 *
925 * This set of routines are used to implement fast searches for
926 * the most important ready task.
927 *
928 */
929/**@{**/
930
931/**
932 * This definition is set to TRUE if the port uses the generic bitfield
933 * manipulation implementation.
934 */
935#define CPU_USE_GENERIC_BITFIELD_CODE TRUE
936
937/**
938 * This routine sets @a _output to the bit number of the first bit
939 * set in @a _value.  @a _value is of CPU dependent type
940 * @a Priority_bit_map_Word.  This type may be either 16 or 32 bits
941 * wide although only the 16 least significant bits will be used.
942 *
943 * There are a number of variables in using a "find first bit" type
944 * instruction.
945 *
946 *   -# What happens when run on a value of zero?
947 *   -# Bits may be numbered from MSB to LSB or vice-versa.
948 *   -# The numbering may be zero or one based.
949 *   -# The "find first bit" instruction may search from MSB or LSB.
950 *
951 * RTEMS guarantees that (1) will never happen so it is not a concern.
952 * (2),(3), (4) are handled by the macros @ref _CPU_Priority_Mask and
953 * @ref _CPU_Priority_bits_index.  These three form a set of routines
954 * which must logically operate together.  Bits in the _value are
955 * set and cleared based on masks built by @ref _CPU_Priority_Mask.
956 * The basic major and minor values calculated by @ref _Priority_Major
957 * and @ref _Priority_Minor are "massaged" by @ref _CPU_Priority_bits_index
958 * to properly range between the values returned by the "find first bit"
959 * instruction.  This makes it possible for @ref _Priority_Get_highest to
960 * calculate the major and directly index into the minor table.
961 * This mapping is necessary to ensure that 0 (a high priority major/minor)
962 * is the first bit found.
963 *
964 * This entire "find first bit" and mapping process depends heavily
965 * on the manner in which a priority is broken into a major and minor
966 * components with the major being the 4 MSB of a priority and minor
967 * the 4 LSB.  Thus (0 << 4) + 0 corresponds to priority 0 -- the highest
968 * priority.  And (15 << 4) + 14 corresponds to priority 254 -- the next
969 * to the lowest priority.
970 *
971 * If your CPU does not have a "find first bit" instruction, then
972 * there are ways to make do without it.  Here are a handful of ways
973 * to implement this in software:
974 *
975@verbatim
976      - a series of 16 bit test instructions
977      - a "binary search using if's"
978      - _number = 0
979        if _value > 0x00ff
980          _value >>=8
981          _number = 8;
982
983        if _value > 0x0000f
984          _value >=8
985          _number += 4
986
987        _number += bit_set_table[ _value ]
988@endverbatim
989
990 *   where bit_set_table[ 16 ] has values which indicate the first
991 *     bit set
992 *
993 * @param[in] _value is the value to be scanned
994 * @param[in] _output is the first bit set
995 *
996 * Port Specific Information:
997 *
998 * XXX document implementation including references if appropriate
999 */
1000
1001#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
1002#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
1003  { \
1004    (_output) = 0;   /* do something to prevent warnings */ \
1005  }
1006#endif
1007
1008/** @} */
1009
1010/* end of Bitfield handler macros */
1011
1012/**
1013 * This routine builds the mask which corresponds to the bit fields
1014 * as searched by @ref _CPU_Bitfield_Find_first_bit.  See the discussion
1015 * for that routine.
1016 *
1017 * Port Specific Information:
1018 *
1019 * XXX document implementation including references if appropriate
1020 */
1021#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
1022
1023#define _CPU_Priority_Mask( _bit_number ) \
1024  ( 1 << (_bit_number) )
1025
1026#endif
1027
1028/**
1029 * @ingroup CPUBitfield
1030 *
1031 * This routine translates the bit numbers returned by
1032 * @ref _CPU_Bitfield_Find_first_bit into something suitable for use as
1033 * a major or minor component of a priority.  See the discussion
1034 * for that routine.
1035 *
1036 * @param[in] _priority is the major or minor number to translate
1037 *
1038 * Port Specific Information:
1039 *
1040 * XXX document implementation including references if appropriate
1041 */
1042#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
1043
1044#define _CPU_Priority_bits_index( _priority ) \
1045  (_priority)
1046
1047#endif
1048
1049/* end of Priority handler macros */
1050
1051/* functions */
1052
1053/**
1054 * This routine performs CPU dependent initialization.
1055 *
1056 * Port Specific Information:
1057 *
1058 * XXX document implementation including references if appropriate
1059 */
1060void _CPU_Initialize(void);
1061
1062/**
1063 * @ingroup CPUInterrupt
1064 *
1065 * This routine installs a "raw" interrupt handler directly into the
1066 * processor's vector table.
1067 *
1068 * @param[in] vector is the vector number
1069 * @param[in] new_handler is the raw ISR handler to install
1070 * @param[in] old_handler is the previously installed ISR Handler
1071 *
1072 * Port Specific Information:
1073 *
1074 * XXX document implementation including references if appropriate
1075 */
1076void _CPU_ISR_install_raw_handler(
1077  uint32_t    vector,
1078  proc_ptr    new_handler,
1079  proc_ptr   *old_handler
1080);
1081
1082/**
1083 * @ingroup CPUInterrupt
1084 *
1085 * This routine installs an interrupt vector.
1086 *
1087 * @param[in] vector is the vector number
1088 * @param[in] new_handler is the RTEMS ISR handler to install
1089 * @param[in] old_handler is the previously installed ISR Handler
1090 *
1091 * Port Specific Information:
1092 *
1093 * XXX document implementation including references if appropriate
1094 */
1095void _CPU_ISR_install_vector(
1096  uint32_t    vector,
1097  proc_ptr    new_handler,
1098  proc_ptr   *old_handler
1099);
1100
1101/**
1102 * @ingroup CPUInterrupt
1103 * This routine installs the hardware interrupt stack pointer.
1104 *
1105 * NOTE:  It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK
1106 *        is TRUE.
1107 *
1108 * Port Specific Information:
1109 *
1110 * XXX document implementation including references if appropriate
1111 */
1112void _CPU_Install_interrupt_stack( void );
1113
1114/**
1115 * This routine is the CPU dependent IDLE thread body.
1116 *
1117 * NOTE:  It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY
1118 *         is TRUE.
1119 *
1120 * Port Specific Information:
1121 *
1122 * XXX document implementation including references if appropriate
1123 */
1124void *_CPU_Thread_Idle_body( uintptr_t ignored );
1125
1126/**
1127 * @ingroup CPUContext
1128 *
1129 * This routine switches from the run context to the heir context.
1130 *
1131 * @param[in] run points to the context of the currently executing task
1132 * @param[in] heir points to the context of the heir task
1133 *
1134 * Port Specific Information:
1135 *
1136 * XXX document implementation including references if appropriate
1137 */
1138void _CPU_Context_switch(
1139  Context_Control  *run,
1140  Context_Control  *heir
1141);
1142
1143/**
1144 * @ingroup CPUContext
1145 *
1146 * This routine is generally used only to restart self in an
1147 * efficient manner.  It may simply be a label in @ref _CPU_Context_switch.
1148 *
1149 * @param[in] new_context points to the context to be restored.
1150 *
1151 * NOTE: May be unnecessary to reload some registers.
1152 *
1153 * Port Specific Information:
1154 *
1155 * XXX document implementation including references if appropriate
1156 */
1157void _CPU_Context_restore(
1158  Context_Control *new_context
1159) RTEMS_NO_RETURN;
1160
1161/**
1162 * @ingroup CPUContext
1163 *
1164 * This routine saves the floating point context passed to it.
1165 *
1166 * @param[in] fp_context_ptr is a pointer to a pointer to a floating
1167 * point context area
1168 *
1169 * @return on output @a *fp_context_ptr will contain the address that
1170 * should be used with @ref _CPU_Context_restore_fp to restore this context.
1171 *
1172 * Port Specific Information:
1173 *
1174 * XXX document implementation including references if appropriate
1175 */
1176void _CPU_Context_save_fp(
1177  Context_Control_fp **fp_context_ptr
1178);
1179
1180/**
1181 * @ingroup CPUContext
1182 *
1183 * This routine restores the floating point context passed to it.
1184 *
1185 * @param[in] fp_context_ptr is a pointer to a pointer to a floating
1186 * point context area to restore
1187 *
1188 * @return on output @a *fp_context_ptr will contain the address that
1189 * should be used with @ref _CPU_Context_save_fp to save this context.
1190 *
1191 * Port Specific Information:
1192 *
1193 * XXX document implementation including references if appropriate
1194 */
1195void _CPU_Context_restore_fp(
1196  Context_Control_fp **fp_context_ptr
1197);
1198
1199/**
1200 * @ingroup CPUContext
1201 *
1202 * @brief Clobbers all volatile registers with values derived from the pattern
1203 * parameter.
1204 *
1205 * This function is used only in test sptests/spcontext01.
1206 *
1207 * @param[in] pattern Pattern used to generate distinct register values.
1208 *
1209 * @see _CPU_Context_validate().
1210 */
1211void _CPU_Context_volatile_clobber( uintptr_t pattern );
1212
1213/**
1214 * @ingroup CPUContext
1215 *
1216 * @brief Initializes and validates the CPU context with values derived from
1217 * the pattern parameter.
1218 *
1219 * This function will not return if the CPU context remains consistent.  In
1220 * case this function returns the CPU port is broken.
1221 *
1222 * This function is used only in test sptests/spcontext01.
1223 *
1224 * @param[in] pattern Pattern used to generate distinct register values.
1225 *
1226 * @see _CPU_Context_volatile_clobber().
1227 */
1228void _CPU_Context_validate( uintptr_t pattern );
1229
1230/**
1231 * @brief The set of registers that specifies the complete processor state.
1232 *
1233 * The CPU exception frame may be available in fatal error conditions like for
1234 * example illegal opcodes, instruction fetch errors, or data access errors.
1235 *
1236 * @see rtems_fatal(), RTEMS_FATAL_SOURCE_EXCEPTION, and
1237 * rtems_exception_frame_print().
1238 */
1239typedef struct {
1240  uint32_t processor_state_register;
1241  uint32_t integer_registers [1];
1242  double float_registers [1];
1243} CPU_Exception_frame;
1244
1245/**
1246 * @brief Prints the exception frame via printk().
1247 *
1248 * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION.
1249 */
1250void _CPU_Exception_frame_print( const CPU_Exception_frame *frame );
1251
1252/**
1253 * @ingroup CPUEndian
1254 *
1255 * The following routine swaps the endian format of an unsigned int.
1256 * It must be static because it is referenced indirectly.
1257 *
1258 * This version will work on any processor, but if there is a better
1259 * way for your CPU PLEASE use it.  The most common way to do this is to:
1260 *
1261 *    swap least significant two bytes with 16-bit rotate
1262 *    swap upper and lower 16-bits
1263 *    swap most significant two bytes with 16-bit rotate
1264 *
1265 * Some CPUs have special instructions which swap a 32-bit quantity in
1266 * a single instruction (e.g. i486).  It is probably best to avoid
1267 * an "endian swapping control bit" in the CPU.  One good reason is
1268 * that interrupts would probably have to be disabled to ensure that
1269 * an interrupt does not try to access the same "chunk" with the wrong
1270 * endian.  Another good reason is that on some CPUs, the endian bit
1271 * endianness for ALL fetches -- both code and data -- so the code
1272 * will be fetched incorrectly.
1273 *
1274 * @param[in] value is the value to be swapped
1275 * @return the value after being endian swapped
1276 *
1277 * Port Specific Information:
1278 *
1279 * XXX document implementation including references if appropriate
1280 */
1281static inline uint32_t CPU_swap_u32(
1282  uint32_t value
1283)
1284{
1285  uint32_t byte1, byte2, byte3, byte4, swapped;
1286
1287  byte4 = (value >> 24) & 0xff;
1288  byte3 = (value >> 16) & 0xff;
1289  byte2 = (value >> 8)  & 0xff;
1290  byte1 =  value        & 0xff;
1291
1292  swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
1293  return swapped;
1294}
1295
1296/**
1297 * @ingroup CPUEndian
1298 *
1299 * This routine swaps a 16 bir quantity.
1300 *
1301 * @param[in] value is the value to be swapped
1302 * @return the value after being endian swapped
1303 */
1304#define CPU_swap_u16( value ) \
1305  (((value&0xff) << 8) | ((value >> 8)&0xff))
1306
1307/**
1308 * @brief Unsigned integer type for CPU counter values.
1309 */
1310typedef uint32_t CPU_Counter_ticks;
1311
1312/**
1313 * @brief Returns the current CPU counter value.
1314 *
1315 * A CPU counter is some free-running counter.  It ticks usually with a
1316 * frequency close to the CPU or system bus clock.  The board support package
1317 * must ensure that this function works before the RTEMS initialization.
1318 * Otherwise invalid profiling statistics will be gathered.
1319 *
1320 * @return The current CPU counter value.
1321 */
1322CPU_Counter_ticks _CPU_Counter_read( void );
1323
1324/**
1325 * @brief Returns the difference between the second and first CPU counter
1326 * value.
1327 *
1328 * This operation may be carried out as a modulo operation depending on the
1329 * range of the CPU counter device.
1330 *
1331 * @param[in] second The second CPU counter value.
1332 * @param[in] first The first CPU counter value.
1333 *
1334 * @return Returns second minus first modulo counter period.
1335 */
1336CPU_Counter_ticks _CPU_Counter_difference(
1337  CPU_Counter_ticks second,
1338  CPU_Counter_ticks first
1339);
1340
1341#ifdef RTEMS_SMP
1342  /**
1343   * @brief Performs CPU specific SMP initialization in the context of the boot
1344   * processor.
1345   *
1346   * This function is invoked on the boot processor during system
1347   * initialization.  All interrupt stacks are allocated at this point in case
1348   * the CPU port allocates the interrupt stacks.  This function is called
1349   * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is
1350   * used.
1351   *
1352   * @return The count of physically or virtually available processors.
1353   * Depending on the configuration the application may use not all processors.
1354   */
1355  uint32_t _CPU_SMP_Initialize( void );
1356
1357  /**
1358   * @brief Starts a processor specified by its index.
1359   *
1360   * This function is invoked on the boot processor during system
1361   * initialization.
1362   *
1363   * This function will be called after _CPU_SMP_Initialize().
1364   *
1365   * @param[in] cpu_index The processor index.
1366   *
1367   * @retval true Successful operation.
1368   * @retval false Unable to start this processor.
1369   */
1370  bool _CPU_SMP_Start_processor( uint32_t cpu_index );
1371
1372  /**
1373   * @brief Performs final steps of CPU specific SMP initialization in the
1374   * context of the boot processor.
1375   *
1376   * This function is invoked on the boot processor during system
1377   * initialization.
1378   *
1379   * This function will be called after all processors requested by the
1380   * application have been started.
1381   *
1382   * @param[in] cpu_count The minimum value of the count of processors
1383   * requested by the application configuration and the count of physically or
1384   * virtually available processors.
1385   */
1386  void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
1387
1388  /**
1389   * @brief Prepares a CPU to start multitasking in terms of SMP.
1390   *
1391   * This function is invoked on all processors requested by the application
1392   * during system initialization.
1393   *
1394   * This function will be called after all processors requested by the
1395   * application have been started right before the context switch to the first
1396   * thread takes place.
1397   */
1398  void _CPU_SMP_Prepare_start_multitasking( void );
1399
1400  /**
1401   * @brief Returns the index of the current processor.
1402   *
1403   * An architecture specific method must be used to obtain the index of the
1404   * current processor in the system.  The set of processor indices is the
1405   * range of integers starting with zero up to the processor count minus one.
1406   */
1407  static inline uint32_t _CPU_SMP_Get_current_processor( void )
1408  {
1409    return 123;
1410  }
1411
1412  /**
1413   * @brief Sends an inter-processor interrupt to the specified target
1414   * processor.
1415   *
1416   * This operation is undefined for target processor indices out of range.
1417   *
1418   * @param[in] target_processor_index The target processor index.
1419   */
1420  void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
1421
1422  /**
1423   * @brief Broadcasts a processor event.
1424   *
1425   * Some architectures provide a low-level synchronization primitive for
1426   * processors in a multi-processor environment.  Processors waiting for this
1427   * event may go into a low-power state and stop generating system bus
1428   * transactions.  This function must ensure that preceding store operations
1429   * can be observed by other processors.
1430   *
1431   * @see _CPU_SMP_Processor_event_receive().
1432   */
1433  static inline void _CPU_SMP_Processor_event_broadcast( void )
1434  {
1435    __asm__ volatile ( "" : : : "memory" );
1436  }
1437
1438  /**
1439   * @brief Receives a processor event.
1440   *
1441   * This function will wait for the processor event and may wait forever if no
1442   * such event arrives.
1443   *
1444   * @see _CPU_SMP_Processor_event_broadcast().
1445   */
1446  static inline void _CPU_SMP_Processor_event_receive( void )
1447  {
1448    __asm__ volatile ( "" : : : "memory" );
1449  }
1450
1451  /**
1452   * @brief Gets the is executing indicator of the thread context.
1453   *
1454   * @param[in] context The context.
1455   */
1456  static inline bool _CPU_Context_Get_is_executing(
1457    const Context_Control *context
1458  )
1459  {
1460    return context->is_executing;
1461  }
1462
1463  /**
1464   * @brief Sets the is executing indicator of the thread context.
1465   *
1466   * @param[in] context The context.
1467   * @param[in] is_executing The new value for the is executing indicator.
1468   */
1469  static inline void _CPU_Context_Set_is_executing(
1470    Context_Control *context,
1471    bool is_executing
1472  )
1473  {
1474    context->is_executing = is_executing;
1475  }
1476#endif
1477
1478#ifdef __cplusplus
1479}
1480#endif
1481
1482#endif
Note: See TracBrowser for help on using the repository browser.