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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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