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 5/9] hw/xtensa/xtfpga: refactor bootparameters filling
Date: Mon, 23 Jun 2014 20:12:52 +0400 [thread overview]
Message-ID: <1403539976-22581-6-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1403539976-22581-1-git-send-email-jcmvbkbc@gmail.com>
Separate filling first/last tag and size calculation from the kernel
command line setup.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
hw/xtensa/bootparam.h | 5 +++++
hw/xtensa/xtfpga.c | 28 ++++++++++++++++------------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/hw/xtensa/bootparam.h b/hw/xtensa/bootparam.h
index e6cf3b1..e839bee 100644
--- a/hw/xtensa/bootparam.h
+++ b/hw/xtensa/bootparam.h
@@ -16,6 +16,11 @@ typedef struct BpTag {
uint16_t size;
} BpTag;
+static inline size_t get_tag_size(size_t data_size)
+{
+ return data_size + sizeof(BpTag) + 4;
+}
+
static inline ram_addr_t put_tag(ram_addr_t addr, uint16_t tag,
size_t size, const void *data)
{
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 6d070b0..689d078 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -237,26 +237,30 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
/* Use presence of kernel file name as 'boot from SRAM' switch. */
if (kernel_filename) {
+ size_t bp_size = 2 * get_tag_size(0);
+ uint32_t tagptr = 0xfe000000 + board->sram_size;
+ uint32_t cur_tagptr;
+
rom = g_malloc(sizeof(*rom));
memory_region_init_ram(rom, NULL, "lx60.sram", board->sram_size);
vmstate_register_ram_global(rom);
memory_region_add_subregion(system_memory, 0xfe000000, rom);
+ if (kernel_cmdline) {
+ bp_size += get_tag_size(strlen(kernel_cmdline) + 1);
+ }
+
/* Put kernel bootparameters to the end of that SRAM */
+ tagptr = (tagptr - bp_size) & ~0xff;
+ cur_tagptr = put_tag(tagptr, BP_TAG_FIRST, 0, NULL);
+
if (kernel_cmdline) {
- size_t cmdline_size = strlen(kernel_cmdline) + 1;
- size_t bp_size = sizeof(BpTag[4]) + cmdline_size;
- uint32_t tagptr = (0xfe000000 + board->sram_size - bp_size) & ~0xff;
-
- env->regs[2] = tagptr;
-
- tagptr = put_tag(tagptr, BP_TAG_FIRST, 0, NULL);
- if (cmdline_size > 1) {
- tagptr = put_tag(tagptr, BP_TAG_COMMAND_LINE,
- cmdline_size, kernel_cmdline);
- }
- tagptr = put_tag(tagptr, BP_TAG_LAST, 0, NULL);
+ cur_tagptr = put_tag(cur_tagptr, BP_TAG_COMMAND_LINE,
+ strlen(kernel_cmdline) + 1, kernel_cmdline);
}
+ cur_tagptr = put_tag(cur_tagptr, BP_TAG_LAST, 0, NULL);
+ env->regs[2] = tagptr;
+
uint64_t elf_entry;
uint64_t elf_lowaddr;
int success = load_elf(kernel_filename, translate_phys_addr, cpu,
--
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 ` Max Filippov [this message]
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 ` [Qemu-devel] [PATCH 8/9] hw/xtensa/xtfpga: implement DTB loading Max Filippov
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-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).