Changeset 2e92a5d in rtems


Ignore:
Timestamp:
Oct 12, 2009, 8:22:18 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
b96e09c
Parents:
68b0a2a8
Message:

2009-10-09 Sebastian Huber <sebastian.huber@…>

  • bootcard: Update for heap API changes.
Location:
c/src/lib/libbsp/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/ChangeLog

    r68b0a2a8 r2e92a5d  
     12009-10-09      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * bootcard: Update for heap API changes.
     4
    152009-09-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
    26
  • c/src/lib/libbsp/shared/bootcard.c

    r68b0a2a8 r2e92a5d  
     1/**
     2 * @file
     3 *
     4 * @ingroup bsp_bootcard
     5 *
     6 * @brief Standard system startup.
     7 */
     8
    19/*
    210 *  This is the C entry point for ALL RTEMS BSPs.  It is invoked
     
    513 *  sequence.  The basic flow of initialization is:
    614 *
    7  *  + start.S: basic CPU setup (stack, zero BSS) 
     15 *  + start.S: basic CPU setup (stack, zero BSS)
    816 *    + boot_card
    9  *      + if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    10  *        - obtain information on BSP memory and allocate RTEMS Workspace
    1117 *      + bspstart.c: bsp_start - more advanced initialization
     18 *      + obtain information on BSP memory and allocate RTEMS Workspace
    1219 *      + rtems_initialize_data_structures
    13  *      + if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    14  *        - Allocate memory to C Program Heap
    15  *        - initialize C Library and C Program Heap
     20 *      + allocate memory to C Program Heap
     21 *      + initialize C Library and C Program Heap
    1622 *      + bsp_pretasking_hook
    17  *      + if defined(RTEMS_DEBUG)
     23 *      + if defined( RTEMS_DEBUG )
    1824 *        - rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
    1925 *      + rtems_initialize_before_drivers
     
    6571 *  the RTEMS Workspace and C Program Heap.
    6672 */
    67 static rtems_status_code bootcard_bsp_libc_helper(
    68   void    *work_area_start,
    69   intptr_t work_area_size,
    70   void    *heap_start,
    71   intptr_t heap_size
     73static void bootcard_bsp_libc_helper(
     74  void      *work_area_start,
     75  uintptr_t work_area_size,
     76  void      *heap_start,
     77  uintptr_t heap_size
    7278)
    7379{
    74   intptr_t heap_size_default = 0;
    75 
    76   if ( !rtems_unified_work_area &&
     80  if ( !rtems_unified_work_area &&
    7781       heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
    78     /* Place the heap immediately following the work area */
    79     heap_start = work_area_start + rtems_configuration_get_work_space_size();
    80 
    81     /* Ensure proper alignement */
    82     if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
    83       heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT)
    84         & ~(CPU_ALIGNMENT - 1));
    85     }
    86 
    87     /*
    88      * For the default heap size use the free space from the end of the
    89      * work space up to the end of the work area as heap.
    90      */
    91     heap_size_default = work_area_size -
    92         rtems_configuration_get_work_space_size();
    93 
    94     /* Keep it as a multiple of 16 bytes */
    95     heap_size_default &= ~((intptr_t) 0xf);
    96 
    97     /* Use default heap size if requested */
     82    uintptr_t work_space_size = rtems_configuration_get_work_space_size();
     83
     84    heap_start = (char *) work_area_start + work_space_size;
     85
    9886    if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
     87      uintptr_t heap_size_default = work_area_size - work_space_size;
     88
    9989      heap_size = heap_size_default;
    10090    }
    101              
    102     /* Check heap size */
    103     if (heap_size > heap_size_default) {
    104       return RTEMS_INVALID_SIZE;
    105     }
    10691  }
    10792
    10893  bsp_libc_init(heap_start, heap_size, 0);
    109 
    110   return RTEMS_SUCCESSFUL;
    11194}
    11295
     
    122105{
    123106  rtems_interrupt_level  bsp_isr_level;
    124   rtems_status_code      sc = RTEMS_SUCCESSFUL;
    125107  void                  *work_area_start = NULL;
    126108  uintptr_t              work_area_size = 0;
     
    155137                    &heap_start, &heap_size);
    156138
    157   if ( (uint32_t) work_area_size <= (uint32_t) Configuration.work_space_size ) {
     139  if ( work_area_size <= Configuration.work_space_size ) {
    158140    printk(
    159       "bootcard: Work space too big for work area! (0x%08lx > 0x%08lx)\n",
    160       (uint32_t)Configuration.work_space_size,
    161       (uint32_t)work_area_size
     141      "bootcard: work space too big for work area: %p > %p\n",
     142      (void *) Configuration.work_space_size,
     143      (void *) work_area_size
    162144    );
    163145    bsp_cleanup();
     
    169151    Configuration.work_space_size  = work_area_size;
    170152  } else {
    171     Configuration.work_space_start = (char *) work_area_start;
     153    Configuration.work_space_start = work_area_start;
    172154  }
    173155
     
    185167   *  framework.
    186168   */
    187   sc = bootcard_bsp_libc_helper(
     169  bootcard_bsp_libc_helper(
    188170    work_area_start,
    189171    work_area_size,
     
    191173    heap_size
    192174  );
    193   if ( sc != RTEMS_SUCCESSFUL ) {
    194     printk( "bootcard: Cannot initialize C library!\n");
    195     bsp_cleanup();
    196     return -1;
    197   }
    198175
    199176  /*
     
    208185
    209186  /*
    210    *  If debug is enabled, then enable all dynamic RTEMS debug 
     187   *  If debug is enabled, then enable all dynamic RTEMS debug
    211188   *  capabilities.
    212189   *
     
    227204   *  Execute BSP specific pre-driver hook. Drivers haven't gotten
    228205   *  to initialize yet so this is a good chance to initialize
    229    *  buses, spurious interrupt handlers, etc.. 
     206   *  buses, spurious interrupt handlers, etc..
    230207   *
    231208   *  NOTE: Many BSPs do not require this handler and use the
Note: See TracChangeset for help on using the changeset viewer.