Ignore:
Timestamp:
Sep 4, 2006, 11:29:29 PM (14 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
b59eff1
Parents:
f74578a2
Message:
  • startup/bspstart.c, start/start.S: Since the crude memory autodetection code can easily fail (boards with 'reserved' regions - I experienced a hard lockup on a dell precision 490 when writing past the bios-reported memory size) I added code that a) tries to save and use multiboot info, if present b) allows applications to override/set memory size via a weak alias.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/startup/bspstart.c

    rf74578a2 r662c157  
    4141+--------------------------------------------------------------------------*/
    4242extern uint32_t         _end;         /* End of BSS. Defined in 'linkcmds'. */
     43
     44/* rudimentary multiboot info */
     45struct multiboot_info {
     46        uint32_t        flags;          /* start.S only raises flags for items actually saved; this allows us to check for the size of the data structure */
     47        uint32_t        mem_lower;      /* avail kB in lower memory */
     48        uint32_t        mem_upper;      /* avail kB in lower memory */
     49        /* ... (unimplemented) */
     50};
     51
     52extern struct multiboot_info _boot_multiboot_info;
    4353/*
    4454 * Size of heap if it is 0 it will be dynamically defined by memory size,
     
    4656 */
    4757uint32_t         _heap_size = 0;
     58
     59/* Alternative way to hardcode the board's memory size [rather than heap size].
     60 * Can easily be overridden by application.
     61 */
     62extern uint32_t bsp_mem_size __attribute__ ((weak, alias("bsp_mem_size_default")));
     63uint32_t bsp_mem_size_default = 0;
    4864
    4965/* Size of stack used during initialization. Defined in 'start.s'.  */
     
    93109      lowest = 2;
    94110
     111  /* The memory detection algorithm is very crude; try
     112   * to use multiboot info, if possible (set from start.S)
     113   */
     114  if (   bsp_mem_size == 0
     115      && (_boot_multiboot_info.flags & 1)
     116      && _boot_multiboot_info.mem_upper ) {
     117    bsp_mem_size = _boot_multiboot_info.mem_upper * 1024;
     118  }
     119
    95120  if (_heap_size == 0) {
    96     /*
    97      * We have to dynamically size memory. Memory size can be anything
    98      * between no less than 2M and 2048M.
    99      * let us first write
    100      */
    101     for (i=2048; i>=lowest; i--) {
    102       topAddr = i*1024*1024 - 4;
    103       *(volatile uint32_t*)topAddr = topAddr;
    104     }
    105 
    106    for(i=lowest; i<=2048; i++) {
    107      topAddr = i*1024*1024 - 4;
    108      val =  *(uint32_t*)topAddr;
    109      if (val != topAddr) {
    110        break;
    111      }
    112    }
    113 
    114     topAddr = (i-1)*1024*1024 - 4;
     121
     122    if ( bsp_mem_size == 0 ) {
     123        /*
     124         * We have to dynamically size memory. Memory size can be anything
     125         * between no less than 2M and 2048M.
     126         * let us first write
     127         */
     128        for (i=2048; i>=lowest; i--) {
     129          topAddr = i*1024*1024 - 4;
     130          *(volatile uint32_t*)topAddr = topAddr;
     131        }
     132
     133        for(i=lowest; i<=2048; i++) {
     134          topAddr = i*1024*1024 - 4;
     135          val =  *(uint32_t*)topAddr;
     136          if (val != topAddr) {
     137            break;
     138          }
     139        }
     140     
     141        topAddr = (i-1)*1024*1024 - 4;
     142
     143      } else {
     144
     145        topAddr = bsp_mem_size;
     146
     147      }
    115148
    116149    _heap_size = topAddr - rtemsFreeMemStart;
     
    144177  Calibrate_loop_1ms();
    145178
     179  /* set the value of start of free memory. */
    146180  rtemsFreeMemStart = (uint32_t)&_end + _stack_size;
    147                                     /* set the value of start of free memory. */
    148181
    149182  /* If we don't have command line arguments set default program name. */
Note: See TracChangeset for help on using the changeset viewer.