1 | /** |
---|
2 | * @file rtems/bspsmp.h |
---|
3 | * |
---|
4 | * @brief Interface Between RTEMS and an SMP Aware BSP |
---|
5 | * |
---|
6 | * This include file defines the interface between RTEMS and an |
---|
7 | * SMP aware BSP. These methods will only be used when RTEMS |
---|
8 | * is configured with SMP support enabled. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * COPYRIGHT (c) 1989-2011. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.com/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef _RTEMS_BSPSMP_H |
---|
21 | #define _RTEMS_BSPSMP_H |
---|
22 | |
---|
23 | #include <rtems/score/cpuopts.h> |
---|
24 | |
---|
25 | #if defined (RTEMS_SMP) |
---|
26 | #include <rtems/score/percpu.h> |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup RTEMS BSP SMP Interface |
---|
30 | * |
---|
31 | * @ingroup Score |
---|
32 | * |
---|
33 | * This defines the interface between RTEMS and the BSP for |
---|
34 | * SMP support. The interface uses the term primary |
---|
35 | * to refer to the "boot" processor and secondary to refer |
---|
36 | * to the "application" processors. Different architectures |
---|
37 | * use different terminology. |
---|
38 | * |
---|
39 | * It is assumed that when the processor is reset and thus |
---|
40 | * when RTEMS is initialized, that the primary processor is |
---|
41 | * the only one executing. The others are assumed to be in |
---|
42 | * a quiescent or reset state awaiting a command to come online. |
---|
43 | */ |
---|
44 | |
---|
45 | /**@{*/ |
---|
46 | |
---|
47 | #ifdef __cplusplus |
---|
48 | extern "C" { |
---|
49 | #endif |
---|
50 | |
---|
51 | |
---|
52 | #ifndef ASM |
---|
53 | |
---|
54 | /** |
---|
55 | * @brief Performs BSP specific SMP initialization in the context of the main |
---|
56 | * processor. |
---|
57 | * |
---|
58 | * This function is invoked on the main processor by RTEMS during |
---|
59 | * initialization. All interrupt stacks are allocated at this point in case |
---|
60 | * the CPU port allocates the interrupt stacks. |
---|
61 | * |
---|
62 | * The BSP may start secondary processors now. |
---|
63 | * |
---|
64 | * @param[in] configured_cpu_count The count of processors requested by the |
---|
65 | * application configuration. |
---|
66 | * |
---|
67 | * @return The count of processors available for the application in the system. |
---|
68 | * This value is less than or equal to the configured count of processors. |
---|
69 | */ |
---|
70 | uint32_t bsp_smp_initialize( uint32_t configured_cpu_count ); |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief Obtain current CPU index. |
---|
74 | * |
---|
75 | * This method is invoked by RTEMS when it needs to know the index |
---|
76 | * of the CPU it is executing on. |
---|
77 | * |
---|
78 | * @retval This method returns the current CPU index. |
---|
79 | */ |
---|
80 | int bsp_smp_processor_id(void) RTEMS_COMPILER_PURE_ATTRIBUTE; |
---|
81 | |
---|
82 | /** |
---|
83 | * @brief Generate an interprocessor broadcast interrupt. |
---|
84 | * |
---|
85 | * This method is invoked when RTEMS wants to let all of the other |
---|
86 | * CPUs know that it has sent them message. CPUs not including |
---|
87 | * the originating CPU should receive the interrupt. |
---|
88 | |
---|
89 | * |
---|
90 | * @note On CPUs without the capability to generate a broadcast |
---|
91 | * to all other CPUs interrupt, this can be implemented by |
---|
92 | * a loop of sending interrupts to specific CPUs. |
---|
93 | */ |
---|
94 | void bsp_smp_broadcast_interrupt(void); |
---|
95 | |
---|
96 | /** |
---|
97 | * @brief Generate a interprocessor interrupt. |
---|
98 | * |
---|
99 | * This method is invoked by RTEMS to let @a cpu know that it |
---|
100 | * has sent it a message. |
---|
101 | * |
---|
102 | * @param [in] cpu is the recipient CPU |
---|
103 | */ |
---|
104 | void bsp_smp_interrupt_cpu( |
---|
105 | int cpu |
---|
106 | ); |
---|
107 | |
---|
108 | /** |
---|
109 | * @brief Obtain CPU core number. |
---|
110 | * |
---|
111 | * This method is invoked by RTEMS when it needs to know which core |
---|
112 | * number it is executing on. This is used when it needs to perform |
---|
113 | * some action or bookkeeping and needs to distinguish itself from |
---|
114 | * the other cores. For example, it may need to realize it needs to |
---|
115 | * preempt a thread on another node. |
---|
116 | * |
---|
117 | * @retval This method returns the Id of the current CPU core. |
---|
118 | */ |
---|
119 | int bsp_smp_processor_id( void ); |
---|
120 | |
---|
121 | /** |
---|
122 | * @brief Performs high-level initialization of a secondary CPU and runs the |
---|
123 | * application threads. |
---|
124 | * |
---|
125 | * The low-level initialization code must call this function to hand over the |
---|
126 | * control of this processor to RTEMS. Interrupts must be disabled. It must |
---|
127 | * be possible to send inter-processor interrupts to this processor. Since |
---|
128 | * interrupts are disabled the inter-processor interrupt delivery is postponed |
---|
129 | * until interrupts are enabled the first time. This is usually a side-effect |
---|
130 | * of the context switch to the first thread. |
---|
131 | * |
---|
132 | * The pre-requisites for the call to this function are |
---|
133 | * - disabled interrupts, |
---|
134 | * - reception of inter-processor interrupts is possible, |
---|
135 | * - a valid stack pointer and enough stack space, |
---|
136 | * - a valid code memory, and |
---|
137 | * - a valid BSS section. |
---|
138 | * |
---|
139 | * This function must not be called by the main processor. |
---|
140 | */ |
---|
141 | void rtems_smp_secondary_cpu_initialize( void ); |
---|
142 | |
---|
143 | /** |
---|
144 | * @brief Process the incoming interprocessor request. |
---|
145 | * |
---|
146 | * This is the method called by the BSP's interrupt handler |
---|
147 | * to process the incoming interprocessor request. |
---|
148 | */ |
---|
149 | void rtems_smp_process_interrupt(void); |
---|
150 | |
---|
151 | #endif |
---|
152 | |
---|
153 | #ifdef __cplusplus |
---|
154 | } |
---|
155 | #endif |
---|
156 | |
---|
157 | #else |
---|
158 | #define bsp_smp_processor_id() 0 |
---|
159 | #endif |
---|
160 | |
---|
161 | /**@}*/ |
---|
162 | #endif |
---|
163 | |
---|
164 | /* end of include file */ |
---|