Patch from Aleksey <qqi@world.std.com>:

This patch has same changes as one I sent to you earlier plus
    it fixes _heap_size problem for pc386 we had discussed earlier.

    Now, _heap_size is defined and set to 0 in pc386/startup/bspstart.c

    It can be patched to desireable value in binary image. If it is
    left unpatched, then startup code will determine size of memory
    (on the assumption that at least 2MB are present) and use
    max possible heap.
This commit is contained in:
Joel Sherrill
1998-08-19 14:47:39 +00:00
parent 2d7d605fdf
commit 0375c72aaa
2 changed files with 45 additions and 10 deletions

View File

@@ -48,7 +48,6 @@
| Size of heap and stack:
+----------------------------------------------------------------------------*/
.set HEAP_SIZE, 256
.set STACK_SIZE, 0x1000
/*----------------------------------------------------------------------------+
@@ -129,7 +128,6 @@ speakl: jmp speakl # and SPIN!!!
SYM (_establish_stack):
movl $_end, eax # eax = end of bss/start of heap
addl _heap_size, eax # eax = end of heap
addl $STACK_SIZE, eax # make room for stack
andl $0xffffffc0, eax # align it on 16 byte boundary
movl eax, esp # set stack pointer
@@ -175,10 +173,6 @@ END_CODE
BEGIN_DATA
PUBLIC(_heap_size)
SYM(_heap_size):
.long HEAP_SIZE << 10
PUBLIC(_stack_size)
SYM(_stack_size):
.long STACK_SIZE

View File

@@ -42,9 +42,16 @@
/*-------------------------------------------------------------------------+
| Global Variables
+--------------------------------------------------------------------------*/
extern rtems_unsigned32 _end; /* End of BSS. Defined in 'linkcmds'. */
extern rtems_unsigned32 _heap_size; /* Size of stack. Defined in 'start.s'. */
extern rtems_unsigned32 _stack_size; /* Size of heap. Defined in 'start.s'. */
extern rtems_unsigned32 _end; /* End of BSS. Defined in 'linkcmds'. */
/*
* Size of heap if it is 0 it will be dynamically defined by memory size,
* otherwise the value should be changed by binary patch
*/
rtems_unsigned32 _heap_size = 0;
/* Size of stack used during initialization. Defined in 'start.s'. */
extern rtems_unsigned32 _stack_size;
rtems_unsigned32 rtemsFreeMemStart;
/* Address of start of free memory - should be updated
@@ -81,9 +88,43 @@ extern void rtems_irq_mngt_init();
+--------------------------------------------------------------------------*/
void bsp_pretasking_hook(void)
{
rtems_unsigned32 topAddr, val;
int i;
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 rtems_unsigned32 *)topAddr = topAddr;
}
printk("\n");
for(i=2; i<=2048; i++)
{
topAddr = i*1024*1024 - 4;
val = *(rtems_unsigned32 *)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 */
@@ -105,7 +146,7 @@ void bsp_pretasking_hook(void)
+--------------------------------------------------------------------------*/
void bsp_start( void )
{
rtemsFreeMemStart = (rtems_unsigned32)&_end + _heap_size + _stack_size;
rtemsFreeMemStart = (rtems_unsigned32)&_end + _stack_size;
/* set the value of start of free memory. */
/* If we don't have command line arguments set default program name. */