RTEMS: cpukit/include/rtems/confdefs/percpu.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
59extern "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
73 Per_CPU_Control_envelope
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
91 RTEMS_DEFINE_GLOBAL_SYMBOL(
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
99char _ISR_Stack_area_begin[ _CONFIGURE_INTERRUPT_STACK_AREA_SIZE ]
100 RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
101 RTEMS_SECTION( ".rtemsstack.interrupt" );
102
103 RTEMS_DEFINE_GLOBAL_SYMBOL(
104 _ISR_Stack_area_end,
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
134const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE;
135
136/*
137 * If the user provides a custom idle stack allocator, then we do not need
138 * memory reserved for the stacks but the symbol is still referenced in
139 * threadcreateidle.c. The code path just never uses it. Make it minimal
140 * size to proceed.
141 */
142#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE
143 char _Thread_Idle_stacks[
144 _CONFIGURE_MAXIMUM_PROCESSORS
145 * ( CONFIGURE_IDLE_TASK_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE )
146 ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
147 RTEMS_SECTION( ".rtemsstack.idle" );
148#endif
149
150#if defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \
151 !defined(CONFIGURE_IDLE_TASK_BODY)
152 #error "If you define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, then you must define CONFIGURE_IDLE_TASK_BODY as well"
153#endif
154
155#if !defined(CONFIGURE_IDLE_TASK_BODY) && defined(BSP_IDLE_TASK_BODY)
156 #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY
157#endif
158
159#ifdef CONFIGURE_IDLE_TASK_BODY
160 const Thread_Idle_body _Thread_Idle_body = CONFIGURE_IDLE_TASK_BODY;
161#endif
162
163#ifdef __cplusplus
164}
165#endif
166
167#endif /* CONFIGURE_INIT */
168
169#endif /* _RTEMS_CONFDEFS_PERCPU_H */
context.h
Information About Each Thread's Context.
bsp.h
Evaluate BSP Related Configuration Options.
RTEMS_SECTION
#define RTEMS_SECTION(_section)
Instructs the compiler to place a specific variable or function in the specified section.
Definition: basedefs.h:154
RTEMS_ALIGNED
#define RTEMS_ALIGNED(_alignment)
Instructs the compiler to enforce the specified alignment.
Definition: basedefs.h:216
RTEMS_DEFINE_GLOBAL_SYMBOL
#define RTEMS_DEFINE_GLOBAL_SYMBOL(_name, _value)
Defines a global symbol with the specified name and value.
Definition: basedefs.h:360
CONTEXT_FP_SIZE
#define CONTEXT_FP_SIZE
Size of floating point context area.
Definition: context.h:52
_ISR_Stack_area_end
const char _ISR_Stack_area_end[]
The interrupt stack area end.
_ISR_Stack_area_begin
char _ISR_Stack_area_begin[]
The interrupt stack area begin.
_SMP_Processor_configured_maximum
#define _SMP_Processor_configured_maximum
The configured processor maximum.
Definition: smp.h:49
Thread_Idle_body
void *(* Thread_Idle_body)(uintptr_t)
The idle thread body type.
Definition: threadidledata.h:62
_Thread_Idle_body
const Thread_Idle_body _Thread_Idle_body
The idle thread body.
Definition: threadidledefault.c:35
_Thread_Idle_stacks
char _Thread_Idle_stacks[]
The idle thread stacks.
_Thread_Idle_stack_size
const size_t _Thread_Idle_stack_size
The idle thread stack size in bytes.
percpu.h
smp.h
SuperCore SMP Support API.
Per_CPU_Control_envelope
Definition: percpu.h:610