[OpenBIOS] [RFC 3/3] SPARC32/64: Mimic Sun's OBP behaviour if a divide by zero occurs.

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Mon Jan 7 20:08:38 CET 2013


On 07/01/13 18:41, Tarl Neustaedter wrote:

>> Here is the post I referenced sent by your imposter:
>> http://lists.openbios.org/pipermail/openbios/2011-August/006626.html.
>
> Artyom's post says it returns no value _IFF_ he gets a trap 3e. A trap
> 3e (on SPARC) is a non-resumable trap; the world has gone to shit, all
> you can do is poke around in the debris and find out what blew up. In
> this case, it re-enters forth clobbering anything that might have been
> in progress.

Ah I see. So for example if on SPARC that was in the middle of a CIF 
interpret call or similar, then you'd be dropped back to the OpenBoot 
prompt at this point too? I didn't pick up on that from Artyom's 
original email.

> I think Mark's patch is the correct one if this is indeed what PPC does;
> I'm suspicious because I see elsewhere that current PPCs do indeed trap
> on divide by zero. Rather than allowing divide by zero, I'd think it
> would make more sense to figure out where that is coming from and
> prevent whatever parameter is causing this from ever being set to values
> that will cause a trap.

Unfortunately the sad truth is that BootX is written to rely on this 
(ahem) feature to work if booting from anything that isn't the network:

  0 value screenIH
  0 value cursorAddr
  0 value cursorX
  0 value cursorY
  0 value cursorW
  0 value cursorH
  0 value cursorFrames
  0 value cursorPixelSize
  0 value cursorStage
  0 value cursorTime
  0 value cursorDelay

  ...

  : slw_spin_init
    dup FFFF and to cursorH 10 >> drop
    dup FFFF and to cursorW 10 >> to cursorPixelSize
    dup FFFF and to cursorY 10 >> d# 1000 swap / to cursorDelay
    dup FFFF and to cursorX 10 >> to cursorFrames
    to cursorAddr
    to screenIH
    ['] slw_spin to spin ;

And slw_spin_init is invoked from DrawSplashScreen() like this:

if (gBootFileType != kNetworkDeviceType) {
     SpinInit(0, 0, NULL, 0, 0, 0, 0, 0, 0, 0);
}

... which of course when booting from the cd: device immediately traps 
without the patch. Sigh. On the plus side, the patch only changes the 
"/" Forth word within OpenBIOS in the hope that anything deliberately 
dividing by zero to invoke a fatal trap will still stop dead in its tracks.


ATB,

Mark.



More information about the OpenBIOS mailing list