Subject: JavaStation w/ OBP3 - some progress
To: None <port-sparc@netbsd.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: port-sparc
Date: 04/03/2001 07:45:53
I'm playing with JS1 (aka mr. coffee, aka brick) with OpenBoot 3.x.
POST jumper is "in" and it enters POST on serial console after power on.

    JavaStation
    OpenBoot 3.11.2, 64 MB memory installed, Serial #8893604.
    Ethernet address 8:0:20:87:b4:a4, Host ID: 8087b4a4.
    
    Type any key to interrupt automatic startup                           
    6 
    ok boot

OBP3 is an Open Firmware and it's a little particular about what it
boots.  Stock boot.net has wrong header (0x30800007 is interpreted as
text size) and image crashes immediately when load attempts to start
it.  See IEEE draft std. P1275.1/D14a (sparc supplement) for details:

    <http://playground.sun.com/1275/bindings/sparc/d14a/12751d1a.ps>

I used elftoaout(1) to get secondary boot with good header.  Now that
one boots, but crashes in prom_init when it tries to access
obpvec->pv_magic, since obpvec (i.e. 'romp') is zero (see below).


BTW, locore.s has an attempt at detecting OFW (i.e. OBP3) system as
well, but as far as I can tell it gonna crash in a similar way at this
line:

    /* First, check `romp->pv_magic' */
    ld [%g7 + PV_MAGIC], %o0	     ! v = pv->pv_magic

The correct test, I guess is to check if %o0 was zero.


Then locore has the is_openfirm label, and reading from there it seems
that promlib.c is prepared to deal with OWF.  However
stand/common/srt0.S is different from sparc/locore.s:

	/*
	 * Save address of PROM vector (passed in %i0).
	 */
	sethi	%hi(_C_LABEL(romp)), %o1
	st	%i0, [%o1 + %lo(_C_LABEL(romp))]

	/* Also save %i3, which is the Openfirmware entry, if any */
	sethi	%hi(_C_LABEL(opf_romp)), %o1
	st	%i3, [%o1 + %lo(_C_LABEL(opf_romp))]
	b,a	is_sun4cm

and opf_romp is _never_ referenced anywhere, romp is zero and hence
boot.net crashes in prom_init.

So for I just short-circuited this code in srt0.S to always stuff %i3
to romp and let prom_init deal with that.

This image proceeds as far as:

>> NetBSD/sparc Secondary Boot, Revision 1.9
>> (toor@felix.sparc.spb.su, Wed Mar 21 23:56:32 MSK 2001)
Booting netbsd
loadfile: open("netbsd")
open netbsd: No such file or directory
... loadfile(netbsd) ok
: trying netbsd.gz...

[... skipped attempts at loading other kernels from default list ...]

device[/sbus/ledma@4,8400010/le@4,8c00000:dhcp] ("halt" to halt): halt
Program terminated
ok 


Good thing about it is that promlib is working: it can put/getchar, it
finds which boot device is chosen etc.


I'm slowly learning my way around the source tree and any advice on
how to proceed is greatly appreciated.  Meanwhile, as time permits,
I'm going to sprinkle more tracing printf to grok what open() thinks
and where it tries to get the file from.

Thanks in advance.

SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen