j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: mcayland Date: Fri May 21 13:07:53 2010 New Revision: 772 URL: http://tracker.coreboot.org/trac/openbios/changeset/772
Log: Move creation of MMU translation property entries into architecture-specific files, rather than in ofmem_common.c. This is because different architectures have different translation entries described within the OF platform bindings. With thanks to Andreas Färber and Igor Kovalenko.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.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 Mon May 3 13:29:38 2010 (r771) +++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Fri May 21 13:07:53 2010 (r772) @@ -141,6 +141,30 @@ 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 */ /************************************************************************/
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Mon May 3 13:29:38 2010 (r771) +++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Fri May 21 13:07:53 2010 (r772) @@ -69,6 +69,28 @@ 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 */ /************************************************************************/
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/ofmem.h Mon May 3 13:29:38 2010 (r771) +++ trunk/openbios-devel/include/libopenbios/ofmem.h Fri May 21 13:07:53 2010 (r772) @@ -63,6 +63,8 @@ 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);
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c ============================================================================== --- trunk/openbios-devel/libopenbios/ofmem_common.c Mon May 3 13:29:38 2010 (r771) +++ trunk/openbios-devel/libopenbios/ofmem_common.c Fri May 21 13:07:53 2010 (r772) @@ -182,15 +182,15 @@ 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",