Changeset 37030e3 in rtems


Ignore:
Timestamp:
Dec 9, 2015, 7:05:57 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
20d7093a
Parents:
938ef78c
git-author:
Sebastian Huber <sebastian.huber@…> (12/09/15 07:05:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/10/15 07:32:36)
Message:

bsps: Call bsp_work_area_initialize() early

Call bsp_work_area_initialize() before bsp_start(). This allows
bsp_start() to use malloc() etc. which is beneficial for systems with a
plug-and-play hardware enumeration.

Update #2408.

Files:
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc176x/Makefile.am

    r938ef78c r37030e3  
    9595libbsp_a_SOURCES += ../../shared/bsplibc.c
    9696libbsp_a_SOURCES += ../../shared/bsppost.c
     97libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
    9798libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
    9899libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
  • c/src/lib/libbsp/arm/lpc176x/startup/bspstart.c

    r938ef78c r37030e3  
    4343#endif
    4444
    45 void bsp_pretasking_hook( void )
     45static void heap_extend( void )
    4646{
    4747#ifdef LPC176X_HEAP_EXTEND
     
    8787  /* DMA */
    8888  lpc176x_dma_initialize();
     89
     90  heap_extend();
    8991}
  • c/src/lib/libbsp/arm/lpc24xx/Makefile.am

    r938ef78c r37030e3  
    9797        ../../shared/bsplibc.c \
    9898        ../../shared/bsppost.c \
     99        ../../shared/bsppretaskinghook.c \
    99100        ../../shared/bsppredriverhook.c \
    100101        ../../shared/gnatinstallhandler.c \
  • c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c

    r938ef78c r37030e3  
    4444#endif
    4545
    46 void bsp_pretasking_hook(void)
     46static void heap_extend(void)
    4747{
    4848  #ifdef LPC24XX_HEAP_EXTEND
     
    9292  /* DMA */
    9393  lpc24xx_dma_initialize();
     94
     95  heap_extend();
    9496}
  • c/src/lib/libbsp/i386/pc386/include/bsp.h

    r938ef78c r37030e3  
    188188void rtems_irq_mngt_init(void);          /* from 'irq_init.c' */
    189189
    190 void bsp_size_memory(void);              /* from 'bspstart.c' */
    191 
    192190#if (BSP_IS_EDISON == 0)
    193191  void Clock_driver_install_handler(void);             /* from 'ckinit.c'  */
  • c/src/lib/libbsp/i386/pc386/startup/bspgetworkarea.c

    r938ef78c r37030e3  
    5353extern uint32_t _stack_size;
    5454
    55 void bsp_size_memory(void)
     55static void bsp_size_memory(void)
    5656{
    5757  uintptr_t topAddr;
     
    127127void bsp_work_area_initialize(void)
    128128{
    129   void *area_start = (void *) rtemsWorkAreaStart;
    130   uintptr_t area_size  = (uintptr_t) bsp_mem_size - (uintptr_t) rtemsWorkAreaStart;
     129  void *area_start;
     130  uintptr_t area_size;
    131131
     132  /*
     133   *  We need to determine how much memory there is in the system.
     134   */
     135  bsp_size_memory();
     136
     137  area_start = (void *) rtemsWorkAreaStart;
     138  area_size  = (uintptr_t) bsp_mem_size - (uintptr_t) rtemsWorkAreaStart;
    132139  bsp_work_area_initialize_default( area_start, area_size );
    133140}
  • c/src/lib/libbsp/i386/pc386/startup/bspstart.c

    r938ef78c r37030e3  
    5959{
    6060  /*
    61    *  We need to determine how much memory there is in the system.
    62    */
    63   bsp_size_memory();
    64 
    65   /*
    6661   * Turn off watchdog
    6762   */
  • c/src/lib/libbsp/shared/bootcard.c

    r938ef78c r37030e3  
    7676
    7777  /*
     78   *  Initialize the RTEMS Workspace and the C Program Heap.
     79   */
     80  bsp_work_area_initialize();
     81
     82  /*
    7883   * Invoke Board Support Package initialization routine written in C.
    7984   */
    8085  bsp_start();
    81 
    82   /*
    83    *  Initialize the RTEMS Workspace and the C Program Heap.
    84    */
    85   bsp_work_area_initialize();
    8686
    8787  /*
  • c/src/lib/libbsp/shared/include/bootcard.h

    r938ef78c r37030e3  
    7979 * - disable interrupts, interrupts will be enabled during the first context
    8080 *   switch
    81  * - bsp_start() - more advanced initialization
    8281 * - bsp_work_area_initialize() - initialize the RTEMS Workspace and the C
    8382 *   Program Heap
     83 * - bsp_start() - more advanced initialization
    8484 * - rtems_initialize_data_structures()
    8585 * - initialize C Library
  • c/src/lib/libbsp/sparc/erc32/Makefile.am

    r938ef78c r37030e3  
    4444libbsp_a_SOURCES += startup/bspidle.c
    4545libbsp_a_SOURCES += startup/bspdelay.c
    46 libbsp_a_SOURCES += ../../sparc/shared/startup/early_malloc.c
    4746libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
    4847libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_halt.c
  • c/src/lib/libbsp/sparc/erc32/include/bsp.h

    r938ef78c r37030e3  
    9393
    9494void bsp_spurious_initialize( void );
    95 
    96 /* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
    97  * can be called at any time. The work-area will shrink when called before
    98  * bsp_work_area_initialize(). malloc() is called to get memory when this
    99  * function is called after bsp_work_area_initialize().
    100  */
    101 void *bsp_early_malloc(int size);
    10295
    10396/* Interrupt Service Routine (ISR) pointer */
  • c/src/lib/libbsp/sparc/leon2/Makefile.am

    r938ef78c r37030e3  
    4343libbsp_a_SOURCES += startup/bspidle.c
    4444libbsp_a_SOURCES += startup/bspdelay.c
    45 libbsp_a_SOURCES += ../../sparc/shared/startup/early_malloc.c
    4645libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
    4746libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_halt.c
  • c/src/lib/libbsp/sparc/leon2/include/bsp.h

    r938ef78c r37030e3  
    118118void bsp_spurious_initialize( void );
    119119
    120 /* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
    121  * can be called at any time. The work-area will shrink when called before
    122  * bsp_work_area_initialize(). malloc() is called to get memory when this
    123  * function is called after bsp_work_area_initialize().
    124  */
    125 void *bsp_early_malloc(int size);
    126 
    127120/* Interrupt Service Routine (ISR) pointer */
    128121typedef void (*bsp_shared_isr)(void *arg);
  • c/src/lib/libbsp/sparc/leon3/Makefile.am

    r938ef78c r37030e3  
    3939    ../../sparc/shared/startup/bspgetworkarea.c ../../shared/sbrk.c \
    4040    startup/setvec.c \
    41     startup/spurious.c startup/bspidle.S startup/bspdelay.c \
    42     ../../sparc/shared/startup/early_malloc.c
     41    startup/spurious.c startup/bspidle.S startup/bspdelay.c
    4342libbsp_a_SOURCES += startup/cpucounter.c
    4443libbsp_a_SOURCES += ../../sparc/shared/startup/bsp_fatal_exit.c
  • c/src/lib/libbsp/sparc/leon3/include/bsp.h

    r938ef78c r37030e3  
    140140 */
    141141void rtems_bsp_delay(int usecs);
    142 
    143 /* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
    144  * can be called at any time. The work-area will shrink when called before
    145  * bsp_work_area_initialize(). malloc() is called to get memory when this
    146  * function is called after bsp_work_area_initialize().
    147  */
    148 void *bsp_early_malloc(int size);
    149142
    150143/* Interrupt Service Routine (ISR) pointer */
  • c/src/lib/libbsp/sparc/shared/amba/ambapp.c

    r938ef78c r37030e3  
    2424static struct ambapp_dev *ambapp_alloc_dev_struct(int dev_type)
    2525{
    26   int size = sizeof(struct ambapp_dev);
    2726  struct ambapp_dev *dev;
     27  size_t size = sizeof(*dev);
    2828
    2929  if (dev_type == DEV_APB_SLV)
     
    3131  else
    3232    size += sizeof(struct ambapp_ahb_info); /* AHB */
    33   dev = (struct ambapp_dev *)bsp_early_malloc(size);
    34   if (dev == NULL)
    35     return NULL;
    36   memset(dev, 0 , size);
    37   dev->dev_type = dev_type;
     33  dev = (struct ambapp_dev *)calloc(1, size);
     34  if (dev != NULL)
     35    dev->dev_type = dev_type;
    3836  return dev;
    3937}
  • c/src/lib/libbsp/sparc/shared/startup/bspgetworkarea.c

    r938ef78c r37030e3  
    2121extern uint32_t rdb_start;
    2222
    23 /* Must be aligned to 8, _end is aligned to 8 */
    24 unsigned int early_mem = (unsigned int)&end;
    25 
    2623/*
    2724 *  This method returns the base address and size of the area which
     
    3532
    3633  /* Early dynamic memory allocator is placed just above _end  */
    37   void *work_area_start = (void *)early_mem;
     34  void *work_area_start = (void *)&end;
    3835  uintptr_t work_area_size  =
    39     (uintptr_t)rdb_start - (uintptr_t)early_mem - STACK_SIZE;
    40   early_mem        = ~0; /* Signal bsp_early_malloc not to be used anymore */
     36    (uintptr_t)rdb_start - (uintptr_t)&end - STACK_SIZE;
    4137
    4238  /*
  • doc/bsp_howto/init.t

    r938ef78c r37030e3  
    149149for later use by the application.
    150150
    151 @item It invokes the BSP specific routine @code{bsp_start()} which is
    152 written in C and thus able to perform more advanced initialization.
    153 Often MMU and bus initialization occurs here.
    154 
    155151@item It invokes the BSP specific routine @code{bsp_work_area_initialize()}
    156152which is supposed to initialize the RTEMS Workspace and the C Program Heap.
     
    161157@code{#include <bsp/bootcard.h>}.
    162158
     159@item It invokes the BSP specific routine @code{bsp_start()} which is
     160written in C and thus able to perform more advanced initialization.
     161Often MMU, bus and interrupt controller initialization occurs here.  Since the
     162RTEMS Workspace and the C Program Heap was already initialized by
     163@code{bsp_work_area_initialize()}, this routine may use @code{malloc()}, etc.
     164
    163165@item It invokes the RTEMS directive
    164166@code{rtems_initialize_data_structures()} to initialize the RTEMS
     
    215217That's it.  We just went through the entire sequence.
    216218
     219@subsection bsp_work_area_initialize() - BSP Specific Work Area Initialization
     220
     221This is the first BSP specific C routine to execute during system
     222initialization.  It must initialize the support for allocating memory from the
     223C Program Heap and RTEMS Workspace commonly referred to as the work areas.
     224Many BSPs place the work areas at the end of RAM although this is certainly not
     225a requirement.  Usually the default implementation in
     226@file{c/src/lib/libbsp/shared/bspgetworkarea.c} should be sufficient.  Custom
     227implementations can use @code{bsp_work_area_initialize_default()} or
     228@code{bsp_work_area_initialize_with_table()} available as inline functions from
     229@code{#include <bsp/bootcard.h>}.
     230
    217231@subsection bsp_start() - BSP Specific Initialization
    218232
    219 This is the first BSP specific C routine to execute during system
    220 initialization.  This routine often performs required fundamental
    221 hardware initialization such as setting bus controller registers
    222 that do not have a direct impact on whether or not C code can execute.
    223 The source code for this routine is usually found in the following
    224 file:
    225 
    226 @example
    227 c/src/lib/libbsp/CPU/BSP/startup/bspstart.c
    228 @end example
    229 
    230 On older BSPs not using @code{boot_card()}'s support for allocating memory
    231 to the C Program Heap and RTEMS Workspace, one of the most important
    232 functions performed by this routine is determining where the RTEMS
    233 Workspace is to be located in memory.  All RTEMS objects and task stacks
    234 will be allocated from this Workspace.  The RTEMS Workspace is distinct
    235 from the application heap used for @code{malloc()}.  Many BSPs place
    236 the RTEMS Workspace area at the end of RAM although this is certainly
    237 not a requirement.
     233This is the second BSP specific C routine to execute during system
     234initialization.  It is called right after @code{bsp_work_area_initialize()}.
     235The @code{bsp_start()} routine often performs required fundamental hardware
     236initialization such as setting bus controller registers that do not have a
     237direct impact on whether or not C code can execute.  The interrupt controllers
     238are usually initialized here.  The source code for this routine is usually
     239found in the file @file{c/src/lib/libbsp/$@{CPU@}/$@{BSP@}/startup/bspstart.c}.
     240It is not allowed to create any operating system objects, e.g. RTEMS
     241semaphores.
    238242
    239243After completing execution, this routine returns to the @code{boot_card()}
    240 routine.
     244routine.  In case of errors, the initialization should be terminated via
     245@code{bsp_fatal()}.
    241246
    242247@subsection RTEMS Pretasking Callback
Note: See TracChangeset for help on using the changeset viewer.