Subject: Old World PowerBook support
To: netbsd-macppc macppc <port-macppc@netbsd.org>
From: Michael Lorenz <macallan@netbsd.org>
List: port-macppc
Date: 09/19/2006 15:56:52
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

since I got a PowerBook 3400c to play with I couldn't help trying 
NetBSD on it ;)
Turns out the 3.x CDs don't boot but Izumi Tsutsui's patched iso images 
work just fine ( just do the usual setenv dance and then boot ata1/@0:0 
netbsd.macppc )
Then the console is horribly slow and it turns out that using both 
OFB_ENABLE_CACHE and the ohare L2 cache wedges the machine. Luckily 
documentation for the Chips & Technologies 65550 graphics controller is 
freely available from Intel so we don't need that anymore.
Finally I found out why the built-in ethernet controller doesn't work. 
It attaches just fine but doesn't get any interrupts which keeps it 
from ever transferring anything in any direction.
The reasons are:
- - OF lies about the interrupt line. Claims IRQ 27 which is wrong.
- - the interrupts arrive at a 2nd, cascaded ohare PIC which our current 
interrupt handling code is blissfully unaware of.
To get around that I added a hack to rewrite the tlp's interrupt line 
register to 60 and rewrote half of the old world interrupt handling to 
deal with cascaded PICs. Tested it on a PowerBook 3400c with two 
cascaded ohare and on a beige G3 with a heathrow - seems to work fine 
so far.
The code should support:
- - Grand Central, 32 IRQs
- - single O'Hare, 32 IRQs
- - single Heathrow, 64 IRQs
- - two O'Hare, 64 IRQs
Not sure about Gatwick - no hardware to test. Will probably just work.

If you have a PowerBook 3400c ( or a similar machine like the original 
PowerBook G3 ) with non-functional tlp please try this test kernel:
ftp://ftp.netbsd.org/pub/NetBSD/misc/macallan/macppc/netbsd.pb3400c.bz2

it contains a driver for the graphics controller and my 
interrupt-related changes.

Here's a dmesg:
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 
2005, 2006
     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 4.99.2 (DRAMBUIE) #56: Tue Sep 19 01:55:54 EDT 2006
         root@cointreau:/wd/build/obj/sys/arch/macppc/compile/DRAMBUIE
total memory = 49152 KB
avail memory = 43432 KB
sysctl_createv: sysctl_create(security) returned 17
found OHare at 0xf3000000
found OHare2 at 0x80900000, irq 28
Handling 64 interrupts
bootpath: ata0/@0/netbsd.new
mainbus0 (root)
cpu0 at mainbus0: 603ev (Revision 2.1), ID 0 (primary)
cpu0: HID0 90c000<DOZE,DPM,ICE,DCE>, powersave: 1
cpu0: 200.00 MHz
cpu0: ohare L2 cache enabled
bandit0 at mainbus0
pci0 at bandit0 bus 0model: AAPL,3400/2400
frobbing tlp IRQ to 60
pci0: i/o space, memory space enabled
pchb0 at pci0 dev 11 function 0
pchb0: Apple Computer Bandit Host-PCI Bridge (rev. 0x03)
tlp0 at pci0 dev 13 function 0: DECchip 21041 Ethernet, pass 2.1
pci_intr_map: pin: 1, line: 60
tlp0: interrupting at irq 60
tlp0: Ethernet address 00:00:94:7b:63:0d
tlp0: 10baseT, 10base2, 10base5, 10baseT-FDX
obio0 at pci0 dev 14 function 0: addr 0x80900000
obio1 at pci0 dev 16 function 0: addr 0xf3000000
mesh0 at obio1 offset 0x10000 irq 12: 50MHz, SCSI ID 7
scsibus0 at mesh0: 8 targets, 8 luns per target
zsc0 at obio1: irq 15,16
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
awacs0 at obio1 offset 0x14000: irq 17,8,9
audio0 at awacs0: full duplex
mediabay0 at obio1 offset 0x34 irq 29 level-triggered
wdc0 at mediabay0 offset 0x21000 irq 14
atabus0 at wdc0 channel 0
wdc1 at obio1 offset 0x20000 irq 13: DMA transfer
atabus1 at wdc1 channel 0
adb0 at obio1 offset 0x16000 irq 18: 2 targets
aed0 at adb0 addr 0: ADB Event device
akbd0 at adb0 addr 2: PowerBook extended keyboard
wskbd0 at akbd0: console keyboard
ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi
wsmouse0 at ams0 mux 0
apm0 at adb0: battery flags 0xE5, 91% charged
chipsfb0 at pci0 dev 17 function 0: Chips and Technologies 65550 (rev. 
0x45)
Panel size: 800 x 600
chipsfb0: initial resolution 800x600, 8 bit
chipsfb0: 16 MB aperture at 0x81000000
pci_intr_map: pin: 0, line: 0
pci_intr_map: interrupt pin 0
chipsfb0: failed to map interrupt
wsdisplay0 at chipsfb0 kbdmux 1: console (default, vt100 emulation), 
using wskbd0
wsmux1: connecting to wsdisplay0
cbb0 at pci0 dev 19 function 0: Texas Instruments PCI1130 PCI-CardBus 
Bridge (rev. 0x04)
cbb1 at pci0 dev 19 function 1: Texas Instruments PCI1130 PCI-CardBus 
Bridge (rev. 0x04)
pci_intr_map: pin: 1, line: 22
cbb0: interrupting at irq 22
cbb0: secondary bus number uninitialized; try PCI_BUS_FIXUP
cardslot0 at cbb0 slot 0 flags 0
pcmcia0 at cardslot0
pci_intr_map: pin: 2, line: 23
cbb1: interrupting at irq 23
cbb1: secondary bus number uninitialized; try PCI_BUS_FIXUP
cardslot1 at cbb1 slot 1 flags 0
pcmcia1 at cardslot1
scsibus0: waiting 2 seconds for devices to settle...
atapibus0 at atabus0: 2 targets
cd0 at atapibus0 drive 0: <CD-ROMFFREDDIE, , 1.0b> cdrom removable
cd0: drive supports PIO mode 3, DMA mode 1
cd0(wdc0:0:0): using PIO mode 3
wi0 at pcmcia1 function 0: <Dell, TrueMobile 1150 Series PC Card, 
Version 01.01, >
wi0: 802.11 address 00:02:2d:20:46:36
wi0: using Lucent Technologies, WaveLAN/IEEE
wi0: Lucent Firmware: Station (6.10.1)
wi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
wd0 at atabus1 drive 0: <IBM-DCRA-22160>
wd0: drive supports 16-sector PIO transfers, LBA addressing
wd0: 2067 MB, 4200 cyl, 16 head, 63 sec, 512 bytes/sect x 4233600 
sectors
wd0: drive supports PIO mode 4, DMA mode 2
wd0(wdc1:0:0): using PIO mode 4, DMA mode 2 (using DMA)
boot device: wd0
root on wd0a dumps on wd0b
root file system type: ffs
wsdisplay0: screen 1 added (default, vt100 emulation)
wsdisplay0: screen 2 added (default, vt100 emulation)
wsdisplay0: screen 3 added (default, vt100 emulation)
wsdisplay0: screen 4 added (default, vt100 emulation)

The warning about failed interrupt mapping from chipsfb is harmless - 
the driver is still a bit rough. Supports basic acceleration like 
scrolling and rectangle fills but characters are still drawn in 
software and it doesn't know how to program video modes. XFree86's 
chips driver needs some minor patches ( endianness related. Text in 
xterms is rendered wrong - I'll commit a fix when I get around to clean 
it up ) and it fails to clean up after itself so the console looks 
funny when X exits - it's fully functional though.

have fun
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iQEVAwUBRRBLhMpnzkX8Yg2nAQJpDggAqwQ/Z++DZohMYoab42dNmeEa8ImCmLfB
HYgFSwmcuQYVZrVA6O02GKaF+k5g9I3aeq/+iXg9X1pCeJvu5F3xCSijxHJbdPWI
/BoE4ZzxwLcPgrwKoQ4DN49e8kF/6w4zOilA5kefpEuc1Dn833PAOprhd0fnfeVq
P1BuuhE5GKQZLh5Mb1TJg6gQwDGVnY4Ddx65qmLRNgOgbKrDX4aTDF7NavZQkawj
78LqJ/4+VWq7IM/5C8HwMpXQkk9dvG1iASHQo53IjW9QVEGT1E9iEDiG3b3wfoPk
/2q84wOT6kzYZORrKhDFWD3xkFwNbSdQdmdOFgZohBgvHuI88H9WJA==
=LAyh
-----END PGP SIGNATURE-----