From nobody Fri Apr 26 00:10:44 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549658052648672.9627475565201; Fri, 8 Feb 2019 12:34:12 -0800 (PST) Received: from localhost ([127.0.0.1]:34081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsCqe-00066O-Lo for importer@patchew.org; Fri, 08 Feb 2019 15:34:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsCpg-0005kj-Rp for qemu-devel@nongnu.org; Fri, 08 Feb 2019 15:33:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsCpg-0000mi-1z for qemu-devel@nongnu.org; Fri, 08 Feb 2019 15:33:08 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gsCpf-0000kF-Rs for qemu-devel@nongnu.org; Fri, 08 Feb 2019 15:33:07 -0500 Received: by mail-wm1-f67.google.com with SMTP id v26so5302126wmh.3 for ; Fri, 08 Feb 2019 12:33:07 -0800 (PST) Received: from thl530.multi.box (p5791D7D0.dip0.t-ipconnect.de. [87.145.215.208]) by smtp.gmail.com with ESMTPSA id c202sm5643061wmd.40.2019.02.08.10.33.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 10:33:14 -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=l43QgKL8EQqjY0x0O281L8qGcn++nyVqerr9Lgz4m7U=; b=PMpjPgR3c4M4Rryj1zxbtUcqepTLvA/XzXYflxh9m/wPj4Qg75vUhRcyyvBA03X6Ay z+TWljf9yE9BBQyInKSsQY0Qn6RZCMESuom8VxPqaE8CWOv+1hg8nr1j2bhN2tLBO3ww kJivJsjIOsSoiBnPCja4GMpjazPnnPL+nXekorRF1l2lsNVPP7onK31h9FoB0K0geRwm EXTZEM+vICwzMrMbXCUf7p7YQ7j4EHuHniUJtmPpj5VIyrXSpxcdM4XoufdTMMmcy2xR Sx51+JsPa/pFjgsHaLobdnb9KeSyfKqoX4/o9z+aj+QmfiRU257Kbood6R1LAnmG2w7m TOhA== X-Gm-Message-State: AHQUAuZlo+B610cOW/Nw+giWot6ZVhjS042GnNdmhVRWIq14wY5Vp/xI Lk46sQEuPdpavzUgsdhf9camf8Dc X-Google-Smtp-Source: AHgI3Iay2wmr7FB/VQ0UuD/CgyMrVNadiawqxiJZA/e738udNgs6FT4nSbOynt084r6ZrCue58BMkg== X-Received: by 2002:adf:b68a:: with SMTP id j10mr4083958wre.224.1549650795662; Fri, 08 Feb 2019 10:33:15 -0800 (PST) From: Thomas Huth To: qemu-devel@nongnu.org Date: Fri, 8 Feb 2019 19:33:07 +0100 Message-Id: <20190208183307.2499-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.67 Subject: [Qemu-devel] [PATCH v2] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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). Reviewed-by: Stefano Garzarella Signed-off-by: Thomas Huth --- v2: Added a comment about the initial PC hw/m68k/mcf5208.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index 0f2245dd81..e1fd9dfd53 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -27,6 +27,8 @@ =20 #define SYS_FREQ 166666666 =20 +#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 =3D get_system_memory(); + MemoryRegion *rom =3D g_new(MemoryRegion, 1); MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 @@ -237,6 +240,10 @@ static void mcf5208evb_init(MachineState *machine) env->vbr =3D 0; /* TODO: Configure BARs. */ =20 + /* ROM at 0x00000000 */ + memory_region_init_rom(rom, NULL, "mcf5208.rom", ROM_SIZE, &error_fata= l); + memory_region_add_subregion(address_space_mem, 0x00000000, rom); + /* DRAM at 0x40000000 */ memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_siz= e); memory_region_add_subregion(address_space_mem, 0x40000000, ram); @@ -285,9 +292,30 @@ static void mcf5208evb_init(MachineState *machine) /* 0xfc0a4000 GPIO. */ /* 0xfc0a8000 SDRAM controller. */ =20 + /* Load firmware */ + if (bios_name) { + char *fn; + uint8_t *ptr; + + fn =3D 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); + /* Initial PC is always at offset 4 in firmware binaries */ + ptr =3D rom_ptr(0x4, 4); + assert(ptr !=3D NULL); + env->pc =3D ldl_p(ptr); + } + /* Load kernel. */ if (!kernel_filename) { - if (qtest_enabled()) { + if (qtest_enabled() || bios_name) { return; } error_report("Kernel image must be specified"); --=20 2.17.2