Author: blueswirl Date: 2008-12-31 17:19:15 +0100 (Wed, 31 Dec 2008) New Revision: 333
Modified: openbios-devel/arch/ppc/qemu/init.c openbios-devel/arch/ppc/qemu/ofmem.c openbios-devel/include/ofmem.h Log: Define the translations property for cpu (Laurent Vivier)
Modified: openbios-devel/arch/ppc/qemu/init.c =================================================================== --- openbios-devel/arch/ppc/qemu/init.c 2008-12-31 16:18:34 UTC (rev 332) +++ openbios-devel/arch/ppc/qemu/init.c 2008-12-31 16:19:15 UTC (rev 333) @@ -28,6 +28,7 @@ #include "ofmem.h" #include "openbios-version.h" #include "libc/byteorder.h" +#include "libc/vsprintf.h" #define NO_QEMU_PROTOS #include "openbios/fw_cfg.h"
@@ -424,6 +425,7 @@ #endif uint64_t ram_size; const struct cpudef *cpu; + char buf[64];
devtree_init();
@@ -485,6 +487,8 @@ #ifdef CONFIG_DRIVER_PCI ob_pci_init(); #endif + snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name); + ofmem_register(find_dev(buf)); node_methods_init();
#ifdef USE_RTAS
Modified: openbios-devel/arch/ppc/qemu/ofmem.c =================================================================== --- openbios-devel/arch/ppc/qemu/ofmem.c 2008-12-31 16:18:34 UTC (rev 332) +++ openbios-devel/arch/ppc/qemu/ofmem.c 2008-12-31 16:19:15 UTC (rev 333) @@ -110,6 +110,36 @@ return (ulong)OF_MALLOC_BASE; }
+static phandle_t cpu_handle = 0; +static void +ofmem_update_translations( void ) +{ + ofmem_t *ofmem = OFMEM; + translation_t *t; + int ncells; + cell *props; + + if (cpu_handle == 0) + return; + + for( t = ofmem->trans, ncells = 0; t ; t=t->next, ncells++ ) + ; + + props = malloc(ncells * sizeof(cell) * 4); + if (props == NULL) + return; + + for( t = ofmem->trans, ncells = 0 ; t ; t=t->next ) { + props[ncells++] = t->virt; + props[ncells++] = t->size; + props[ncells++] = t->phys; + props[ncells++] = t->mode; + } + set_property(cpu_handle, "translations", + (char*)props, ncells * sizeof(cell)); + free(props); +} + /************************************************************************/ /* OF private allocations */ /************************************************************************/ @@ -502,6 +532,8 @@ t->next = *tt; *tt = t;
+ ofmem_update_translations(); + return 0; }
@@ -703,3 +735,10 @@ ofmem_claim_phys( get_ram_top(), get_ram_size() - get_ram_top(), 0); ofmem_claim_virt( get_ram_top(), get_ram_size() - get_ram_top(), 0); } + +void +ofmem_register( phandle_t ph ) +{ + cpu_handle = ph; + ofmem_update_translations(); +}
Modified: openbios-devel/include/ofmem.h =================================================================== --- openbios-devel/include/ofmem.h 2008-12-31 16:18:34 UTC (rev 332) +++ openbios-devel/include/ofmem.h 2008-12-31 16:19:15 UTC (rev 333) @@ -36,6 +36,7 @@ void dsi_exception( void ); void isi_exception( void ); void setup_mmu( ulong ramsize ); +void ofmem_register( phandle_t ph ); #endif
#endif /* _H_OFMEM */