Re: [hatari-devel] Wrong stackframe for non-autovector IRQ and CPU >= 68020 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Le 07/05/2019 à 18:43, Nicolas Pomarède a écrit :
Le 06/05/2019 à 19:04, Toni Wilen a écrit :
I'll think about it after bug fix release of winuae is out (next few
weeks). Also need to check Motorola documentation carefully because I am
not familiar enough with autovectored interrupts, they are not used in
Amigas.
It probably is best if you attach patch example that is tested and
confirmed working. I can't test it :)
hi,
thanks for looking into it, I will send later a patch that you can try.
Here're the changes made into Hatari to handle both vectored and
autovectored interrupts. To simplify we can take the example of the STF
which is common to all Atari machines.
STF has vectored and autovectored interrupts :
- the HBL and VBL interrupts are using level 2 and level 4 and are
autovectored, so they will use $68 (hbl) and $70 (vbl)
- MFP (which handles timers and some irq signal for external devices,
more or less like the CIAs in the Amiga) will use vectored interrupts.
The MFP will have an internal int number between 0 and 15 and will
translate this into a vector address passed to the cpu during the IACK
sequence. By default, the vector address will be between $100 and $140.
(this vector mode is rather similar to the amiga)
For this, iack_cycle in newcpu is replaced by some atari specific code
which basically does :
static int iack_cycle(int nr)
{
if ( nr == 30 ) /* MFP int 6 */
{
vector = MFP_ProcessIACK ( nr );
}
else if ( nr==26 || nr==28 ) /* HBL or VBL */
{
vector = nr;
}
return vector;
}
Then I changed some of the Exception_xxx functions to do this nr/vector
translation when it was missing from WinUAE :
// 68030 MMU
static void Exception_mmu030 (int nr, uaecptr oldpc)
{
uae_u32 currpc = m68k_getpc (), newpc;
int interrupt;
interrupt = nr >= 24 && nr < 24 + 8;
+#ifdef WINUAE_FOR_HATARI
+ if (interrupt)
+ nr = iack_cycle(nr);
+#endif
// 68040/060 MMU
static void Exception_mmu (int nr, uaecptr oldpc)
{
uae_u32 currpc = m68k_getpc (), newpc;
int interrupt;
interrupt = nr >= 24 && nr < 24 + 8;
// exception vector fetch and exception stack frame
// operations don't allocate new cachelines
cache_default_data |= CACHE_DISABLE_ALLOCATE;
+#ifdef WINUAE_FOR_HATARI
+ if (interrupt)
+ nr = iack_cycle(nr);
+#endif
Code was already present in Exception_normal, but only for <= 68010, but
Exception_normal can be called from all cpu types, iack_cycle should be
called to do the translation too
static void Exception_normal (int nr)
{
uae_u32 newpc;
uae_u32 currpc = m68k_getpc();
uae_u32 nextpc;
int sv = regs.s;
int interrupt;
int vector_nr = nr;
cache_default_data |= CACHE_DISABLE_ALLOCATE;
interrupt = nr >= 24 && nr < 24 + 8;
+#ifndef WINUAE_FOR_HATARI
if (interrupt && currprefs.cpu_model <= 68010)
+#else
+ if (interrupt)
+#endif
vector_nr = iack_cycle(nr);
Then as pointed in the previous email, Exception_normal should be
further changed to pass "vector" to Exception_build_stack_frame_XXX else
in case of a vectored interrupt the stack will not be correct (this
should be reproducible in the case of the Amiga).
As confirmed by christian with the above changes in Hatari the interrupt
vector address stored in the stack is correct when using mmu or mmu030
modes and 68000 CE mode is correct too, so only _normal case need to be
fixed.
Nicolas