Changeset 3d15f1b2 in rtems for c


Ignore:
Timestamp:
Nov 3, 2008, 7:58:43 PM (12 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.9
Children:
8667514
Parents:
d12091dc
Message:

2008-11-03 Till Straumann <strauman@…>

  • shared/startup/pretaskinghook.c, shared/startup/sbrk.c: Fixed PR#1335. Pass initial starting address to heap initialization to avoid 1st 'sbrk'. User may now define 'BSP_sbrk_policy' variable (see sbrk.c) to tune behavior.
Location:
c/src/lib/libbsp/powerpc
Files:
3 edited

Legend:

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

    rd12091dc r3d15f1b2  
     12008-11-03      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * shared/startup/pretaskinghook.c, shared/startup/sbrk.c:
     4        Fixed PR#1335.
     5
    162008-10-23      Eric Norum <norume@aps.anl.gov>
    27
  • c/src/lib/libbsp/powerpc/shared/startup/pretaskinghook.c

    rd12091dc r3d15f1b2  
    6262#endif   
    6363
    64   /* Must install sbrk helpers since we rely on sbrk for giving
    65    * us even the first chunk of memory (bsp_libc_init(heap start==NULL))
    66    */
    67 
    6864  rtems_malloc_sbrk_helpers = &rtems_malloc_sbrk_helpers_table;
    6965
    70   bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared);
     66  bsp_libc_init((void *)BSP_heap_start, heap_size, heap_sbrk_spared);
    7167
    7268  /* Note that VME support may be omitted also by
  • c/src/lib/libbsp/powerpc/shared/startup/sbrk.c

    rd12091dc r3d15f1b2  
    7474static uint32_t         remaining_size=0;
    7575
     76/* App. may provide a value by defining the BSP_sbrk_policy
     77 * variable.
     78 *
     79 *  (-1) -> give all memory to the heap at initialization time
     80 *  > 0  -> value used as sbrk amount; initially give 32M
     81 *    0  -> limit memory effectively to 32M.
     82 *
     83 */
     84extern uint32_t         BSP_sbrk_policy __attribute__((weak));
     85
    7686#define LIMIT_32M  0x02000000
    7787
     
    8292
    8393  remaining_start =  heap_start;
    84   remaining_size  =*  heap_size_p;
     94  remaining_size  = *heap_size_p;
     95
    8596  if (remaining_start < LIMIT_32M &&
    8697      remaining_start + remaining_size > LIMIT_32M) {
     
    8899    rval = remaining_start + remaining_size - LIMIT_32M;
    89100    *heap_size_p = LIMIT_32M - remaining_start;
     101        remaining_start = LIMIT_32M;
     102        remaining_size  = rval;
    90103  }
     104
     105  if ( 0 != &BSP_sbrk_policy ) {
     106        switch ( BSP_sbrk_policy ) {
     107                case (uint32_t)(-1):
     108                        remaining_start  = heap_start + *heap_size_p;
     109                        remaining_size   = 0;
     110                        /* return a nonzero sbrk_amount because the libsupport code
     111                         * at some point divides by this number prior to trying an
     112                         * sbrk() which will fail.
     113                         */
     114                        rval = 1;
     115                break;
     116
     117                case 0:
     118                        remaining_size = 0;
     119                        /* see above for why we return 1 */
     120                        rval = 1;
     121                break;
     122
     123                default:
     124                        if ( rval > BSP_sbrk_policy )
     125                                rval = BSP_sbrk_policy;
     126                break;
     127        }
     128  }
     129
    91130  return rval;
    92131}
     
    96135  void *rval=(void*)-1;
    97136
     137  /* FIXME: BEWARE if size >2G */
    98138  if (incr <= remaining_size) {
    99139    remaining_size-=incr;
     
    103143    errno = ENOMEM;
    104144  }
     145#ifdef DEBUG
     146  printk("************* SBRK 0x%08x (ret 0x%08x) **********\n", incr, rval);
     147#endif
    105148  return rval;
    106149}
Note: See TracChangeset for help on using the changeset viewer.