[OpenBIOS] [commit] r905 - trunk/openbios-devel/arch/ppc/qemu

repository service svn at openbios.org
Sat Oct 16 19:36:09 CEST 2010


Author: blueswirl
Date: Sat Oct 16 19:36:08 2010
New Revision: 905
URL: http://tracker.coreboot.org/trac/openbios/changeset/905

Log:
ppc: Move malloc zone

ofmem was fixed at 0x05400000, followed by the malloc zone. The latter was
bounded by the stack (now client stack), relative to the top of RAM.
An increase of RAM would therefore only enlarge the malloc zone.

Move the malloc zone below the client stack, with a fixed size of 2 MiB.
The size is derived from the memory map depicted in ofmem.c;
having a fixed size leaves room for memory claim'ed by clients
and by OpenBIOS.

v2:
* Through the preceding patch the malloc zone goes below the client stack
  rather than below the stack. Adjust and prettify the illustration.

Cc: Alexander Graf <agraf at suse.de>
Signed-off-by: Andreas Färber <andreas.faerber at web.de>
Signed-off-by: Blue Swirl <blauwirbel at gmail.com>

Modified:
   trunk/openbios-devel/arch/ppc/qemu/ofmem.c
   trunk/openbios-devel/arch/ppc/qemu/start.S

Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/ofmem.c	Sat Oct 16 19:36:04 2010	(r904)
+++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c	Sat Oct 16 19:36:08 2010	(r905)
@@ -47,11 +47,9 @@
 #define FREE_BASE		0x00004000
 #define OF_CODE_START	0xfff00000UL
 #define IO_BASE			0x80000000
-#define OFMEM			((ofmem_t*)0x05400000)
-
-#define OF_MALLOC_BASE		((char*)OFMEM + ((sizeof(ofmem_t) + 3) & ~3))
 
 #define HASH_SIZE		(2 << 15)
+#define OFMEM_SIZE		(2 * 1024 * 1024)
 
 #define	SEGR_USER		BIT(2)
 #define SEGR_BASE		0x0400
@@ -86,7 +84,7 @@
 unsigned long
 get_ram_top( void )
 {
-	return get_hash_base() - (32 + 64 + 64) * 1024;
+	return get_hash_base() - (32 + 64 + 64) * 1024 - OFMEM_SIZE;
 }
 
 unsigned long
@@ -107,12 +105,12 @@
 
 ofmem_t* ofmem_arch_get_private(void)
 {
-	return OFMEM;
+	return (ofmem_t*)(get_heap_top() - OFMEM_SIZE);
 }
 
 void* ofmem_arch_get_malloc_base(void)
 {
-	return OF_MALLOC_BASE;
+	return (char*)ofmem_arch_get_private() + ALIGN_SIZE(sizeof(ofmem_t), 4);
 }
 
 ucell ofmem_arch_get_heap_top(void)
@@ -388,15 +386,12 @@
 void
 setup_mmu( unsigned long ramsize )
 {
-	ofmem_t *ofmem = OFMEM;
+	ofmem_t *ofmem;
 	unsigned long sdr1, sr_base, msr;
 	unsigned long hash_base;
 	unsigned long hash_mask = 0xffff0000;
 	int i;
 
-	memset(ofmem, 0, sizeof(ofmem_t));
-	ofmem->ramsize = ramsize;
-
 	/* SDR1: Storage Description Register 1 */
 
 	if(is_ppc64())
@@ -415,6 +410,10 @@
 		asm volatile("mtsrin %0,%1" :: "r" (sr_base + i), "r" (j) );
 	}
 
+	ofmem = ofmem_arch_get_private();
+	memset(ofmem, 0, sizeof(ofmem_t));
+	ofmem->ramsize = ramsize;
+
 	memcpy((void *)get_rom_base(), (void *)OF_CODE_START, 0x00100000);
 
 	/* Enable MMU */

Modified: trunk/openbios-devel/arch/ppc/qemu/start.S
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/start.S	Sat Oct 16 19:36:04 2010	(r904)
+++ trunk/openbios-devel/arch/ppc/qemu/start.S	Sat Oct 16 19:36:08 2010	(r905)
@@ -313,17 +313,21 @@
 	 *     |                         |
 	 *     +-------------------------+
 	 *     |                         |
-	 *     | Exception Stack (32 kB)
+	 *     | Exception Stack (32 kB) |
 	 *     |                         |
 	 *     +-------------------------+
 	 *     |                         |
-	 *     | Stack (64 kB)
+	 *     | Stack (64 kB)           |
 	 *     |                         |
 	 *     +-------------------------+
 	 *     |                         |
 	 *     | Client Stack (64 kB)    |
 	 *     |                         |
 	 *     +-------------------------+
+	 *     |                         |
+	 *     | Malloc Zone (2 MiB)     |
+	 *     |                         |
+	 *     +-------------------------+
 	 *     :                         :
 	 * Bottom
 	 */



More information about the OpenBIOS mailing list