Changeset 0612ad2 in rtems


Ignore:
Timestamp:
Nov 3, 2008, 8:23:29 PM (11 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, master
Children:
4df8765
Parents:
bc5d870
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:
2 edited

Legend:

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

    rbc5d870 r0612ad2  
     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-02      Sebastian Huber <sebastian.huber@embedded-brains.de>
    27
  • c/src/lib/libbsp/powerpc/shared/startup/sbrk.c

    rbc5d870 r0612ad2  
    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
     
    8494
    8595  remaining_start =  heap_start;
    86   remaining_size  =*  heap_size_p;
     96  remaining_size  = *heap_size_p;
     97
    8798  if (remaining_start < LIMIT_32M &&
    8899      remaining_start + remaining_size > LIMIT_32M) {
     
    90101    rval = remaining_start + remaining_size - LIMIT_32M;
    91102    *heap_size_p = LIMIT_32M - remaining_start;
     103        remaining_start = LIMIT_32M;
     104        remaining_size  = rval;
    92105  }
     106
     107  if ( 0 != &BSP_sbrk_policy ) {
     108        switch ( BSP_sbrk_policy ) {
     109                case (uint32_t)(-1):
     110                        remaining_start  = heap_start + *heap_size_p;
     111                        remaining_size   = 0;
     112                        /* return a nonzero sbrk_amount because the libsupport code
     113                         * at some point divides by this number prior to trying an
     114                         * sbrk() which will fail.
     115                         */
     116                        rval = 1;
     117                break;
     118
     119                case 0:
     120                        remaining_size = 0;
     121                        /* see above for why we return 1 */
     122                        rval = 1;
     123                break;
     124
     125                default:
     126                        if ( rval > BSP_sbrk_policy )
     127                                rval = BSP_sbrk_policy;
     128                break;
     129        }
     130  }
     131
    93132  return rval;
    94133}
     
    98137  void *rval=(void*)-1;
    99138
     139  /* FIXME: BEWARE if size >2G */
    100140  if (incr <= remaining_size) {
    101141    remaining_size-=incr;
     
    105145    errno = ENOMEM;
    106146  }
     147#ifdef DEBUG
     148  printk("************* SBRK 0x%08x (ret 0x%08x) **********\n", incr, rval);
     149#endif
    107150  return rval;
    108151}
Note: See TracChangeset for help on using the changeset viewer.