[OpenBIOS] [commit] r1019 - in trunk/openbios-devel: arch/ppc/qemu arch/sparc32 arch/sparc64 include/libopenbios libopenbios
repository service
svn at openbios.org
Tue Feb 8 23:06:47 CET 2011
Author: mcayland
Date: Tue Feb 8 23:06:46 2011
New Revision: 1019
URL: http://tracker.coreboot.org/trac/openbios/changeset/1019
Log:
Delegate construction of memory "available" property to each architecture.
This is required because some architectures do not strictly follow the convention
of using physical addresses sizes in the /memory node and virtual addresses in
the /virtual-memory node.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
Modified:
trunk/openbios-devel/arch/ppc/qemu/ofmem.c
trunk/openbios-devel/arch/sparc32/lib.c
trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
trunk/openbios-devel/include/libopenbios/ofmem.h
trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sun Jan 30 14:07:40 2011 (r1018)
+++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Tue Feb 8 23:06:46 2011 (r1019)
@@ -195,6 +195,30 @@
transentry[i++] = t->mode;
}
+/* Return the size of a memory available entry given the phandle in cells */
+int ofmem_arch_get_available_entry_size(phandle_t ph)
+{
+ if (ph == s_phandle_memory) {
+ return 1 + ofmem_arch_get_physaddr_cellsize();
+ } else {
+ return 1 + 1;
+ }
+}
+
+/* Generate memory available property entry for PPC */
+void ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size)
+{
+ int i = 0;
+
+ if (ph == s_phandle_memory) {
+ i += ofmem_arch_encode_physaddr(availentry, start);
+ } else {
+ availentry[i++] = start;
+ }
+
+ availentry[i] = size;
+}
+
/************************************************************************/
/* OF private allocations */
/************************************************************************/
Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c Sun Jan 30 14:07:40 2011 (r1018)
+++ trunk/openbios-devel/arch/sparc32/lib.c Tue Feb 8 23:06:46 2011 (r1019)
@@ -59,8 +59,6 @@
static unsigned long *context_table;
static unsigned long *l1;
-static phandle_t s_phandle_memory = 0;
-static phandle_t s_phandle_mmu = 0;
static ucell *mem_reg = 0;
static ucell *mem_avail = 0;
static ucell *virt_avail = 0;
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sun Jan 30 14:07:40 2011 (r1018)
+++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Tue Feb 8 23:06:46 2011 (r1019)
@@ -124,6 +124,30 @@
transentry[2] = t->mode;
}
+/* Return the size of a memory available entry given the phandle in cells */
+int ofmem_arch_get_available_entry_size(phandle_t ph)
+{
+ if (ph == s_phandle_memory) {
+ return 1 + ofmem_arch_get_physaddr_cellsize();
+ } else {
+ return 1 + 1;
+ }
+}
+
+/* Generate memory available property entry for Sparc32 */
+void ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size)
+{
+ int i = 0;
+
+ if (ph == s_phandle_memory) {
+ i += ofmem_arch_encode_physaddr(availentry, start);
+ } else {
+ availentry[i++] = start;
+ }
+
+ availentry[i] = size;
+}
+
/************************************************************************/
/* misc */
/************************************************************************/
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sun Jan 30 14:07:40 2011 (r1018)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Tue Feb 8 23:06:46 2011 (r1019)
@@ -110,6 +110,30 @@
transentry[2] = t->mode;
}
+/* Return the size of a memory available entry given the phandle in cells */
+int ofmem_arch_get_available_entry_size(phandle_t ph)
+{
+ if (ph == s_phandle_memory) {
+ return 1 + ofmem_arch_get_physaddr_cellsize();
+ } else {
+ return 1 + 1;
+ }
+}
+
+/* Generate memory available property entry for Sparc64 */
+void ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size)
+{
+ int i = 0;
+
+ if (ph == s_phandle_memory) {
+ i += ofmem_arch_encode_physaddr(availentry, start);
+ } else {
+ availentry[i++] = start;
+ }
+
+ availentry[i] = size;
+}
+
/************************************************************************/
/* misc */
/************************************************************************/
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sun Jan 30 14:07:40 2011 (r1018)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Tue Feb 8 23:06:46 2011 (r1019)
@@ -69,6 +69,8 @@
extern retain_t* ofmem_arch_get_retained(void);
extern int ofmem_arch_get_physaddr_cellsize(void);
extern int ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value);
+extern int ofmem_arch_get_available_entry_size(phandle_t ph);
+extern void ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size);
extern int ofmem_arch_get_translation_entry_size(void);
extern void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t);
extern ucell ofmem_arch_default_translation_mode( phys_addr_t phys );
@@ -120,6 +122,10 @@
extern void ofmem_release_virt( ucell virt, ucell size );
extern phys_addr_t ofmem_translate( ucell virt, ucell *ret_mode );
+/* memory and virtual-memory nodes */
+extern phandle_t s_phandle_memory;
+extern phandle_t s_phandle_mmu;
+
/* Currently the same for all architectures */
#define PAGE_SHIFT 12
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/ofmem_common.c Sun Jan 30 14:07:40 2011 (r1018)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c Tue Feb 8 23:06:46 2011 (r1019)
@@ -222,8 +222,8 @@
fword("encode-property");
}
-static phandle_t s_phandle_memory = 0;
-static phandle_t s_phandle_mmu = 0;
+phandle_t s_phandle_memory = 0;
+phandle_t s_phandle_mmu = 0;
static void ofmem_update_mmu_translations( void )
{
@@ -290,8 +290,7 @@
/* inverse of phys_range list could take 2 or more additional cells for the tail
For /memory, physical addresses may be wider than one ucell. */
- prop_used = (ncells + 1) * sizeof(ucell) *
- (((ph == s_phandle_memory) ? ofmem_arch_get_physaddr_cellsize() : 1) + 1);
+ prop_used = (ncells + 1) * sizeof(ucell) * ofmem_arch_get_available_entry_size(ph) + 1;
if (prop_used > *mem_prop_size) {
@@ -325,28 +324,16 @@
size = r->start - start;
if (size) {
- if (ph == s_phandle_memory) {
- /* physical address for /memory */
- ncells += ofmem_arch_encode_physaddr(&prop[ncells], start);
- } else {
- /* virtual address for MMU */
- prop[ncells++] = start;
- }
- prop[ncells++] = size;
+ ofmem_arch_create_available_entry(ph, &prop[ncells], start, size);
+ ncells += ofmem_arch_get_available_entry_size(ph);
}
start = r->start + r->size;
}
/* tail */
if (start < top_address) {
- if (ph == s_phandle_memory) {
- /* physical address for /memory */
- ncells += ofmem_arch_encode_physaddr(&prop[ncells], start);
- } else {
- /* virtual address for MMU */
- prop[ncells++] = start;
- }
- prop[ncells++] = top_address - start;
+ ofmem_arch_create_available_entry(ph, &prop[ncells], start, top_address - start);
+ ncells += ofmem_arch_get_available_entry_size(ph);
}
ofmem_set_property(ph, "available",
More information about the OpenBIOS
mailing list