Author: mcayland Date: Tue Apr 9 20:32:53 2013 New Revision: 1114 URL: http://tracker.coreboot.org/trac/openbios/changeset/1114
Log: SPARC32: Move Forth dictionary location to a fixed location.
Instead of using the automatic allocator to determine the location of the Forth dictionary, allocate it at a fixed location just underneath the ROM itself at 0xffd00000.
This patch also prevents corruption within the RAM of the Forth machine by ensuring that we allocate virtual memory outside of OpenBIOS itself, plus reduces the size of the Forth dictionary to 128K so that it meets the memory constraints required to boot Linux and also kadb from older versions of SunOS (as reported by Artyom Tarasenko).
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Tue Apr 9 20:32:49 2013 (r1113) +++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Tue Apr 9 20:32:53 2013 (r1114) @@ -61,7 +61,7 @@
ucell ofmem_arch_get_virt_top(void) { - return (ucell)TOP_OF_RAM; + return (ucell)OFMEM_VIRT_TOP; }
phys_addr_t ofmem_arch_get_phys_top(void)
Modified: trunk/openbios-devel/arch/sparc32/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/openbios.c Tue Apr 9 20:32:49 2013 (r1113) +++ trunk/openbios-devel/arch/sparc32/openbios.c Tue Apr 9 20:32:53 2013 (r1114) @@ -25,9 +25,9 @@ #include "packages/video.h" #define NO_QEMU_PROTOS #include "arch/common/fw_cfg.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc32/ofmem_sparc32.h"
-#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */ +#define MEMORY_SIZE (128*1024) /* 128K ram for hosted system */ #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" #define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
@@ -813,13 +813,16 @@ if (!phys) printk("panic: not enough physical memory on host system.\n");
- virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE); + virt = ofmem_claim_virt(OF_CODE_START - MEMORY_SIZE, MEMORY_SIZE, 0); if (!virt) printk("panic: not enough virtual memory on host system.\n");
/* Generate the mapping (and lock translation into the TLBs) */ ofmem_map(phys, virt, MEMORY_SIZE, ofmem_arch_default_translation_mode(phys));
+ /* Mark everything up until OFMEM_VIRT_TOP as in use */ + ofmem_claim_virt(OFMEM_VIRT_TOP, OF_CODE_START - MEMORY_SIZE - OFMEM_VIRT_TOP, 0); + /* we push start and end of memory to the stack * so that it can be used by the forth word QUIT * to initialize the memory allocator
Modified: trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h ============================================================================== --- trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h Tue Apr 9 20:32:49 2013 (r1113) +++ trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h Tue Apr 9 20:32:53 2013 (r1114) @@ -16,6 +16,9 @@
#include "libopenbios/ofmem.h"
+#define OF_CODE_START 0xffd00000 +#define OFMEM_VIRT_TOP 0xfe000000 + struct mem; extern struct mem cdvmem;
Sorry, somehow I missed testing this patch. It breaks loading kadb:
0 > boot disk kadb -kdvs Not a bootable ELF image Loading a.out image... Loaded 7680 bytes entry point is 0x4000 bootpath: /iommu/sbus/espdma/esp/sd@0,0
Jumping to entry point 00004000 for type 00000005... switching to new context: OFMEM: ofmem_claim phys=ffffffffffffffff size=00001000 align=00001000 OFMEM: ofmem_claim_virt virt=00000000 size=00001000 align=00001000 OFMEM: ofmem_map_page_range fdfff000 -> 000fdf000 00001000 mode 000000bc OFMEM: ofmem_claim phys=ffffffffffffffff size=00001000 align=00001000 OFMEM: ofmem_claim_virt virt=00000000 size=00001000 align=00001000 OFMEM: ofmem_map_page_range fdffe000 -> 000fde000 00001000 mode 000000bc OFMEM: ofmem_claim phys=ffffffffffffffff size=00001000 align=00001000 OFMEM: ofmem_claim_virt virt=00000000 size=00001000 align=00001000 OFMEM: ofmem_map_page_range fdffd000 -> 000fdd000 00001000 mode 000000bc OFMEM: ofmem_claim phys=ffffffffffffffff size=00014000 align=00014000 OFMEM: warning: bad alignment 00014000 rounded up to 00020000 OFMEM: ofmem_claim_virt virt=00000000 size=00014000 align=00014000 OFMEM: warning: bad alignment 00014000 rounded up to 00020000 OFMEM: ofmem_map_page_range fdfe0000 -> 000fc0000 00014000 mode 000000bc Boot Release 4.1.4 (sun4m) #2: Fri Oct 14 11:07:52 PDT 1994 Copyright (c) 1983-1990, Sun Microsystems, Inc. Boot: Romvec version 3. OFMEM: ofmem_claim phys=ffffffffffffffff size=00001000 align=00001000 OFMEM: ofmem_claim_virt virt=00000000 size=00001000 align=00001000 OFMEM: ofmem_map_page_range fdffc000 -> 000fdc000 00001000 mode 000000bc root on /iommu/sbus/espdma/esp/sd@0,0 fstype 4.2 Boot: kadb OFMEM: ofmem_claim phys=ffffffffffffffff size=00001000 align=00001000 OFMEM: ofmem_claim_virt virt=00000000 size=00001000 align=00001000 OFMEM: ofmem_map_page_range fdffb000 -> 000fdb000 00001000 mode 000000bc .Size: 121296........................ ....+103120+14200 bytes Statistics: OFMEM: ofmem_claim phys=ffffffffffffffff size=0003c000 align=0003c000 OFMEM: warning: bad alignment 0003c000 rounded up to 00040000 OFMEM: ofmem_claim_virt virt=ffc00000 size=0003c000 align=00000000 OFMEM: Non-free virtual memory claimed!
^^^^^
OFMEM: ofmem_map: Bad parameters (000f80000 FFFFFFFF 0003C000) OFMEM: ofmem_map_page_range fffff000 -> 000f80000 0003c000 mode 000000bc Unhandled Exception 0x00000002 PC = 0x00005b84 NPC = 0x00005b88 Stopping execution
On Tue, Apr 9, 2013 at 8:32 PM, repository service svn@openbios.org wrote:
Author: mcayland Date: Tue Apr 9 20:32:53 2013 New Revision: 1114 URL: http://tracker.coreboot.org/trac/openbios/changeset/1114
Log: SPARC32: Move Forth dictionary location to a fixed location.
Instead of using the automatic allocator to determine the location of the Forth dictionary, allocate it at a fixed location just underneath the ROM itself at 0xffd00000.
This patch also prevents corruption within the RAM of the Forth machine by ensuring that we allocate virtual memory outside of OpenBIOS itself, plus reduces the size of the Forth dictionary to 128K so that it meets the memory constraints required to boot Linux and also kadb from older versions of SunOS (as reported by Artyom Tarasenko).
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
--- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Tue Apr 9 20:32:49 2013 (r1113) +++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Tue Apr 9 20:32:53 2013 (r1114) @@ -61,7 +61,7 @@
ucell ofmem_arch_get_virt_top(void) {
return (ucell)TOP_OF_RAM;
return (ucell)OFMEM_VIRT_TOP;
}
phys_addr_t ofmem_arch_get_phys_top(void)
Modified: trunk/openbios-devel/arch/sparc32/openbios.c
--- trunk/openbios-devel/arch/sparc32/openbios.c Tue Apr 9 20:32:49 2013 (r1113) +++ trunk/openbios-devel/arch/sparc32/openbios.c Tue Apr 9 20:32:53 2013 (r1114) @@ -25,9 +25,9 @@ #include "packages/video.h" #define NO_QEMU_PROTOS #include "arch/common/fw_cfg.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc32/ofmem_sparc32.h"
-#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */ +#define MEMORY_SIZE (128*1024) /* 128K ram for hosted system */ #define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" #define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
@@ -813,13 +813,16 @@ if (!phys) printk("panic: not enough physical memory on host system.\n");
- virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE);
virt = ofmem_claim_virt(OF_CODE_START - MEMORY_SIZE, MEMORY_SIZE, 0); if (!virt) printk("panic: not enough virtual memory on host system.\n");
/* Generate the mapping (and lock translation into the TLBs) */ ofmem_map(phys, virt, MEMORY_SIZE, ofmem_arch_default_translation_mode(phys));
/* Mark everything up until OFMEM_VIRT_TOP as in use */
ofmem_claim_virt(OFMEM_VIRT_TOP, OF_CODE_START - MEMORY_SIZE - OFMEM_VIRT_TOP, 0);
/* we push start and end of memory to the stack * so that it can be used by the forth word QUIT * to initialize the memory allocator
Modified: trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h
--- trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h Tue Apr 9 20:32:49 2013 (r1113) +++ trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h Tue Apr 9 20:32:53 2013 (r1114) @@ -16,6 +16,9 @@
#include "libopenbios/ofmem.h"
+#define OF_CODE_START 0xffd00000 +#define OFMEM_VIRT_TOP 0xfe000000
struct mem; extern struct mem cdvmem;
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you
-- Regards, Artyom Tarasenko
linux/sparc and solaris/sparc under qemu blog: http://tyom.blogspot.com/search/label/qemu