From bc6c861323c69b877711c8dce135cf022567be25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Sat, 2 Apr 2016 10:39:26 +0000 Subject: [PATCH] fix ST RAM values for initial SP & PC to allow FreeMint reboots on CTRL-ALT-DELETE --- BaS_gcc/sys/BaS.c | 10 ++++++++++ BaS_gcc/sys/exceptions.S | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/BaS_gcc/sys/BaS.c b/BaS_gcc/sys/BaS.c index ef1947d..493a8e8 100644 --- a/BaS_gcc/sys/BaS.c +++ b/BaS_gcc/sys/BaS.c @@ -529,6 +529,16 @@ void BaS(void) FireTOS(); // Should never return } + /* + * fix initial pc/sp in ST RAM for FreeMiNT. It expects valid values there + * like on original STs (where these values reside in ROM) and uses them on + * CTRL-ALT-DELETE reboots. + */ + struct rom_header *bas_header = (struct rom_header *) TARGET_ADDRESS; + struct rom_header *stram_header = (struct rom_header *) 0x0; + + *stram_header = *bas_header; + xprintf("call EmuTOS\r\n"); struct rom_header *os_header = (struct rom_header *) TOS; os_header->initial_pc(); diff --git a/BaS_gcc/sys/exceptions.S b/BaS_gcc/sys/exceptions.S index caebf09..acc857d 100644 --- a/BaS_gcc/sys/exceptions.S +++ b/BaS_gcc/sys/exceptions.S @@ -581,7 +581,7 @@ _lowlevel_isr_handler: jsr _isr_execute_handler // call the C handler addq.l #4,sp // adjust stack tst.b d0 // handled? - beq lowlevel_forward // no, forward it to TOS + beq lowlevel_forward // no, forward it to TOS movem.l (sp),d0-d1/a0-a1 // restore registers unlk a6