RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
wkspace.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef _RTEMS_CONFDEFS_WKSPACE_H
37#define _RTEMS_CONFDEFS_WKSPACE_H
38
39#ifndef __CONFIGURATION_TEMPLATE_h
40#error "Do not include this file directly, use <rtems/confdefs.h> instead"
41#endif
42
43#ifdef CONFIGURE_INIT
44
51#include <rtems/score/coremsg.h>
52#include <rtems/score/context.h>
53#include <rtems/score/memory.h>
54#include <rtems/score/stack.h>
55#include <rtems/sysinit.h>
56
57#ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR
58 #define _Configure_From_stackspace( _stack_size ) \
59 CONFIGURE_TASK_STACK_FROM_ALLOCATOR( _stack_size + CONTEXT_FP_SIZE )
60#else
61 #define _Configure_From_stackspace( _stack_size ) \
62 _Configure_From_workspace( _stack_size + CONTEXT_FP_SIZE )
63#endif
64
65#ifndef CONFIGURE_EXTRA_TASK_STACKS
66 #define CONFIGURE_EXTRA_TASK_STACKS 0
67#endif
68
69#ifndef CONFIGURE_EXECUTIVE_RAM_SIZE
70
71#define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( _messages, _size ) \
72 _Configure_From_workspace( \
73 ( _messages ) * ( _Configure_Align_up( _size, sizeof( uintptr_t ) ) \
74 + sizeof( CORE_message_queue_Buffer_control ) ) )
75
76#ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY
77 #define CONFIGURE_MESSAGE_BUFFER_MEMORY 0
78#endif
79
80#ifndef CONFIGURE_MEMORY_OVERHEAD
81 #define CONFIGURE_MEMORY_OVERHEAD 0
82#endif
83
84/*
85 * We must be able to split the free block used for the second last allocation
86 * into two parts so that we have a free block for the last allocation. See
87 * _Heap_Block_split().
88 */
89#define _CONFIGURE_HEAP_HANDLER_OVERHEAD \
90 _Configure_Align_up( HEAP_BLOCK_HEADER_SIZE, CPU_HEAP_ALIGNMENT )
91
92#define CONFIGURE_EXECUTIVE_RAM_SIZE \
93 ( _CONFIGURE_MEMORY_FOR_POSIX_OBJECTS \
94 + CONFIGURE_MESSAGE_BUFFER_MEMORY \
95 + 1024 * CONFIGURE_MEMORY_OVERHEAD \
96 + _CONFIGURE_HEAP_HANDLER_OVERHEAD )
97
98#define _CONFIGURE_STACK_SPACE_SIZE \
99 ( _CONFIGURE_INIT_TASK_STACK_EXTRA \
100 + _CONFIGURE_POSIX_INIT_THREAD_STACK_EXTRA \
101 + _CONFIGURE_LIBBLOCK_TASKS_STACK_EXTRA \
102 + CONFIGURE_EXTRA_TASK_STACKS \
103 + rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) \
104 * _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) \
105 + rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS ) \
106 * _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) \
107 + _CONFIGURE_HEAP_HANDLER_OVERHEAD )
108
109#else /* CONFIGURE_EXECUTIVE_RAM_SIZE */
110
111#if CONFIGURE_EXTRA_TASK_STACKS != 0
112 #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_TASK_STACKS"
113#endif
114
115#define _CONFIGURE_STACK_SPACE_SIZE 0
116
117#endif /* CONFIGURE_EXECUTIVE_RAM_SIZE */
118
119#ifdef __cplusplus
120extern "C" {
121#endif
122
123const uintptr_t _Workspace_Size = CONFIGURE_EXECUTIVE_RAM_SIZE;
124
125#ifdef CONFIGURE_UNIFIED_WORK_AREAS
126 const bool _Workspace_Is_unified = true;
127#endif
128
129uint32_t rtems_minimum_stack_size = CONFIGURE_MINIMUM_TASK_STACK_SIZE;
130
131const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
132
133#if defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
134 && defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
135 /* Custom allocator may or may not use the work space. */
136 #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
137 const bool _Stack_Allocator_avoids_workspace = true;
138 #else
139 const bool _Stack_Allocator_avoids_workspace = false;
140 #endif
141
142 /* Custom allocator may or may not need initialization. */
143 #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
146 #else
148 #endif
149
150 /* Custom allocator must include allocate and free */
153
156
157/*
158 * Must provide both a custom stack allocator and deallocator
159 */
160#elif defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
161 || defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
162 #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
163#endif
164
165/*
166 * Custom IDLE thread stacks allocator. If this is provided, it is assumed
167 * that the allocator is providing its own memory for these stacks.
168 */
169#ifdef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE
171 CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE;
172#endif
173
174#ifdef CONFIGURE_DIRTY_MEMORY
175 RTEMS_SYSINIT_ITEM(
177 RTEMS_SYSINIT_DIRTY_MEMORY,
178 RTEMS_SYSINIT_ORDER_MIDDLE
179 );
180#endif
181
182#ifdef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY
183 const bool _Memory_Zero_before_use = true;
184
185 RTEMS_SYSINIT_ITEM(
187 RTEMS_SYSINIT_ZERO_MEMORY,
188 RTEMS_SYSINIT_ORDER_MIDDLE
189 );
190#endif
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif /* CONFIGURE_INIT */
197
198#endif /* _RTEMS_CONFDEFS_WKSPACE_H */
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Evaluate Block Device Cache Configuration Options.
Information About Each Thread's Context.
Constants and Structures Associated with the Message Queue Handler.
Information About the Thread Stack Handler.
const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle
The stack allocator allocate stack for idle thread handler.
Definition: stackallocatorforidle.c:58
const bool _Memory_Zero_before_use
Indicates if the memory is zeroed during system initialization.
Definition: memoryzerobeforeuse.c:34
void _Memory_Dirty_free_areas(void)
Dirty all free memory areas of the system.
Definition: memorydirtyfreeareas.c:34
void _Memory_Zero_free_areas(void)
Zeros all free memory areas of the system.
Definition: memoryzerofreeareas.c:34
void(* Stack_Allocator_initialize)(size_t stack_space_size)
The stack allocator initialization handler.
Definition: stack.h:65
const bool _Stack_Allocator_avoids_workspace
Indicates if the stack allocator avoids the workspace.
Definition: stackallocator.c:35
void *(* Stack_Allocator_allocate)(size_t stack_size)
Stack allocator allocate handler.
Definition: stack.h:75
const uintptr_t _Stack_Space_size
The configured stack space size.
const Stack_Allocator_allocate _Stack_Allocator_allocate
The stack allocator allocate handler.
Definition: stackallocator.c:39
const Stack_Allocator_free _Stack_Allocator_free
The stack allocator free handler.
Definition: stackallocator.c:41
const Stack_Allocator_initialize _Stack_Allocator_initialize
The stack allocator initialization handler.
Definition: stackallocator.c:37
void(* Stack_Allocator_free)(void *addr)
Stack allocator free handler.
Definition: stack.h:82
uint32_t rtems_minimum_stack_size
The minimum stack size.
void *(* Stack_Allocator_allocate_for_idle)(uint32_t cpu, size_t stack_size)
Stack allocator allocate for idle handler.
Definition: stack.h:96
const bool _Workspace_Is_unified
Indicates if the workspace and C program heap are unified.
Definition: wkspaceisunifieddefault.c:34
const uintptr_t _Workspace_Size
The workspace size in bytes.
#define CONFIGURE_TASK_STACK_ALLOCATOR_INIT
Task stack allocator initialization configuration option.
Definition: stackalloc.h:76
#define CONFIGURE_TASK_STACK_ALLOCATOR
Task stack allocator configuration option.
Definition: stackalloc.h:81
#define CONFIGURE_TASK_STACK_DEALLOCATOR
Task stack deallocator configuration option.
Definition: stackalloc.h:86
Evaluate User Initialization Task Configuration Options.
Evaluate POSIX Initialization Thread Configuration Options.
Evaluate POSIX API Objects Configuration Options.
Memory Handler API.
Evaluate Thread Configuration Options.
Configuration Options Workspace Support Macros.