Subject: Alternate boot program
To: None <port-sgimips@netbsd.org>
From: sgimips NetBSD list <sgimips@mrynet.com>
List: port-sgimips
Date: 04/20/2002 18:51:42
Is there any interest in a boot block that works along the lines
of other platforms' boots?

I have a modified boot program that I'm using locally that implements
the command mode similar to that of the i386 platform (from which I
ripped code).

The functionality implmented includes:

o	A timed period to allow a key to be pressed to interrupt
	the boot to enter into a command mode.
o	limited ls(1) functionality.
o	the 'dev' directive to redirect the default device.
o	the 'boot' command to manually specify the kernel to boot
	from within the boot program.
o	the 'quit' (and 'halt' and 'exit' aliases) to return back
	to the PROM.
o	added a '-m' flag to bypass the seconds countdown and enter
	directly into command mode when boot starts up.
	(i.e. >> boot --m)

This all started out from the need to debug PROM device access and
the end result was this modified boot program.  It has come in
VERY handy when trying to determine what kernel names are on 
different drives before booting.

The only issue so far is rewriting the arguments to the booted
kernel when selecting a boot drive different than the one
indicated in the PROM environment.  I haven't resolved if this should
be done or not (I can think of situations where I want to boot
a kernel from one drive, but have the root partition remain on
the one indicated by the PROM environment).

Any comments?  suggestions?  recommendations?  expensive spirits?

-scott

A sample boot session follows.

============================

System Maintenance Menu

1) Start System
2) Install System Software
3) Run Diagnostics
4) Recover System
5) Enter Command Monitor

Option? 5
Command Monitor.  Type "exit" to return to the menu.
>> boot -f bootp():/abyss/indy/boot2
Setting $netaddr to 198.182.227.85 (from server 198.182.227.1)
Obtaining /abyss/indy/boot2 from server 198.182.227.1
49680+0+3536 entry: 0x89000000

NetBSD/sgimips 1.5ZC Bootstrap, Revision 1.1
(root@mod81, Sat Apr 20 17:32:46 CDT 2002)

Mem block: type 0 base 0x0 size 0x1000
Mem block: type 1 base 0x1000 size 0x1000
Mem block: type 3 base 0x8002000 size 0x73e000
Mem block: type 6 base 0x8740000 size 0xc0000
Mem block: type 3 base 0x8800000 size 0x800000
Mem block: type 5 base 0x9000000 size 0xd000
Mem block: type 3 base 0x900d000 size 0x4ff3000
Local storage a87fe160
argv[0]: bootp():/abyss/indy/boot2
argv[1]: ConsoleIn=serial(0)
argv[2]: ConsoleOut=serial(0)
argv[3]: SystemPartition=scsi(0)disk(1)rdisk(0)partition(8)
argv[4]: OSLoader=boot2
argv[5]: OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0)
argv[6]: OSLoadFilename=/netbsd
Boot args: 


Press return to boot now, any other key for boot menu
booting scsi(0)disk(1)rdisk(0)partition(0)/netbsd --- starting in 0 
Type "?" or "help" for help.
dev=scsi(0)disk(1)rdisk(0)partition(0)
boot> ls scsi(1)disk(4)rdisk(0)partition(0)/
devopen: scsi(1)disk(4)rdisk(0)partition(0) type scsi file /
2: . (DIR)
2: .. (DIR)
3: netbsd (REG)
4: netbsd.ecoff (REG)
3520: sgimips (DIR)
dev=scsi(0)disk(1)rdisk(0)partition(0)
boot> ls /
devopen: scsi(0)disk(1)rdisk(0)partition(0) type scsi file /
2: . (DIR)
2: .. (DIR)
8832: usr (DIR)
17664: etc (DIR)
26496: kern (DIR)
3: netbsd (REG)
4: netbsd.ecoff (REG)
35328: altroot (DIR)
35329: bin (DIR)
17666: dev (DIR)
8833: home (DIR)
26497: mnt (DIR)
8834: root (DIR)
26498: sbin (DIR)
5: stand (DIR)
6: tmp (DIR)
7: var (DIR)
42: .cshrc (REG)
43: .profile (REG)
75: sys (LNK)
73: netbsdC.gz (REG)
dev=scsi(0)disk(1)rdisk(0)partition(0)
boot> dev=scsi(1)disk(4)rdisk(0)partition(0)
Unknown command.
Commands are:
   boot [scsi(N)disk(N)rdisk(N)partition(N)][filename] [-amqsv]
        (ex. "scsi(0)disk(1)rdisk(0)partition(0):netbsd.old -s"
   ls [path]
   dev xd[N[x]]:
   help|?
   quit
dev=scsi(0)disk(1)rdisk(0)partition(0)
boot> dev scsi(1)disk(4)rdisk(0)partition(0)
dev=scsi(1)disk(4)rdisk(0)partition(0)
boot> ls
devopen: scsi(1)disk(4)rdisk(0)partition(0) type scsi file /
2: . (DIR)
2: .. (DIR)
3: netbsd (REG)
4: netbsd.ecoff (REG)
3520: sgimips (DIR)
dev=scsi(1)disk(4)rdisk(0)partition(0)
boot> boot blahblah
Loading scsi(1)disk(4)rdisk(0)partition(0)blahblah
devopen: scsi(1)disk(4)rdisk(0)partition(0) type scsi file blahblah
open scsi(1)disk(4)rdisk(0)partition(0)blahblah: No such file or directory
dev=scsi(1)disk(4)rdisk(0)partition(0)
boot> dev scsi(0)disk(1)rdisk(0)partition(0)
dev=scsi(0)disk(1)rdisk(0)partition(0)
boot> boot netbsdC.gz
Loading scsi(0)disk(1)rdisk(0)partition(0)netbsdC.gz
devopen: scsi(0)disk(1)rdisk(0)partition(0) type scsi file netbsdC.gz
1501856+141004 [61936+51164]=0x1acd4c
Starting at 0x88069000

nsym 0x1 ssym 0x881fa16c esym 0x88215d4c
Found bootinfo at 0x8900c2d0
zs channel 0 had address 0xbfbd9830
argv[0]: bootp():/abyss/indy/boot2
argv[1]: ConsoleIn=serial(0)
argv[2]: ConsoleOut=serial(0)
argv[3]: SystemPartition=scsi(0)disk(1)rdisk(0)partition(8)
argv[4]: OSLoader=boot2
argv[5]: OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0)
argv[6]: OSLoadFilename=/netbsd
[ using 113632 bytes of netbsd ELF symbol table ]
IOC rev 0, machine Indigo2 (Fullhouse), board rev 8
Timer calibration, got 500000 cycles (500000, 500000, 500000)
CPU clock speed = 50.00Mhz
Mem block 1: type 0, base 0x0, size 0x1
Mem block 2: type 1, base 0x1, size 0x1
Mem block 3: type 3, base 0x8002, size 0x73e
Mem block 4: type 6, base 0x8740, size 0xc0
Mem block 5: type 3, base 0x8800, size 0x800
Mem block 6: type 5, base 0x9000, size 0xd
Mem block 7: type 3, base 0x900d, size 0x4ff3
Cluster 2 contains kernel
Loading chunk before kernel: 0x8002 / 0x8069
Loading chunk after kernel: 0x8216 / 0x8740
Loading cluster 4: 0x8800 / 0x9000
Loading cluster 5: 0x9000 / 0x900d
Loading cluster 6: 0x900d / 0xe000
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 1.5ZC (GENERIC) #0: Sun Apr 14 18:52:52 CDT 2002
    root@mod81:/sgimips/src/sys/arch/sgimips/compile/GENERIC
98304 KB memory, 88068 KB free, 768 KB for ARCS, 5016 KB in 1254 buffers
mainbus0 (root): SGI-IP22 [SGI, 6907b330], 1 processor
cpu0 at mainbus0: MIPS R4000 CPU (0x430) Rev. 3.0 with MIPS R4010 FPC Rev. 0.0

...  [boot proceeds normally]

And to exemplify the -m operation:

>> boot -f bootp():/abyss/indy/boot2 --m
Setting $netaddr to 198.182.227.85 (from server 198.182.227.1)
Obtaining /abyss/indy/boot2 from server 198.182.227.1
49680+0+3536 entry: 0x89000000

NetBSD/sgimips 1.5ZC Bootstrap, Revision 1.1
(root@mod81, Sat Apr 20 17:32:46 CDT 2002)

Mem block: type 0 base 0x0 size 0x1000
Mem block: type 1 base 0x1000 size 0x1000
Mem block: type 3 base 0x8002000 size 0x73e000
Mem block: type 6 base 0x8740000 size 0xc0000
Mem block: type 3 base 0x8800000 size 0x800000
Mem block: type 5 base 0x9000000 size 0xd000
Mem block: type 3 base 0x900d000 size 0x4ff3000
Local storage a87fe160
argv[0]: bootp():/abyss/indy/boot2
argv[1]: -m
argv[2]: ConsoleIn=serial(0)
argv[3]: ConsoleOut=serial(0)
argv[4]: SystemPartition=scsi(0)disk(1)rdisk(0)partition(8)
argv[5]: OSLoader=boot2
argv[6]: OSLoadPartition=scsi(0)disk(1)rdisk(0)partition(0)
argv[7]: OSLoadFilename=/netbsd
Boot args: m
Type "?" or "help" for help.
dev=scsi(0)disk(1)rdisk(0)partition(0)
boot>