summaryrefslogtreecommitdiffstats
path: root/hw/xtensa/xtfpga.c
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2014-06-23 18:45:43 +0400
committerMax Filippov <jcmvbkbc@gmail.com>2014-06-29 02:32:42 +0400
commit996dfe98ed6bd57290f198ca29d0d9c614b4feef (patch)
treeb8c42d717bf6e9b7b02d4650fe0a3f3a9cf465a4 /hw/xtensa/xtfpga.c
parent364d4802429a5c7d3985f322e54a104024fd3f75 (diff)
downloadhqemu-996dfe98ed6bd57290f198ca29d0d9c614b4feef.zip
hqemu-996dfe98ed6bd57290f198ca29d0d9c614b4feef.tar.gz
hw/xtensa/xtfpga: implement DTB loading
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'hw/xtensa/xtfpga.c')
-rw-r--r--hw/xtensa/xtfpga.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 0e0d825..01825d6 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -37,6 +37,7 @@
#include "hw/block/flash.h"
#include "sysemu/blockdev.h"
#include "sysemu/char.h"
+#include "sysemu/device_tree.h"
#include "qemu/error-report.h"
#include "bootparam.h"
@@ -178,6 +179,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = qemu_opt_get(machine_opts, "kernel");
const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
+ const char *dtb_filename = qemu_opt_get(machine_opts, "dtb");
int n;
if (!cpu_model) {
@@ -246,6 +248,9 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
.start = tswap32(0),
.end = tswap32(machine->ram_size),
};
+ uint32_t lowmem_end = machine->ram_size < 0x08000000 ?
+ machine->ram_size : 0x08000000;
+ uint32_t cur_lowmem = QEMU_ALIGN_UP(lowmem_end / 2, 4096);
rom = g_malloc(sizeof(*rom));
memory_region_init_ram(rom, NULL, "lx60.sram", board->sram_size);
@@ -255,6 +260,9 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
if (kernel_cmdline) {
bp_size += get_tag_size(strlen(kernel_cmdline) + 1);
}
+ if (dtb_filename) {
+ bp_size += get_tag_size(sizeof(uint32_t));
+ }
/* Put kernel bootparameters to the end of that SRAM */
tagptr = (tagptr - bp_size) & ~0xff;
@@ -266,6 +274,21 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
cur_tagptr = put_tag(cur_tagptr, BP_TAG_COMMAND_LINE,
strlen(kernel_cmdline) + 1, kernel_cmdline);
}
+ if (dtb_filename) {
+ int fdt_size;
+ void *fdt = load_device_tree(dtb_filename, &fdt_size);
+ uint32_t dtb_addr = tswap32(cur_lowmem);
+
+ if (!fdt) {
+ error_report("could not load DTB '%s'\n", dtb_filename);
+ exit(EXIT_FAILURE);
+ }
+
+ cpu_physical_memory_write(cur_lowmem, fdt, fdt_size);
+ cur_tagptr = put_tag(cur_tagptr, BP_TAG_FDT,
+ sizeof(dtb_addr), &dtb_addr);
+ cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4096);
+ }
cur_tagptr = put_tag(cur_tagptr, BP_TAG_LAST, 0, NULL);
env->regs[2] = tagptr;
OpenPOWER on IntegriCloud