From patchwork Tue Jan 29 22:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10787289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAD4D14E1 for ; Tue, 29 Jan 2019 22:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4AF2D71D for ; Tue, 29 Jan 2019 22:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE2302D850; Tue, 29 Jan 2019 22:20:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6A6BA2D71D for ; Tue, 29 Jan 2019 22:20:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:56440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gobk3-0001LD-O4 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 29 Jan 2019 17:20:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gobjM-0000zg-SX for qemu-devel@nongnu.org; Tue, 29 Jan 2019 17:19:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gobjL-0002AD-Jd for qemu-devel@nongnu.org; Tue, 29 Jan 2019 17:19:44 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33934) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gobjL-00029X-E7 for qemu-devel@nongnu.org; Tue, 29 Jan 2019 17:19:43 -0500 Received: by mail-wm1-f65.google.com with SMTP id y185so14023675wmd.1 for ; Tue, 29 Jan 2019 14:19:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fLBmsXp0bbWDh7EVfYWi8Ar1o9k1Mbg4H+rUl9rkBq0=; b=fiAYYcJuJCC1vVmFbKa/zaEVdwLO90zmXAhBjEje+7zWAnru8DxNwpfAdYPEQtmTiQ h7IvyknXNBLRU7za5/KzlbO7uv9fK2VQNPQOjKYbz3mSd9QP++cgBNx0RWLyfWJMR8YT gd+4nbUviYw0xLvpMCq/zwf9e7EV+MxUEoidKUINuKOvHEuaj0TuZg+IVN7MO9jYNKdv E6RRIxomwWv3ed091v1fQQnfFBUly4wrLd46phq4tbHy1IqA4neaQlQO/+bf678Fo9lM J9tLGmno3xDLKhvkMRu4Vh484i44CwC+u46r14Mp1eXVAo4WG9HJH4udJgotDEroP48j gvhw== X-Gm-Message-State: AJcUukdbX69G7XHdheTe/19gfoENjKpfVCSfZK7DEs4UlcUupLg4Iq5D ccpTMxd9qUkqJESP3jr287aiM2Ln X-Google-Smtp-Source: ALg8bN7HNfMTtPVCh3IYmDVDx9Hb3Dti8N3ikHBIxQBHCO7DCZyQW4Ox2OFf19f2d7siU05rk9cP8g== X-Received: by 2002:a1c:cbc7:: with SMTP id b190mr24273877wmg.13.1548800381467; Tue, 29 Jan 2019 14:19:41 -0800 (PST) Received: from thl530.multi.box (pD9E83E15.dip0.t-ipconnect.de. [217.232.62.21]) by smtp.gmail.com with ESMTPSA id t5sm144864wmd.15.2019.01.29.14.19.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 14:19:40 -0800 (PST) From: Thomas Huth To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 23:19:28 +0100 Message-Id: <20190129221928.11522-1-huth@tuxfamily.org> X-Mailer: git-send-email 2.17.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.65 Subject: [Qemu-devel] [PATCH] hw/m68k/mcf5208: Support loading of bios images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The MCF5208EVB supports 2 MiB of flash at address 0. Add support for this memory region and some code to load the file that can be specified with the "-bios" command line option. This can be used for example to load U-Boot images for the MCF5208EVB (we still lack some features in the CPU emulation for this firmware, though, so it can not be run successfully yet). Signed-off-by: Thomas Huth Reviewed-by: Stefano Garzarella --- hw/m68k/mcf5208.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index 0f2245dd81..021194498d 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -27,6 +27,8 @@ #define SYS_FREQ 166666666 +#define ROM_SIZE 0x200000 + #define PCSR_EN 0x0001 #define PCSR_RLD 0x0002 #define PCSR_PIF 0x0004 @@ -227,6 +229,7 @@ static void mcf5208evb_init(MachineState *machine) hwaddr entry; qemu_irq *pic; MemoryRegion *address_space_mem = get_system_memory(); + MemoryRegion *rom = g_new(MemoryRegion, 1); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); @@ -237,6 +240,10 @@ static void mcf5208evb_init(MachineState *machine) env->vbr = 0; /* TODO: Configure BARs. */ + /* ROM at 0x00000000 */ + memory_region_init_rom(rom, NULL, "mcf5208.rom", ROM_SIZE, &error_fatal); + memory_region_add_subregion(address_space_mem, 0x0, rom); + /* DRAM at 0x40000000 */ memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size); memory_region_add_subregion(address_space_mem, 0x40000000, ram); @@ -285,9 +292,29 @@ static void mcf5208evb_init(MachineState *machine) /* 0xfc0a4000 GPIO. */ /* 0xfc0a8000 SDRAM controller. */ + /* Load firmware */ + if (bios_name) { + char *fn; + uint8_t *ptr; + + fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!fn) { + error_report("Could not find ROM image '%s'", bios_name); + exit(1); + } + if (load_image_targphys(fn, 0x0, ROM_SIZE) < 8) { + error_report("Could not load ROM image '%s'", bios_name); + exit(1); + } + g_free(fn); + ptr = rom_ptr(0x4, 4); + assert(ptr != NULL); + env->pc = ldl_p(ptr); + } + /* Load kernel. */ if (!kernel_filename) { - if (qtest_enabled()) { + if (qtest_enabled() || bios_name) { return; } error_report("Kernel image must be specified");