diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-05-21 15:30:30 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-05-21 15:30:30 +0000 |
commit | fdcfca01a5aac26545055b90502b1e2cd1ccddd2 (patch) | |
tree | f800d752e515373169e14695cb90a0219b4f2a03 /c/src/lib/libbsp/i386/pc386/startup/bspstart.c | |
parent | Fix formatting so script sees PR. (diff) | |
download | rtems-fdcfca01a5aac26545055b90502b1e2cd1ccddd2.tar.bz2 |
2004-05-21 Till Strauman <strauman@slac.stanford.edu>
* PR 624/bsps
startup/bspstart.c: When probing the memory, make sure not to
corrupt the application. Only probe addresses beyond rtemsFreeMemStart.
* Let IBMPC_outch() convert LF -> CRLF to avoid printk scrambling
the screen.
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c index 1162de1b88..6b3997d638 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @@ -81,39 +81,40 @@ void bsp_postdriver_hook(void); void bsp_pretasking_hook(void) { uint32_t topAddr, val; - int i; + int i, lowest; if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1)) /* not aligned => align it */ rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - if(_heap_size == 0) - { - /* - * We have to dynamically size memory. Memory size can be anything - * between 2M and 2048M. - * let us first write - */ - for(i=2048; i>=2; i--) - { - topAddr = i*1024*1024 - 4; - *(volatile uint32_t*)topAddr = topAddr; - } - - for(i=2; i<=2048; i++) - { - topAddr = i*1024*1024 - 4; - val = *(uint32_t*)topAddr; - if(val != topAddr) - { - break; - } - } - - topAddr = (i-1)*1024*1024 - 4; - - _heap_size = topAddr - rtemsFreeMemStart; + /* find the lowest 1M boundary to probe */ + lowest = ((rtemsFreeMemStart + (1<<20)) >> 20) + 1; + if ( lowest < 2 ) + lowest = 2; + + if (_heap_size == 0) { + /* + * We have to dynamically size memory. Memory size can be anything + * between no less than 2M and 2048M. + * let us first write + */ + for (i=2048; i>=lowest; i--) { + topAddr = i*1024*1024 - 4; + *(volatile uint32_t*)topAddr = topAddr; } + for(i=lowest; i<=2048; i++) { + topAddr = i*1024*1024 - 4; + val = *(uint32_t*)topAddr; + if (val != topAddr) { + break; + } + } + + topAddr = (i-1)*1024*1024 - 4; + + _heap_size = topAddr - rtemsFreeMemStart; + } + bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0); rtemsFreeMemStart += _heap_size; /* HEAP_SIZE in KBytes */ |