From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LsJWQ-0002Wo-C7 for qemu-devel@nongnu.org; Fri, 10 Apr 2009 12:24:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LsJWP-0002WE-Jr for qemu-devel@nongnu.org; Fri, 10 Apr 2009 12:24:05 -0400 Received: from [199.232.76.173] (port=57936 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsJWP-0002W6-64 for qemu-devel@nongnu.org; Fri, 10 Apr 2009 12:24:05 -0400 Received: from savannah.gnu.org ([199.232.41.3]:49620 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LsJWO-0005z6-TC for qemu-devel@nongnu.org; Fri, 10 Apr 2009 12:24:05 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LsJWL-0005Wq-61 for qemu-devel@nongnu.org; Fri, 10 Apr 2009 16:24:01 +0000 Received: from pbrook by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LsJWK-0005WP-23 for qemu-devel@nongnu.org; Fri, 10 Apr 2009 16:24:00 +0000 MIME-Version: 1.0 Errors-To: pbrook Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Paul Brook Message-Id: Date: Fri, 10 Apr 2009 16:24:00 +0000 Subject: [Qemu-devel] [7068] Wean device tree code off phys_ram_base. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7068 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7068 Author: pbrook Date: 2009-04-10 16:23:59 +0000 (Fri, 10 Apr 2009) Log Message: ----------- Wean device tree code off phys_ram_base. Signed-off-by: Paul Brook Modified Paths: -------------- trunk/device_tree.c trunk/device_tree.h trunk/hw/ppc440_bamboo.c trunk/hw/ppce500_mpc8544ds.c Modified: trunk/device_tree.c =================================================================== --- trunk/device_tree.c 2009-04-10 14:29:45 UTC (rev 7067) +++ trunk/device_tree.c 2009-04-10 16:23:59 UTC (rev 7068) @@ -25,34 +25,35 @@ #include -void *load_device_tree(const char *filename_path, void *load_addr) +void *load_device_tree(const char *filename_path, int *sizep) { - int dt_file_size; + int dt_size; int dt_file_load_size; int new_dt_size; int ret; - void *dt_file = NULL; - void *fdt; + void *fdt = NULL; - dt_file_size = get_image_size(filename_path); - if (dt_file_size < 0) { + *sizep = 0; + dt_size = get_image_size(filename_path); + if (dt_size < 0) { printf("Unable to get size of device tree file '%s'\n", filename_path); goto fail; } + /* Expand to 2x size to give enough room for manipulation. */ + dt_size *= 2; /* First allocate space in qemu for device tree */ - dt_file = qemu_mallocz(dt_file_size); + fdt = qemu_mallocz(dt_size); - dt_file_load_size = load_image(filename_path, dt_file); + dt_file_load_size = load_image(filename_path, fdt); + if (dt_file_load_size < 0) { + printf("Unable to open device tree file '%s'\n", + filename_path); + goto fail; + } - /* Second we place new copy of 2x size in guest memory - * This give us enough room for manipulation. - */ - new_dt_size = dt_file_size * 2; - - fdt = load_addr; - ret = fdt_open_into(dt_file, fdt, new_dt_size); + ret = fdt_open_into(fdt, fdt, dt_size); if (ret) { printf("Unable to copy device tree in memory\n"); goto fail; @@ -64,12 +65,11 @@ filename_path); goto fail; } - /* free qemu memory with old device tree */ - qemu_free(dt_file); + *sizep = dt_size; return fdt; fail: - qemu_free(dt_file); + qemu_free(fdt); return NULL; } Modified: trunk/device_tree.h =================================================================== --- trunk/device_tree.h 2009-04-10 14:29:45 UTC (rev 7067) +++ trunk/device_tree.h 2009-04-10 16:23:59 UTC (rev 7068) @@ -14,7 +14,7 @@ #ifndef __DEVICE_TREE_H__ #define __DEVICE_TREE_H__ -void *load_device_tree(const char *filename_path, void *load_addr); +void *load_device_tree(const char *filename_path, int *sizep); int qemu_devtree_setprop(void *fdt, const char *node_path, const char *property, uint32_t *val_array, int size); Modified: trunk/hw/ppc440_bamboo.c =================================================================== --- trunk/hw/ppc440_bamboo.c 2009-04-10 14:29:45 UTC (rev 7067) +++ trunk/hw/ppc440_bamboo.c 2009-04-10 16:23:59 UTC (rev 7068) @@ -27,7 +27,7 @@ #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" -static void *bamboo_load_device_tree(void *addr, +static void *bamboo_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base, target_phys_addr_t initrd_size, @@ -37,6 +37,7 @@ #ifdef HAVE_FDT uint32_t mem_reg_property[] = { 0, 0, ramsize }; char *path; + int fdt_size; int pathlen; int ret; @@ -45,7 +46,7 @@ snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE); - fdt = load_device_tree(path, addr); + fdt = load_device_tree(path, &fdt_size); free(path); if (fdt == NULL) goto out; @@ -75,6 +76,8 @@ if (kvm_enabled()) kvmppc_fdt_update(fdt); + cpu_physical_memory_write (addr, (void *)fdt, fdt_size); + out: #endif @@ -165,7 +168,7 @@ else dt_base = kernel_size + loadaddr; - fdt = bamboo_load_device_tree(phys_ram_base + dt_base, ram_size, + fdt = bamboo_load_device_tree(dt_base, ram_size, initrd_base, initrd_size, kernel_cmdline); if (fdt == NULL) { fprintf(stderr, "couldn't load device tree\n"); Modified: trunk/hw/ppce500_mpc8544ds.c =================================================================== --- trunk/hw/ppce500_mpc8544ds.c 2009-04-10 14:29:45 UTC (rev 7067) +++ trunk/hw/ppce500_mpc8544ds.c 2009-04-10 16:23:59 UTC (rev 7068) @@ -71,7 +71,7 @@ } #endif -static void *mpc8544_load_device_tree(void *addr, +static void *mpc8544_load_device_tree(target_phys_addr_t addr, uint32_t ramsize, target_phys_addr_t initrd_base, target_phys_addr_t initrd_size, @@ -81,6 +81,7 @@ #ifdef HAVE_FDT uint32_t mem_reg_property[] = {0, ramsize}; char *path; + int fdt_size; int pathlen; int ret; @@ -89,7 +90,7 @@ snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE); - fdt = load_device_tree(path, addr); + fdt = load_device_tree(path, &fdt_size); qemu_free(path); if (fdt == NULL) goto out; @@ -142,6 +143,8 @@ mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency"); } + cpu_physical_memory_write (addr, (void *)fdt, fdt_size); + out: #endif @@ -259,7 +262,7 @@ /* If we're loading a kernel directly, we must load the device tree too. */ if (kernel_filename) { - fdt = mpc8544_load_device_tree(phys_ram_base + dt_base, ram_size, + fdt = mpc8544_load_device_tree(dt_base, ram_size, initrd_base, initrd_size, kernel_cmdline); if (fdt == NULL) { fprintf(stderr, "couldn't load device tree\n");