The nuCF SCSI shim
A/UX only knows how to boot from SCSI disks. zigzagjoe’s nuCF is a CompactFlash card on the SE/30’s PDS slot, which is decidedly not a SCSI disk. Getting A/UX to boot from it meant convincing two different pieces of software that the card is SCSI ID 6: A/UX Startup on the Mac side, and the A/UX kernel itself.
This post covers how the two halves of that shim work.
Why a shim at all
Under plain Mac OS the nuCF doesn’t need any help: its declaration ROM has a driver, the Mac mounts the card like any other disk, and PrimaryInit makes it the startup device. A/UX ignores all of that, twice over:
- A/UX Startup (the Mac application that loads the kernel, “sash”) reads the A/UX partitions through the old SCSI Manager,
_SCSIDispatch, talking directly to SCSI IDs 0-6. It never goes through a Mac disk driver, so a card with only a driver is invisible to it. - The kernel doesn’t use Mac drivers at all. Its disks go through a generic disk layer, which talks to the hardware through a table of procedures per controller. The only controllers it has on an SE/30 are SCSI IDs.
So the card gets an identity that both of them already understand: a SCSI disk at ID 6.
The Mac side: the NuCF SCSI extension
NuCF SCSI is a 3 KB INIT in the boot volume’s Extensions folder. It’s written in 68k assembly and patches _SCSIDispatch so that anything addressed to ID 6 is answered by the card, and everything else goes to the real SCSI Manager.
Installing
At startup the extension:
- Asks the Slot Manager for the card’s sResource (17/13/1/207) and works out the register base from the slot it’s in,
$Fs000000 | s << 20. - Reads the ID from its own
nCFi128 resource (6 unless you change it in ResEdit; anything over 6 is ignored). - Sends the card an ATA IDENTIFY and takes the sector count from words 60-61. No card, or no answer: it quietly doesn’t install.
- Copies itself into the system heap, flushes the instruction cache, and puts itself in front of
_SCSIDispatch.
Pretending to be a SCSI bus
The old SCSI Manager is a conversation in several calls: SCSIGet to arbitrate, SCSISelect to pick a target, SCSICmd to send the command block, SCSIRead/SCSIWrite with a transfer instruction block (TIB) for the data, and SCSIComplete for the status and message bytes. The patch plays the target’s side of that conversation:
SCSIGetis deferred. AtSCSIGettime nobody knows which ID is coming next, so the patch just notes that a Get happened. If the followingSCSISelectis for ID 6 the session is ours and the real bus is never touched. For any other ID, the patch calls the realSCSIGetthen and passes the select through, so other disks work as normal.SCSICmdcopies the command block and decodes it on the spot.SCSIRead,SCSIWriteand the blind variants run the caller’s TIB themselves:scInc,scNoInc,scAdd,scMove,scLoop,scNop,scStopandscComp(compare, for verify reads).SCSICompletehands back the status byte, message 0, and ends the session.SCSIMsgInandSCSIMsgOutjust succeed.
The commands it understands:
| Command | What it does |
|---|---|
| READ(6), READ(10) | ATA READ SECTORS, one sector at a time into a 512-byte buffer |
| WRITE(6), WRITE(10), WRITE AND VERIFY | gathered into the buffer, ATA WRITE SECTORS when it fills |
| INQUIRY | NUCF CompactFlash 1.0, a fixed disk |
| READ CAPACITY | the IDENTIFY sector count, 512-byte blocks |
| MODE SENSE | made-up format (page 3) and geometry (page 4) pages |
| MODE SELECT | data accepted and thrown away |
| REQUEST SENSE | the sense from the last failed command |
| TEST UNIT READY, SEEK, VERIFY, START/STOP, PREVENT, FORMAT, … | succeed and do nothing |
Anything else gets CHECK CONDITION with “invalid command” sense, a read or write past the end of the card gets “LBA out of range”, and an ATA error comes back as a medium error. That’s about what sash and the A/UX disk utilities expect from a real drive.
The card itself is plain polled PIO: a command to the task file, wait for DRQ, then 128 long-word moves through the data register. Interrupts are masked while each sector moves, so the card’s own Mac driver can’t be entered half way through one.
Picking the card at startup
The extension makes the card reachable; something still has to pick it. A/UX Startup chooses its default disk from the driver of the volume the Mac booted from, and only understands SCSI drivers. A one-word patch to A/UX Startup makes it default to ID 6 when the Mac booted from the card’s own driver. The card’s PrimaryInit already makes itself the startup device, so with both in place a nuCF card boots straight into A/UX even with a BlueSCSI still on the bus (as long as that isn’t on ID 6).
The A/UX side: the nucf kernel driver
Once the kernel is running, A/UX Startup and its SCSI calls are gone. nucf is a small A/UX driver module (/etc/install.d/boot.d/nucf, source in se30/nucf.c in the kit) that gives the same ID to the kernel.
Finding the card
The driver never probes slots. A/UX Startup hands the kernel a table of the board IDs in each slot, and nucf looks for the nuCF’s board ID ($16D2) in it. It’s a software module rather than a slot driver: an early version tied it to one slot through autoconfig, and on the real machine launch then decided the kernel didn’t match the boards present and refused to boot it.
If the card is there, the driver turns off its interrupt line (A/UX only ever polls it), runs IDENTIFY, and prints the model and size on the console:

The kernel on the real SE/30: the board-ID table from A/UX Startup with the nuCF ($16D2) in slot $D, then the card (an iCF9000) as SCSI ID 6 on major 37, which is 24 + 7 + 6.
Standing in for a SCSI controller
A/UX’s generic disk layer handles everything disk-shaped: partition maps, slices, the /dev/dsk/c6d0s0 names, fsck, the root and swap devices. Underneath, each controller is just a table of eight procedures (read, write, drive init, bad block, format, recover, shutdown, drive info), which the SCSI driver normally fills in.
nucf swaps the open routine for the ID’s block and character majors, and on the first open it installs that controller with its own eight procedures before calling the stock open. Everything above that is unchanged A/UX code, so the root device that launch passes in (controller 6) just works.
- Major numbers. The SCSI code numbers controllers through
hd_bus[], filled in by its bus scan, and the real major is24 + 7 * bus + id.launchpasses the root as major24 + id. For an ID the scan found empty,nucffills in bus 1 so the two line up, and the scan then leaves that ID alone. - Scatter-gather. Requests can come as one buffer or a list of pieces, and a sector can straddle two pieces. Those go through a bounce buffer.
- Requests from completions. Every request finishes before its procedure returns, so the completion routine is called right away, and it often starts the next request. Those get queued and run by the outer loop instead of recursing, so the stack doesn’t grow with the queue.
- The Mac environment. The Mac side of A/UX mounts HFS partitions on the disks in the kernel’s
scsiarray[], which the bus scan fills in. The scan skips the card’s ID, sonucfadds the entry itself. That’s how the “nuCF Boot” and “nuCF HD” volumes end up on the 7.5.3 desktop.
Changing the ID
The kernel’s ID lives in nucf_id in /unix, 6 by default. se30patch -i 5 changes it (or -i -1 to leave the card unused), and newconfig keeps the setting when it builds a new kernel. When A/UX boots from a SCSI disk and only uses the card for storage, any free ID works. When it boots from the card, the kernel’s ID has to match the extension’s nCFi and /etc/fstab, which on the card image are all 6.
Whatever ID the card takes, a real SCSI device at that ID can’t be used while the card is installed.
Performance
The extension
The extension was written to be simple, not fast, and it shows:
- One ATA command per sector. Every 512 bytes is a full round trip: wait for the card to be ready, write the task file, issue READ SECTORS for a single sector, wait for DRQ, move the data, wait for the end of the command. CompactFlash cards have a fixed per-command latency, and paying it once per sector instead of once per request is the biggest cost. Writes are worse than reads, since single-sector writes are the worst case for a CF card’s internal flash management.
- Two copies of the data. The sector comes from the card into the extension’s buffer with long-word moves, then goes to the caller’s buffer a byte at a time, as the TIB asks for it. Writes go the other way through the same buffer.
- Interrupts off for every sector. The whole round trip, including waiting for the card, runs at interrupt level 7. VBL tasks, the cursor, sound and the serial ports all wait for it. Over a long read that means a stuttering cursor and a clock that loses ticks, and serial or LocalTalk data arriving at the same time can be dropped.
None of that matters much in practice, because of when it runs. Under Mac OS the card’s own driver handles its volumes; the extension is only in the path for old SCSI Manager calls to ID 6, and the only thing that makes those is A/UX Startup, reading the kernel and a handful of files while it boots. Calls for every other SCSI ID cost a few compares and, at most, one deferred SCSIGet.
The kernel driver
The kernel driver is the one that matters for day-to-day use, since every A/UX disk access and every Mac-environment access to the card’s HFS volumes goes through it. It’s in better shape:
- Up to 256 sectors per command. The disk layer is told there’s no transfer limit, so a large read is one ATA command per 128 KB, not one per sector.
- No extra copy. Sectors go straight between the card’s data register and the caller’s buffer, with an unrolled loop of eight long-word moves. Only a sector that straddles two pieces of a scatter-gather list goes through the bounce buffer, byte by byte.
- Interrupts stay on. The driver never raises the interrupt level, so the clock and serial ports keep running during transfers.
The cost is that it’s polled and synchronous. The CPU spins on the status register for the whole transfer, the request is done before the driver returns, and nothing else runs on the machine meanwhile, so A/UX can’t overlap disk I/O with other work the way it can with an interrupt-driven controller. On this SE/30 that’s less of a loss than it sounds, since one of the Carrera fixes already makes A/UX poll for SCSI reads as well.
The one setting to watch is nucf_debug. With it on, the driver prints a line on the console for every request, as in the photo of the first Finder start in A/UX on the Carrera040. Drawing console text on the SE/30’s screen is far slower than the transfer itself, so leave it off (echo 'nucf_debug?W 0' | adb -w /unix) unless you’re chasing a problem.
Getting it
Both halves are in aux-se30-carrera040.tar.gz. se30/install.sh installs the nucf kernel driver along with the kernel patches, and source/nucf/mac-init/ has the extension’s source (nucfscsi.s) and the script that builds it. The A/UX Startup patch isn’t included, since it’s a patched copy of Apple’s application.
A newer A/UX Startup carries the same shim code itself, so A/UX can start with extensions off: see Starting A/UX from System 7.5.5.