It seems a good time to post an update on my efforts to get OpenBSD working on Old World Macs. Here is the current dmesg (from a 7300): 0 > boot enet:,\boot.mac bsdOW.rd file: 192.168.10.99,/boot.macloading XCOFF tsize=A230 dsize=278 bsize=768 entry=24000 SECTIONS: text 00024000 00024000 0000A230 000000E0 data 0002F000 0002F000 00000278 0000A310 bss 0002F278 0002F278 00000768 00000000 loading .text, done.. loading .data, done.. clearing .bss, done.. >> OpenBSD/macppc Boot configuring L1/L2/L3 caches...no backside L2 cache present... unable to determine proper L2 cache value. no active packagefile: 192.168.10.99,/boot.mac of_mfs.c: open bootpath: enet:,\boot.mac bootargs: bsdOW.rd load enet:,bsdOW.rd... file: 192.168.10.99,bsdOW.rd enet:,bsdOW.rd ope 1456691 bytes loaded! Kernel file opened... Header read... Executing ELF file... Reading segment 0...5793356+246656 Zero out bss... BSS maxp... End of segment 0 pass... FREE phdr... ELF and Section Headers... Frobbing... Returned from elf_exec...=6287156 (0x5fef34u) chaining... OF_stdin: ch-a, OF_stdout: ch-a entering initppc... trap vectors... syncicache... pmap_bootstrap...pmap_avail_setup... region start: aff114 size: 7500eec pmap_remove_avail...pmap_steal_avail...stolen avail start: b08000 size: 4000 HTAB...stolen avail start: c00000 size: 100000 v->p mapping...kernel pmap...pmap_avail_fixup...tlbia...allocate pages...stolen avail start: dcd000 size: 1c8cc stolen avail start: de98cc size: 7233 leaving pmap_bootstrap... BATs... translation... initmsgbug... boot args... devio extent... ofwconsinit...console type: serial zs_conschan base: f3013020, mapped to: ee003020 leaving initppcCopyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2004 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 3.5-stable (OWRAMDISK) #509: Sat Aug 14 12:18:39 EDT 2004 notroot@OpenG4.my.domain:/sys/arch/macppc/compile/OWRAMDISK real mem = 134217728 (131072K) avail mem = 110379008 (107792K) using 1254 buffers containing 6709248 bytes of memory mainbus0 (root) cpu0 at mainbus0: Motorola PowerPC 604ev Rev. 2.4: 200 MHz HID0: 8090c084 mainbus node: PowerPC,604 mainbus node: memory mainbus node: AAPL,ROM mainbus node: bandit bhst0 at mainbus0 found io space: f2000000 800000 found mem f3000000 1000000 mapping f2800000 size 1000 to e74cc000 vbase f2800000 mapping f2c00000 size 1000 to e74cd000 vbase f2c00000 mem base f3000000 sz 1000000 io base f2000000 sz 800000 config addr 800000 config data c00000 ioh_cf8 e74cc000 ioh_cfc e74cd000 bandit_init:bh_conf_read/prime returned 1106b : bandit Revision 0x3 tag: 5800 going to fixup [System BIOS Setting]----------------------- device vendor product register space address size -------------------------------------------- 000:11:0 106b:0001 STATUS_COMMAND (before): 22800016 STATUS_COMMAND (after): 2800016 [OK] 000:15:0 100b:0020 10h port 0x00000400 0x00000100 pci_addr_fixup: range outside extent_mem: 80800000, 1000, skipping STATUS_COMMAND (before): 2900004 STATUS_COMMAND (after): 2900007 [OK] 000:16:0 106b:0002 10h mem 0xf3000000 0x00020000 STATUS_COMMAND (before): 82000016 STATUS_COMMAND (after): 2000016 [OK] --------------------------[ 0 devices bogus] nomap nomap nomap nomap nomap nomap nomap nomap nomap nomap OF_inited=18 nomap nomap no map nomap nomap nomap nomap nomap nomap nomap nomap OF_inited=25 checking node gc...macobio_match called macobio0 at bhst0 bus 0 macobio_attach called for gc controller...node found. using f3000000 for sc_membus_space.bus_base MESH_MATCH called ,ca->ca_name= legacy-interrupt-controller macintr0 at macobio0 macintr_attach: legacy-interrupt-controller baseaddr: f3000000 mapped to e74ce000 macintr_collect_preconf_intr: macobio_attach checking 53c94 MESH_MATCH called ,ca->ca_name= 53c94 macobio_print: 53c94 at macobio0 offset 0x10000 not configured macobio_attach checking mace MESH_MATCH called ,ca->ca_name= mace macobio_print: mace at macobio0 offset 0x11000 not configured macobio_attach checking escc MESH_MATCH called ,ca->ca_name= escc zsc0 at macobio0 offset 0x13000: irq 15,16 zstty0 at zsc0 channel 0 (console i/o) Checking for rate 38400. Found source #0. Rate is 38400, tc is 1, source no. 0, flags 2 Registers are: 4 40, 11 50, 14 1 zstty1 at zsc0 channel 1 macobio_attach checking awacs MESH_MATCH called ,ca->ca_name= awacs awacs0 at macobio0 offset 0x14000: irq 17,8,9 speaker audio0 at awacs0 macobio_attach checking swim3 MESH_MATCH called ,ca->ca_name= swim3 macobio_print: swim3 at macobio0 offset 0x15000 not configured macobio_attach checking via-cuda MESH_MATCH called ,ca->ca_name= via-cuda adb0 at macobio0 offset 0x16000 irq 18: via-cuda 2 targets aed0 at adb0 addr 0: ADB Event device akbd0 at adb0 addr 2: extended keyboard wskbd0 at akbd0 mux 1 ams0 at adb0 addr 3: 1-button, 100 dpi mouse wsmouse0 at ams0 mux 0 macobio_attach checking mesh MESH_MATCH called ,ca->ca_name= mesh macobio_print: mesh at macobio0 offset 0x18000 not configured macobio_attach checking nvram MESH_MATCH called ,ca->ca_name= nvram macobio_print: nvram at macobio0 offset 0x1d000 not configured bhst1 at mainbus0 found io space: f2000000 800000 found mem 80000000 10000000 mem base 80000000 sz 10000000 io base f2000000 sz 800000 config addr 800000 config data c00000 ioh_cf8 e74cc000 ioh_cfc e74cd000 : bandit Revision 0x3 tag: 5800 going to fixup [System BIOS Setting]----------------------- device vendor product register space address size -------------------------------------------- 000:11:0 106b:0001 STATUS_COMMAND (before): 22800016 STATUS_COMMAND (after): 2800016 [OK] 000:15:0 100b:0020 10h port 0x00000400 0x00000100 14h mem 0x80800000 0x00001000 STATUS_COMMAND (before): 2900007 STATUS_COMMAND (after): 2900007 [OK] 000:16:0 106b:0002 pci_addr_fixup: range outside extent_mem: f3000000, 20000, skipping STATUS_COMMAND (before): 82000016 STATUS_COMMAND (after): 2000016 [OK] --------------------------[ 0 devices bogus] nomap nomap nomap nomap nomap nomap nomap nomap nomap nomap OF_inited=18 nomap nomap no map nomap nomap nomap nomap nomap nomap nomap nomap OF_inited=25 macobio_match called pci0 at bhst1 bus 0 tag: 5800, id: 1106b, nfunctions: 1 pchb0 at pci0 dev 11 function 0 "Apple Bandit" rev 0x03 tag: 7800, id: 20100b, nfunctions: 1 sis0 at pci0 dev 15 function 0 "NS DP83815 10/100" rev 0x00mapping 80800000 size 1000 to e74d5000 vbase 80800000 sis: iobase 80800000, iosize 1000, mapped e74d5000 : DP83815D, irq 25, address 00:00:94:cb:df:4c nsphyter0 at sis0 phy 0: DP83815 10/100 integrated, rev. 1 tag: 8000, id: 2106b, nfunctions: 1 "Apple GC" rev 0x02 at pci0 dev 16 function 0 not configured mainbus node: chaos chaos device found...attaching...bhst2 at mainbus0 found io space: f0000000 800000 found mem 90000000 10000000 mapping f0800000 size 1000 to e74d6000 vbase f0800000 mapping f0c00000 size 1000 to e74d7000 vbase f0c00000 mem base 90000000 sz 10000000 io base f0000000 sz 800000 config addr 800000 config data c00000 ioh_cf8 e74d6000 ioh_cfc e74d7000 bandit_init:bh_conf_read/prime returned 3106b : chaos Revision 0x0 tag: 15800 going to fixup [System BIOS Setting]----------------------- device vendor product register space address size -------------------------------------------- 000:11:0 106b:0003 14h mem 0x90000000 0x00010000 18h mem 0x94000000 0x04000000 STATUS_COMMAND (before): 0 STATUS_COMMAND (after): 0 [OK] --------------------------[ 0 devices bogus] OF_inited=26 macobio_match called vci0 at bhst2 bus 1"Apple Control" rev 0x00 at vci0 dev 11 function 0 not configured rd0: fixed, 8192 blocks bootpath: 'enet/bsdOW.rd' string [/bsdOW.rd] not found Warning: boot device unrecognized: enet/bsdOW.rd rootdev=0x1100 rrootdev=0x1100 rawdev=0x1102 Checking for rate 38400. Found source #0. Rate is 38400, tc is 1, source no. 0, flags 2 Registers are: 4 40, 11 50, 14 1 erase ^?, werase ^W, kill ^U, intr ^C, status ^T (I)nstall, (U)pgrade or (S)hell? s # ifconfig -a lo0: flags=8008 mtu 33224 sis0: flags=8802 mtu 1500 address: 00:00:94:cb:df:4c media: Ethernet autoselect (none) status: no carrier # ifconfig sis0 inet 192.168.10.74 netmask 255.255.255.0 # ifconfig -a lo0: flags=8008 mtu 33224 sis0: flags=8843 mtu 1500 address: 00:00:94:cb:df:4c media: Ethernet autoselect (10baseT) status: active inet 192.168.10.74 netmask 0xffffff00 broadcast 192.168.10.255 # ping 192.168.10.99 PING 192.168.10.99 (192.168.10.99): 56 data bytes ping: sendto: Host is down ping: wrote 192.168.10.99 64 chars, ret=-1 ping: sendto: Host is down ping: wrote 192.168.10.99 64 chars, ret=-1 ping: sendto: Host is down ping: wrote 192.168.10.99 64 chars, ret=-1 ping: sendto: Host is down ping: wrote 192.168.10.99 64 chars, ret=-1 ping: sendto: Host is down ping: wrote 192.168.10.99 64 chars, ret=-1 --- 192.168.10.99 ping statistics --- 11 packets transmitted, 0 packets received, 100.0% packet loss # As can be seen, it is a working shell. There are several aspects to the above dmesg that I will document here. The first is the opening boot comment: >> OpenBSD/macppc Boot configuring L1/L2/L3 caches...no backside L2 cache present... unable to determine proper L2 cache value. This message is because the particular CPU installed is stock and does not have a backside L2 cache. The bootloader available at http://www.dialectronics.com/bootloader/ can measure the size of a backside cache and autoconfigure it, eliminating the need for compiling the value into the kernel in case OF can not configure it (some aftermarket cards lack the properties for OF to be able to). This has been documented extensively previously on this list. The second part of the bootloader message no active packagefile: 192.168.10.99,/boot.mac of_mfs.c: open bootpath: enet:,\boot.mac bootargs: bsdOW.rd load enet:,bsdOW.rd... file: 192.168.10.99,bsdOW.rd enet:,bsdOW.rd ope 1456691 bytes loaded! comes from having modified the network file system loading from the original boot.mac to no longer use NFS to load a RAMDISK installer. Instead I use TFTP to load both the bootloader and the compressed kernel. The compressed kernel file goes into memory at location 0x001000000 (16M) and the of_mfs (Open Firmware Memory File System, as I call it) fakes a file system for libsa during decompression. It is incompatible with NFS because of how the enet booting is handled in the stock nfs code for boot.mac. The big advantage here is that this overcomes a lot of the problems getting the OW RAMDISK onto a medium that the OW Mac can boot from. If you have a Mac with a tftp server (there are both freeware and shareware), you can use it to get the installer running on the OW Mac you want to use, or could if there was other parts functioning. After the various debugging messages prior to the Copyright, the following is present: mainbus node: bandit bhst0 at mainbus0 found io space: f2000000 800000 found mem f3000000 1000000 mapping f2800000 size 1000 to e74cc000 vbase f2800000 mapping f2c00000 size 1000 to e74cd000 vbase f2c00000 mem base f3000000 sz 1000000 io base f2000000 sz 800000 config addr 800000 config data c00000 ioh_cf8 e74cc000 ioh_cfc e74cd000 bandit_init:bh_conf_read/prime returned 1106b : bandit Revision 0x3 tag: 5800 going to fixup [System BIOS Setting]----------------------- device vendor product register space address size -------------------------------------------- 000:11:0 106b:0001 STATUS_COMMAND (before): 22800016 STATUS_COMMAND (after): 2800016 [OK] 000:15:0 100b:0020 10h port 0x00000400 0x00000100 pci_addr_fixup: range outside extent_mem: 80800000, 1000, skipping STATUS_COMMAND (before): 2900004 STATUS_COMMAND (after): 2900007 [OK] 000:16:0 106b:0002 10h mem 0xf3000000 0x00020000 STATUS_COMMAND (before): 82000016 STATUS_COMMAND (after): 2000016 [OK] --------------------------[ 0 devices bogus] This is representative of changes I made to pci_addr_fixup.c and mpcpcibr.c. In the case of the latter, I went ahead and created a completely new device based on the mpc106 code in the tree. I call this "bhst" for Bandit Host Turns out that first generation OW PCI Macs don't have "PCI-PCI Bridges" but instead have "PCI/Host Bridges." This results in some slightly different configuration register settings but as you can see, instead of 0xff for the revision, the code correctly reports 0x3. Another aspect of Macs with Bandit is that devices will get "loaded" into both memory spaces that bridges have. In later Macs, as far as I can tell, devices will only get loaded into the second memory space. Because of this, if pci_addr_fixup.c is passed a bus that is outside the memory space passed in, there will be an extent manager panic. In order to get around this, I had to take two steps. First, I skip devices loaded outside of the given memory space. The device skipped above is in one of the PCI slots, which gets loaded at 0x80000000, whereas the GC (Grand Central) dbdma chip gets loaded at 0xf3000000. Second, I call the bhst device twice from mainbus.c. The first pass uses the first memory space, and the second pass uses the second memory space. I share the I/O space mapping between the two instances of bhst. Next is the attachment of the macobio device to gc. The architecture layout for Bandit Macs is different than more recent Macs. Instead of a separate PCI-PCI Bridge for the interrupt-controller and then the PCI slots, both connect to the same PCI/Host bus. I had to fiddle with the files.macppc arrangement to get this to work. The next set of messages are from the devices under GC. There are extra debug messages for mesh because mesh doesn't work. It won't compile as is in the tree, and while I made what I believe to be appropriate changes to get it to compile, it does not work. The version of mesh.c in the tree is from a much earlier version of mesh.c than is current in NetBSD and preceeds a complete rewrite in which they eliminated the last of disk discovery problems While I attempted to grasp the changes and apply them while maintaining the existing version, I have not been able to get it to work. As far as I can tell, the problem is an asynchronous DMA event during disk discovery that is either not completing or is not being recognized as completed. I have further thoughts that I will elaborate on later. For now, I just return zero in mesh_match so that while the device is recognized, it does not attach. Otherwise scsibus gets irritated and things never complete. The second call to bhst yields pci0 at bhst1 bus 0 and further attachment of PCI devices in the slots, as can be seen by the attachment of sis0 to an Asante FriendlyNET PCI 696 card. The given MAC address is only after I added some code to if_sis.c to do some byte swapping after little endian issues. However, the card still does not work. The sis* driver does not work with the card installed on 3.5 on an AGP G4, by the way, so I believe the problem is in the driver, not the architecture. The first really working device is the third and final attachment of a bhst device: mainbus node: chaos chaos device found...attaching...bhst2 at mainbus0 found io space: f0000000 800000 found mem 90000000 10000000 mapping f0800000 size 1000 to e74d6000 vbase f0800000 mapping f0c00000 size 1000 to e74d7000 vbase f0c00000 mem base 90000000 sz 10000000 io base f0000000 sz 800000 config addr 800000 config data c00000 ioh_cf8 e74d6000 ioh_cfc e74d7000 bandit_init:bh_conf_read/prime returned 3106b : chaos Revision 0x0 tag: 15800 going to fixup [System BIOS Setting]----------------------- device vendor product register space address size -------------------------------------------- 000:11:0 106b:0003 14h mem 0x90000000 0x00010000 18h mem 0x94000000 0x04000000 STATUS_COMMAND (before): 0 STATUS_COMMAND (after): 0 [OK] --------------------------[ 0 devices bogus] OF_inited=26 macobio_match called vci0 at bhst2 bus 1"Apple Control" rev 0x00 at vci0 dev 11 function 0 not configured Although this session was captured through a serial console, I do have the display and keyboard console working. I did this by changing some of the default values in ofw_machdep.c so that if a call into OF failed to get width, height, line-bytes and depth those values don't get set to zero (???). From there I proceeded to write a new device which I call "vci" since that's what Apple says is the type for "/chaos." It responds very much like a PCI device, with a few exceptions. One is that it doesn't like the 0x10 register probed (I like being probed as little as possible, too, so I can relate). The second is that devices loaded by chaos have the PCI bus tag consistent with the range listed in OF (in this case, bus 1) but chaos will make a device appear at every PCI tag unless probed as bus 0. In other words, the device "control" will tag as 15800 but show as 5800. This should still work with 95/9600s with two Bandit chips, but I haven't been able to test this. The end result is that if Open Firmware 1.0.5 can use the display device, it should be useable as a VGA frame buffer. Because of a few subtle differences between a true VGA display device and /chaos/control's "VGA-like" frame buffer capabilities, I added the device "ctl_fb" and attached the wscons stuff to it. In order to get the zs stuff working I also added some changes to ensure that what is being probed is a true ch-a or ch-b serial device, instead of assuming that if it isn't ch-b it must be ch-a. The last stuff shows the shell functioning and being able to use ifconfig. However, without mesh or mace (the motherboard ethernet), there's little one can do. The card above is a popular Asante card ($20 at Other World Computing) and works well with MacOS and NetBSD. It's not bootable, though, as it contains no Open Firmware code. It also doesn't work with OpenBSD's sis* driver. I believe the problem here is endian, as in the sis driver is little-endian and macppc is big-endian. While bus_space_write_* can handle endian issues, I'm not sure that everything gets wrapped properly. Also, there is an odd note in the 7500/8500 hardware note from Apple regarding Bandit. It says that Bandit handles the (PowerPC) big-endian to (PCI) little-endian swapping. I can not find any other hardware notes on Macs with PCI-PCI Bridges that have the same note. I am not sure what to make of this. It could be there is a problem with an odd number of swaps, the data stream could be correct but the descriptor swapped, or it could be something completely different. I've spent some time with bus_space_write|read_* to see how the endian issue affects things. I eliminated the option to be big-endian so that every write used out32rb (for example). I got to the shell but it was very unstable and would lockup on the second keystroke. This leads me to believe that not every bus_space_write|read_* uses the _reverse setting, but I have not been able to confirm this nor identify patterns. I suspect that endian issues are affecting the mesh driver as well. As best as I can tell, any device that either does not use DBDMA or does so only on a byte by byte basis (like zs) appears to be working. No device, such as mesh, that uses DBDMA is working. Unfortunately, the same can be said about what devices are in the macppc tree and officially supported. The mesh driver does not appear to be on a supported model, and the sis* driver is in dev/pci but not macppc/dev. I tried to bring NetBSD's mace driver over, but it is so far out of sorts with OpenBSD that I decided against spending much time on it. As far as I can tell, I'm properly reading and writing to PCI registers in both memory spaces, as well as the I/O space. I'm pretty sure GC is working when dealing with single byte/non-endian issues. The sis* driver is able to read several non-base configuration registers on the Asante card, so I think the bhst stuff can deal with the PCI slots as well, but without a card with a known working driver I can not tell. I haven't tested against two Bandit chips, but I set up the bus ID stuff to come from the OF ranges property (on PCI/Host Bridges the start and end bus number are the same). It might be that someone with appropriate knowledge will instantly recognize that last little piece and get a working install. I've tried to clean up the code as best I could, but it's been somewhat like sculpting with a shotgun. I haven't gone into detail here beyond overall ideas because I put comments in the code that should address the specific changes. Comments that are "//" are mine; the rest should be from the tree. There are two files (L2Config.c and vci.c) that are original, and one (of_mfs.c) that is based on code by Tsubai Masanari with adaptation to Open Firmware by me. They are copyrighted, but the reality is that if one posts code publically, eventually it'll show up somewhere as someone else's work. Just ask Paul Mackerras. If you don't like that, don't post publically. The following is a list of modified files available at http://www.dialectronics.com/OldWorldMacs/code/ bsdOWc.rd boot24z.mac (two earlier versions of boot24*.mac are available as well - boot24d.mac has no cache enabling code, boot24t.mac does, both still use regular NFS) (to go in macppc/pci) bandit_host.c bandit_host.h vci.c vci_addr_fixup.c vgafb.c vgafb_control.c (to go in macppc/macppc) cpu.c db_interface.c machdep.c mainbus.c ofw_machdep.c openfirm.c (to go in macppc/dev) macintr.c mesh.c meshreg.h zs.c (to go in macppc/include) bus.h cpu.h (to go in macppc/stand) boot.c Locore.c ofdev.c of_mfs.c L2Config.c (to go in macppc/stand/boot.mac) fix-coff.c (properly licensed ELF->xcoff code, hack-off.c is not) Makefile.boot.mac (as Makefile) (to go in macppc/conf) files.macppc OWRAMDISK (to go in dev/pci) if_sis.c (minor byte swapping in sis_attach) I believe that covers what I know to this point. If I've missed a file, please let me know. This will be the final update, by the way. If someone has questions I will try to answer them, but I have decided not to stay with OpenBSD. I had hoped to use this project to gain experience with bringing OpenBSD to newer hardware, but in the end I realized it was time to stop and look at other operating systems. I would have posted diffs instead of the source file, but a clever way to get people to stop wanting to invest time and effort with OpenBSD is to bitch to tech@openbsd.org about contributors using tabs instead of spaces. tim --