RTEMS  5.1
percpu.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
19 /*
20  * Copyright (C) 2018, 2020 embedded brains GmbH (http://www.embedded-brains.de)
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions
24  * are met:
25  * 1. Redistributions of source code must retain the above copyright
26  * notice, this list of conditions and the following disclaimer.
27  * 2. Redistributions in binary form must reproduce the above copyright
28  * notice, this list of conditions and the following disclaimer in the
29  * documentation and/or other materials provided with the distribution.
30  *
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
35  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGE.
42  */
43 
44 #ifndef _RTEMS_CONFDEFS_PERCPU_H
45 #define _RTEMS_CONFDEFS_PERCPU_H
46 
47 #ifndef __CONFIGURATION_TEMPLATE_h
48 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
49 #endif
50 
51 #ifdef CONFIGURE_INIT
52 
53 #include <rtems/confdefs/bsp.h>
54 #include <rtems/score/context.h>
55 #include <rtems/score/percpu.h>
56 #include <rtems/score/smp.h>
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /* Ensure that _CONFIGURE_MAXIMUM_PROCESSORS > 1 only in SMP configurations */
63 #if defined(CONFIGURE_MAXIMUM_PROCESSORS) && defined(RTEMS_SMP)
64  #define _CONFIGURE_MAXIMUM_PROCESSORS CONFIGURE_MAXIMUM_PROCESSORS
65 #else
66  #define _CONFIGURE_MAXIMUM_PROCESSORS 1
67 #endif
68 
69 #ifdef RTEMS_SMP
70  const uint32_t _SMP_Processor_configured_maximum =
71  _CONFIGURE_MAXIMUM_PROCESSORS;
72 
74  _Per_CPU_Information[ _CONFIGURE_MAXIMUM_PROCESSORS ];
75 #endif
76 
77 /* Interrupt stack configuration */
78 
79 #ifndef CONFIGURE_INTERRUPT_STACK_SIZE
80  #ifdef BSP_INTERRUPT_STACK_SIZE
81  #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE
82  #else
83  #define CONFIGURE_INTERRUPT_STACK_SIZE CPU_STACK_MINIMUM_SIZE
84  #endif
85 #endif
86 
87 #if CONFIGURE_INTERRUPT_STACK_SIZE % CPU_INTERRUPT_STACK_ALIGNMENT != 0
88  #error "CONFIGURE_INTERRUPT_STACK_SIZE fails to meet the CPU port interrupt stack alignment"
89 #endif
90 
92  _ISR_Stack_size,
93  CONFIGURE_INTERRUPT_STACK_SIZE
94 );
95 
96 #define _CONFIGURE_INTERRUPT_STACK_AREA_SIZE \
97  ( CONFIGURE_INTERRUPT_STACK_SIZE * _CONFIGURE_MAXIMUM_PROCESSORS )
98 
99 char _ISR_Stack_area_begin[ _CONFIGURE_INTERRUPT_STACK_AREA_SIZE ]
101 RTEMS_SECTION( ".rtemsstack.interrupt" );
102 
105  RTEMS_SYMBOL_NAME( _ISR_Stack_area_begin )
106  + _CONFIGURE_INTERRUPT_STACK_AREA_SIZE
107 );
108 
109 /* Thread stack size configuration */
110 
111 #ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE
112  #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE
113 #endif
114 
115 #ifndef CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE
116  #define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \
117  ( 2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE )
118 #endif
119 
120 /* Idle thread configuration */
121 
122 #ifndef CONFIGURE_IDLE_TASK_STACK_SIZE
123  #ifdef BSP_IDLE_TASK_STACK_SIZE
124  #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE
125  #else
126  #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
127  #endif
128 #endif
129 
130 #if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE
131  #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE"
132 #endif
133 
134 const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE;
135 
137  _CONFIGURE_MAXIMUM_PROCESSORS
138  * ( CONFIGURE_IDLE_TASK_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE )
140 RTEMS_SECTION( ".rtemsstack.idle" );
141 
142 #if defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \
143  !defined(CONFIGURE_IDLE_TASK_BODY)
144  #error "If you define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, then you must define CONFIGURE_IDLE_TASK_BODY as well"
145 #endif
146 
147 #if !defined(CONFIGURE_IDLE_TASK_BODY) && defined(BSP_IDLE_TASK_BODY)
148  #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY
149 #endif
150 
151 #ifdef CONFIGURE_IDLE_TASK_BODY
152  const Thread_Idle_body _Thread_Idle_body = CONFIGURE_IDLE_TASK_BODY;
153 #endif
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* CONFIGURE_INIT */
160 
161 #endif /* _RTEMS_CONFDEFS_PERCPU_H */
char _ISR_Stack_area_begin[]
The interrupt stack area begin.
const Thread_Idle_body _Thread_Idle_body
The idle thread body.
Definition: threadidledefault.c:35
Information About Each Thread's Context.
#define CONTEXT_FP_SIZE
Size of floating point context area.
Definition: context.h:52
void *(* Thread_Idle_body)(uintptr_t)
The idle thread body type.
Definition: threadidledata.h:62
#define _SMP_Processor_configured_maximum
The configured processor maximum.
Definition: smp.h:49
#define RTEMS_ALIGNED(_alignment)
Instructs the compiler to enforce the specified alignment.
Definition: basedefs.h:216
#define CPU_INTERRUPT_STACK_ALIGNMENT
Definition: cpu.h:605
SuperCore SMP Support API.
const size_t _Thread_Idle_stack_size
The idle thread stack size in bytes.
Definition: percpu.h:610
const char _ISR_Stack_area_end[]
The interrupt stack area end.
Evaluate BSP Related Configuration Options.
#define RTEMS_SECTION(_section)
Instructs the compiler to place a specific variable or function in the specified section.
Definition: basedefs.h:154
#define RTEMS_DEFINE_GLOBAL_SYMBOL(_name, _value)
Defines a global symbol with the specified name and value.
Definition: basedefs.h:360
char _Thread_Idle_stacks[]
The idle thread stacks.