source: rtems/cpukit/score/include/rtems/score/smpimpl.h @ 79e2d9b

4.115
Last change on this file since 79e2d9b was 79e2d9b, checked in by Sebastian Huber <sebastian.huber@…>, on 03/06/14 at 10:11:59

score: Add per-CPU state function

Add _Per_CPU_State_wait_for_ready_to_start_multitasking(). Add new
fatal SMP error SMP_FATAL_SHUTDOWN_EARLY.

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