From 12eab86f392d6b9ca6d732bed51d19e6267cac6e Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 21 May 2010 11:07:53 +0000 Subject: [PATCH] =?UTF-8?q?Move=20creation=20of=20MMU=20translation=20prop?= =?UTF-8?q?erty=20entries=20into=20architecture-specific=20files,=20rather?= =?UTF-8?q?=20than=20in=20ofmem=5Fcommon.c.=20This=20is=20because=20differ?= =?UTF-8?q?ent=20architectures=20have=20different=20translation=20entries?= =?UTF-8?q?=20described=20within=20the=20OF=20platform=20bindings.=20With?= =?UTF-8?q?=20thanks=20to=20Andreas=20F=C3=A4rber=20and=20Igor=20Kovalenko?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mark Cave-Ayland git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@772 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/ppc/qemu/ofmem.c | 24 ++++++++++++++++++++++++ arch/sparc64/ofmem_sparc64.c | 22 ++++++++++++++++++++++ include/libopenbios/ofmem.h | 2 ++ libopenbios/ofmem_common.c | 8 ++++---- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/arch/ppc/qemu/ofmem.c b/arch/ppc/qemu/ofmem.c index 9f8cd50..7631a1c 100644 --- a/arch/ppc/qemu/ofmem.c +++ b/arch/ppc/qemu/ofmem.c @@ -141,6 +141,30 @@ retain_t *ofmem_arch_get_retained(void) return NULL; } +int ofmem_arch_get_translation_entry_size(void) +{ + /* Return size of a single MMU package translation property entry in cells */ + return 4; +} + +void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t) +{ + /* Generate translation property entry for PPC. According to the + platform bindings for PPC (http://playground.sun.com/1275/bindings/ppc/release/ppc-2_1.html#REF34579) + a translation property entry has the following layout: + + virtual address + length + physical address + mode + */ + + transentry[0] = t->virt; + transentry[1] = t->size; + transentry[2] = t->phys; + transentry[3] = t->mode; +} + /************************************************************************/ /* OF private allocations */ /************************************************************************/ diff --git a/arch/sparc64/ofmem_sparc64.c b/arch/sparc64/ofmem_sparc64.c index 1a2623a..97e4afe 100644 --- a/arch/sparc64/ofmem_sparc64.c +++ b/arch/sparc64/ofmem_sparc64.c @@ -69,6 +69,28 @@ retain_t *ofmem_arch_get_retained(void) return (retain_t *)(qemu_mem_size - sizeof(retain_t)); } +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 */ /************************************************************************/ diff --git a/include/libopenbios/ofmem.h b/include/libopenbios/ofmem.h index bebeb1e..b79909c 100644 --- a/include/libopenbios/ofmem.h +++ b/include/libopenbios/ofmem.h @@ -63,6 +63,8 @@ extern void* ofmem_arch_get_malloc_base(void); extern ucell ofmem_arch_get_heap_top(void); extern ucell ofmem_arch_get_virt_top(void); extern retain_t* ofmem_arch_get_retained(void); +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( ucell phys ); extern void ofmem_arch_early_map_pages(ucell phys, ucell virt, ucell size, ucell mode); diff --git a/libopenbios/ofmem_common.c b/libopenbios/ofmem_common.c index 8a577b6..1e797b3 100644 --- a/libopenbios/ofmem_common.c +++ b/libopenbios/ofmem_common.c @@ -182,15 +182,15 @@ static void ofmem_update_mmu_translations( void ) for( t = ofmem->trans, ncells = 0; t ; t=t->next, ncells++ ) { } - props = malloc(ncells * sizeof(ucell) * 3); + props = malloc(ncells * sizeof(ucell) * ofmem_arch_get_translation_entry_size()); if (props == NULL) return; + /* Call architecture-specific routines to generate translation entries */ for( t = ofmem->trans, ncells = 0 ; t ; t=t->next ) { - props[ncells++] = t->virt; - props[ncells++] = t->size; - props[ncells++] = t->mode; + ofmem_arch_create_translation_entry(&props[ncells], t); + ncells += ofmem_arch_get_translation_entry_size(); } set_property(s_phandle_mmu, "translations",