mirror of https://github.com/xqemu/xqemu.git
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
This commit is contained in:
parent
5c130f659b
commit
7ec632b45c
|
@ -25,34 +25,35 @@
|
||||||
|
|
||||||
#include <libfdt.h>
|
#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 dt_file_load_size;
|
||||||
int new_dt_size;
|
int new_dt_size;
|
||||||
int ret;
|
int ret;
|
||||||
void *dt_file = NULL;
|
void *fdt = NULL;
|
||||||
void *fdt;
|
|
||||||
|
|
||||||
dt_file_size = get_image_size(filename_path);
|
*sizep = 0;
|
||||||
if (dt_file_size < 0) {
|
dt_size = get_image_size(filename_path);
|
||||||
|
if (dt_size < 0) {
|
||||||
printf("Unable to get size of device tree file '%s'\n",
|
printf("Unable to get size of device tree file '%s'\n",
|
||||||
filename_path);
|
filename_path);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Expand to 2x size to give enough room for manipulation. */
|
||||||
|
dt_size *= 2;
|
||||||
/* First allocate space in qemu for device tree */
|
/* 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
|
ret = fdt_open_into(fdt, fdt, dt_size);
|
||||||
* 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);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Unable to copy device tree in memory\n");
|
printf("Unable to copy device tree in memory\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -64,12 +65,11 @@ void *load_device_tree(const char *filename_path, void *load_addr)
|
||||||
filename_path);
|
filename_path);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
/* free qemu memory with old device tree */
|
*sizep = dt_size;
|
||||||
qemu_free(dt_file);
|
|
||||||
return fdt;
|
return fdt;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
qemu_free(dt_file);
|
qemu_free(fdt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#ifndef __DEVICE_TREE_H__
|
#ifndef __DEVICE_TREE_H__
|
||||||
#define __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,
|
int qemu_devtree_setprop(void *fdt, const char *node_path,
|
||||||
const char *property, uint32_t *val_array, int size);
|
const char *property, uint32_t *val_array, int size);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
|
#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,
|
uint32_t ramsize,
|
||||||
target_phys_addr_t initrd_base,
|
target_phys_addr_t initrd_base,
|
||||||
target_phys_addr_t initrd_size,
|
target_phys_addr_t initrd_size,
|
||||||
|
@ -37,6 +37,7 @@ static void *bamboo_load_device_tree(void *addr,
|
||||||
#ifdef HAVE_FDT
|
#ifdef HAVE_FDT
|
||||||
uint32_t mem_reg_property[] = { 0, 0, ramsize };
|
uint32_t mem_reg_property[] = { 0, 0, ramsize };
|
||||||
char *path;
|
char *path;
|
||||||
|
int fdt_size;
|
||||||
int pathlen;
|
int pathlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ static void *bamboo_load_device_tree(void *addr,
|
||||||
|
|
||||||
snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE);
|
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);
|
free(path);
|
||||||
if (fdt == NULL)
|
if (fdt == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -75,6 +76,8 @@ static void *bamboo_load_device_tree(void *addr,
|
||||||
if (kvm_enabled())
|
if (kvm_enabled())
|
||||||
kvmppc_fdt_update(fdt);
|
kvmppc_fdt_update(fdt);
|
||||||
|
|
||||||
|
cpu_physical_memory_write (addr, (void *)fdt, fdt_size);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -165,7 +168,7 @@ static void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
|
||||||
else
|
else
|
||||||
dt_base = kernel_size + loadaddr;
|
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);
|
initrd_base, initrd_size, kernel_cmdline);
|
||||||
if (fdt == NULL) {
|
if (fdt == NULL) {
|
||||||
fprintf(stderr, "couldn't load device tree\n");
|
fprintf(stderr, "couldn't load device tree\n");
|
||||||
|
|
|
@ -71,7 +71,7 @@ out:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void *mpc8544_load_device_tree(void *addr,
|
static void *mpc8544_load_device_tree(target_phys_addr_t addr,
|
||||||
uint32_t ramsize,
|
uint32_t ramsize,
|
||||||
target_phys_addr_t initrd_base,
|
target_phys_addr_t initrd_base,
|
||||||
target_phys_addr_t initrd_size,
|
target_phys_addr_t initrd_size,
|
||||||
|
@ -81,6 +81,7 @@ static void *mpc8544_load_device_tree(void *addr,
|
||||||
#ifdef HAVE_FDT
|
#ifdef HAVE_FDT
|
||||||
uint32_t mem_reg_property[] = {0, ramsize};
|
uint32_t mem_reg_property[] = {0, ramsize};
|
||||||
char *path;
|
char *path;
|
||||||
|
int fdt_size;
|
||||||
int pathlen;
|
int pathlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ static void *mpc8544_load_device_tree(void *addr,
|
||||||
|
|
||||||
snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE);
|
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);
|
qemu_free(path);
|
||||||
if (fdt == NULL)
|
if (fdt == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -142,6 +143,8 @@ static void *mpc8544_load_device_tree(void *addr,
|
||||||
mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency");
|
mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpu_physical_memory_write (addr, (void *)fdt, fdt_size);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -259,7 +262,7 @@ static void mpc8544ds_init(ram_addr_t ram_size, int vga_ram_size,
|
||||||
|
|
||||||
/* If we're loading a kernel directly, we must load the device tree too. */
|
/* If we're loading a kernel directly, we must load the device tree too. */
|
||||||
if (kernel_filename) {
|
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);
|
initrd_base, initrd_size, kernel_cmdline);
|
||||||
if (fdt == NULL) {
|
if (fdt == NULL) {
|
||||||
fprintf(stderr, "couldn't load device tree\n");
|
fprintf(stderr, "couldn't load device tree\n");
|
||||||
|
|
Loading…
Reference in New Issue