[ Index ] [ Prev: Mapping Games ] [ Next: Work Around The Clock ]
A few trivial bugfixes (such as not dereferencing NULL pointers stupidly) later, I was ready to work on the device tree. I had already noticed the PROM show-tree command would not list everything, but I wanted to try walking the tree myself nevertheless.
The first step in doing this was to create a so-called PROM library, to mimic the (limited) PROM functionality with a Sun-like interface. Most of these functions live in arch/sparc/sparc/autoconf.c, which I had copied verbatim, then partially commented out; I decided to put my replacements into arch/solbourne/solbourne/prom_machdep.c, in the hope that, eventually, what would be left in autoconf.c could be shared between sparc and solbourne.
Aside from the node retrieval routines, only getprop and getproplen had to be written - the other getprop* routines could be changed to only use the aforementioned routines and not require specific handling.
Of course, things started to become nasty when I was actually looking into the PROM data. Not because it was incorrectly documented... but because it was not mapped anymore!
Since accessing the PROM is supposed to be a pretty uncommon operation (except during kernel configuration), I thought it was fine to map the PROM using the PTW facility, only for the time it is necessary. This ended up as two functions, prom_map and prom_unmap, which would do the trick. I could then start walking the device tree:
[ bsd ELF symbol table not valid: bad magic ] [ bsd a.out symbol table not valid ] [ no symbol table formats found ] Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2005 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 3.7-current (GENERIC) #243: Thu Apr 7 21:56:43 GMT 2005 miod@credogne.gentiane.org:/usr/src/sys/arch/solbourne/compile/GENERIC real mem = 16777216 avail mem = 9650176 using 102 buffers containing 835584 bytes of memory bootpath: tftp.ei()/aoutbsd mainbus0 (root): S4000 cpu0 at mainbus0: KAP_M2 @ 33 MHz, on-chip FPU clock0 at mainbus0: OKI MSM62X42BRS WARNING: lance interrupt 0 has nonzero vector lance at mainbus0 ioaddr 0x40000030 not configured Z85C30 at mainbus0 ioaddr 0x40000030 not configured Sbus at mainbus0 ioaddr 0x40000030 not configured WARNING: scsi interrupt 0 has nonzero vector scsi at mainbus0 ioaddr 0x40000020 not configured root device :
Few surprises, here. First, the floppy and audio devices are indeed missing, they were not specifically hidden by the PROM show-tree command. Then, there were a few unexpected warnings, basically telling us that the node properties are not exactly in the way the kernel expects them to be (simply because the Sun PROM behaves differently). With a few more lines of code, I dumped the properties themselves:
>> node: 0xfd7d9f88 next: 0x0 child: 0xfd7d9f2c name: Root attribute: model size: 5 string: S4000 attribute: name size: 3 string: KAP attribute: cpu size: 4 000000 f4 >> node: 0xfd7d9f2c next: 0xfd7d9e88 child: 0x0 name: lance-device attribute: reg size: 12 00000004 40000030 00000008 attribute: intr size: 8 00000006 00000001 attribute: driver size: 2 string: ei attribute: name size: 5 string: lance attribute: model size: 8 string: AMD 7990 attribute: type size: 7 string: network >> node: 0xfd7d9e88 next: 0xfd7d9d40 child: 0xfd7d9e54 name: uart attribute: name size: 6 string: Z85C30 >> node: 0xfd7d9e54 next: 0xfd7d9dc8 child: 0x0 name: Keyboard/Mouse attribute: reg size: 12 00000008 80004000 00000032 attribute: intr size: 8 00000007 00000001 attribute: driver size: 2 string: zs attribute: name size: 2 string: zs attribute: model size: 9 string: Z8530 SCC >> node: 0xfd7d9dc8 next: 0x0 child: 0x0 name: Ports A/B attribute: reg size: 12 00000008 80008000 00000032 attribute: intr size: 8 00000007 00000001 attribute: driver size: 2 string: zs attribute: name size: 2 string: zs attribute: model size: 9 string: Z8530 SCC >> node: 0xfd7d9d40 next: 0xfd7d9bf0 child: 0xfd7d9d14 name: Sbus attribute: name size: 4 string: Sbus >> node: 0xfd7d9d14 next: 0x0 child: 0x0 name: Sbus3 attribute: name size: 12 string: SOLB,sga attribute: model size: 8 string: sga20 attribute: type size: 7 string: display attribute: intr size: 8 00000005 00000000 attribute: reg size: 12 string: 0 attribute: depth size: 4 00000001 attribute: linebytes size: 4 00000800 attribute: width size: 4 00000480 attribute: height size: 4 00000384 attribute: sol-res-bytes size: 4 00000480 attribute: address size: 4 30400000 >> node: 0xfd7d9bf0 next: 0x0 child: 0xfd7d9b54 name: scsi-chip attribute: reg size: 12 00000004 40000020 00000008 attribute: intr size: 8 00000005 00000001 attribute: driver size: 2 string: si attribute: name size: 4 string: scsi attribute: model size: 8 string: WD33C93A attribute: type size: 2 string: io >> node: 0xfd7d9b54 next: 0xfd7d9b3c child: 0x0 name: Target0 >> node: 0xfd7d9b3c next: 0xfd7d9b24 child: 0x0 name: Target1 >> node: 0xfd7d9b24 next: 0xfd7d9b0c child: 0x0 name: Target2 >> node: 0xfd7d9b0c next: 0xfd7d9af4 child: 0x0 name: Target3 >> node: 0xfd7d9af4 next: 0xfd7d9adc child: 0x0 name: Target4 >> node: 0xfd7d9adc next: 0xfd7d9ac4 child: 0x0 name: Target5 >> node: 0xfd7d9ac4 next: 0x0 child: 0x0 name: Target6
At this point, I realized that, except for the SBus card, the properties did not tell me anything I didn't know from the header files or the OS/MP dmesg, and that, since the hardware design is fixed, I would save time by simply creating a table of the on-board devices, and probe them from this table. This would let me see the audio and floppy devices; SBus devices, on the other hand, would be probed using the tree, but starting at the ``SBus'' node.
To make my life easier, I decided not to attach these devices directly to the fictitious mainbus0 node, but to use a obio (on-board io) layer. I came up with this table in arch/solbourne/dev/obio.c:
/* * A list of the on-board devices in the IDT systems. This is better than * having people playing with locators in their kernel configuration * files, and necessary because the device tree built by the PROM does not * list all on-board devices (audio and floppy are missing). */ const struct { char *devname; paddr_t address; int intr; } obio_devices[] = { { "tod", TODCLOCK_BASE, -1 }, { "nvram", NVRAM_BASE, -1 }, { "zs", ZS0_BASE, 12 }, { "zs", ZS1_BASE, 12 }, { "fdc", FDC_BASE, 11 }, { "audioamd", AUDIO_BASE, 13 }, { "wdsc", SE_BASE + 0x20, 4 }, { "le", SE_BASE + 0x30, 6 }, { NULL, 0 } };
Note that the clock device in the early dmesg above has become tod, as it is only a time-of-day device...
With this, and adding zs configuration lines to my kernel, I eventually reached this point:
ROM> boot aoutbsd rarp: using IP address 10.0.1.164 = A0001A4 rarp: server at IP address 10.0.1.101 = A000165 Boot: tftp.ei()/aoutbsd Entry: 0xfd084000 Size: 0xcc000+0x1fee0+0x328d0 [ bsd ELF symbol table not valid: bad magic ] [ bsd a.out symbol table not valid ] [ no symbol table formats found ] console is ttya Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2005 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 3.7-current (GENERIC) #285: Fri Apr 8 21:47:42 GMT 2005 miod@credogne.gentiane.org:/usr/src/sys/arch/solbourne/compile/GENERIC real mem = 16777216 avail mem = 9650176 using 102 buffers containing 835584 bytes of memory bootpath: tftp.ei()/aoutbsd mainbus0 (root): S4000 cpu0 at mainbus0: KAP_M2 @ 36 MHz, on-chip FPU obio0 at mainbus0 tod0 at obio0 addr 0x80014000: OKI MSM62X42BRS nvram at obio0 addr 0x80000000 not configured zs0 at obio0 addr 0x80008000 pri 12, softpri 6 zstty0 at zs0 channel 0 (console i/o) zstty1 at zs0 channel 1 zs1 at obio0 addr 0x80004000 pri 12, softpri 6 zstty2 at zs1 channel 0: keyboard zstty3 at zs1 channel 1: mouse fdc at obio0 addr 0x8000c000 not configured audioamd at obio0 addr 0x80010000 not configured wdsc at obio0 addr 0x40000000 not configured le at obio0 addr 0x4000000 not configured root device :
I now needed to get the ethernet chip to work, and I would be on my road to userland!
[ Index ] [ Prev: Mapping Games ] [ Next: Work Around The Clock ]