[OpenBIOS] [commit] r1257 - trunk/openbios-devel/arch/sparc32

repository service svn at openbios.org
Mon Jan 13 10:47:07 CET 2014


Author: mcayland
Date: Mon Jan 13 10:47:06 2014
New Revision: 1257
URL: http://tracker.coreboot.org/trac/openbios/changeset/1257

Log:
SPARC32: create proper romvec memory lists from OFMEM memory properties

Previously we would try and set safe values for the romvec properties list
rather than calculating them. This should provide older clients with a more
accurate representation of the memory areas they are allowed to use.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>

Modified:
   trunk/openbios-devel/arch/sparc32/boot.c
   trunk/openbios-devel/arch/sparc32/lib.c
   trunk/openbios-devel/arch/sparc32/romvec.c

Modified: trunk/openbios-devel/arch/sparc32/boot.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/boot.c	Mon Jan 13 10:47:04 2014	(r1256)
+++ trunk/openbios-devel/arch/sparc32/boot.c	Mon Jan 13 10:47:06 2014	(r1257)
@@ -8,6 +8,7 @@
 #include "drivers/drivers.h"
 #include "libc/diskio.h"
 #include "libc/vsprintf.h"
+#include "libopenbios/ofmem.h"
 #include "libopenbios/sys_info.h"
 #include "openprom.h"
 #include "boot.h"
@@ -20,17 +21,20 @@
 char boot_device;
 const void *romvec;
 
+static struct linux_mlist_v0 *totphyslist, *availlist, *prommaplist;
 
 static void setup_romvec(void)
 {
 	/* SPARC32 is slightly unusual in that before invoking any loaders, a romvec array
 	   needs to be set up to pass certain parameters using a C struct. Hence this function
 	   extracts the relevant boot information and places it in obp_arg. */
-	
-	int intprop, proplen, target, device;
+
+	int intprop, proplen, target, device, i;
+	unsigned int *intprop_ptr;
 	phandle_t chosen;
 	char *prop, *id, *name;
 	static char bootpathbuf[128], bootargsbuf[128], buf[128];
+	struct linux_mlist_v0 **pp;
 
 	/* Get the stdin and stdout paths */
 	chosen = find_dev("/chosen");
@@ -132,6 +136,60 @@
         	obp_arg.argv[1] = bootargsbuf;
 
 	}
+
+	/* Generate the totphys (total memory available) list */
+	prop = get_property(s_phandle_memory, "reg", &proplen);
+	intprop_ptr = (unsigned int *)prop;
+
+	for (pp = &totphyslist, i = 0; i < (proplen / sizeof(int)); pp = &(**pp).theres_more, i+=3) {
+		*pp = (struct linux_mlist_v0 *)malloc(sizeof(struct linux_mlist_v0));
+		(**pp).theres_more = NULL;
+		(**pp).start_adr = (char *)intprop_ptr[1];
+		(**pp).num_bytes = intprop_ptr[2];
+
+		printk("start_adr: %x\n", (int)(**pp).start_adr);
+		printk("num_bytes: %x\n", (**pp).num_bytes);
+
+		intprop_ptr += 3;
+	}
+
+	/* Generate the avail (physical memory available) list */
+	prop = get_property(s_phandle_memory, "available", &proplen);
+	intprop_ptr = (unsigned int *)prop;
+
+	for (pp = &availlist, i = 0; i < (proplen / sizeof(int)); pp = &(**pp).theres_more, i+=3) {
+		*pp = (struct linux_mlist_v0 *)malloc(sizeof(struct linux_mlist_v0));
+		(**pp).theres_more = NULL;
+		(**pp).start_adr = (char *)intprop_ptr[1];
+		(**pp).num_bytes = intprop_ptr[2];
+
+		intprop_ptr += 3;
+	}
+
+	/* Generate the prommap (taken virtual memory) list from inverse of available */
+	prop = get_property(s_phandle_mmu, "available", &proplen);
+	intprop_ptr = (unsigned int *)prop;
+
+	for (pp = &prommaplist, i = 0; i < (proplen / sizeof(int)); pp = &(**pp).theres_more, i+=3) {
+		*pp = (struct linux_mlist_v0 *)malloc(sizeof(struct linux_mlist_v0));
+		(**pp).theres_more = NULL;
+		(**pp).start_adr = (char *)(intprop_ptr[1] + intprop_ptr[2]);
+
+		if (i + 3 < (proplen / sizeof(int))) {
+			/* Size from next entry */
+			(**pp).num_bytes = (intprop_ptr[4] + intprop_ptr[5]) - (intprop_ptr[1] + intprop_ptr[2]);
+		} else {
+			/* Tail (size from top of virtual memory) */
+			(**pp).num_bytes = 0xffffffffUL - (intprop_ptr[1] + intprop_ptr[2]);
+		}
+
+		intprop_ptr += 3;
+	}
+
+	/* Finally set the memory properties */
+	((struct linux_romvec *)romvec)->pv_v0mem.v0_totphys = &totphyslist;
+	((struct linux_romvec *)romvec)->pv_v0mem.v0_available = &availlist;
+	((struct linux_romvec *)romvec)->pv_v0mem.v0_prommap = &prommaplist;
 }
 
 

Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c	Mon Jan 13 10:47:04 2014	(r1256)
+++ trunk/openbios-devel/arch/sparc32/lib.c	Mon Jan 13 10:47:06 2014	(r1257)
@@ -59,14 +59,6 @@
 unsigned long *l1;
 static unsigned long *context_table;
 
-static ucell *mem_reg = 0;
-static ucell *mem_avail = 0;
-static ucell *virt_avail = 0;
-
-static struct linux_mlist_v0 totphys[1];
-static struct linux_mlist_v0 totmap[1];
-static struct linux_mlist_v0 totavail[1];
-
 struct linux_mlist_v0 *ptphys;
 struct linux_mlist_v0 *ptmap;
 struct linux_mlist_v0 *ptavail;
@@ -200,55 +192,6 @@
     ofmem_arch_map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
 }
 
-static void
-update_memory_properties(void)
-{
-    /* Update the device tree memory properties from the master
-       totphys, totmap and totavail romvec arrays */
-    mem_reg[0] = 0;
-    mem_reg[1] = pointer2cell(totphys[0].start_adr);
-    mem_reg[2] = totphys[0].num_bytes;
-
-    virt_avail[0] = 0;
-    virt_avail[1] = 0;
-    virt_avail[2] = pointer2cell(totmap[0].start_adr);
-
-    mem_avail[0] = 0;
-    mem_avail[1] = pointer2cell(totavail[0].start_adr);
-    mem_avail[2] = totavail[0].num_bytes;
-}
-
-static void
-init_romvec_mem(void)
-{
-    ptphys = totphys;
-    ptmap = totmap;
-    ptavail = totavail;
-
-    /*
-     * Form memory descriptors.
-     */
-    totphys[0].theres_more = NULL;
-    totphys[0].start_adr = (char *) 0;
-    totphys[0].num_bytes = qemu_mem_size;
-
-    totavail[0].theres_more = NULL;
-    totavail[0].start_adr = (char *) 0;
-    totavail[0].num_bytes = va2pa((int)&_start) - PAGE_SIZE;
-
-    totmap[0].theres_more = NULL;
-    totmap[0].start_adr = &_start;
-    totmap[0].num_bytes = (unsigned long) &_iomem -
-        (unsigned long) &_start + PAGE_SIZE;
-
-    /* Pointers to device tree memory properties */
-    mem_reg = malloc(sizeof(ucell) * 3);
-    mem_avail = malloc(sizeof(ucell) * 3);
-    virt_avail = malloc(sizeof(ucell) * 3);
-
-    update_memory_properties();
-}
-
 char *obp_dumb_mmap(char *va, int which_io, unsigned int pa,
                     unsigned int size)
 {
@@ -326,8 +269,6 @@
     phys_addr_t virtregsize;
     ofmem_t *ofmem = ofmem_arch_get_private();
 
-    init_romvec_mem();
-
     /* Find the phandles for the /memory and /virtual-memory nodes */
     push_str("/memory");
     fword("find-package");

Modified: trunk/openbios-devel/arch/sparc32/romvec.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/romvec.c	Mon Jan 13 10:47:04 2014	(r1256)
+++ trunk/openbios-devel/arch/sparc32/romvec.c	Mon Jan 13 10:47:06 2014	(r1257)
@@ -461,9 +461,9 @@
     romvec0.pv_romvers = 3;
     romvec0.pv_plugin_revision = 2;
     romvec0.pv_printrev = 0x20019;
-    romvec0.pv_v0mem.v0_totphys = &ptphys;
-    romvec0.pv_v0mem.v0_prommap = &ptmap;
-    romvec0.pv_v0mem.v0_available = &ptavail;
+    romvec0.pv_v0mem.v0_totphys = NULL;
+    romvec0.pv_v0mem.v0_prommap = NULL;
+    romvec0.pv_v0mem.v0_available = NULL;
     romvec0.pv_nodeops = &nodeops0;
     romvec0.pv_bootstr = (void *)doublewalk;
     romvec0.pv_v0devops.v0_devopen = &obp_devopen_handler;



More information about the OpenBIOS mailing list