[OpenBIOS] [PATCH 01/13] Change the SPARC32 build system so that OFMEM is now included within SPARC32 builds.

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Fri Dec 31 00:22:29 CET 2010


Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
---
 openbios-devel/arch/sparc32/build.xml             |    1 +
 openbios-devel/arch/sparc32/lib.c                 |   10 ++
 openbios-devel/arch/sparc32/ofmem_sparc32.c       |  135 +++++++++++++++++++++
 openbios-devel/config/examples/sparc32_config.xml |    2 +
 4 files changed, 148 insertions(+), 0 deletions(-)
 create mode 100644 openbios-devel/arch/sparc32/ofmem_sparc32.c

diff --git a/openbios-devel/arch/sparc32/build.xml b/openbios-devel/arch/sparc32/build.xml
index 222dfb7..3d2f71d 100644
--- a/openbios-devel/arch/sparc32/build.xml
+++ b/openbios-devel/arch/sparc32/build.xml
@@ -15,6 +15,7 @@
   <object source="udiv.S"/>
   <object source="linux_load.c"/>
   <object source="sys_info.c"/>
+  <object source="ofmem_sparc32.c"/>
   <object source="romvec.c"/>
   <object source="call-romvec.S"/>
   <object source="entry.S"/>
diff --git a/openbios-devel/arch/sparc32/lib.c b/openbios-devel/arch/sparc32/lib.c
index a30729f..10599ce 100644
--- a/openbios-devel/arch/sparc32/lib.c
+++ b/openbios-devel/arch/sparc32/lib.c
@@ -497,6 +497,16 @@ void obp_dumb_munmap(__attribute__((unused)) char *va,
     DPRINTF("obp_dumb_munmap: virta 0x%x, sz %d\n", (unsigned int)va, size);
 }
 
+void ofmem_arch_unmap_pages(ucell virt, ucell size)
+{
+    /* Currently do nothing */
+}
+
+void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
+{
+    /* Currently do nothing */
+}
+
 char *obp_dumb_memalloc(char *va, unsigned int size)
 {
     size = (size + 7) & ~7;
diff --git a/openbios-devel/arch/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c
new file mode 100644
index 0000000..fffd32a
--- /dev/null
+++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c
@@ -0,0 +1,135 @@
+/*
+ *	<ofmem_sparc32.c>
+ *
+ *	OF Memory manager
+ *
+ *   Copyright (C) 1999-2004 Samuel Rydh (samuel at ibrium.se)
+ *   Copyright (C) 2004 Stefan Reinauer
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation
+ *
+ */
+
+#include "config.h"
+#include "libopenbios/bindings.h"
+#include "libc/string.h"
+#include "libopenbios/ofmem.h"
+#include "asm/asi.h"
+#include "pgtsrmmu.h"
+
+#define OF_MALLOC_BASE		((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
+
+/* Temporarily very small */
+#define MEMSIZE (1 * 1024)
+static union {
+	char memory[MEMSIZE];
+	ofmem_t ofmem;
+} s_ofmem_data;
+
+#define OFMEM      	(&s_ofmem_data.ofmem)
+#define TOP_OF_RAM 	(s_ofmem_data.memory + MEMSIZE)
+
+translation_t **g_ofmem_translations = &s_ofmem_data.ofmem.trans;
+
+extern uint32_t qemu_mem_size;
+
+static inline size_t ALIGN_SIZE(size_t x, size_t a)
+{
+    return (x + a - 1) & ~(a-1);
+}
+
+static ucell get_heap_top( void )
+{
+	return (ucell)TOP_OF_RAM;
+}
+
+ofmem_t* ofmem_arch_get_private(void)
+{
+	return OFMEM;
+}
+
+void* ofmem_arch_get_malloc_base(void)
+{
+	return OF_MALLOC_BASE;
+}
+
+ucell ofmem_arch_get_heap_top(void)
+{
+	return get_heap_top();
+}
+
+ucell ofmem_arch_get_virt_top(void)
+{
+	return (ucell)TOP_OF_RAM;
+}
+
+phys_addr_t ofmem_arch_get_phys_top(void)
+{
+	ofmem_t *ofmem = ofmem_arch_get_private();
+
+	return (uintptr_t)ofmem->ramsize - 0x1000000;
+}
+
+retain_t *ofmem_arch_get_retained(void)
+{
+	/* Not used */
+	return 0;
+}
+
+int ofmem_arch_get_physaddr_cellsize(void)
+{
+	return 2;
+}
+
+int ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value)
+{
+	int n = 0;
+
+	p[n++] = value >> 32;
+	p[n++] = value;
+
+	return n;
+}
+
+int ofmem_arch_get_translation_entry_size(void)
+{
+	/* Return size of a single MMU package translation property entry in cells */
+	return 3;
+}
+
+void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t)
+{
+	/* Generate translation property entry for SPARC. While there is no
+	formal documentation for this, both Linux kernel and OpenSolaris sources
+	expect a translation property entry to have the following layout:
+
+		virtual address
+		length
+		mode
+	*/
+
+	transentry[0] = t->virt;
+	transentry[1] = t->size;
+	transentry[2] = t->mode;
+}
+
+/************************************************************************/
+/* misc                                                                 */
+/************************************************************************/
+
+ucell ofmem_arch_default_translation_mode( phys_addr_t phys )
+{
+	return SRMMU_REF | SRMMU_CACHE | SRMMU_PRIV;
+}
+
+/************************************************************************/
+/* init / cleanup                                                       */
+/************************************************************************/
+
+void ofmem_init( void )
+{
+	memset(&s_ofmem_data, 0, sizeof(s_ofmem_data));
+	s_ofmem_data.ofmem.ramsize = qemu_mem_size;
+}
diff --git a/openbios-devel/config/examples/sparc32_config.xml b/openbios-devel/config/examples/sparc32_config.xml
index 233bacb..ba4b7d7 100644
--- a/openbios-devel/config/examples/sparc32_config.xml
+++ b/openbios-devel/config/examples/sparc32_config.xml
@@ -26,6 +26,8 @@
   <option name="CONFIG_DEBLOCKER" type="boolean" value="true"/>
   <option name="CONFIG_FONT_8X8" type="boolean" value="true"/>
   <option name="CONFIG_FONT_8X16" type="boolean" value="false"/>
+  <option name="CONFIG_OFMEM" type="boolean" value="true"/>
+  <option name="CONFIG_OFMEM_MALLOC_ALIGN" type="integer" value="8"/>
   <option name="CONFIG_LOADER_AOUT" type="boolean" value="true"/>
   <option name="CONFIG_LOADER_BOOTINFO" type="boolean" value="false"/>
   <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/>
-- 
1.7.2.3




More information about the OpenBIOS mailing list