19 January 2008, 00:51 | #1 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,343
|
RESET without jumping into Kickstart?
Hi,
I know the normal software reset method is to (for example) load A0 appropriately (pointing to e.g. 2 or $FC0002 etc.), then do RESET / JMP (A0), where the RESET instruction is longword aligned. That's because memory probably goes away at reset; the JMP opcode is prefetched before reset occurs. (Chip memory disappears to be replaced by an image of the Kickstart ROM, and autoconfig fast memory goes away too. $C00000 memory probably remains accessible however.) What I'm curious to know is... can something similar be done, but to remove the ROM overlay? In other words, can code execution continue after reset, even from chip RAM? Like this: Code:
; Code in chip memory (not autoconfig fast RAM) ; (Disable interrupts first) LEA ($BFE001).L,A0 MOVE.B (A0),D0 BCLR.B #0,D0 ;Clear OVL bit (will be clear anyway) BRA.W .DoIt CNOP 0,4 .DoIt: RESET MOVE.B D0,(A0) [Some more code here] I'm guessing this isn't possible, since I seem to remember Dave Haynie having to do something funky with the instruction cache in the SetCPU source code... -- M |
19 January 2008, 09:35 | #2 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,518
|
It is possible, Double Dragon 2 protection did it
Code:
0003ffd8 46fc 2700 MV2SR.W #$2700 0003ffdc 7003 MOVE.L #$00000003,D0 0003ffde 4df9 96df f000 LEA.L $96dff000,A6 0003ffe4 4bf9 23bf e201 LEA.L $23bfe201,A5 0003ffea 49f9 45bf e001 LEA.L $45bfe001,A4 0003fff0 41f9 0090 0000 LEA.L $00900000,A0 0003fff6 43e8 0001 LEA.L (A0,$0001) == $00900001,A1 0003fffa 51d4 SF .B (A4) == 0003fffc 0003fffc 4e70 RESET.L 0003fffe 1a80 MOVE.B D0,(A5) 00040000 4e71 NOP.L 00040002 51d4 SF .B (A4) == 00040004 00040004 3d7c 7fff 069a MOVE.W #$7fff,(A6,$069a) == $96dff69a |
23 January 2008, 22:16 | #3 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
|
Nice, a disassembler that gives different binary when you assemble it again Not to mention generating sources that don't use the syntax in the CPU Programmer's manual (Referring to the moveq #3,d0 and reset instructions, respectively.)
Overall, that disassembly looks n.a.s.t.y. Um, what is the purpose of executing code after reset? Either it resets or it doesnt? Explain please |
23 January 2008, 22:26 | #4 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,518
|
Quote:
Sources are that way -> |
|
24 January 2008, 00:25 | #5 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
|
Hm. I thought the disasm came from that cartridge thingy you emulate? Sorry, didn't think you coded it. Doesn't mean I'll retract my surly comments though, after all they are correct
If the disasm is open source, I can help you if I can use a nicer OOP language than cpp! |
24 January 2008, 00:36 | #6 | ||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,518
|
Quote:
Quote:
|
||
24 January 2008, 01:56 | #7 | |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,343
|
Quote:
-- M |
|
24 January 2008, 16:27 | #8 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
On some accelerator boards (e.g. Blizzard 1230-IV like mine), executing the reset instruction resets everything, cpu included. The instruction after the reset isn't even executed. Hence your code would be doomed on such a machine.
Btw that DD2 protection code is awful (Commodore said : do not put anything in the upper bits of an address !!!) |
14 April 2020, 07:53 | #9 |
Registered User
Join Date: Aug 2006
Location: Finland
Age: 51
Posts: 242
|
Mind some necromancy here.. I tried reset codes for fun last night and just did not get them working as I hoped for on my A3000 (with CS2 040). The intention was to keep the code in Chip RAM. If the code is in the RAM that does not disappear or get OVLed during the reset (beyond $80000) it works as expected but if located lower in the Chip RAM it seems the code after the reset instruction never got executed. Am I obviously missing something should-be-known-stupid here?
|
14 April 2020, 09:27 | #10 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,518
|
ROM gets overlayed on top of chip RAM when reset is executed. You need to set CIA overlay bit immediately after the RESET. Because 68020+ pipeline is 3 words + 1 long word input buffer, it should be much easier to handle than with 68000 (which has only 2 word pipeline = RESET + CIA modification instruction must fit in 2 words)
It probably is best to prepare data and address registers for OVL setting, execute RESET, set CIA OVL bit (I think it is enough to set OVL data direction), then execute bra.s (or jmp (an)) to force pipeline refill because at least input buffer will now have long word loaded from ROM which you don't want to execute. |
14 April 2020, 10:09 | #11 | |
Registered User
Join Date: Aug 2006
Location: Finland
Age: 51
Posts: 242
|
Quote:
Code:
reset move.b d0,(a5) ; D0=3, A5=$bfe201 jmp (a4) ; A4 points to a code 4k further in Chip RAM |
|
14 April 2020, 11:23 | #12 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,518
|
Does it work if your JMP jumps to RAM that does not disappear? (=confirms that CPU does not immediately jump somewhere unknown, at least immediately)
Do you see color bars if you do something like loop: move.w (a0),(a1); bra.s loop) after the reset-instruction, A0=dff006 and A1=dff180? Make sure CPU instruction cache is enabled. It also could be some accelerator board side-effect, for example if board has maprom support, it requires some logic to handle also overlay. Perhaps it is only reset when board detects hardware reset. |
14 April 2020, 12:41 | #13 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
All of this cannot really work on a 040. Note that the 040 *requires* a running MMU, and that the RAM the MMU tables are located in may go away on a reset if it is autoconfig-RAM. Thus, at least you should also ensure that the MMU is either disabled (mmu.library WithoutMMU()) or ensure that the MMU tables are in chip-mem as well in a location without ROM overlay (you can create a custom MMU table with the library, and ensure by the memory allocation bits that it is in chip). You also could try that the reset, and CIA modification and jmp are in a a cache-line, i.e. aligned to a 16-byte boundary. One way or another, this type of stunt requires a bit more care on the higher processors, and it is in general advisable to rely on the os function ColdReboot() (or the patches installed therein) to do the right thing for you.
|
14 April 2020, 13:38 | #14 | |
Registered User
Join Date: Aug 2006
Location: Finland
Age: 51
Posts: 242
|
Quote:
Last edited by mr.spiv; 14 April 2020 at 13:51. |
|
14 April 2020, 16:41 | #15 | |
Registered User
Join Date: Aug 2006
Location: Finland
Age: 51
Posts: 242
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Jumping around in Dragon Ninja | Tim Janssen | support.Games | 40 | 08 December 2019 17:04 |
jumping jack'son speed...mmm... | lee777 | support.Games | 7 | 14 March 2011 15:45 |
The definite guide to using a button instead of UP for jumping in WinUAE | Hobbe | support.WinUAE | 14 | 18 June 2009 21:28 |
Jumping CDXL Animations | moffball71 | support.WinUAE | 2 | 30 April 2005 01:17 |
Jumping FMV sequence with WinUAE | moffball71 | support.WinUAE | 2 | 02 May 2004 12:21 |
|
|