1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSApplicationConfiguration |
---|
7 | * |
---|
8 | * @brief Evaluate Per-CPU Configuration Options |
---|
9 | * |
---|
10 | * Since the idle thread stack size (CONFIGURE_IDLE_TASK_STACK_SIZE) depends on |
---|
11 | * CONFIGURE_MINIMUM_TASK_STACK_SIZE, the POSIX-specific |
---|
12 | * CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE configuration option is also evaluated |
---|
13 | * in this header file for simplicity. |
---|
14 | * |
---|
15 | * This header file defines _CONFIGURE_MAXIMUM_PROCESSORS for use by other |
---|
16 | * configuration header files. |
---|
17 | */ |
---|
18 | |
---|
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 | |
---|
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 | char _ISR_Stack_area_begin[ |
---|
97 | _CONFIGURE_MAXIMUM_PROCESSORS * CONFIGURE_INTERRUPT_STACK_SIZE |
---|
98 | ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT ) |
---|
99 | RTEMS_SECTION( ".rtemsstack.interrupt.begin" ); |
---|
100 | |
---|
101 | /* Thread stack size configuration */ |
---|
102 | |
---|
103 | #ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE |
---|
104 | #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE |
---|
105 | #endif |
---|
106 | |
---|
107 | #ifndef CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE |
---|
108 | #define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \ |
---|
109 | ( 2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE ) |
---|
110 | #endif |
---|
111 | |
---|
112 | /* Idle thread configuration */ |
---|
113 | |
---|
114 | #ifndef CONFIGURE_IDLE_TASK_STACK_SIZE |
---|
115 | #ifdef BSP_IDLE_TASK_STACK_SIZE |
---|
116 | #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE |
---|
117 | #else |
---|
118 | #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE |
---|
119 | #endif |
---|
120 | #endif |
---|
121 | |
---|
122 | #if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE |
---|
123 | #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE" |
---|
124 | #endif |
---|
125 | |
---|
126 | const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE; |
---|
127 | |
---|
128 | char _Thread_Idle_stacks[ |
---|
129 | _CONFIGURE_MAXIMUM_PROCESSORS |
---|
130 | * ( CONFIGURE_IDLE_TASK_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE ) |
---|
131 | ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT ) |
---|
132 | RTEMS_SECTION( ".rtemsstack.idle" ); |
---|
133 | |
---|
134 | #if defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \ |
---|
135 | !defined(CONFIGURE_IDLE_TASK_BODY) |
---|
136 | #error "If you define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, then you must define CONFIGURE_IDLE_TASK_BODY as well" |
---|
137 | #endif |
---|
138 | |
---|
139 | #if !defined(CONFIGURE_IDLE_TASK_BODY) && defined(BSP_IDLE_TASK_BODY) |
---|
140 | #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY |
---|
141 | #endif |
---|
142 | |
---|
143 | #ifdef CONFIGURE_IDLE_TASK_BODY |
---|
144 | const Thread_Idle_body _Thread_Idle_body = CONFIGURE_IDLE_TASK_BODY; |
---|
145 | #endif |
---|
146 | |
---|
147 | #ifdef __cplusplus |
---|
148 | } |
---|
149 | #endif |
---|
150 | |
---|
151 | #endif /* CONFIGURE_INIT */ |
---|
152 | |
---|
153 | #endif /* _RTEMS_CONFDEFS_PERCPU_H */ |
---|