From: Max Filippov <jcmvbkbc@gmail.com>
To: qemu-devel@nongnu.org
Cc: Max Filippov <jcmvbkbc@gmail.com>,
Waldemar Brodkorb <mail@waldemar-brodkorb.de>
Subject: [Qemu-devel] [PATCH 8/9] hw/xtensa/xtfpga: implement DTB loading
Date: Mon, 23 Jun 2014 20:12:55 +0400 [thread overview]
Message-ID: <1403539976-22581-9-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1403539976-22581-1-git-send-email-jcmvbkbc@gmail.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
hw/xtensa/xtfpga.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
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;
--
1.8.1.4
next prev parent reply other threads:[~2014-06-23 16:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 16:12 [Qemu-devel] [PATCH 0/9] target-xtensa: linux booting improvements Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 1/9] hw/xtensa: remove extraneous xtensa_ prefix from file names Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 2/9] hw/xtensa: replace fprintfs with error_report Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 3/9] hw/xtensa/xtfpga: retrieve parameters from machine_opts Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 4/9] hw/xtensa/xtfpga: use symbolic constants for bootparam tags Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 5/9] hw/xtensa/xtfpga: refactor bootparameters filling Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 6/9] hw/xtensa/xtfpga: add memory info to bootparam Max Filippov
2014-06-23 16:12 ` [Qemu-devel] [PATCH 7/9] hw/xtensa/xtfpga: implement uImage loading Max Filippov
2014-06-23 16:12 ` Max Filippov [this message]
2014-06-23 16:12 ` [Qemu-devel] [PATCH 9/9] hw/xtensa/xtfpga: implement initrd loading Max Filippov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403539976-22581-9-git-send-email-jcmvbkbc@gmail.com \
--to=jcmvbkbc@gmail.com \
--cc=mail@waldemar-brodkorb.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.