Ticket #1797: rtems-4.10.0-heapspace_05162011.diff

File rtems-4.10.0-heapspace_05162011.diff, 6.1 KB (added by feng1, on May 16, 2011 at 5:36:21 PM)

Fixed the bugs for the limitation of the 1st 32 MB of memory on PPC BSPs.

  • c/src/lib/libbsp/powerpc/ChangeLog

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/powerpc/ChangeLog rtems-4.10.0/c/src/lib/libbsp/powerpc/ChangeLog
    old new  
     12011-05-13      Gedare Bloom <gedare@gwmail.gwu.edu>
     2        * shared/startup/sbrk.c : Renamed bsp_sbrk_init().
     3       
     42011-05-07      Kate Feng <feng@bnl.gov>
     5
     6        * shared/startup/bspgetworkarea.c: Removed _bsp_sbrk_init().
     7        * shared/startup/pretaskinghook.c: Removed rtems/malloc.h.
     8
     9       
    1102011-03-04      Joel Sherrill <joel.sherrilL@OARcorp.com>
    211
    312        * shared/start/start.S: Remove conflict markers in comment.
  • c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c rtems-4.10.0/c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c
    old new  
    1616#endif
    1717
    1818extern void *__rtems_end;
    19 extern uintptr_t _bsp_sbrk_init(uintptr_t, uintptr_t*);
    2019
    2120/*
    2221 *  This method returns the base address and size of the area which
     
    3130)
    3231{
    3332  uintptr_t work_size;
    34   uintptr_t spared;
    3533  uintptr_t work_area;
    3634
    3735  work_area = (uintptr_t)&__rtems_end +
    3836              rtems_configuration_get_interrupt_stack_size();
    3937  work_size = (uintptr_t)BSP_mem_size - work_area;
    4038
    41   spared = _bsp_sbrk_init( work_area, &work_size );
    42 
    4339  *work_area_start = (void *)work_area,
    4440  *work_area_size  = work_size;
    4541  *heap_start      = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
  • c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c rtems-4.10.0/c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c
    old new  
    2626#include <rtems/bspIo.h>
    2727#endif
    2828
    29 #include <rtems/malloc.h>
    30 
    3129/*
    3230 *  bsp_pretasking_hook
    3331 *
  • c/src/lib/libbsp/powerpc/shared/startup/sbrk.c

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/powerpc/shared/startup/sbrk.c rtems-4.10.0/c/src/lib/libbsp/powerpc/shared/startup/sbrk.c
    old new  
    8585
    8686#define LIMIT_32M  0x02000000
    8787
    88 uintptr_t _bsp_sbrk_init(
     88uintptr_t bsp_sbrk_init(
    8989  uintptr_t         heap_start,
    9090  uintptr_t         *heap_size_p
    9191)
  • c/src/lib/libbsp/shared/bootcard.c

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/shared/bootcard.c rtems-4.10.0/c/src/lib/libbsp/shared/bootcard.c
    old new  
    5151
    5252#include <rtems.h>
    5353
     54#include <bsp.h>
    5455#include <bsp/bootcard.h>
    5556#include <rtems/bspIo.h>
    5657
     
    6566 */
    6667extern bool rtems_unified_work_area;
    6768
     69#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     70uintptr_t bsp_sbrk_init(uintptr_t, uintptr_t*);
     71#endif
     72
    6873/*
    6974 *  These are the prototypes and helper routines which are used
    7075 *  when the BSP lets the framework handle RAM allocation between
     
    7782  uintptr_t  heap_size
    7883)
    7984{
     85  void *heap_start_aligned;
     86  uintptr_t heap_sbrk_spared=0;
     87
    8088  if ( !rtems_unified_work_area &&
    8189       heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
    8290    uintptr_t work_space_size = rtems_configuration_get_work_space_size();
     
    8997      heap_size = heap_size_default;
    9098    }
    9199  }
     100  else {
     101     heap_start = (char *) work_area_start;
     102     heap_size = work_area_size;
     103  }
    92104
    93   bsp_libc_init(heap_start, heap_size, 0);
     105  heap_start_aligned = (void *)((uintptr_t)(heap_start + CPU_ALIGNMENT - 1)
     106                                & ~(CPU_ALIGNMENT-1));
     107  heap_size -= ((uintptr_t) heap_start_aligned - (uintptr_t) heap_start);
     108
     109#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     110     heap_sbrk_spared = bsp_sbrk_init((uintptr_t) heap_start_aligned, &heap_size);
     111#endif
     112
     113  bsp_libc_init(heap_start_aligned, heap_size, heap_sbrk_spared);
    94114}
    95115
    96116/*
     
    146166    return -1;
    147167  }
    148168
    149   if ( rtems_unified_work_area ) {
    150     Configuration.work_space_start = work_area_start;
     169  Configuration.work_space_start = work_area_start;
     170  if ( rtems_unified_work_area )
    151171    Configuration.work_space_size  = work_area_size;
    152   } else {
    153     Configuration.work_space_start = work_area_start;
    154   }
    155172
    156173  #if (BSP_DIRTY_MEMORY == 1)
    157174    memset( work_area_start, 0xCF,  work_area_size );
  • c/src/lib/libbsp/shared/ChangeLog

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/shared/ChangeLog rtems-4.10.0/c/src/lib/libbsp/shared/ChangeLog
    old new  
     12011-05-12      Joel Sherrill <joel.sherrill@OARcorp.com> 
     2        * bootcard.c:
     3        Added #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK to minimize code
     4        for small targets.
     5       
     62011-05-12      Kate Feng <feng@bnl.gov>
     7       
     8        * bootcard.c: To comply with Joe's future plan on memory protections,
     9        Fixed the value of heap_start & heap_size for the single-heap case.
     10        Added bsp_sbrk_init() to fix PPC memory allocation beyond 32 MB.
     11        * sbrk.c: Added bsp_sbrk_init() to comply with Joe's future plan
     12        for memory protections,
     13       
    1142010-05-28      Ralf Corsépius <ralf.corsepius@rtems.org>
    215
    316        * umon/tfsDriver.c:
  • c/src/lib/libbsp/shared/sbrk.c

    diff -Naur rtems-4.10.0.orig/c/src/lib/libbsp/shared/sbrk.c rtems-4.10.0/c/src/lib/libbsp/shared/sbrk.c
    old new  
    2323#include <sys/types.h>
    2424#include <unistd.h>
    2525
     26uintptr_t bsp_sbrk_init(
     27  uintptr_t         heap_start,
     28  uintptr_t         *heap_size_p
     29)
     30{
     31  /* BSP dependent */
     32  return(0);
     33}
     34
    2635void * sbrk(ptrdiff_t incr)
    2736{
    2837  errno = ENOMEM;