[musashi] fix stackframe type for bus errors

Thu, 08 Dec 2011 23:44:19 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 08 Dec 2011 23:44:19 +0000
changeset 110
acea4b2f396f
parent 109
2f8afb9e5baa
child 111
4c85846b09cd

[musashi] fix stackframe type for bus errors

Bus errors incorrectly pushed a Type 0000 stackframe, when they should have pushed a Type 1000 (Type $8) stackframe.
Also, type 1000 frames were not handled for 68010 CPUs. They are now, but code must later be added to handle them for 68020s. FIXME!

Reported-By: Armin Diehl <ad ardiehl.de>

src/musashi/m68k_in.c file | annotate | diff | revisions
src/musashi/m68kcpu.h file | annotate | diff | revisions
     1.1 diff -r 2f8afb9e5baa -r acea4b2f396f src/musashi/m68k_in.c
     1.2 --- a/src/musashi/m68k_in.c	Tue Nov 15 10:12:37 2011 +0000
     1.3 +++ b/src/musashi/m68k_in.c	Thu Dec 08 23:44:19 2011 +0000
     1.4 @@ -8636,8 +8636,32 @@
     1.5  				m68ki_jump(new_pc);
     1.6  				m68ki_set_sr(new_sr);
     1.7  				return;
     1.8 +			} else if (format_word == 8) {
     1.9 +				/* Format 8 stack frame -- 68010 only. 29 word bus/address error */
    1.10 +				new_sr = m68ki_pull_16();
    1.11 +				new_pc = m68ki_pull_32();
    1.12 +				m68ki_fake_pull_16();	/* format word */
    1.13 +				m68ki_fake_pull_16();	/* special status word */
    1.14 +				m68ki_fake_pull_32();	/* fault address */
    1.15 +				m68ki_fake_pull_16();	/* unused/reserved */
    1.16 +				m68ki_fake_pull_16();	/* data output buffer */
    1.17 +				m68ki_fake_pull_16();	/* unused/reserved */
    1.18 +				m68ki_fake_pull_16();	/* data input buffer */
    1.19 +				m68ki_fake_pull_16();	/* unused/reserved */
    1.20 +				m68ki_fake_pull_16();	/* instruction input buffer */
    1.21 +				m68ki_fake_pull_32();	/* internal information, 16 words */
    1.22 +				m68ki_fake_pull_32();	/* (actually, we use 8 DWORDs) */
    1.23 +				m68ki_fake_pull_32();
    1.24 +				m68ki_fake_pull_32();
    1.25 +				m68ki_fake_pull_32();
    1.26 +				m68ki_fake_pull_32();
    1.27 +				m68ki_fake_pull_32();
    1.28 +				m68ki_fake_pull_32();
    1.29 +				m68ki_jump(new_pc);
    1.30 +				m68ki_set_sr(new_sr);
    1.31 +				return;
    1.32  			}
    1.33 -			/* Not handling bus fault (9) */
    1.34 +			/* FIXME: Not handling other exception types (9) */
    1.35  			m68ki_exception_format_error();
    1.36  			return;
    1.37  		}
    1.38 @@ -8669,7 +8693,7 @@
    1.39  				m68ki_set_sr(new_sr);
    1.40  				return;
    1.41  		}
    1.42 -		/* Not handling long or short bus fault */
    1.43 +		/* FIXME: Not handling long or short bus fault */
    1.44  		m68ki_exception_format_error();
    1.45  		return;
    1.46  	}
     2.1 diff -r 2f8afb9e5baa -r acea4b2f396f src/musashi/m68kcpu.h
     2.2 --- a/src/musashi/m68kcpu.h	Tue Nov 15 10:12:37 2011 +0000
     2.3 +++ b/src/musashi/m68kcpu.h	Thu Dec 08 23:44:19 2011 +0000
     2.4 @@ -1700,7 +1700,7 @@
     2.5  INLINE void m68ki_jump_bus_error_vector(void)
     2.6  {
     2.7  	uint sr = m68ki_init_exception();
     2.8 -	m68ki_stack_frame_0000(REG_PPC, sr, EXCEPTION_BUS_ERROR);
     2.9 +	m68ki_stack_frame_1000(REG_PPC, sr, EXCEPTION_BUS_ERROR);
    2.10  	m68ki_jump_vector(EXCEPTION_BUS_ERROR);
    2.11  }
    2.12