English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 11 September 2021, 13:15   #1
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Correct way to hard reset in the bootblock on 1.3-3.1?

I've updated a boot block which works correctly on 1.3-3.1. However, a hard reset consistently puts a PAL 1.3 A500 in NTSC mode until I've booted to CLI once and soft reset manually.

What can I do to prevent this?

The bootdisk is found here, and here's the relevant portion of code:

Code:
;a6=execbase, -$1e=Supervisor()
HardReset:
	clr.l $26(a6)
SoftReset:
	lea RCont(PC),a5
	JSR -$1e(a6)
RCont:	lea 2.w,a0
	RESET
	JMP (a0)
Photon is offline  
Old 11 September 2021, 13:48   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
The correct way is to use exec/ColdReboot() whenever it is available, because this call does some additional services compared to the code above, and your system may need such services.

Even under 1.3, the above code is not correct, problem being that your code may be in chip mem or expansion ram, and then the "reset" "pulls the rug" under the CPU. You can make it "somewhat working" by using the prefetch feature of the 68k, though then the reset and the JMP need to be on the same LW.
Thomas Richter is offline  
Old 11 September 2021, 13:54   #3
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Hmm, are you sure this works in 100% cases? E.g. KS 3.0 exec ColdReset jumps to a second reset at $f800d0, while you jump to $f800d2.
You took a shortcut (exec goes through the ROM end address) since ROM gets mapped to $0 and at $2 there's a jmp $f800d2, but you also don't have a decrement by 2 before taking a post-reset jmp (a0), and overshoot the 2nd reset by 2 bytes.
Not sure if related or intended, just in case...
a/b is offline  
Old 11 September 2021, 13:58   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Quote:
Originally Posted by Thomas Richter View Post
though then the reset and the JMP need to be on the same LW.
Wasn't that debunked? I'm sure there was a discussion or at least a mention on these forums about it. I think it was some discussion with Toni about emulation...
a/b is offline  
Old 11 September 2021, 14:05   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
Sounds like you trigger KS 1.3 bug, there is always 1/227 chance of NTSC misdetection.

68000/010 prefetch is fully word based, long word alignment won't make any difference whatsoever.

68020+ prefetch long words. If unaligned, it still prefetches full long from aligned address (=address - 2).
Toni Wilen is online now  
Old 11 September 2021, 14:14   #6
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Quote:
Originally Posted by Toni Wilen View Post
Sounds like you trigger KS 1.3 bug, there is always 1/227 chance of NTSC misdetection.
Thx Toni

This piece of code seems to trigger it 227/227 times (on 1.3 only)

Quote:
Originally Posted by Thomas Richter View Post
The correct way is to use exec/ColdReboot() whenever it is available, because this call does some additional services compared to the code above, and your system may need such services.

Even under 1.3, the above code is not correct, problem being that your code may be in chip mem or expansion ram, and then the "reset" "pulls the rug" under the CPU. You can make it "somewhat working" by using the prefetch feature of the 68k, though then the reset and the JMP need to be on the same LW.
Thx Thomas o/

It was not aligned to longword, but I fixed that and still the same behavior.

So no software in RAM can use the RESET instruction for anything? What about MapROM and resident stuff? Certainly they use this instruction.

I'd be happy to use ColdReboot(), so what would the use of it look like, is it consistent across OS1.3-3.1, and is there a WarmReboot()?

Last edited by Photon; 11 September 2021 at 16:24.
Photon is offline  
Old 11 September 2021, 14:19   #7
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Quote:
Originally Posted by a/b View Post
Hmm, are you sure this works in 100% cases? E.g. KS 3.0 exec ColdReset jumps to a second reset at $f800d0, while you jump to $f800d2.
Offset 2 of the kickstart is supposed to contain a JMP ABS.L opcode, and offset 4 is the initial PC vector of the 68k, so that could possibly be fine. There is indeed a second reset instruction just below the actual init code you can use if you want to. It is another option you can take, i.e. check whether it is present, and you call supervisor with target address of this reset. This would make the code independent of the ROM mirror. But, again, note that exec/ColdReboot() is really really the recommended way of doing this.
Thomas Richter is offline  
Old 11 September 2021, 14:30   #8
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Code:
		
		cmpi.w	#36,lib_Version(a6)
		blo.b	.v1x
		jmp	_LVOColdReboot(a6)
.v1x		jsr	_LVOSuperState(a6)
		lea	$01000002,a0
		suba.l	-22(a0),a0
		reset
		jmp	(a0)
ross is offline  
Old 11 September 2021, 15:20   #9
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Precisely.
Thomas Richter is offline  
Old 11 September 2021, 17:40   #10
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Ross's code works, and for a soft reset I would go
Code:
jsr	_LVOSuperState(a6)
lea.w 2,a0
reset
jmp (a0)
(correct?) But this doesn't work on >1.3?

Last edited by Photon; 11 September 2021 at 19:28.
Photon is offline  
Old 11 September 2021, 18:51   #11
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
See Ross' code. That's the better choice. Again, if exec/ColdReboot() exists, use it!
Thomas Richter is offline  
Old 11 September 2021, 18:59   #12
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Thomas, I'm using it, I'm just wondering if the code in my last comment is a correct SoftReset. I need that also in my bootblock.

My existing SoftReset code works fine on all systems, I just want to know if it's correct.

Last edited by Photon; 11 September 2021 at 19:32.
Photon is offline  
Old 11 September 2021, 20:14   #13
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Well, as stated, not always, and exactly not if ColdReboot() has something else to do. In many, but no all cases, the two snippets work identical. I'd go for Ross' code, still.
Thomas Richter is offline  
Old 11 September 2021, 21:21   #14
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
I actually just checked ColdReboot() in two ways: resident vectors and cleared memory. Ross's code for 1.3 does that, but ColdReboot() under 2.0+ keeps resident vectors (e.g. from 3.1 early boot menu/"boot without s-seq") and does not clear memory. (!)

Sheesh...

Let's define a hard reset then: resident vectors are killed, and (at least pertinent) memory is cleared. (This is the only way for a bootblock to kill a (in-RAM) virus before booting.)

Now I'm in a dilemma, because I can use only the 1.3 part of Ross's code in this use case. I hoped to get this mammagamma done...

Edit: So it could be a difference in expectations, hence my definition. Is there documentation on what ColdReboot() does?

Last edited by Photon; 11 September 2021 at 22:06.
Photon is offline  
Old 11 September 2021, 22:08   #15
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
So you want the system to rebuild execbase and company?
There are several ways (such as clearing the exec checksum).

But if you want to be brutal:
Code:
.v1x		jsr	_LVOSuperState(a6)
		jsr	_LVODisable(a6)
		lea	$01000002,a0
		suba.l	-22(a0),a0
		st	7.w
		reset
		jmp	(a0)
ross is offline  
Old 11 September 2021, 22:30   #16
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Regarding clearing Exec checksum: Is this what existing old code does in OP? (clr.l $26(a6)) this doesn't clear RAM or resident vectors on 3.1 at least. This is the definition and what it does on 1.3 (with <=512KB Chip RAM, I just found out)

I can try your brutal code. I've already spent 7h on this, what's an hour more on a Saturday. *makes Scooby-Doo sound*

Edit: just to be clear the only goal left is code to make hardresets clear RAM and kill resident vectors on 2.0+. SlightlyBelowRoomTemperatureMaybeAThinSweaterIsCalledForBoot() in Exec V36+ does... less.

Edit 2: Nope, brutal code did not clear memory at $7e000 under 3.1 seems to clear resident vectors tho!

Last edited by Photon; 11 September 2021 at 22:49.
Photon is offline  
Old 11 September 2021, 22:49   #17
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Photon View Post
Regarding clearing Exec checksum: Is this what existing old code does in OP? (clr.l $26(a6)) this doesn't clear RAM or resident vectors on 3.1 at least. This is the definition and what it does on 1.3 (with <=512KB Chip RAM, I just found out)

I can try your brutal code. I've already spent 7h on this, what's an hour more on a Saturday. *makes Scooby-Doo sound*

Edit: just to be clear the only goal left is code to make hardresets clear RAM and kill resident vectors on 2.0+. SlightlyBelowRoomTemperatureMaybeAThinSweaterIsCalledForBoot() in Exec V36+ does... less.
No, 'brutal code' do not clear RAM, it only destroy execbase so system is constrained to rebuild all from scratch.
But I think there is no clear-ram code in KS3.x, you have to do it manually..
ross is offline  
Old 11 September 2021, 22:55   #18
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
OK, primary goal is to kill viruses, so I will let go of secondary purpose of clearing RAM on >1.3. Thanks again Ross. You know so much OS stuff!

I mean I could feed the Amiga users who dare boot a floppy on a 3.1 machine to the sharks WRT viruses. They might have valid resident vectors like Blizzard accelerator stuff. Then again those users can opt to not hardreset because they know. It would be nice for an antivirus boot block to actually work on >1.3.
Photon is offline  
Old 11 September 2021, 23:05   #19
malko
Ex nihilo nihil
 
malko's Avatar
 
Join Date: Oct 2017
Location: CH
Posts: 4,856
Quote:
Originally Posted by Photon View Post
[...] Thanks again Ross. You know so much OS stuff! [...]
malko is offline  
Old 11 September 2021, 23:57   #20
admiral
Engineer
 
Join Date: Oct 2018
Location: Shadow realm
Posts: 165
Quote:
Originally Posted by Photon View Post
OK, primary goal is to kill viruses, so I will let go of secondary purpose of clearing RAM on >1.3.
I seem ignorant: What is this ram-clearing on v36+? What significance does 0x7e000 have?

Last edited by admiral; 11 September 2021 at 23:57. Reason: format
admiral is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga 1200 problem with soft reset (and hard reset) joora support.Hardware 6 21 July 2020 10:53
Crack tells me to "hard reset" to clear Ram apachacha support.WinUAE 6 28 December 2011 11:30
is this correct? CU_AMiGA MarketPlace 1 28 September 2007 20:05
Hard and soft reset Photon request.UAE Wishlist 3 28 November 2006 16:08
Hard reset BippyM support.WinUAE 3 22 February 2006 01:47

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:06.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09685 seconds with 14 queries