[rtems commit] bsps/stackalloc: Add initialization hook

Gedare Bloom gedare at rtems.org
Thu Apr 26 12:40:23 UTC 2012


On Thu, Apr 26, 2012 at 5:00 AM, Sebastian Huber <sebh at rtems.org> wrote:
> Module:    rtems
> Branch:    master
> Commit:    ed67d9317125d386ea6be12ee6ec256dd59f838a
> Changeset: http://git.rtems.org/rtems/commit/?id=ed67d9317125d386ea6be12ee6ec256dd59f838a
>
> Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
> Date:      Thu Apr 26 10:03:38 2012 +0200
>
> bsps/stackalloc: Add initialization hook
>
> ---
>
>  c/src/lib/libbsp/shared/include/stackalloc.h |   11 ++++++++++
>  c/src/lib/libbsp/shared/src/stackalloc.c     |   28 +++++++++++--------------
>  2 files changed, 23 insertions(+), 16 deletions(-)
>
> diff --git a/c/src/lib/libbsp/shared/include/stackalloc.h b/c/src/lib/libbsp/shared/include/stackalloc.h
> index b8516ef..6ed898f 100644
> --- a/c/src/lib/libbsp/shared/include/stackalloc.h
> +++ b/c/src/lib/libbsp/shared/include/stackalloc.h
> @@ -52,6 +52,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);
> +
For shared BSP code should we adopt the naming conventions of cpukit
and avoid using abbreviations? here it would be
bsp_stack_allocate_initialize. Similar with the macro.

> +/**
>  * @brief Task stack allocator for @ref CONFIGURE_TASK_STACK_ALLOCATOR.
>  *
>  * In case the designated task stack space from bsp_stack_initialize() is
> @@ -65,6 +71,11 @@ void *bsp_stack_allocate(size_t size);
>  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.
>  */
>  #define CONFIGURE_TASK_STACK_ALLOCATOR bsp_stack_allocate
> diff --git a/c/src/lib/libbsp/shared/src/stackalloc.c b/c/src/lib/libbsp/shared/src/stackalloc.c
> index be84057..b8d7b9c 100644
> --- a/c/src/lib/libbsp/shared/src/stackalloc.c
> +++ b/c/src/lib/libbsp/shared/src/stackalloc.c
> @@ -27,30 +27,26 @@
>
>  #include <bsp/linker-symbols.h>
>
> -#define BSP_STACK_MAGIC 0xdeadbeef
> +static Heap_Control bsp_stack_heap;
>
> -static Heap_Control bsp_stack_heap = {
> -  .page_size = BSP_STACK_MAGIC
> -};
> +void bsp_stack_allocate_init(size_t stack_space_size)
> +{
> +  _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 *stack = NULL;
>
> -  if (bsp_stack_heap.page_size == BSP_STACK_MAGIC) {
> -    uintptr_t rv = _Heap_Initialize(
> -      &bsp_stack_heap,
> -      bsp_section_stack_begin,
> -      (uintptr_t) bsp_section_stack_size,
> -      CPU_STACK_ALIGNMENT
> -    );
> -    if (rv == 0) {
> -      return NULL;
> -    }
> +  if (bsp_stack_heap.area_begin != 0) {
> +    stack = _Heap_Allocate(&bsp_stack_heap, size);
>   }
>
> -  stack = _Heap_Allocate(&bsp_stack_heap, size);
> -
>   if (stack == NULL) {
>     stack = _Workspace_Allocate(size);
>   }
>
> _______________________________________________
> rtems-vc mailing list
> rtems-vc at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-vc




More information about the devel mailing list