Re: [hatari-devel] Wrong stackframe for non-autovector IRQ and CPU >= 68020

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Le 05/05/2019 à 14:34, Christian Zietz a écrit :
Hi,

Hatari (or rather the CPU emulation) puts a wrong exception frame on the
stack for non-autovector interrupts (such as MFP, SCC) when a 68020 or
higher CPU is selected. Steps to reproduce: Boot any TOS (that supports
a 68020 or higher), break into the debugger and place a break point on
the handler for MFP Timer C. The vector offset is 0x114:

m $114
00000114: 00 e0 08 b6 00 e0 0d 6c 00 e0 07 5a 00 e0 07 5a
a $e008b6
c
[...]
1. CPU breakpoint condition(s) matched 1 times.
         pc = $e008b6
[...]
m "a7"
m "a7"
- 'a7' -> $a298
0000A298: 23 04 00 e1 fe c8 *00* *78* 00 00 01 8f 00 00 00 00

The two bytes I marked with asterisks are supposed to contain the vector
offset, i.e., 0x114, but the contain the offset to the auto-vector
interrupt level 6 (0x078) instead.

Interestingly, the stack frame is correct for 68010 CPUs or when I use a
68030 including MMU emulation.

Hi

nice catch :)

So far, WinUAE cpu core only handles vector_nr (the corresponding value for non autovectored int) by calling the function iack_cycle().
But this function is only called in 68000 CE mode and in Exception_normal()

But in Exception_normal, we have this final else :
} else {
Exception_build_stack_frame_common(oldpc, currpc, regs.mmu_ssw, nr);
        used_exception_build_stack_frame = true;
}

the problem is that vector_nr is not passed to this function and instead this stores on the stack :
    x_put_word (m68k_areg (regs, 7), (format << 12) | (nr * 4));

(in our case, format=0)

Toni, do you agree that vector_nr should be passed to Exception_build_stack_frame_common and Exception_build_stack_frame ?

Also, in Hatari I added a call to iack_cycle into Exception_mmu030 and Exception_mmu to include correct vector number in the stack in case of interrupt :

#ifdef WINUAE_FOR_HATARI if (interrupt) nr = iack_cycle(nr);
#endif

Maybe something similar should be added into WinUAE too (by replacing 'nr' directly or using 'vector_nr' too) ?

Nicolas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/