Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSImplApplConfig
0007  *
0008  * @brief This header file evaluates configuration options related to the
0009  *   per-CPU configuration.
0010  *
0011  * Since the idle thread stack size (CONFIGURE_IDLE_TASK_STACK_SIZE) depends on
0012  * CONFIGURE_MINIMUM_TASK_STACK_SIZE, the POSIX-specific
0013  * CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE configuration option is also evaluated
0014  * in this header file for simplicity.
0015  *
0016  * This header file defines _CONFIGURE_MAXIMUM_PROCESSORS for use by other
0017  * configuration header files.
0018  */
0019 
0020 /*
0021  * Copyright (C) 2018, 2020 embedded brains GmbH & Co. KG
0022  *
0023  * Redistribution and use in source and binary forms, with or without
0024  * modification, are permitted provided that the following conditions
0025  * are met:
0026  * 1. Redistributions of source code must retain the above copyright
0027  *    notice, this list of conditions and the following disclaimer.
0028  * 2. Redistributions in binary form must reproduce the above copyright
0029  *    notice, this list of conditions and the following disclaimer in the
0030  *    documentation and/or other materials provided with the distribution.
0031  *
0032  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0033  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0034  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0035  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0036  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0037  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0038  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0039  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0040  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0041  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0042  * POSSIBILITY OF SUCH DAMAGE.
0043  */
0044 
0045 #ifndef _RTEMS_CONFDEFS_PERCPU_H
0046 #define _RTEMS_CONFDEFS_PERCPU_H
0047 
0048 #ifndef __CONFIGURATION_TEMPLATE_h
0049 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
0050 #endif
0051 
0052 #ifdef CONFIGURE_INIT
0053 
0054 #include <rtems/confdefs/bsp.h>
0055 #include <rtems/score/context.h>
0056 #include <rtems/score/percpu.h>
0057 #include <rtems/score/smp.h>
0058 
0059 #ifdef __cplusplus
0060 extern "C" {
0061 #endif
0062 
0063 /* Ensure that _CONFIGURE_MAXIMUM_PROCESSORS > 1 only in SMP configurations */
0064 #if defined(CONFIGURE_MAXIMUM_PROCESSORS) && defined(RTEMS_SMP)
0065   #define _CONFIGURE_MAXIMUM_PROCESSORS CONFIGURE_MAXIMUM_PROCESSORS
0066 #else
0067   #define _CONFIGURE_MAXIMUM_PROCESSORS 1
0068 #endif
0069 
0070 #ifdef RTEMS_SMP
0071   const uint32_t _SMP_Processor_configured_maximum =
0072     _CONFIGURE_MAXIMUM_PROCESSORS;
0073 
0074   Per_CPU_Control_envelope
0075     _Per_CPU_Information[ _CONFIGURE_MAXIMUM_PROCESSORS ];
0076 #endif
0077 
0078 /* Interrupt stack configuration */
0079 
0080 #ifndef CONFIGURE_INTERRUPT_STACK_SIZE
0081   #if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \
0082     defined(BSP_INTERRUPT_STACK_SIZE)
0083     #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE
0084   #else
0085     #define CONFIGURE_INTERRUPT_STACK_SIZE CPU_STACK_MINIMUM_SIZE
0086   #endif
0087 #endif
0088 
0089 #if CONFIGURE_INTERRUPT_STACK_SIZE % CPU_INTERRUPT_STACK_ALIGNMENT != 0
0090   #error "CONFIGURE_INTERRUPT_STACK_SIZE fails to meet the CPU port interrupt stack alignment"
0091 #endif
0092 
0093 RTEMS_DEFINE_GLOBAL_SYMBOL(
0094   _ISR_Stack_size,
0095   CONFIGURE_INTERRUPT_STACK_SIZE
0096 );
0097 
0098 #define _CONFIGURE_INTERRUPT_STACK_AREA_SIZE \
0099   ( CONFIGURE_INTERRUPT_STACK_SIZE * _CONFIGURE_MAXIMUM_PROCESSORS )
0100 
0101 char _ISR_Stack_area_begin[ _CONFIGURE_INTERRUPT_STACK_AREA_SIZE ]
0102 RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
0103 RTEMS_SECTION( ".rtemsstack.interrupt" );
0104 
0105 RTEMS_DEFINE_GLOBAL_SYMBOL(
0106   _ISR_Stack_area_end,
0107   RTEMS_SYMBOL_NAME( _ISR_Stack_area_begin )
0108     + _CONFIGURE_INTERRUPT_STACK_AREA_SIZE
0109 );
0110 
0111 /* Thread stack size configuration */
0112 
0113 #ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE
0114   #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE
0115 #endif
0116 
0117 #ifndef CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE
0118   #define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \
0119     ( 2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE )
0120 #endif
0121 
0122 /* Idle thread configuration */
0123 
0124 #ifndef CONFIGURE_IDLE_TASK_STACK_SIZE
0125   #if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \
0126     defined(BSP_IDLE_TASK_STACK_SIZE)
0127     #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE
0128   #else
0129     #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
0130   #endif
0131 #endif
0132 
0133 #if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE
0134   #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE"
0135 #endif
0136 
0137 const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE;
0138 
0139 #if defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \
0140   !defined(CONFIGURE_IDLE_TASK_BODY)
0141   #error "If you define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, then you must define CONFIGURE_IDLE_TASK_BODY as well"
0142 #endif
0143 
0144 #if !defined(CONFIGURE_IDLE_TASK_BODY) && \
0145   !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && defined(BSP_IDLE_TASK_BODY)
0146   #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY
0147 #endif
0148 
0149 #ifdef CONFIGURE_IDLE_TASK_BODY
0150   const Thread_Idle_body _Thread_Idle_body = CONFIGURE_IDLE_TASK_BODY;
0151 #endif
0152 
0153 #ifdef __cplusplus
0154 }
0155 #endif
0156 
0157 #endif /* CONFIGURE_INIT */
0158 
0159 #endif /* _RTEMS_CONFDEFS_PERCPU_H */