Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Ticket #1924: config_v1.patch

File config_v1.patch, 11.7 KB (added by Sebastian Huber, on 12/13/11 at 16:01:09)

Configuration changes.

  • sapi/include/confdefs.h

    RCS file: /usr1/CVS/rtems/cpukit/sapi/include/confdefs.h,v
    retrieving revision 1.178
    diff -u -r1.178 confdefs.h
     
    4444 */
    4545#include <rtems.h>
    4646#include <rtems/score/apimutex.h>
     47#include <rtems/score/wkspace.h>
    4748
    4849#ifdef __cplusplus
    4950extern "C" {
     
    823824#endif
    824825
    825826/**
    826  *  Configure the very much optional task stack allocator
     827 *  Configure the very much optional task stack allocator initialization
    827828 */
    828 #ifndef CONFIGURE_TASK_STACK_ALLOCATOR
    829   #define CONFIGURE_TASK_STACK_ALLOCATOR NULL
     829#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
     830  #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL
    830831#endif
    831832
    832 /**
    833  *  Configure the very much optional task stack deallocator
     833/*
     834 *  Configure the very much optional task stack allocator and deallocator.
    834835 */
    835 #ifndef CONFIGURE_TASK_STACK_DEALLOCATOR
    836   #define CONFIGURE_TASK_STACK_DEALLOCATOR NULL
     836#if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
     837  && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
     838  #define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate
     839  #define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free
     840#elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
     841  && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \
     842    || (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
     843      && defined(CONFIGURE_TASK_STACK_DEALLOCATOR))
     844  #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
    837845#endif
    838846
    839847/**
     
    869877  #endif
    870878 
    871879  #ifdef CONFIGURE_UNIFIED_WORK_AREAS
    872     #include <rtems/score/wkspace.h>
    873880    Heap_Control  *RTEMS_Malloc_Heap = &_Workspace_Area;
    874881  #else
    875882    Heap_Control   RTEMS_Malloc_Area;
     
    929936  (ssize_t)((_size) + HEAP_BLOCK_HEADER_SIZE + CPU_HEAP_ALIGNMENT - 1)
    930937
    931938/**
     939 *  This is a helper macro used in stack space calculations in this file.  It
     940 *  may be provided by the application in case a special task stack allocator
     941 *  is used.  The default is allocation from the RTEMS Workspace.
     942 */
     943#ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR
     944  #define _Configure_From_stackspace(_stack_size) \
     945    CONFIGURE_TASK_STACK_FROM_ALLOCATOR(_stack_size)
     946#else
     947  #define _Configure_From_stackspace(_stack_size) \
     948    _Configure_From_workspace(_stack_size)
     949#endif
     950
     951/**
    932952 *  Do not use the unlimited bit as part of the multiplication
    933953 *  for memory usage.
    934954 */
     
    20512071
    20522072#define CONFIGURE_IDLE_TASKS_STACK \
    20532073  (CONFIGURE_IDLE_TASKS_COUNT * \
    2054     _Configure_From_workspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) )
     2074    _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) )
    20552075
    20562076#define CONFIGURE_TASKS_STACK \
    20572077  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_TASKS ) * \
    2058     _Configure_From_workspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) )
     2078    _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) )
    20592079
    20602080#define CONFIGURE_POSIX_THREADS_STACK \
    20612081  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \
    2062     _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
     2082    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
    20632083
    20642084#define CONFIGURE_GOROUTINES_STACK \
    20652085  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \
    2066     _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
     2086    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
    20672087
    20682088#define CONFIGURE_ADA_TASKS_STACK \
    20692089  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \
    2070     _Configure_From_workspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
     2090    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
    20712091
    20722092#else /* CONFIGURE_EXECUTIVE_RAM_SIZE */
    20732093
     
    21802200    CONFIGURE_IDLE_TASK_BODY,                 /* user's IDLE task */
    21812201    CONFIGURE_IDLE_TASK_STACK_SIZE,           /* IDLE task stack size */
    21822202    CONFIGURE_INTERRUPT_STACK_SIZE,           /* interrupt stack size */
     2203    CONFIGURE_TASK_STACK_ALLOCATOR_INIT,      /* stack allocator init */
    21832204    CONFIGURE_TASK_STACK_ALLOCATOR,           /* stack allocator */
    21842205    CONFIGURE_TASK_STACK_DEALLOCATOR,         /* stack deallocator */
    21852206    CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY,   /* true to clear memory */
  • sapi/include/rtems/config.h

    RCS file: /usr1/CVS/rtems/cpukit/sapi/include/rtems/config.h,v
    retrieving revision 1.57
    diff -u -r1.57 config.h
     
    8484} rtems_multiprocessing_table;
    8585#endif
    8686
     87/**
     88 * @brief Task stack allocator initialization hook.
     89 *
     90 * @param[in] stack_space_size Size of the stack space in bytes.
     91 */
     92typedef void (*rtems_stack_allocate_init_hook)( size_t stack_space_size );
     93
     94/**
     95 * @brief Task stack allocator hook.
     96 *
     97 * @param[in] stack_size Size of the task stack in bytes.
     98 *
     99 * @retval NULL Not enough memory.
     100 * @retval other Pointer to task stack.
     101 */
     102typedef void *(*rtems_stack_allocate_hook)( size_t stack_size );
     103
     104/**
     105 * @brief Task stack deallocator hook.
     106 *
     107 * @param[in] addr Pointer to previously allocated task stack.
     108 */
     109typedef void (*rtems_stack_free_hook)( void *addr );
     110
    87111/*
    88112 *  The following records define the Configuration Table.  The
    89113 *  information contained in this table is required in all
     
    139163   */
    140164  uint32_t                       interrupt_stack_size;
    141165
    142   /** The BSP may want to provide it's own stack allocation routines.
    143    *  In this case, the BSP will provide this stack allocation hook.
     166  /**
     167   * @brief Optional task stack allocator initialization hook.
    144168   */
    145   void *                       (*stack_allocate_hook)( size_t );
     169  rtems_stack_allocate_init_hook stack_allocate_init_hook;
    146170
    147   /** The BSP may want to provide it's own stack free routines.
    148    *  In this case, the BSP will provide this stack free hook.
     171  /**
     172   * @brief Optional task stack allocator hook.
    149173   */
    150   void                         (*stack_free_hook)( void *);
     174  rtems_stack_allocate_hook      stack_allocate_hook;
     175
     176  /**
     177   * @brief Optional task stack free hook.
     178   */
     179  rtems_stack_free_hook          stack_free_hook;
    151180
    152181  /** If this element is TRUE, then RTEMS will zero the Executive Workspace.
    153182   *  When this element is FALSE, it is assumed that the BSP or invoking
     
    268297#define rtems_configuration_get_interrupt_stack_size() \
    269298        (Configuration.interrupt_stack_size)
    270299
     300#define rtems_configuration_get_stack_allocate_init_hook() \
     301        (Configuration.stack_allocate_init_hook)
     302
    271303#define rtems_configuration_get_stack_allocate_hook() \
    272304        (Configuration.stack_allocate_hook)
    273305
  • score/src/thread.c

    RCS file: /usr1/CVS/rtems/cpukit/score/src/thread.c,v
    retrieving revision 1.68
    diff -u -r1.68 thread.c
     
    4949
    5050void _Thread_Handler_initialization(void)
    5151{
    52   uint32_t     ticks_per_timeslice;
    53   uint32_t     maximum_extensions;
     52  uint32_t ticks_per_timeslice =
     53    rtems_configuration_get_ticks_per_timeslice();
     54  uint32_t maximum_extensions =
     55    rtems_configuration_get_maximum_extensions();
     56  rtems_stack_allocate_init_hook stack_allocate_init_hook =
     57    rtems_configuration_get_stack_allocate_init_hook();
    5458  uint32_t     maximum_internal_threads;
    5559  #if defined(RTEMS_MULTIPROCESSING)
    56     uint32_t   maximum_proxies;
     60    uint32_t maximum_proxies =
     61      _Configuration_MP_table->maximum_proxies;
    5762  #endif
    5863
    59   ticks_per_timeslice = Configuration.ticks_per_timeslice;
    60   maximum_extensions  = Configuration.maximum_extensions;
    61   #if defined(RTEMS_MULTIPROCESSING)
    62     maximum_proxies   =  _Configuration_MP_table->maximum_proxies;
    63   #endif
    64   /*
    65    * BOTH stacks hooks must be set or both must be NULL.
    66    * Do not allow mixture.
    67    */
    68     if ( !( (!Configuration.stack_allocate_hook)
    69             == (!Configuration.stack_free_hook) ) )
     64  if ( rtems_configuration_get_stack_allocate_hook() == NULL ||
     65       rtems_configuration_get_stack_free_hook() == NULL)
    7066    _Internal_error_Occurred(
    7167      INTERNAL_ERROR_CORE,
    7268      true,
    7369      INTERNAL_ERROR_BAD_STACK_HOOK
    7470    );
    7571
     72  if ( stack_allocate_init_hook != NULL )
     73    (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() );
     74
    7675  _Thread_Dispatch_necessary = false;
    7776  _Thread_Executing         = NULL;
    7877  _Thread_Heir              = NULL;
  • score/src/threadstackallocate.c

    RCS file: /usr1/CVS/rtems/cpukit/score/src/threadstackallocate.c,v
    retrieving revision 1.15
    diff -u -r1.15 threadstackallocate.c
     
    4646{
    4747  void *stack_addr = 0;
    4848  size_t the_stack_size;
     49  rtems_stack_allocate_hook stack_allocate_hook =
     50    rtems_configuration_get_stack_allocate_hook();
    4951
    5052  the_stack_size = _Stack_Ensure_minimum( stack_size );
    5153
    5254  /*
    53    * Call ONLY the CPU table stack allocate hook, _or_ the
    54    * the RTEMS workspace allocate.  This is so the stack free
    55    * routine can call the correct deallocation routine.
     55   *  Pad the requested size so we allocate enough memory
     56   *  so the context initialization can align it properly.  The address
     57   *  returned the workspace allocate must be directly stored in the
     58   *  stack control block because it is later used in the free sequence.
     59   *
     60   *  Thus it is the responsibility of the CPU dependent code to
     61   *  get and keep the stack adjust factor, the stack alignment, and
     62   *  the context initialization sequence in sync.
    5663   */
     64  the_stack_size = _Stack_Adjust_size( the_stack_size );
    5765
    58   if ( Configuration.stack_allocate_hook ) {
    59     stack_addr = (*Configuration.stack_allocate_hook)( the_stack_size );
    60   } else {
    61 
    62     /*
    63      *  First pad the requested size so we allocate enough memory
    64      *  so the context initialization can align it properly.  The address
    65      *  returned the workspace allocate must be directly stored in the
    66      *  stack control block because it is later used in the free sequence.
    67      *
    68      *  Thus it is the responsibility of the CPU dependent code to
    69      *  get and keep the stack adjust factor, the stack alignment, and
    70      *  the context initialization sequence in sync.
    71      */
    72 
    73     the_stack_size = _Stack_Adjust_size( the_stack_size );
    74     stack_addr = _Workspace_Allocate( the_stack_size );
    75   }
     66  stack_addr = (*stack_allocate_hook)( the_stack_size );
    7667
    7768  if ( !stack_addr )
    7869    the_stack_size = 0;
  • score/src/threadstackfree.c

    RCS file: /usr1/CVS/rtems/cpukit/score/src/threadstackfree.c,v
    retrieving revision 1.8
    diff -u -r1.8 threadstackfree.c
     
    4141  Thread_Control *the_thread
    4242)
    4343{
     44  rtems_stack_free_hook stack_free_hook =
     45    rtems_configuration_get_stack_free_hook();
     46
    4447  #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
    4548    /*
    4649     *  If the API provided the stack space, then don't free it.
     
    5558   * routine properly matches the allocation of the stack.
    5659   */
    5760
    58   if ( Configuration.stack_free_hook )
    59     (*Configuration.stack_free_hook)( the_thread->Start.Initial_stack.area );
    60   else
    61     _Workspace_Free( the_thread->Start.Initial_stack.area );
     61  (*stack_free_hook)( the_thread->Start.Initial_stack.area );
    6262}