[hatari-devel] VME access |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
I'm thinking of making VME register access run-
time configurable, so that Hatari TT emulation can
be used with Linux.
Any comments on the attached patch to implement that?
- Eero
commit 79d204d04be354b025006e655520abb44f783d86
Author: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Sat Jan 2 21:04:39 2021 +0200
Make MegaSTE/TT VME access error disabling run-time configurable
Because it's needed for TOS MegaSTE detection, but causes Linux
TT boot to fail, due to missing VME emulation.
diff --git a/doc/hatari.1 b/doc/hatari.1
index 8940400c..123d76e9 100644
--- a/doc/hatari.1
+++ b/doc/hatari.1
@@ -481,6 +481,13 @@ Select machine type (x = st, megast, ste, megaste, tt or falcon)
.B \-\-blitter <bool>
Enable blitter emulation (ST only)
.TP
+.B \-\-vme\-errors <bool>
+Hatari doesn't emulate VME yet, and this controls whether access to
+VME registers causes errors. TOS uses VME registers just to detect
+MegaSTE, so disable errors to support that (and to use 14MB of RAM on
+VME machines). M68k Linux actually sets up SCU interrupts after
+detecting VME, so enable errors for Linux (MegaSTE/TT only)
+.TP
.B \-\-dsp <x>
Falcon DSP emulation (x = none, dummy or emu, Falcon only)
.TP
diff --git a/doc/manual.html b/doc/manual.html
index fc8b5628..94f4ecde 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -997,6 +997,14 @@ megaste, tt or falcon)</p>
<p class="parameter">--blitter
<bool></p>
<p class="paramdesc">Enable blitter emulation (ST only)</p>
+<p class="parameter">--vme-errors <bool></p>
+<p class="paramdesc">
+Hatari doesn't emulate VME yet, and this controls whether access to
+VME registers causes errors. TOS uses VME registers just to detect
+MegaSTE, so disable errors to support that (and to use 14MB of RAM on
+VME machines). M68k Linux actually sets up SCU interrupts after
+detecting VME, so enable errors for Linux (MegaSTE/TT only)
+</p>
<p class="parameter">--dsp <x></p>
<p class="paramdesc">Falcon DSP emulation (x = none, dummy
or emu, Falcon only)</p>
diff --git a/src/configuration.c b/src/configuration.c
index d487469d..a418c715 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -602,6 +602,7 @@ static const struct Config_Tag configs_System[] =
{ "bCompatibleCpu", Bool_Tag, &ConfigureParams.System.bCompatibleCpu },
{ "nModelType", Int_Tag, &ConfigureParams.System.nMachineType },
{ "bBlitter", Bool_Tag, &ConfigureParams.System.bBlitter },
+ { "bVmeErrors", Bool_Tag, &ConfigureParams.System.bVmeErrors },
{ "nDSPType", Int_Tag, &ConfigureParams.System.nDSPType },
{ "bPatchTimerD", Bool_Tag, &ConfigureParams.System.bPatchTimerD },
{ "bFastBoot", Bool_Tag, &ConfigureParams.System.bFastBoot },
@@ -899,6 +900,7 @@ void Configuration_SetDefault(void)
ConfigureParams.System.VideoTimingMode = VIDEO_TIMING_MODE_WS3;
ConfigureParams.System.bCompatibleCpu = true;
ConfigureParams.System.bBlitter = false;
+ ConfigureParams.System.bVmeErrors = false;
ConfigureParams.System.bPatchTimerD = false;
ConfigureParams.System.bFastBoot = false;
ConfigureParams.System.bFastForward = false;
@@ -1291,6 +1293,7 @@ void Configuration_MemorySnapShot_Capture(bool bSave)
MemorySnapShot_Store(&ConfigureParams.System.bCompatibleCpu, sizeof(ConfigureParams.System.bCompatibleCpu));
MemorySnapShot_Store(&ConfigureParams.System.nMachineType, sizeof(ConfigureParams.System.nMachineType));
MemorySnapShot_Store(&ConfigureParams.System.bBlitter, sizeof(ConfigureParams.System.bBlitter));
+ MemorySnapShot_Store(&ConfigureParams.System.bVmeErrors, sizeof(ConfigureParams.System.bVmeErrors));
MemorySnapShot_Store(&ConfigureParams.System.nDSPType, sizeof(ConfigureParams.System.nDSPType));
MemorySnapShot_Store(&bOldRealTimeClock, sizeof(bOldRealTimeClock)); /* TODO: Can be removed later */
MemorySnapShot_Store(&ConfigureParams.System.bPatchTimerD, sizeof(ConfigureParams.System.bPatchTimerD));
diff --git a/src/includes/configuration.h b/src/includes/configuration.h
index ace90653..25b58112 100644
--- a/src/includes/configuration.h
+++ b/src/includes/configuration.h
@@ -380,6 +380,7 @@ typedef struct
bool bCompatibleCpu; /* Prefetch mode */
MACHINETYPE nMachineType;
bool bBlitter; /* TRUE if Blitter is enabled */
+ bool bVmeErrors; /* TRUE for MegaSTE/TT VME errors */
DSPTYPE nDSPType; /* how to "emulate" DSP */
bool bPatchTimerD;
bool bFastBoot; /* Enable to patch TOS for fast boot */
diff --git a/src/ioMem.c b/src/ioMem.c
index 6b3c92e8..7133c3d1 100644
--- a/src/ioMem.c
+++ b/src/ioMem.c
@@ -182,6 +182,20 @@ static void IoMem_FixVoidAccessForMegaST(void)
}
}
+/*
+ * Disable errors on accessing VME registers
+ */
+static void IoMem_DisableVmeErrors(void)
+{
+ int addr;
+
+ /* TOS uses VME FF8E09 address to detect Mega-STE */
+ for (addr = 0xff8e01; addr <= 0xff8e0f; addr += 2)
+ {
+ pInterceptReadTable[addr - 0xff8000] = IoMem_ReadWithoutInterception;
+ pInterceptWriteTable[addr - 0xff8000] = IoMem_WriteWithoutInterception;
+ }
+}
/**
* Fix up the IO memory access table for the Mega STE.
@@ -202,13 +216,6 @@ static void IoMem_FixAccessForMegaSTE(void)
pInterceptReadTable[0xff8e23 - 0xff8000] = IoMem_VoidRead;
pInterceptWriteTable[0xff8e23 - 0xff8000] = IoMem_VoidWrite;
- /* VME bus - we don't support it yet, but TOS uses FF8E09 to detect the Mega-STE */
- for (addr = 0xff8e01; addr <= 0xff8e0f; addr += 2)
- {
- pInterceptReadTable[addr - 0xff8000] = IoMem_ReadWithoutInterception;
- pInterceptWriteTable[addr - 0xff8000] = IoMem_WriteWithoutInterception;
- }
-
/* The Mega-STE has a Z85C30 SCC serial port, too: */
for (addr = 0xff8c80; addr <= 0xff8c87; addr++)
{
@@ -329,6 +336,18 @@ void IoMem_Init(void)
IoMem_FixAccessForMegaSTE();
+ /*
+ * VME bus - we don't support it yet, but whether accessing VME registers
+ * on machines with VME (MegaSTE/TT) is run-time configurable because:
+ * - TOS uses FF8E09 to detect Mega-STE, so VME address errors need to
+ * be disabled to support that
+ * - Linux actually uses VME, so it fails to boot, if VME register accesses
+ * don't give errors, but VME doesn't work properly
+ */
+ if (!ConfigureParams.System.bVmeErrors &&
+ (Config_IsMachineTT() || Config_IsMachineMegaSTE()))
+ IoMem_DisableVmeErrors();
+
/* Set registers for Falcon */
if (Config_IsMachineFalcon())
{
diff --git a/src/ioMemTabTT.c b/src/ioMemTabTT.c
index 4de5f246..5c211206 100644
--- a/src/ioMemTabTT.c
+++ b/src/ioMemTabTT.c
@@ -180,6 +180,7 @@ const INTERCEPT_ACCESS_FUNC IoMemTable_TT[] =
{ 0xff8c80, 8, SCC_IoMem_ReadByte, SCC_IoMem_WriteByte }, /* SCC */
{ 0xff8c88, 8, IoMem_VoidRead_00, IoMem_VoidWrite }, /* No bus error here */
+#if 0 /* set at run-time for MegaSTE & TT in ioMem.c */
{ 0xff8e01, 1, IoMem_ReadWithoutInterception, IoMem_WriteWithoutInterception }, /* SCU system interrupt mask */
{ 0xff8e03, 1, IoMem_ReadWithoutInterception, IoMem_WriteWithoutInterception }, /* SCU system interrupt state */
{ 0xff8e05, 1, IoMem_ReadWithoutInterception, IoMem_WriteWithoutInterception }, /* SCU system interrupter */
@@ -188,6 +189,7 @@ const INTERCEPT_ACCESS_FUNC IoMemTable_TT[] =
{ 0xff8e0b, 1, IoMem_ReadWithoutInterception, IoMem_WriteWithoutInterception }, /* SCU general purpose 2 */
{ 0xff8e0d, 1, IoMem_ReadWithoutInterception, IoMem_WriteWithoutInterception }, /* SCU VME interrupt mask */
{ 0xff8e0f, 1, IoMem_ReadWithoutInterception, IoMem_WriteWithoutInterception }, /* SCU VME interrupt state */
+#endif
{ 0xff9000, SIZE_WORD, IoMem_VoidRead, IoMem_VoidWrite }, /* No bus error here */
{ 0xff9200, SIZE_WORD, IoMemTabTT_ReadDIPSwitches, IoMem_VoidWrite }, /* DIP switches */
diff --git a/src/options.c b/src/options.c
index 1fa4232c..b54536a2 100644
--- a/src/options.c
+++ b/src/options.c
@@ -161,6 +161,7 @@ enum {
#endif
OPT_MACHINE, /* system options */
OPT_BLITTER,
+ OPT_VME_ERRORS,
OPT_DSP,
OPT_TIMERD,
OPT_FASTBOOT,
@@ -446,6 +447,8 @@ static const opt_t HatariOptions[] = {
"<x>", "Select machine type (x = st/megast/ste/megaste/tt/falcon)" },
{ OPT_BLITTER, NULL, "--blitter",
"<bool>", "Use blitter emulation (ST only)" },
+ { OPT_VME_ERRORS, NULL, "--vme-errors",
+ "<bool>", "MegaSTE/TT VME access generates errors" },
{ OPT_DSP, NULL, "--dsp",
"<x>", "DSP emulation (x = none/dummy/emu, Falcon only)" },
{ OPT_TIMERD, NULL, "--timer-d",
@@ -1971,6 +1974,9 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
}
break;
+ case OPT_VME_ERRORS:
+ ok = Opt_Bool(argv[++i], OPT_VME_ERRORS, &ConfigureParams.System.bVmeErrors);
+ break;
case OPT_TIMERD:
ok = Opt_Bool(argv[++i], OPT_TIMERD, &ConfigureParams.System.bPatchTimerD);
break;