Changeset ed67d93 in rtems


Ignore:
Timestamp:
Apr 26, 2012, 8:03:38 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
0b61e27
Parents:
c36ebbd
git-author:
Sebastian Huber <sebastian.huber@…> (04/26/12 08:03:38)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/26/12 08:05:42)
Message:

bsps/stackalloc: Add initialization hook

Location:
c/src/lib/libbsp/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/include/stackalloc.h

    rc36ebbd red67d93  
    5353
    5454/**
     55 * @brief Task stack allocator initialization for
     56 * @ref CONFIGURE_TASK_STACK_ALLOCATOR_INIT.
     57 */
     58void bsp_stack_allocate_init(size_t stack_space_size);
     59
     60/**
    5561 * @brief Task stack allocator for @ref CONFIGURE_TASK_STACK_ALLOCATOR.
    5662 *
     
    6470 */
    6571void bsp_stack_free(void *stack);
     72
     73/**
     74 * @brief Task stack allocator initialization configuration option.
     75 */
     76#define CONFIGURE_TASK_STACK_ALLOCATOR_INIT bsp_stack_allocate_init
    6677
    6778/**
  • c/src/lib/libbsp/shared/src/stackalloc.c

    rc36ebbd red67d93  
    2828#include <bsp/linker-symbols.h>
    2929
    30 #define BSP_STACK_MAGIC 0xdeadbeef
     30static Heap_Control bsp_stack_heap;
    3131
    32 static Heap_Control bsp_stack_heap = {
    33   .page_size = BSP_STACK_MAGIC
    34 };
     32void bsp_stack_allocate_init(size_t stack_space_size)
     33{
     34  _Heap_Initialize(
     35    &bsp_stack_heap,
     36    bsp_section_stack_begin,
     37    (uintptr_t) bsp_section_stack_size,
     38    CPU_STACK_ALIGNMENT
     39  );
     40}
    3541
    3642void *bsp_stack_allocate(size_t size)
     
    3844  void *stack = NULL;
    3945
    40   if (bsp_stack_heap.page_size == BSP_STACK_MAGIC) {
    41     uintptr_t rv = _Heap_Initialize(
    42       &bsp_stack_heap,
    43       bsp_section_stack_begin,
    44       (uintptr_t) bsp_section_stack_size,
    45       CPU_STACK_ALIGNMENT
    46     );
    47     if (rv == 0) {
    48       return NULL;
    49     }
     46  if (bsp_stack_heap.area_begin != 0) {
     47    stack = _Heap_Allocate(&bsp_stack_heap, size);
    5048  }
    51 
    52   stack = _Heap_Allocate(&bsp_stack_heap, size);
    5349
    5450  if (stack == NULL) {
Note: See TracChangeset for help on using the changeset viewer.