Changeset 4f599ed in rtems for c/src


Ignore:
Timestamp:
05/18/11 05:26:53 (13 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.11, 5, master
Children:
7383b644
Parents:
42ba091
Message:

2011-05-18 Till Straumann <strauman@…>

PR1797/bsps: Applied cleaned-up version of Kate's patch.
CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK is now a 'bspopts.h'
setting and as such configurable.

Location:
c/src/lib/libbsp
Files:
25 edited

Legend:

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

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * shared/bootcard.c, shared/include/bootcard.h: cleaned-up and
     5        applied fixes proposed by PR#1797.
     6
     72011-05-12  Joel Sherrill <joel.sherrill@OARcorp.com> 
     8
     9        PR1797/bsps
     10        * bootcard.c:
     11        Added #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK to minimize code
     12        for small targets.
     13
     142011-05-12  Kate Feng <feng@bnl.gov>
     15       
     16        PR1797/bsps
     17        * bootcard.c:
     18        Fixed the value of heap_start & heap_size for the single-heap case.
     19        Added bsp_sbrk_init() to fix PPC memory allocation beyond 32 MB.
     20
    1212010-04-14      Ralf Corsépius <ralf.corsepius@rtems.org>
    222
  • c/src/lib/libbsp/powerpc/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17  Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * shared/startup/sbrk.c: Cleanup; changed default
     5        BSP_sbrk_policy to yield all memory to the heap.
     6        App must specify a different policy if desired.
     7
     82011-05-13  Gedare Bloom <gedare@gwmail.gwu.edu>
     9
     10        PR1797/bsps
     11        * shared/startup/sbrk.c : Renamed bsp_sbrk_init().
     12       
     132011-05-07  Kate Feng <feng@bnl.gov>
     14
     15        PR1797/bsps
     16        * shared/startup/bspgetworkarea.c: Removed _bsp_sbrk_init().
     17        * shared/startup/pretaskinghook.c: Removed rtems/malloc.h.
     18
    1192011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    220
  • c/src/lib/libbsp/powerpc/beatnik/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac, include/bsp.h: Made
     5        CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
     6
    172011-05-16      Till Straumann <strauman@slac.stanford.edu>
    28
  • c/src/lib/libbsp/powerpc/beatnik/configure.ac

    r42ba091 r4f599ed  
    3333 The BSP actually contains the call that enables this.])
    3434
     35RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     36RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     37[If defined then the BSP may reduce the available memory size
     38initially. This can be useful for debugging (reduce the core
     39size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     40Note that the policy can still be defined by the application
     41(see sbrk.c, BSP_sbrk_policy). By undefining
     42CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     43and a little memory is saved.])
     44
    3545# Explicitly list all Makefiles here
    3646AC_CONFIG_FILES([Makefile])
  • c/src/lib/libbsp/powerpc/beatnik/include/bsp.h

    r42ba091 r4f599ed  
    6464#define BSP_INTERRUPT_STACK_SIZE          (16 * 1024)
    6565
    66 #define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
    67 
    6866/*
    6967 *  base address definitions for several devices
  • c/src/lib/libbsp/powerpc/ep1a/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac: Made CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     5        a bspopts.h setting.
     6
    172011-03-04      Joel Sherrill <joel.sherrilL@OARcorp.com>
    28
  • c/src/lib/libbsp/powerpc/ep1a/configure.ac

    r42ba091 r4f599ed  
    3434[whether using console interrupts])
    3535
     36RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     37RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     38[If defined then the BSP may reduce the available memory size
     39initially. This can be useful for debugging (reduce the core
     40size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     41Note that the policy can still be defined by the application
     42(see sbrk.c, BSP_sbrk_policy). By undefining
     43CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     44and a little memory is saved.])
     45
    3646RTEMS_CHECK_NETWORKING
    3747AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
  • c/src/lib/libbsp/powerpc/motorola_powerpc/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac, include/bsp.h: Made
     5        CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
     6
    172011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    28
  • c/src/lib/libbsp/powerpc/motorola_powerpc/configure.ac

    r42ba091 r4f599ed  
    3232 The BSP actually contains the call that enables this.])
    3333
     34RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     35RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     36[If defined then the BSP may reduce the available memory size
     37initially. This can be useful for debugging (reduce the core
     38size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     39Note that the policy can still be defined by the application
     40(see sbrk.c, BSP_sbrk_policy). By undefining
     41CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     42and a little memory is saved.])
     43
    3444RTEMS_BSPOPTS_SET([mvme2100],[mvme2100],[1])
    3545RTEMS_BSPOPTS_SET([mvme2100],[*],[])
  • c/src/lib/libbsp/powerpc/motorola_powerpc/include/bsp.h

    r42ba091 r4f599ed  
    2424 *  confdefs.h overrides for this BSP:
    2525 */
    26 #define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
    2726
    2827/*
  • c/src/lib/libbsp/powerpc/mvme3100/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac, include/bsp.h: Made
     5        CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
     6
    172011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    28
  • c/src/lib/libbsp/powerpc/mvme3100/configure.ac

    r42ba091 r4f599ed  
    3636 The BSP actually contains the call that enables this.])
    3737
     38RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     39RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     40[If defined then the BSP may reduce the available memory size
     41initially. This can be useful for debugging (reduce the core
     42size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     43Note that the policy can still be defined by the application
     44(see sbrk.c, BSP_sbrk_policy). By undefining
     45CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     46and a little memory is saved.])
     47
    3848RTEMS_BSP_CLEANUP_OPTIONS(0, 1)
    3949
  • c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h

    r42ba091 r4f599ed  
    2626 *  confdefs.h overrides for this BSP:
    2727 */
    28 #define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
    2928
    3029#define BSP_INTERRUPT_STACK_SIZE          (16 * 1024)
  • c/src/lib/libbsp/powerpc/mvme5500/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac, include/bsp.h: Made
     5        CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK a bspopts.h setting.
     6
    172011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    28
  • c/src/lib/libbsp/powerpc/mvme5500/configure.ac

    r42ba091 r4f599ed  
    3232 The BSP actually contains the call that enables this.])
    3333
     34RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     35RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     36[If defined then the BSP may reduce the available memory size
     37initially. This can be useful for debugging (reduce the core
     38size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     39Note that the policy can still be defined by the application
     40(see sbrk.c, BSP_sbrk_policy). By undefining
     41CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     42and a little memory is saved.])
     43
    3444RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
    3545
  • c/src/lib/libbsp/powerpc/mvme5500/include/bsp.h

    r42ba091 r4f599ed  
    117117#define BSP_INTERRUPT_STACK_SIZE  (16 * 1024) /* <skf> 2/09 wants it to be adjustable by BSP */
    118118
    119 #define CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK   /* <skf> 4/09 see shared/startup/sbrk.c and rtems/confdefs.h */
    120 
    121119/* uart.c uses out_8 instead of outb  */
    122120#define BSP_UART_IOBASE_COM1    GT64x60_DEV1_BASE + 0x20000
  • c/src/lib/libbsp/powerpc/psim/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac: Made CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     5        a bspopts.h setting.
     6
    172011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    28
  • c/src/lib/libbsp/powerpc/psim/configure.ac

    r42ba091 r4f599ed  
    4040 significantly reduce simulation times.])
    4141
     42RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     43RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     44[If defined then the BSP may reduce the available memory size
     45initially. This can be useful for debugging (reduce the core
     46size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     47Note that the policy can still be defined by the application
     48(see sbrk.c, BSP_sbrk_policy). By undefining
     49CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     50and a little memory is saved.])
     51
    4252RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
    4353
  • c/src/lib/libbsp/powerpc/score603e/ChangeLog

    r42ba091 r4f599ed  
     12011-05-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR1797/bsps
     4        * configure.ac: Made CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     5        a bspopts.h setting.
     6
    172011-02-11      Ralf Corsépius <ralf.corsepius@rtems.org>
    28
  • c/src/lib/libbsp/powerpc/score603e/configure.ac

    r42ba091 r4f599ed  
    6262 The BSP actually contains the call that enables this.])
    6363
     64RTEMS_BSPOPTS_SET([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK], [*], [1])
     65RTEMS_BSPOPTS_HELP([CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK],
     66[If defined then the BSP may reduce the available memory size
     67initially. This can be useful for debugging (reduce the core
     68size) or dynamic loading (std gcc text offsets/jumps are < +/-32M).
     69Note that the policy can still be defined by the application
     70(see sbrk.c, BSP_sbrk_policy). By undefining
     71CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK this feature is removed
     72and a little memory is saved.])
     73
    6474RTEMS_BSPOPTS_SET([PPC_VECTOR_FILE_BASE],[*],[0x0100])
    6575RTEMS_BSPOPTS_HELP([PPC_VECTOR_FILE_BASE],
  • c/src/lib/libbsp/powerpc/shared/startup/bspgetworkarea.c

    r42ba091 r4f599ed  
    1717
    1818extern void *__rtems_end;
    19 extern uintptr_t _bsp_sbrk_init(uintptr_t, uintptr_t*);
    2019
    2120/*
     
    3231{
    3332  uintptr_t work_size;
    34   uintptr_t spared;
    3533  uintptr_t work_area;
    3634
     
    3836              rtems_configuration_get_interrupt_stack_size();
    3937  work_size = (uintptr_t)BSP_mem_size - work_area;
    40 
    41   spared = _bsp_sbrk_init( work_area, &work_size );
    4238
    4339  *work_area_start = (void *)work_area,
  • c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c

    r42ba091 r4f599ed  
    2626#include <rtems/bspIo.h>
    2727#endif
    28 
    29 #include <rtems/malloc.h>
    3028
    3129/*
  • c/src/lib/libbsp/powerpc/shared/startup/sbrk.c

    r42ba091 r4f599ed  
    7171#include <unistd.h>
    7272
    73 static uint32_t         remaining_start=0;
    74 static uint32_t         remaining_size=0;
     73static void *           remaining_start=(void*)-1LL;
     74static uintptr_t        remaining_size=0;
    7575
    7676/* App. may provide a value by defining the BSP_sbrk_policy
     
    8282 *
    8383 */
    84 extern uint32_t         BSP_sbrk_policy __attribute__((weak));
     84extern uintptr_t        BSP_sbrk_policy __attribute__((weak));
    8585
    86 #define LIMIT_32M  0x02000000
     86#define LIMIT_32M  ((void*)0x02000000)
    8787
    88 uintptr_t _bsp_sbrk_init(
    89   uintptr_t         heap_start,
     88uintptr_t bsp_sbrk_init(
     89  void              *heap_start,
    9090  uintptr_t         *heap_size_p
    9191)
    9292{
    9393  uintptr_t         rval=0;
     94  uintptr_t         policy;
    9495
    9596  remaining_start =  heap_start;
     
    105106  }
    106107
    107   if ( 0 != &BSP_sbrk_policy ) {
    108     switch ( BSP_sbrk_policy ) {
    109       case (uint32_t)(-1):
    110         *heap_size_p    += rval;
    111         remaining_start  = heap_start + *heap_size_p;
    112         remaining_size   = 0;
    113         /* return a nonzero sbrk_amount because the libsupport code
    114          * at some point divides by this number prior to trying an
    115          * sbrk() which will fail.
    116          */
    117         rval = 1;
    118         break;
     108  policy = (0 == &BSP_sbrk_policy ? (uintptr_t)(-1) : BSP_sbrk_policy);
     109  switch ( policy ) {
     110      case (uintptr_t)(-1):
     111        *heap_size_p    += rval;
     112        remaining_start  = heap_start + *heap_size_p;
     113        remaining_size   = 0;
     114      break;
    119115
    120116      case 0:
    121         remaining_size = 0;
    122         /* see above for why we return 1 */
    123         rval = 1;
    124         break;
     117        remaining_size = 0;
     118      break;
    125119
    126120      default:
    127         if ( rval > BSP_sbrk_policy )
    128             rval = BSP_sbrk_policy;
    129         break;
     121        if ( rval > policy )
     122          rval = policy;
     123      break;
    130124    }
    131125  }
     
    144138
    145139  /* FIXME: BEWARE if size >2G */
    146   if (incr <= remaining_size) {
     140  if ( remaining_start != (void*)-1LL && incr <= remaining_size) {
    147141    remaining_size-=incr;
    148     rval = (void*)remaining_start;
     142    rval = remaining_start;
    149143    remaining_start += incr;
    150144  } else {
  • c/src/lib/libbsp/shared/bootcard.c

    r42ba091 r4f599ed  
    5454#include <bsp/bootcard.h>
    5555#include <rtems/bspIo.h>
     56#include <rtems/malloc.h>
     57
     58#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     59#include <unistd.h> /* for sbrk() */
     60#endif
    5661
    5762/*
     
    7580  uintptr_t  work_area_size,
    7681  void      *heap_start,
    77   uintptr_t  heap_size
     82  uintptr_t  heap_size,
     83  uintptr_t  sbrk_amount
    7884)
    7985{
    80   if ( !rtems_unified_work_area &&
    81        heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA) {
    82     uintptr_t work_space_size = rtems_configuration_get_work_space_size();
    83 
    84     heap_start = (char *) work_area_start + work_space_size;
    85 
    86     if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
    87       uintptr_t heap_size_default = work_area_size - work_space_size;
    88 
    89       heap_size = heap_size_default;
     86  if ( heap_start == BSP_BOOTCARD_HEAP_USES_WORK_AREA ) {
     87    if ( rtems_unified_work_area ) {
     88      uintptr_t work_space_size = rtems_configuration_get_work_space_size();
     89
     90      heap_start = (char *) work_area_start + work_space_size;
     91
     92      if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
     93        uintptr_t heap_size_default = work_area_size - work_space_size;
     94
     95        heap_size = heap_size_default;
     96      }
     97    } else {
     98      heap_start = work_area_start;
     99      if (heap_size == BSP_BOOTCARD_HEAP_SIZE_DEFAULT) {
     100        heap_size = work_area_size;
     101      }
    90102    }
    91103  }
    92104
    93   bsp_libc_init(heap_start, heap_size, 0);
     105  bsp_libc_init(heap_start, heap_size, sbrk_amount);
    94106}
    95107
     
    109121  void                  *heap_start = NULL;
    110122  uintptr_t              heap_size = 0;
     123  uintptr_t              sbrk_amount = 0;
    111124
    112125  /*
     
    136149  bsp_get_work_area(&work_area_start, &work_area_size,
    137150                    &heap_start, &heap_size);
     151
     152#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     153  /* This routine may reduce the work area size with the
     154   * option to extend it later via sbrk(). If the application
     155   * was configured w/o CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK then
     156   * omit this step.
     157   */
     158  if ( rtems_malloc_sbrk_helpers ) {
     159    sbrk_amount = bsp_sbrk_init(work_area_start, &work_area_size);
     160    if ( work_area_size <  Configuration.work_space_size && sbrk_amount > 0 ) {
     161      /* Need to use sbrk right now */
     162      uintptr_t sbrk_now;
     163
     164      sbrk_now = (Configuration.work_space_size - work_area_size) / sbrk_amount;
     165      sbrk( sbrk_now * sbrk_amount );
     166    }
     167  }
     168#else
     169  if ( rtems_malloc_sbrk_helpers ) {
     170    printk("Configuration error!\n"
     171           "Application was configured with CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK\n"
     172           "but BSP was configured w/o sbrk support\n");
     173    bsp_cleanup();
     174    return -1;
     175  }
     176#endif
    138177
    139178  if ( work_area_size <= Configuration.work_space_size ) {
     
    171210    work_area_size,
    172211    heap_start,
    173     heap_size
     212    heap_size,
     213    sbrk_amount
    174214  );
    175215
  • c/src/lib/libbsp/shared/include/bootcard.h

    r42ba091 r4f599ed  
    9090
    9191/**
     92 * @brief Gives the BSP a chance to reduce the work area size with sbrk() adding more later.
     93 *
     94 * bsp_sbrk_init() may reduce the work area size passed in. The routine
     95 * returns the 'sbrk_amount' to be used when extending the heap.
     96 * Note that the return value may be zero.
     97 *
     98 */
     99
     100#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
     101uintptr_t bsp_sbrk_init(
     102  void              *work_area_begin,
     103  uintptr_t         *work_area_size_p
     104);
     105#endif
     106
     107
     108/**
    92109 * @brief Standard system initialization procedure.
    93110 *
Note: See TracChangeset for help on using the changeset viewer.