From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Thomas Huth <huth@tuxfamily.org>
Subject: [Qemu-devel] [PULL 13/13] hw/m68k/mcf5208: Support loading of bios images
Date: Thu, 28 Feb 2019 13:27:55 +0100 [thread overview]
Message-ID: <1551356875-30676-14-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1551356875-30676-1-git-send-email-thuth@redhat.com>
From: Thomas Huth <huth@tuxfamily.org>
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 <sgarzare@redhat.com>
Signed-off-by: Thomas Huth <huth@tuxfamily.org>
---
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 8531e07..6f6efae 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, 0x00000000, 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,30 @@ 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);
+ /* Initial PC is always at offset 4 in firmware binaries */
+ 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");
--
1.8.3.1
next prev parent reply other threads:[~2019-02-28 12:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 12:27 [Qemu-devel] [PULL 00/13] MAINTAINERS, test and m68k Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 01/13] MAINTAINERS: Add missing entries for the sun4u machines Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 02/13] MAINTAINERS: Add missing entries for the PC machines Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 03/13] MAINTAINERS: Add missing entries for the QObject section Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 04/13] MAINTAINERS: Add missing test entries to the Cryptography section Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 05/13] MAINTAINERS: Add an entry for the Dino machine Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 06/13] MAINTAINERS: Add maintainer to the POSIX subsystem Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 07/13] MAINTAINERS: Orphanize the 'GDB stub' subsystem Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 08/13] MAINTAINERS: Add maintainers to the Linux subsystem Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 09/13] MAINTAINERS: Add maintainer to the TCG/i386 subsystem Thomas Huth
2019-02-28 16:28 ` Richard Henderson
2019-02-28 17:41 ` Thomas Huth
2019-03-01 19:54 ` Richard Henderson
2019-02-28 12:27 ` [Qemu-devel] [PULL 10/13] MAINTAINERS: Add some missing entries for the sun4m machine Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 11/13] MAINTAINERS: Clean up the RISC-V TCG backend section Thomas Huth
2019-02-28 12:27 ` [Qemu-devel] [PULL 12/13] tests/test-qga: Reenable guest-agent qtest Thomas Huth
2019-02-28 12:27 ` Thomas Huth [this message]
2019-03-01 10:37 ` [Qemu-devel] [PULL 00/13] MAINTAINERS, test and m68k Peter Maydell
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=1551356875-30676-14-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=huth@tuxfamily.org \
--cc=peter.maydell@linaro.org \
--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).