forked from Imagelibrary/rtems
bsps/stackalloc: Add initialization hook
This commit is contained in:
@@ -51,6 +51,12 @@ extern "C" {
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Task stack allocator initialization for
|
||||||
|
* @ref CONFIGURE_TASK_STACK_ALLOCATOR_INIT.
|
||||||
|
*/
|
||||||
|
void bsp_stack_allocate_init(size_t stack_space_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Task stack allocator for @ref CONFIGURE_TASK_STACK_ALLOCATOR.
|
* @brief Task stack allocator for @ref CONFIGURE_TASK_STACK_ALLOCATOR.
|
||||||
*
|
*
|
||||||
@@ -64,6 +70,11 @@ void *bsp_stack_allocate(size_t size);
|
|||||||
*/
|
*/
|
||||||
void bsp_stack_free(void *stack);
|
void bsp_stack_free(void *stack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Task stack allocator initialization configuration option.
|
||||||
|
*/
|
||||||
|
#define CONFIGURE_TASK_STACK_ALLOCATOR_INIT bsp_stack_allocate_init
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Task stack allocator configuration option.
|
* @brief Task stack allocator configuration option.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,30 +27,26 @@
|
|||||||
|
|
||||||
#include <bsp/linker-symbols.h>
|
#include <bsp/linker-symbols.h>
|
||||||
|
|
||||||
#define BSP_STACK_MAGIC 0xdeadbeef
|
static Heap_Control bsp_stack_heap;
|
||||||
|
|
||||||
static Heap_Control bsp_stack_heap = {
|
void bsp_stack_allocate_init(size_t stack_space_size)
|
||||||
.page_size = BSP_STACK_MAGIC
|
{
|
||||||
};
|
_Heap_Initialize(
|
||||||
|
&bsp_stack_heap,
|
||||||
|
bsp_section_stack_begin,
|
||||||
|
(uintptr_t) bsp_section_stack_size,
|
||||||
|
CPU_STACK_ALIGNMENT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void *bsp_stack_allocate(size_t size)
|
void *bsp_stack_allocate(size_t size)
|
||||||
{
|
{
|
||||||
void *stack = NULL;
|
void *stack = NULL;
|
||||||
|
|
||||||
if (bsp_stack_heap.page_size == BSP_STACK_MAGIC) {
|
if (bsp_stack_heap.area_begin != 0) {
|
||||||
uintptr_t rv = _Heap_Initialize(
|
stack = _Heap_Allocate(&bsp_stack_heap, size);
|
||||||
&bsp_stack_heap,
|
|
||||||
bsp_section_stack_begin,
|
|
||||||
(uintptr_t) bsp_section_stack_size,
|
|
||||||
CPU_STACK_ALIGNMENT
|
|
||||||
);
|
|
||||||
if (rv == 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stack = _Heap_Allocate(&bsp_stack_heap, size);
|
|
||||||
|
|
||||||
if (stack == NULL) {
|
if (stack == NULL) {
|
||||||
stack = _Workspace_Allocate(size);
|
stack = _Workspace_Allocate(size);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user