![]() |
|
|||
File indexing completed on 2025-05-11 08:24:13
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreStack 0007 * 0008 * @brief This header file provides interfaces of the 0009 * @ref RTEMSScoreStack which are used by the implementation and the 0010 * @ref RTEMSImplApplConfig. 0011 */ 0012 0013 /* 0014 * Copyright (C) 2022 embedded brains GmbH & Co. KG 0015 * Copyright (C) 1989, 2021 On-Line Applications Research Corporation (OAR) 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _RTEMS_SCORE_STACK_H 0040 #define _RTEMS_SCORE_STACK_H 0041 0042 #include <rtems/score/basedefs.h> 0043 0044 #ifdef __cplusplus 0045 extern "C" { 0046 #endif 0047 0048 /** 0049 * @defgroup RTEMSScoreStack Stack Handler 0050 * 0051 * @ingroup RTEMSScore 0052 * 0053 * @brief This group contains the Stack Handler implementation. 0054 * 0055 * This handler encapsulates functionality which is used in the management 0056 * of thread stacks. It provides mechanisms which can be used to initialize 0057 * and utilize stacks. 0058 * 0059 * @{ 0060 */ 0061 0062 /** 0063 * The following constant defines the minimum stack size which every 0064 * thread must exceed. 0065 */ 0066 #define STACK_MINIMUM_SIZE CPU_STACK_MINIMUM_SIZE 0067 0068 /** 0069 * The following defines the control block used to manage each stack. 0070 */ 0071 typedef struct { 0072 /** This is the stack size. */ 0073 size_t size; 0074 /** This is the low memory address of stack. */ 0075 void *area; 0076 } Stack_Control; 0077 0078 /** 0079 * @brief The stack allocator initialization handler. 0080 * 0081 * @param stack_space_size The size of the stack space in bytes. 0082 */ 0083 typedef void ( *Stack_Allocator_initialize )( size_t stack_space_size ); 0084 0085 /** 0086 * @brief Stack allocator allocate handler. 0087 * 0088 * @param stack_size The size of the stack area to allocate in bytes. 0089 * 0090 * @retval NULL Not enough memory. 0091 * @retval other Pointer to begin of stack area. 0092 */ 0093 typedef void *( *Stack_Allocator_allocate )( size_t stack_size ); 0094 0095 /** 0096 * @brief Stack allocator free handler. 0097 * 0098 * @param] addr A pointer to previously allocated stack area or NULL. 0099 */ 0100 typedef void ( *Stack_Allocator_free )( void *addr ); 0101 0102 /** 0103 * @brief Stack allocator allocate for idle handler. 0104 * 0105 * The allocate for idle handler is optional even when the user thread stack 0106 * allocator and deallocator are configured. 0107 * 0108 * @param cpu is the index of the CPU for the IDLE thread using this stack. 0109 * 0110 * @param stack_size[in, out] is pointer to a size_t object. On function 0111 * entry, the object contains the proposed size of the stack area to allocate 0112 * in bytes. The proposed size does not take the actual thread-local storage 0113 * size of the application into account. The stack allocator can modify the 0114 * size to ensure that there is enough space available in the stack area for 0115 * the thread-local storage. 0116 * 0117 * @retval NULL There was not enough memory available to allocate a stack area. 0118 * 0119 * @return Returns the pointer to begin of the allocated stack area. 0120 */ 0121 typedef void *( *Stack_Allocator_allocate_for_idle )( 0122 uint32_t cpu, 0123 size_t *stack_size 0124 ); 0125 0126 /** 0127 * @brief The minimum stack size. 0128 * 0129 * Application provided via <rtems/confdefs.h>. 0130 */ 0131 extern uint32_t rtems_minimum_stack_size; 0132 0133 /** 0134 * @brief The configured stack space size. 0135 * 0136 * Application provided via <rtems/confdefs.h>. 0137 */ 0138 extern const uintptr_t _Stack_Space_size; 0139 0140 /** 0141 * @brief Indicates if the stack allocator avoids the workspace. 0142 * 0143 * Application provided via <rtems/confdefs.h>. 0144 */ 0145 extern const bool _Stack_Allocator_avoids_workspace; 0146 0147 /** 0148 * @brief The stack allocator initialization handler. 0149 * 0150 * Application provided via <rtems/confdefs.h>. 0151 */ 0152 extern const Stack_Allocator_initialize _Stack_Allocator_initialize; 0153 0154 /** 0155 * @brief The stack allocator allocate handler. 0156 * 0157 * Application provided via <rtems/confdefs.h>. 0158 */ 0159 extern const Stack_Allocator_allocate _Stack_Allocator_allocate; 0160 0161 /** 0162 * @brief The stack allocator free handler. 0163 * 0164 * Application provided via <rtems/confdefs.h>. 0165 */ 0166 extern const Stack_Allocator_free _Stack_Allocator_free; 0167 0168 /** 0169 * @brief Do the stack allocator initialization during system initialize. 0170 * 0171 * This function is used to initialize application provided stack allocators. 0172 */ 0173 void _Stack_Allocator_do_initialize( void ); 0174 0175 /** 0176 * @brief Allocates the IDLE thread storage area from the workspace. 0177 * 0178 * If the thread storage area cannot be allocated, then the 0179 * ::INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STACK fatal error will occur. 0180 * 0181 * @param unused is an unused parameter. 0182 * 0183 * @param stack_size[in] is pointer to a size_t object. On function entry, the 0184 * object contains the size of the task storage area to allocate in bytes. 0185 * 0186 * @return Returns a pointer to the begin of the allocated task storage area. 0187 */ 0188 void *_Stack_Allocator_allocate_for_idle_workspace( 0189 uint32_t unused, 0190 size_t *storage_size 0191 ); 0192 0193 /** 0194 * @brief The size in bytes of the idle thread storage area used by 0195 * _Stack_Allocator_allocate_for_idle_static(). 0196 * 0197 * Application provided via <rtems/confdefs.h>. 0198 */ 0199 extern const size_t _Stack_Allocator_allocate_for_idle_storage_size; 0200 0201 /** 0202 * @brief The thread storage areas used by 0203 * _Stack_Allocator_allocate_for_idle_static(). 0204 * 0205 * Application provided via <rtems/confdefs.h>. 0206 */ 0207 extern char _Stack_Allocator_allocate_for_idle_storage_areas[]; 0208 0209 /** 0210 * @brief Allocates the IDLE thread storage from the memory statically 0211 * allocated by <rtems/confdefs.h>. 0212 * 0213 * @param cpu_index is the index of the CPU for the IDLE thread using this stack. 0214 * 0215 * @param stack_size[out] is pointer to a size_t object. On function return, the 0216 * object value is set to the value of 0217 * ::_Stack_Allocator_allocate_for_idle_storage_size. 0218 * 0219 * @return Returns a pointer to the begin of the allocated task storage area. 0220 */ 0221 void *_Stack_Allocator_allocate_for_idle_static( 0222 uint32_t cpu_index, 0223 size_t *storage_size 0224 ); 0225 0226 /** 0227 * @brief The stack allocator allocate stack for idle thread handler. 0228 * 0229 * Application provided via <rtems/confdefs.h>. 0230 */ 0231 extern const Stack_Allocator_allocate_for_idle 0232 _Stack_Allocator_allocate_for_idle; 0233 0234 /** @} */ 0235 0236 #ifdef __cplusplus 0237 } 0238 #endif 0239 0240 #endif 0241 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |