diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2014-06-21 13:10:38 +0400 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2014-06-29 02:32:42 +0400 |
commit | a9a28591fbd4dc20d19b6408361b45c9b7300434 (patch) | |
tree | 7c734a7912988a20f315ab557eeb568c6a81b9e4 /hw/xtensa/xtfpga.c | |
parent | 62dbaede80b396aaae5394a9b6922b51be835e86 (diff) | |
download | qemu-a9a28591fbd4dc20d19b6408361b45c9b7300434.zip qemu-a9a28591fbd4dc20d19b6408361b45c9b7300434.tar.gz qemu-a9a28591fbd4dc20d19b6408361b45c9b7300434.tar.bz2 |
hw/xtensa/xtfpga: refactor bootparameters filling
Separate filling first/last tag and size calculation from the kernel
command line setup.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'hw/xtensa/xtfpga.c')
-rw-r--r-- | hw/xtensa/xtfpga.c | 28 |
1 files changed, 16 insertions, 12 deletions
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, |