source: rtems/cpukit/score/include/rtems/score/smpimpl.h @ 3380ee8

4.115
Last change on this file since 3380ee8 was 3380ee8, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/14 at 05:46:53

score: Use common names for per-CPU variables

Use "cpu" for an arbitrary Per_CPU_Control variable.

Use "cpu_self" for the Per_CPU_Control of the current processor.

Use "cpu_index" for an arbitrary processor index.

Use "cpu_index_self" for the processor index of the current processor.

Use "cpu_count" for the processor count obtained via
_SMP_Get_processor_count().

Use "cpu_max" for the processor maximum obtained by
rtems_configuration_get_maximum_processors().

  • Property mode set to 100644
File size: 4.5 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_SCHEDULER_WITHOUT_PROCESSORS,
56  SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
57} SMP_Fatal_code;
58
59static inline void _SMP_Fatal( SMP_Fatal_code code )
60{
61  _Terminate( RTEMS_FATAL_SOURCE_SMP, false, code );
62}
63
64/**
65 *  @brief Initialize SMP Handler
66 *
67 *  This method initialize the SMP Handler.
68 */
69#if defined( RTEMS_SMP )
70  void _SMP_Handler_initialize( void );
71#else
72  #define _SMP_Handler_initialize() \
73    do { } while ( 0 )
74#endif
75
76#if defined( RTEMS_SMP )
77
78/**
79 * @brief Performs high-level initialization of a secondary processor and runs
80 * the application threads.
81 *
82 * The low-level initialization code must call this function to hand over the
83 * control of this processor to RTEMS.  Interrupts must be disabled.  It must
84 * be possible to send inter-processor interrupts to this processor.  Since
85 * interrupts are disabled the inter-processor interrupt delivery is postponed
86 * until interrupts are enabled the first time.  Interrupts are enabled during
87 * the execution begin of threads in case they have interrupt level zero (this
88 * is the default).
89 *
90 * The pre-requisites for the call to this function are
91 * - disabled interrupts,
92 * - delivery of inter-processor interrupts is possible,
93 * - a valid stack pointer and enough stack space,
94 * - a valid code memory, and
95 * - a valid BSS section.
96 *
97 * This function must not be called by the main processor.  The main processor
98 * uses _Thread_Start_multitasking() instead.
99 *
100 * This function does not return to the caller.
101 */
102void _SMP_Start_multitasking_on_secondary_processor( void )
103  RTEMS_COMPILER_NO_RETURN_ATTRIBUTE;
104
105/**
106 * @brief Interrupt handler for inter-processor interrupts.
107 */
108static inline void _SMP_Inter_processor_interrupt_handler( void )
109{
110  Per_CPU_Control *cpu_self = _Per_CPU_Get();
111
112  if ( cpu_self->message != 0 ) {
113    uint32_t  message;
114    ISR_Level level;
115
116    _Per_CPU_ISR_disable_and_acquire( cpu_self, level );
117    message = cpu_self->message;
118    cpu_self->message = 0;
119    _Per_CPU_Release_and_ISR_enable( cpu_self, level );
120
121    if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) {
122      rtems_fatal( RTEMS_FATAL_SOURCE_SMP, SMP_FATAL_SHUTDOWN );
123      /* does not continue past here */
124    }
125  }
126}
127
128/**
129 *  @brief Sends a SMP message to a processor.
130 *
131 *  The target processor may be the sending processor.
132 *
133 *  @param[in] cpu_index The target processor of the message.
134 *  @param[in] message The message.
135 */
136void _SMP_Send_message( uint32_t cpu_index, uint32_t message );
137
138/**
139 *  @brief Request of others CPUs.
140 *
141 *  This method is invoked by RTEMS when it needs to make a request
142 *  of the other CPUs.  It should be implemented using some type of
143 *  interprocessor interrupt. CPUs not including the originating
144 *  CPU should receive the message.
145 *
146 *  @param [in] message is message to send
147 */
148void _SMP_Broadcast_message(
149  uint32_t  message
150);
151
152#endif /* defined( RTEMS_SMP ) */
153
154/**
155 * @brief Requests a multitasking start on all configured and available
156 * processors.
157 */
158#if defined( RTEMS_SMP )
159  void _SMP_Request_start_multitasking( void );
160#else
161  #define _SMP_Request_start_multitasking() \
162    do { } while ( 0 )
163#endif
164
165/**
166 * @brief Requests a shutdown of all processors.
167 *
168 * This function is a part of the system termination procedure.
169 *
170 * @see _Terminate().
171 */
172#if defined( RTEMS_SMP )
173  void _SMP_Request_shutdown( void );
174#else
175  #define _SMP_Request_shutdown() \
176    do { } while ( 0 )
177#endif
178
179/** @} */
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif
186/* end of include file */
Note: See TracBrowser for help on using the repository browser.