From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
Laurent Vivier <laurent@vivier.eu>
Subject: [PULL 3/4] q800: implement mac rom reset function for BIOS-less mode
Date: Tue, 7 Jan 2020 14:27:14 +0100 [thread overview]
Message-ID: <20200107132715.722101-4-laurent@vivier.eu> (raw)
In-Reply-To: <20200107132715.722101-1-laurent@vivier.eu>
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
On Linux, calling `reboot(RB_AUTOBOOT);` will result in
arch/m68k/mac/misc.c's mac_reset function being called. That in turn
looks at the rombase (or uses 0x40800000 is there's no rombase), adds
0xa, and jumps to that address. At the moment, there's nothing there, so
the kernel just crashes when trying to reboot. So, this commit adds a
very simple implementation at that location, which just writes to via2
to power down. We also correct the value of ROMBASE while we're at it.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200102120150.281082-1-Jason@zx2c4.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
hw/m68k/q800.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 0c445c74bf..0e5a08f993 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -47,7 +47,7 @@
#include "sysemu/runstate.h"
#include "sysemu/reset.h"
-#define MACROM_ADDR 0x40000000
+#define MACROM_ADDR 0x40800000
#define MACROM_SIZE 0x00100000
#define MACROM_FILENAME "MacROM.bin"
@@ -128,6 +128,27 @@ static void main_cpu_reset(void *opaque)
cpu->env.pc = ldl_phys(cs->as, 4);
}
+static uint8_t fake_mac_rom[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ /* offset: 0xa - mac_reset */
+
+ /* via2[vDirB] |= VIA2B_vPower */
+ 0x20, 0x7C, 0x50, 0xF0, 0x24, 0x00, /* moveal VIA2_BASE+vDirB,%a0 */
+ 0x10, 0x10, /* moveb %a0@,%d0 */
+ 0x00, 0x00, 0x00, 0x04, /* orib #4,%d0 */
+ 0x10, 0x80, /* moveb %d0,%a0@ */
+
+ /* via2[vBufB] &= ~VIA2B_vPower */
+ 0x20, 0x7C, 0x50, 0xF0, 0x20, 0x00, /* moveal VIA2_BASE+vBufB,%a0 */
+ 0x10, 0x10, /* moveb %a0@,%d0 */
+ 0x02, 0x00, 0xFF, 0xFB, /* andib #-5,%d0 */
+ 0x10, 0x80, /* moveb %d0,%a0@ */
+
+ /* while (true) ; */
+ 0x60, 0xFE /* bras [self] */
+};
+
static void q800_init(MachineState *machine)
{
M68kCPU *cpu = NULL;
@@ -346,6 +367,12 @@ static void q800_init(MachineState *machine)
(graphic_width * graphic_depth + 7) / 8);
BOOTINFO1(cs->as, parameters_base, BI_MAC_SCCBASE, SCC_BASE);
+ rom = g_malloc(sizeof(*rom));
+ memory_region_init_ram_ptr(rom, NULL, "m68k_fake_mac.rom",
+ sizeof(fake_mac_rom), fake_mac_rom);
+ memory_region_set_readonly(rom, true);
+ memory_region_add_subregion(get_system_memory(), MACROM_ADDR, rom);
+
if (kernel_cmdline) {
BOOTINFOSTR(cs->as, parameters_base, BI_COMMAND_LINE,
kernel_cmdline);
--
2.24.1
next prev parent reply other threads:[~2020-01-07 14:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-07 13:27 [PULL 0/4] Q800 for 5.0 patches Laurent Vivier
2020-01-07 13:27 ` [PULL 1/4] q800: fix mac_via RTC PRAM commands Laurent Vivier
2020-01-07 13:27 ` [PULL 2/4] q800: add a block backend to the PRAM Laurent Vivier
2020-01-24 12:48 ` Peter Maydell
2020-02-10 11:51 ` Peter Maydell
2020-02-10 12:00 ` Laurent Vivier
2020-01-07 13:27 ` Laurent Vivier [this message]
2020-01-07 13:27 ` [PULL 4/4] target/m68k: only change valid bits in CACR Laurent Vivier
2020-01-07 17:54 ` [PULL 0/4] Q800 for 5.0 patches 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=20200107132715.722101-4-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=Jason@zx2c4.com \
--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).