source: rtems/cpukit/score/include/rtems/score/smpimpl.h @ e239760

4.115
Last change on this file since e239760 was e239760, checked in by Sebastian Huber <sebastian.huber@…>, on 04/29/14 at 14:09:35

score: SMP_FATAL_SCHEDULER_WITHOUT_PROCESSORS

Avoid the SMP_FATAL_SCHEDULER_WITHOUT_PROCESSORS fatal error and make it
a run-time error in rtems_scheduler_ident() and _Scheduler_Get_by_id().

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSMPImpl
5 *
6 * @brief SuperCore SMP Implementation
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2011.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_SCORE_SMPIMPL_H
19#define _RTEMS_SCORE_SMPIMPL_H
20
21#include <rtems/score/smp.h>
22#include <rtems/score/percpu.h>
23#include <rtems/fatal.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @defgroup ScoreSMP SMP Support
31 *
32 * @ingroup Score
33 *
34 * This defines the interface of the SuperCore SMP support.
35 *
36 * @{
37 */
38
39/**
40 * @brief SMP message to request a processor shutdown.
41 *
42 * @see _SMP_Send_message().
43 */
44#define SMP_MESSAGE_SHUTDOWN UINT32_C(0x1)
45
46/**
47 * @brief SMP fatal codes.
48 */
49typedef enum {
50  SMP_FATAL_SHUTDOWN,
51  SMP_FATAL_SHUTDOWN_EARLY,
52  SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER,
53  SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT,
54  SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR,
55  SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
56} SMP_Fatal_code;
57
58static inline void _SMP_Fatal( SMP_Fatal_code code )
59{
60  _Terminate( RTEMS_FATAL_SOURCE_SMP, false, code );
61}
62
63/**
64 *  @brief Initialize SMP Handler
65 *
66 *  This method initialize the SMP Handler.
67 */
68#if defined( RTEMS_SMP )
69  void _SMP_Handler_initialize( void );
70#else
71  #define _SMP_Handler_initialize() \
72    do { } while ( 0 )
73#endif
74
75#if defined( RTEMS_SMP )
76
77/**
78 * @brief Performs high-level initialization of a secondary processor and runs
79 * the application threads.
80 *
81 * The low-level initialization code must call this function to hand over the
82 * control of this processor to RTEMS.  Interrupts must be disabled.  It must
83 * be possible to send inter-processor interrupts to this processor.  Since
84 * interrupts are disabled the inter-processor interrupt delivery is postponed
85 * until interrupts are enabled the first time.  Interrupts are enabled during
86 * the execution begin of threads in case they have interrupt level zero (this
87 * is the default).
88 *
89 * The pre-requisites for the call to this function are
90 * - disabled interrupts,
91 * - delivery of inter-processor interrupts is possible,
92 * - a valid stack pointer and enough stack space,
93 * - a valid code memory, and
94 * - a valid BSS section.
95 *
96 * This function must not be called by the main processor.  The main processor
97 * uses _Thread_Start_multitasking() instead.
98 *
99 * This function does not return to the caller.
100 */
101void _SMP_Start_multitasking_on_secondary_processor( void )
102  RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
103
104/**
105 * @brief Interrupt handler for inter-processor interrupts.
106 */
107static inline void _SMP_Inter_processor_interrupt_handler( void )
108{
109  Per_CPU_Control *cpu_self = _Per_CPU_Get();
110
111  if ( cpu_self->message != 0 ) {
112    uint32_t  message;
113    ISR_Level level;
114
115    _Per_CPU_ISR_disable_and_acquire( cpu_self, level );
116    message = cpu_self->message;
117    cpu_self->message = 0;
118    _Per_CPU_Release_and_ISR_enable( cpu_self, level );
119
120    if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) {
121      rtems_fatal( RTEMS_FATAL_SOURCE_SMP, SMP_FATAL_SHUTDOWN );
122      /* does not continue past here */
123    }
124  }
125}
126
127/**
128 *  @brief Sends a SMP message to a processor.
129 *
130 *  The target processor may be the sending processor.
131 *
132 *  @param[in] cpu_index The target processor of the message.
133 *  @param[in] message The message.
134 */
135void _SMP_Send_message( uint32_t cpu_index, uint32_t message );
136
137/**
138 *  @brief Request of others CPUs.
139 *
140 *  This method is invoked by RTEMS when it needs to make a request
141 *  of the other CPUs.  It should be implemented using some type of
142 *  interprocessor interrupt. CPUs not including the originating
143 *  CPU should receive the message.
144 *
145 *  @param [in] message is message to send
146 */
147void _SMP_Broadcast_message(
148  uint32_t  message
149);
150
151#endif /* defined( RTEMS_SMP ) */
152
153/**
154 * @brief Requests a multitasking start on all configured and available
155 * processors.
156 */
157#if defined( RTEMS_SMP )
158  void _SMP_Request_start_multitasking( void );
159#else
160  #define _SMP_Request_start_multitasking() \
161    do { } while ( 0 )
162#endif
163
164/**
165 * @brief Requests a shutdown of all processors.
166 *
167 * This function is a part of the system termination procedure.
168 *
169 * @see _Terminate().
170 */
171#if defined( RTEMS_SMP )
172  void _SMP_Request_shutdown( void );
173#else
174  #define _SMP_Request_shutdown() \
175    do { } while ( 0 )
176#endif
177
178/** @} */
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif
185/* end of include file */
Note: See TracBrowser for help on using the repository browser.