From patchwork Mon Oct 31 22:17:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 122998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BDEE3B6F71 for ; Tue, 1 Nov 2011 10:11:50 +1100 (EST) Received: from localhost ([::1]:48741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RL0Bh-00009t-Bt for incoming@patchwork.ozlabs.org; Mon, 31 Oct 2011 18:18:37 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RL0Ax-0006u0-6W for qemu-devel@nongnu.org; Mon, 31 Oct 2011 18:17:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RL0Au-0004xR-O4 for qemu-devel@nongnu.org; Mon, 31 Oct 2011 18:17:51 -0400 Received: from [188.134.19.124] (port=52716 helo=octofox.metropolis) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RL0Au-0004vz-DQ for qemu-devel@nongnu.org; Mon, 31 Oct 2011 18:17:48 -0400 Received: from octofox.metropolis (localhost [127.0.0.1]) by octofox.metropolis (8.14.5/8.14.5) with ESMTP id p9VMHjEQ017375; Tue, 1 Nov 2011 02:17:45 +0400 Received: (from jcmvbkbc@localhost) by octofox.metropolis (8.14.5/8.14.5/Submit) id p9VMHjVk017374; Tue, 1 Nov 2011 02:17:45 +0400 From: Max Filippov To: Anthony Liguori Date: Tue, 1 Nov 2011 02:17:29 +0400 Message-Id: <1320099455-17326-5-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 1.7.6.4 In-Reply-To: <1320099455-17326-1-git-send-email-jcmvbkbc@gmail.com> References: <1320099455-17326-1-git-send-email-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 188.134.19.124 Cc: Blue Swirl , jcmvbkbc@gmail.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 2/3] xtensa_lx60: pass kernel arguments from -append X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create boot parameters in the end of SRAM region, insert kernel arguments specified in -append there. Signed-off-by: Max Filippov --- hw/xtensa_bootparam.h | 25 +++++++++++++++++++++++++ hw/xtensa_lx60.c | 24 ++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 hw/xtensa_bootparam.h diff --git a/hw/xtensa_bootparam.h b/hw/xtensa_bootparam.h new file mode 100644 index 0000000..38ef32b --- /dev/null +++ b/hw/xtensa_bootparam.h @@ -0,0 +1,25 @@ +#ifndef HW_XTENSA_BOOTPARAM +#define HW_XTENSA_BOOTPARAM + +typedef struct BpTag { + uint16_t tag; + uint16_t size; +} BpTag; + +static inline ram_addr_t put_tag(ram_addr_t addr, uint16_t tag, + size_t size, const void *data) +{ + BpTag bp_tag = { + .tag = tswap16(tag), + .size = tswap16((size + 3) & ~3), + }; + + cpu_physical_memory_write(addr, &bp_tag, sizeof(bp_tag)); + addr += sizeof(bp_tag); + cpu_physical_memory_write(addr, data, size); + addr += (size + 3) & ~3; + + return addr; +} + +#endif diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index cb047d2..069b21c 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -34,6 +34,7 @@ #include "pc.h" #include "sysbus.h" #include "flash.h" +#include "xtensa_bootparam.h" typedef struct LxBoardDesc { size_t flash_size; @@ -188,10 +189,6 @@ static void lx_init(const LxBoardDesc *board, memory_region_init_ram(ram, NULL, "xtensa.sram", ram_size); memory_region_add_subregion(system_memory, 0, ram); - rom = g_malloc(sizeof(*rom)); - memory_region_init_ram(rom, NULL, "xtensa.rom", 0x1000); - memory_region_add_subregion(system_memory, 0xfe000000, rom); - system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "system.io", 224 * 1024 * 1024); memory_region_add_subregion(system_memory, 0xf0000000, system_io); @@ -223,6 +220,25 @@ static void lx_init(const LxBoardDesc *board, /* Use presence of kernel file name as 'boot from SRAM' switch. */ if (kernel_filename) { + rom = g_malloc(sizeof(*rom)); + memory_region_init_ram(rom, NULL, "lx60.sram", board->sram_size); + memory_region_add_subregion(system_memory, 0xfe000000, rom); + + /* Put kernel bootparameters to the end of that SRAM */ + 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, 0x7b0b, 0, NULL); + if (cmdline_size > 1) { + tagptr = put_tag(tagptr, 0x1001, + cmdline_size, kernel_cmdline); + } + tagptr = put_tag(tagptr, 0x7e0b, 0, NULL); + } uint64_t elf_entry; uint64_t elf_lowaddr; int success = load_elf(kernel_filename, translate_phys_addr, env,