summaryrefslogtreecommitdiff
path: root/device_tree.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-10 16:23:59 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-10 16:23:59 +0000
commit7ec632b45c223bc6a01a8f5a6549854e8624b0c0 (patch)
tree8baa43f3512ceb9962c193624e40b7df9cc9573b /device_tree.c
parent5c130f659b20d53667e07957ebaa3e656f72b276 (diff)
Wean device tree code off phys_ram_base.
Signed-off-by: Paul Brook <paul@codesourcery.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7068 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'device_tree.c')
-rw-r--r--device_tree.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/device_tree.c b/device_tree.c
index 4fc078159b..e213323dc2 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -25,34 +25,35 @@
#include <libfdt.h>
-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);
-
- /* 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;
+ 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;
+ }
- 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 @@ void *load_device_tree(const char *filename_path, void *load_addr)
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;
}