summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-19 14:47:39 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-19 14:47:39 +0000
commit0375c72aaa7fd786e59b43b0cd3f9cf9f791ab8a (patch)
tree5252c745b8302cf0bc8fb2aa9a01c7dd230423f8 /c
parentPatch from Aleksey <qqi@world.std.com>: (diff)
downloadrtems-0375c72aaa7fd786e59b43b0cd3f9cf9f791ab8a.tar.bz2
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.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/i386/pc386/start/start.s6
-rw-r--r--c/src/lib/libbsp/i386/pc386/startup/bspstart.c49
2 files changed, 45 insertions, 10 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/start/start.s b/c/src/lib/libbsp/i386/pc386/start/start.s
index c2427500dc..323aa3d088 100644
--- a/c/src/lib/libbsp/i386/pc386/start/start.s
+++ b/c/src/lib/libbsp/i386/pc386/start/start.s
@@ -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
diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
index 24303b36a7..13e8610c42 100644
--- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
+++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
@@ -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. */