Changeset 0de9fdf in rtems


Ignore:
Timestamp:
Sep 23, 2008, 7:53:41 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
0c8c169c
Parents:
95aa5e1
Message:

2008-09-23 Joel Sherrill <joel.sherrill@…>

  • bootcard.c, include/bootcard.h: Make letting boot_card() handle work area allocation mandatory. Rename RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION to BSP_BOOTCARD_OPTIONS.
Location:
c/src/lib/libbsp/shared
Files:
3 edited

Legend:

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

    r95aa5e1 r0de9fdf  
     12008-09-23      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * bootcard.c, include/bootcard.h: Make letting boot_card() handle work
     4        area allocation mandatory. Rename
     5        RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION to BSP_BOOTCARD_OPTIONS.
     6
    172008-09-23      Sebastian Huber <sebastian.huber@embedded-brains.de>
    28
  • c/src/lib/libbsp/shared/bootcard.c

    r95aa5e1 r0de9fdf  
    6363 *  the RTEMS Workspace and C Program Heap.
    6464 */
    65 #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    66   static rtems_status_code bootcard_bsp_libc_helper(
    67     void   *work_area_start,
    68     size_t  work_area_size,
    69     void   *heap_start,
    70     size_t  heap_size
    71   )
    72   {
    73     size_t heap_size_default = 0;
    74 
    75     if ( !rtems_unified_work_area &&
    76          heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
    77       /* Use the work area start as heap start */
    78       heap_start = work_area_start;
    79 
    80       /* Ensure proper alignement */
    81       if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
    82         heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT)
    83           & ~(CPU_ALIGNMENT - 1));
    84       }
    85 
    86       /*
    87        * For the default heap size use the free space from the start of the
    88        * work area up to the work space start as heap area.
    89        */
    90       heap_size_default = (size_t) ((char *) Configuration.work_space_start
    91         - (char *) work_area_start);
    92 
    93       /* Keep it as a multiple of 16 bytes */
    94       heap_size_default &= ~((size_t) 0xf);
    95 
    96       /* Use default heap size if requested */
    97       if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
    98         heap_size = heap_size_default;
    99       }
    100                
    101       /* Check heap size */
    102       if (heap_size > heap_size_default) {
    103         return RTEMS_INVALID_SIZE;
    104       }
     65static rtems_status_code bootcard_bsp_libc_helper(
     66  void   *work_area_start,
     67  size_t  work_area_size,
     68  void   *heap_start,
     69  size_t  heap_size
     70)
     71{
     72  size_t heap_size_default = 0;
     73
     74  if ( !rtems_unified_work_area &&
     75       heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
     76    /* Use the work area start as heap start */
     77    heap_start = work_area_start;
     78
     79    /* Ensure proper alignement */
     80    if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
     81      heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT)
     82        & ~(CPU_ALIGNMENT - 1));
    10583    }
    10684
    107     bsp_libc_init(heap_start, heap_size, 0);
    108 
    109     return RTEMS_SUCCESSFUL;
    110   }
    111 #endif
     85    /*
     86     * For the default heap size use the free space from the start of the
     87     * work area up to the work space start as heap area.
     88     */
     89    heap_size_default = (size_t) ((char *) Configuration.work_space_start
     90      - (char *) work_area_start);
     91
     92    /* Keep it as a multiple of 16 bytes */
     93    heap_size_default &= ~((size_t) 0xf);
     94
     95    /* Use default heap size if requested */
     96    if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
     97      heap_size = heap_size_default;
     98    }
     99             
     100    /* Check heap size */
     101    if (heap_size > heap_size_default) {
     102      return RTEMS_INVALID_SIZE;
     103    }
     104  }
     105
     106  bsp_libc_init(heap_start, heap_size, 0);
     107
     108  return RTEMS_SUCCESSFUL;
     109}
    112110
    113111/*
     
    123121)
    124122{
    125   static char  *argv_pointer = NULL;
    126   static char  *envp_pointer = NULL;
    127   char **argv_p = &argv_pointer;
    128   char **envp_p = &envp_pointer;
    129   rtems_interrupt_level bsp_isr_level;
    130   #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    131     rtems_status_code sc = RTEMS_SUCCESSFUL;
    132     void   *work_area_start = NULL;
    133     size_t  work_area_size = 0;
    134     void   *heap_start = NULL;
    135     size_t  heap_size = 0;
    136   #endif
     123  static char            *argv_pointer = NULL;
     124  static char            *envp_pointer = NULL;
     125  char                  **argv_p = &argv_pointer;
     126  char                  **envp_p = &envp_pointer;
     127  rtems_interrupt_level   bsp_isr_level;
     128  rtems_status_code       sc = RTEMS_SUCCESSFUL;
     129  void                   *work_area_start = NULL;
     130  size_t                  work_area_size = 0;
     131  void                   *heap_start = NULL;
     132  size_t                  heap_size = 0;
    137133
    138134  /*
     
    175171   *  the RTEMS Workspace and the C Program Heap is.
    176172   */
    177   #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    178     {
    179       bsp_get_work_area(
    180         &work_area_start,
    181         &work_area_size,
    182         &heap_start,
    183         &heap_size
    184       );
    185    
    186       if ( work_area_size <= Configuration.work_space_size ) {
    187         printk( "bootcard: Work space too big for work area!\n");
    188         bsp_cleanup();
    189         return -1;
    190       }
    191    
    192       if ( rtems_unified_work_area ) {
    193         Configuration.work_space_start = work_area_start;
    194         Configuration.work_space_size  = work_area_size;
    195       } else {
    196         Configuration.work_space_start = (char *) work_area_start +
    197           work_area_size - rtems_configuration_get_work_space_size();
    198       }
    199 
    200       #if (BSP_DIRTY_MEMORY == 1)
    201         memset( work_area_start, 0xCF,  work_area_size);
    202       #endif
    203     }
     173  bsp_get_work_area(&work_area_start, &work_area_size, &heap_start, &heap_size);
     174
     175  if ( work_area_size <= Configuration.work_space_size ) {
     176    printk( "bootcard: Work space too big for work area!\n");
     177    bsp_cleanup();
     178    return -1;
     179  }
     180
     181  if ( rtems_unified_work_area ) {
     182    Configuration.work_space_start = work_area_start;
     183    Configuration.work_space_size  = work_area_size;
     184  } else {
     185    Configuration.work_space_start = (char *) work_area_start +
     186      work_area_size - rtems_configuration_get_work_space_size();
     187  }
     188
     189  #if (BSP_DIRTY_MEMORY == 1)
     190    memset( work_area_start, 0xCF,  work_area_size );
    204191  #endif
    205192
     
    213200   *  framework.
    214201   */
    215   #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    216     sc = bootcard_bsp_libc_helper(
    217       work_area_start,
    218       work_area_size,
    219       heap_start,
    220       heap_size
    221     );
    222     if (sc != RTEMS_SUCCESSFUL) {
    223       printk( "bootcard: Cannot initialize C library!\n");
    224       bsp_cleanup();
    225       return -1;
    226     }
    227   #endif
     202  sc = bootcard_bsp_libc_helper(
     203    work_area_start,
     204    work_area_size,
     205    heap_start,
     206    heap_size
     207  );
     208  if ( sc != RTEMS_SUCCESSFUL ) {
     209    printk( "bootcard: Cannot initialize C library!\n");
     210    bsp_cleanup();
     211    return -1;
     212  }
    228213
    229214  /*
     
    296281   *  Now return to the start code.
    297282   */
    298 
    299283  return 0;
    300284}
  • c/src/lib/libbsp/shared/include/bootcard.h

    r95aa5e1 r0de9fdf  
    3131#include <stdint.h>
    3232
    33 #include <bspopts.h> /* for BSP_BOOTCARD_HANDLES_RAM_ALLOCATION */
     33#include <bspopts.h>
    3434
    3535#ifdef __cplusplus
     
    4949void bsp_reset(void);
    5050
    51 #ifdef BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
    52   #define BSP_BOOTCARD_HEAP_USES_WORK_AREA NULL
     51#define BSP_BOOTCARD_HEAP_USES_WORK_AREA NULL
    5352
    54   #define BSP_BOOTCARD_HEAP_SIZE_DEFAULT 0
     53#define BSP_BOOTCARD_HEAP_SIZE_DEFAULT 0
    5554
    56   void bsp_get_work_area(
    57     void **work_area_start,
    58     size_t *work_area_size,
    59     void **heap_start,
    60     size_t *heap_size
    61   );
    62 #endif
     55void bsp_get_work_area(
     56  void **work_area_start,
     57  size_t *work_area_size,
     58  void **heap_start,
     59  size_t *heap_size
     60);
    6361
    6462int boot_card( int argc, char **argv, char **envp);
Note: See TracChangeset for help on using the changeset viewer.