Changeset cc54cc9 in rtems


Ignore:
Timestamp:
Jul 29, 2008, 7:11:21 AM (12 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 4.9, 5, master
Children:
7d53ba7f
Parents:
af37ae0
Message:

src/irq-legacy.c: Free allocated memory in hander remove
bootcard.c: Check if the heap fits into the work area

Location:
c/src/lib/libbsp/shared
Files:
3 edited

Legend:

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

    raf37ae0 rcc54cc9  
     12008-07-28      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * src/irq-legacy.c: Free allocated memory in hander remove.
     4
     5        * bootcard.c: Check if the heap fits into the work area.
     6
    172008-07-24      Sebastian Huber <sebastian.huber@embedded-brains.de>
    28
  • c/src/lib/libbsp/shared/bootcard.c

    raf37ae0 rcc54cc9  
    5959 */
    6060#if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    61   static void bootcard_bsp_libc_helper(
     61  static rtems_status_code bootcard_bsp_libc_helper(
    6262    void   *work_area_start,
    6363    size_t  work_area_size,
     
    6666  )
    6767  {
     68    size_t heap_size_default = 0;
     69
    6870    if (heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
    6971      /* Use the work area start as heap start */
     
    7274      /* Ensure proper alignement */
    7375      if ((uintptr_t) heap_start & (CPU_ALIGNMENT - 1)) {
    74         heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT - 1));
     76        heap_start = (void *) (((uintptr_t) heap_start + CPU_ALIGNMENT)
     77          & ~(CPU_ALIGNMENT - 1));
    7578      }
    7679
    7780      /*
    78        * Use the free space from the start of the work area up to the work
    79        * space start as heap area.
     81       * For the default heap size use the free space from the start of the
     82       * work area up to the work space start as heap area.
    8083       */
     84      heap_size_default = (char *) Configuration.work_space_start
     85        - (char *) work_area_start;
     86
     87      /* Keep it as a multiple of 16 bytes */
     88      heap_size_default &= ~((size_t) 0xf);
     89
     90      /* Use default heap size if requested */
    8191      if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
    82         heap_size = (char *) Configuration.work_space_start
    83           - (char *) work_area_start;
    84 
    85         /* Keep it as a multiple of 16 bytes */
    86         heap_size &= 0xfffffff0;
     92        heap_size = heap_size_default;
     93      }
     94               
     95      /* Check heap size */
     96      if (heap_size > heap_size_default) {
     97        return RTEMS_INVALID_SIZE;
    8798      }
    8899    }
    89100
    90101    bsp_libc_init( heap_start, (uint32_t) heap_size, 0);
     102
     103    return RTEMS_SUCCESSFUL;
    91104  }
    92105#endif
     
    110123  rtems_interrupt_level bsp_isr_level;
    111124  #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
     125    rtems_status_code sc = RTEMS_SUCCESSFUL;
    112126    void   *work_area_start = NULL;
    113127    size_t  work_area_size = 0;
     
    151165   */
    152166  #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    153   {
    154     void *work_space_start = NULL;
    155 
    156     bsp_get_work_area(
    157       &work_area_start,
    158       &work_area_size,
    159       &heap_start,
    160       &heap_size
    161     );
    162 
    163     work_space_start = (char *) work_area_start + work_area_size
    164       - rtems_configuration_get_work_space_size();
    165 
    166     if ((uintptr_t) work_space_start <= (uintptr_t) work_area_start) {
    167       printk( "bootcard: Not enough RAM!!!\n" );
    168       bsp_cleanup();
    169       return -1;
     167    {
     168      void *work_space_start = NULL;
     169   
     170      bsp_get_work_area(
     171        &work_area_start,
     172        &work_area_size,
     173        &heap_start,
     174        &heap_size
     175      );
     176   
     177      work_space_start = (char *) work_area_start + work_area_size
     178        - rtems_configuration_get_work_space_size();
     179   
     180      if ((uintptr_t) work_space_start <= (uintptr_t) work_area_start) {
     181        printk( "bootcard: Work space to big for work area!\n");
     182        bsp_cleanup();
     183        return -1;
     184      }
     185   
     186      Configuration.work_space_start = work_space_start;
     187   
     188      #if (BSP_DIRTY_MEMORY == 1)
     189        memset( work_area_start, 0xCF,  work_area_size);
     190      #endif
    170191    }
    171 
    172     Configuration.work_space_start = work_space_start;
    173 
    174     #if (BSP_DIRTY_MEMORY == 1)
    175       memset( work_area_start, 0xCF,  work_area_size);
    176     #endif
    177   }
    178 
    179192  #endif
    180193
     
    194207   */
    195208  #if defined(BSP_BOOTCARD_HANDLES_RAM_ALLOCATION)
    196     bootcard_bsp_libc_helper(
     209    sc = bootcard_bsp_libc_helper(
    197210      work_area_start,
    198211      work_area_size,
     
    200213      heap_size
    201214    );
     215    if (sc != RTEMS_SUCCESSFUL) {
     216      printk( "bootcard: Cannot initialize C library!\n");
     217      bsp_cleanup();
     218      return -1;
     219    }
    202220  #endif
    203221
  • c/src/lib/libbsp/shared/src/irq-legacy.c

    raf37ae0 rcc54cc9  
    170170
    171171        sc = rtems_interrupt_handler_remove( cd->name, bsp_interrupt_legacy_dispatch, e.legacy_handler_arg);
     172
     173        free( e.legacy_handler_arg);
     174
    172175        if (sc != RTEMS_SUCCESSFUL) {
    173176                return 0;
Note: See TracChangeset for help on using the changeset viewer.