Skip to content

Latest commit

 

History

History
1853 lines (1608 loc) · 112 KB

aic7880.md

File metadata and controls

1853 lines (1608 loc) · 112 KB

Adaptec AIC-7880 Ultra SCSI controller (SGI O2)

The O2 has two AIC-7880s on the MACE PCI bus: PCI device 1 drives the internal SCSI bus (system disk, optional second disk, CD-ROM) and PCI device 2 the external HD68 connector. IRIX calls them adp78 controllers 0 and 1; hinv reports "Integral SCSI controller 0: Version ADAPTEC 7880".

This document is the specification IRIS implements against. It collects what the chip does from every public source we have and marks where each fact comes from, because Adaptec never published an AIC-7880 data book. It covers the chip's principles of operation, its PCI configuration space, every device register with its bit fields, the sequencer and its instruction set, the sequencer programs the O2's drivers download, how the O2 wires the chips, and the differences between the 7880 and its siblings. The known gaps between this specification and the current emulation are tracked separately in clanker/devices/aic7880-emulation-vs-spec.md.

1. Sources and how they are cited

Tag Source What it is good for
[7870] AIC-7870 Data Book (Adaptec, 1994), docs/datasheets/scsi/AIC-7870_Data_Book.pdf, cited by PDF page The register set the 7880 inherits almost unchanged: every bit of every register, reset values, the data FIFO, pause and interrupt semantics, PCI config space. No Ultra content, no instruction set.
[7850] AIC-7850 Data Book (Adaptec, 1995), docs/datasheets/scsi/AIC-7850_Data_Book.pdf, cited by PDF page The same architecture on the narrow, 3-SCB low-end part. Clearer prose on register sharing, reset, pause, interrupts and the FIFO; useful where the 7870 scan is garbled.
[7890] AIC-7890A/7891 Data Book Rev B 8/98 (bitsavers mirror; see §13) The Ultra2 successor. Same sequencer, documents SEEPROM/FlexPort operation. Register layout differs; use for semantics only.
[7770] AIC-7770 Data Book (bitsavers) The EISA ancestor the Linux register file was transcribed from; its page numbers appear in aic7xxx.reg.
[reg] aic7xxx.reg, Linux drivers/scsi/aic7xxx/ Adaptec/Gibbs register and scratch-RAM definitions, authoritative for names and bit values across the family.
[drv] Linux aic7xxx_core.c, aic7xxx_pci.c, aic7xxx.seq, aicasm/; NetBSD sys/dev/ic/aic7xxx*.c, sys/dev/pci/ahc_pci.c What a driver actually does to the chip, the sequencer instruction encoding, the shipped firmware. Cited as file:line.
[him] Adaptec's Hardware Interface Module as the O2 PROM and IRIX drive the chip: the register traffic they generate and the sequencer image they download, disassembled for this document The firmware the O2 actually runs.
[mace] MACE I/O ASIC Specification rev 2.0, docs/datasheets/o2/mace.pdf; CRIME 1.5 Specification, docs/datasheets/o2/crime1_5.pdf; IRIX 6.3 for O2 Device Driver Programming Guide ch. 15 How the O2 attaches PCI devices: windows, byte swapping, interrupts.
[86box] 86Box src/scsi/scsi_aic7xxx.c (2026) The only other register-level AIC-7xxx model; an independent reading of the data books, used as a cross-check and so marked.
[obs] Observed on IRIS while booting the O2 PROM, IRIX, NetBSD and OpenBSD (clanker/devices/ip32-o2-bringup-log.md) What the real drivers write; the only evidence for the HIM's host-memory structures.

Register addresses are offsets into the 256-byte device register window. A value such as 0x5a is hexadecimal; bit numbers count from 0. "Host" means a PCI access from the CPU; "sequencer" means the chip's own processor.

2. The part

2.1 Family and lineage

The AIC-7880 is Adaptec's single-chip PCI Ultra SCSI (Fast-20) host adapter: PCI 2.1 bus master, 8- or 16-bit single-ended SCSI at up to 20 Mtransfers/s (40 MB/s wide), an on-chip programmable sequencer, 16 internal SCBs and the memory port for an optional external SCB RAM, BIOS ROM and serial EEPROM. It is the AIC-7870 (Fast SCSI, 1994) with the Ultra transfer mode added; the AIC-7850 is the narrow, 3-SCB, no-memory-port member; the AIC-7860 is the 7850 with Ultra; the AIC-7895 is two 7880 channels on one die; the AIC-7890/91/96/97 are the Ultra2 generation, which keeps the sequencer but reorganises the host side (command channel, queue registers, 64-byte SCBs).

Every member shares the register map in §6, the sequencer in §7 and the command flow in §4. The drivers treat the 7880 as "a 7870 plus Ultra" [drv aic7xxx.h:200-205: AHC_AIC7880_FE = AHC_AIC7870_FE | AHC_ULTRA]. What the 7880 adds over the 7870, as far as any source shows:

Difference 7870 7880 Source
PCI device ID 0x7870 (0x7178 on the AHA-2940) 0x8078 generic; board IDs 0x8178, 0x8278, 0x8378, 0x8478, 0x8578, 0x8678, 0x8778, 0x8878, 0x0078 [drv aic7xxx_pci.h:71-82]
SXFRCTL0 bit 5 not used, reads 0 FAST20: doubles the synchronous clock, SXFR 0–2 become 20/16/13.4 MHz [reg], [drv aic7xxx_core.c:117-135], [7870 p. 74]
DEVCONFIG bit 12 — REXTVALID, read-only: an external precision resistor is fitted, Ultra timing valid [drv aic7xxx_pci.c:570-586, 865-873]
Errata flags AHC_PCI_2_1_RETRY_BUG etc. per revision rev 0: AHC_CACHETHEN_BUG, AHC_PCI_MWI_BUG; rev ≥ 1: AHC_PCI_2_1_RETRY_BUG; always AHC_TMODE_WIDEODD_BUG [drv aic7xxx_pci.c:2176-2193]

Everything else in this document that is stated for the 7870 is taken to hold for the 7880. Where a 7880-only behaviour is known only from a driver, the driver is cited.

2.2 Block diagram

[7870 p. 6; 7850 p. 2-5]

   PCI bus (32-bit AD, parity, INTA#)
        │
   ┌────┴─────────────────────────────────────────────────────┐
   │ PCI host interface: config space, target decode of the   │
   │ 256-byte register window (I/O BAR0 or memory BAR1),      │
   │ bus master with LHADDR/HHADDR/HCNT and cache-line        │
   │ commands                                                 │
   └────┬─────────────────────────────────────────────────────┘
        │ 8-byte port
   ┌────┴────────────┐   byte port (DFDAT)   ┌────────────────────────┐
   │ Data FIFO       │◄─────────────────────►│ Sequencer              │
   │ 256 B = 32 QWD  │                       │ 512 × 29-bit program   │
   │ (7850: 128 B)   │                       │ RAM, 9-bit PC, 4-entry │
   └────┬────────────┘                       │ stack, ACCUM/SINDEX/   │
        │ 2-byte port                        │ DINDEX, FLAGS          │
   ┌────┴────────────┐                       └───────────┬────────────┘
   │ SCSI module     │                                   │
   │ 16-byte SCSI    │      internal 8-bit CIOBUS        │
   │ FIFO, STCNT,    │◄──────────────────────────────────┤
   │ SHADDR, sync    │  (256 read + 256 write addresses, │
   │ offset logic,   │   host and sequencer both masters)│
   │ selection timer │                                   │
   └────┬────────────┘       ┌─────────────────┐  ┌──────┴──────────┐
        │                    │ Scratch RAM 64 B│  │ SCB array       │
   SCSI bus (8/16-bit SE)    │ 0x20–0x5f       │  │ 16 × 32 B, one  │
                             └─────────────────┘  │ page at 0xa0–bf │
   Memory port: MA[14:0], MD[7:0], MDP, MRW,      │ (external SRAM  │
   RAMCS#, ROMCS#, SEECS, EXTARBREQ#/ACK# —       │ up to 256 SCBs) │
   external SCB SRAM, BIOS ROM, 93Cxx SEEPROM     └─────────────────┘

Clocks: CLKIN 40 MHz drives the SCSI module, sequencer, FIFO and memory port; PCLK ≤ 33 MHz drives the PCI side. The sequencer runs at CLKIN/4 (10 MHz, SEQCTL.FASTMODE = 1) or CLKIN/5 (8 MHz) [7870 p. 98]. All logic is static. On the O2 the SCSI clock is assumed to be the 40 MHz the part needs for Fast-20; no O2 document states it.

2.3 What is fixed and what is firmware

The silicon provides the SCSI protocol engine (arbitration, selection, reselection, synchronous and asynchronous handshakes, parity, the selection timer, bus-free detection), the DMA engines on both sides of the data FIFO, the SCB page RAM and two 16-entry queues, interrupt latching, and a small RISC processor. It provides no policy: nothing in hardware fetches an SCB, decides which target to select, walks a scatter/gather list, handles messages or posts a completion. All of that is the sequencer program the driver downloads at initialisation, and each driver family brings its own:

  • The O2 PROM and IRIX carry Adaptec's Hardware Interface Module (HIM) and its sequencer image (§8.2).
  • NetBSD, OpenBSD, FreeBSD and Linux carry Justin Gibbs' aic7xxx.seq (§8.1).

Hence the SCB byte layout, the scratch-RAM layout, the meaning of SEQINT codes and the host/firmware handshake are per firmware, and the register semantics in §6 are the only contract shared by all of them. An emulator that executes the downloaded program needs only §6 and §7; an emulator that reimplements a firmware's behaviour needs §8 as well, once per firmware.

3. The O2 integration

[mace §9, §11; CRIME Table 3-1; IRIX 6.3 O2 DDG ch. 15; drv NetBSD arch/sgimips/mace/pci_mace.c, Linux arch/mips/sgi-ip32, pci/fixup-ip32.c]

3.1 Placement and identification

Item Value
PCI bus 0, the only bus; MACE's bridge supports five devices: two on-board SCSI chips and three slots
Internal SCSI device 1, function 0, "SCSI controller 0", IRIX adp78 0
External SCSI device 2, function 0, "SCSI controller 1", IRIX adp78 1
Expansion slots devices 3, 4, 5 (IRIX counts "slot 2" as the first real slot)
Vendor:device 0x9004:0x8078 (both). Subsystem IDs are not decoded by any driver for 9004 parts
Revision not recorded in any source we have; Linux's bug flags differ only between rev 0 and rev ≥ 1 (§2.1). 86Box uses 3 and calls it "Rev B"
Configuration cycles mechanism 1: CONFIG_ADDRESS at physical 0x1f080cf8, CONFIG_DATA at 0x1f080cfc; tag `bus<<16
Interrupt INTA# only, hardwired: SCSI 0 → MACE PCI interrupt input 0 → CRIME interrupt bit 8; SCSI 1 → input 1 → CRIME bit 9. Level-sensitive, enabled in the MACE PCI control register (bits 0 and 1) and the CRIME mask
SEEPROM none fitted. SEECTL.SEERDY never asserts and DEVCONFIG.REXTVALID reads 0; every OS overrides the latter (Linux ORs 0x1000 into config reads of 0x40 for devices 1 and 2, NetBSD and OpenBSD set per-device Ultra overrides) because the chips do run Ultra
Host SCSI ID the PROM programs SCSIID.OID = 0 and leaves SCSISEQ non-zero; NetBSD then reports "Using left over BIOS settings ... SCSI Id=0" on real hardware, and its own default of 7 on a chip nothing initialised. SGI reserves address 0 for the adapter on both buses
Wide both chips are wide (SBLKCTL.SELWIDE reads 1 after chip reset; NetBSD reports "Ultra Wide Channel A")
Termination internal bus terminated on the board; external: active terminator on the last device, nothing needed with nothing attached
Bus speed PCI 33 MHz, 32-bit for these devices; MACE prefetch line 128 bytes; IRIX programs cache line 0x20 dwords and latency 0x30

3.2 CPU access to the registers: windows and byte lanes

The CPU reaches PCI memory space through two windows, PCI I/O space through one, and configuration space through the two registers above:

CPU physical PCI Size Note
0x1800_0000 I/O 0x0000_0000 32 MB low I/O window
0x1a00_0000 memory 0x8000_0000 32 MB low memory window: the PROM, IRIX and NetBSD put device BARs here
0x1_0000_0000 I/O, full 4 GB 64-bit kernels
0x2_0000_0000 memory, full 4 GB 64-bit kernels (OpenBSD)

PCI devices must be placed above 0x8000_0000 in PCI memory space because the lower 2 GB is host memory as seen by bus masters (§3.3). The PROM programs the 7880s' memory BAR1; it leaves I/O BAR0 unassigned, and MACE rev 0's I/O space is unusable for byte and halfword accesses anyway (the bridge presents a 4-byte-aligned address). Every O2 driver therefore drives the chip through its 4 KB memory BAR, in which the 256 registers repeat 16 times. Linux additionally runs the register-access self-test of §5.4 on BAR1 before trusting it.

Byte lanes. The CPU is big-endian and MACE presents PCI space with its byte lanes swapped within each 32-bit word: a 32-bit access is passed straight through, an 8-bit access at CPU offset A reaches device byte A ^ 3, a 16-bit one A ^ 2. Drivers compensate (NetBSD's CHIP_WRONG_ENDIAN, OpenBSD's read_1 XOR 3, IRIX's Table 15-3); gxemul and IRIS apply the same XOR. The chip itself sees ordinary byte accesses at the right offsets. All aic7xxx register accesses are 8-bit, so this only matters to the bridge.

3.3 DMA: the two views of host memory

[mace §9.3.1, p. 159–160; CRIME 1.5 §3 p. 3-7/3-8; IRIX 6.3 O2 DDG ch. 15; him; obs]

A PCI bus master sees the O2's memory twice:

PCI address View Behaviour
0x0000_0000–0x3fff_ffff reverse-endian ("byte-swapped") view sub-64-bit references have their bytes swapped to the device's endianness: PCI byte a is memory byte a. A byte stream (disk data, a CDB) and a little-endian structure (Linux's and the BSDs' SCBs) arrive byte-exact. A 32-bit value the big-endian CPU stored is seen by the little-endian device byte-reversed.
0x4000_0000–0x7fff_ffff native-endian view bytes pass through in the memory system's own order: a 32-bit word reads on PCI with the value the CPU wrote, so PCI byte a is memory byte a ^ 3 for a 32-bit master. The DDG's example: a master writing 0x0807060504030201 here leaves the big-endian CPU reading 0x0807060504030201.
0x8000_0000–0xffff_ffff not host memory other PCI devices

Bit 30 of a DMA address therefore chooses word-preserving (set) or byte-preserving (clear) transfers, and the drivers choose per structure:

  • Linux (dma_addr = phys & 0x3fffffff), NetBSD and OpenBSD (physical addresses untranslated; the O2's first 256 MB of RAM is aliased at physical 0 and the kernels live there) put everything in the low view. Their SCBs and S/G lists are written little-endian with ahc_htole32 and data buffers are byte streams, so the low view is right for all of it.
  • IRIX's HIM sets bit 30 on the SCB pointer array, the SCBs, the S/G lists, the sense mini-list and the completion array (0x4107_52fc), and clears it on the CDB pointer and every data or sense buffer (0x0107_532c), both naming the same bytes. Its SCB and S/G structures are declared for a big-endian host with the byte fields of each 32-bit word reversed, so that the word-preserving view presents Adaptec's little-endian layout to the chip (§8.2).

IRIS currently delivers address order in both views (src/dev/mace_pci.rs) and lets the HIM model compensate by reading those words big-endian and flipping the low two address bits of the completion array; the word width of the real native-view pass-through for 64-bit masters is an open question in §12.

3.4 What the PROM leaves behind

The O2 PROM initialises both chips at power-on: chip reset, pause, CLRINT of every interrupt, SCBPTR 0..15 with the last SCB byte cleared, scratch RAM 0x3a–0x5d filled with the HIM's configuration, a 1696-byte sequencer download, then SCSIID = 0 and a bus scan [obs]. A kernel booted afterwards finds SCSISEQ non-zero, HCNTRL.CHIPRST clear, and the HIM's scratch contents; the BSD driver calls this "left over BIOS settings" and keeps the host ID. NetBSD additionally forces target defaults for devices 1 and 2 because the PROM's per-target rate bytes are conservative.

4. Principles of operation

4.1 The register file and who may touch it

[7870 p. 57, 59, 63, 70, 130–131, 198; 7850 p. 3-3, 4-58/59, 7-3]

The chip has one 256-byte device register space. The host reaches it through BAR0 (I/O) or BAR1 (memory, 4 KB with the 256 bytes repeating); the sequencer addresses the same space with an 8-bit source address and an 8-bit destination address in every instruction. Reads and writes are decoded separately, which is why several addresses are two registers: SCSISIGI (read) and SCSISIGO (write) at 0x03, SSTAT0/CLRSINT0 at 0x0b, SSTAT1/CLRSINT1 at 0x0c, ALLZEROS/NONE at 0x6a, INTSTAT read by the host and written by the sequencer at 0x91, ERROR/CLRINT at 0x92. The sequencer can read, modify and write a register in one instruction; the host can only read or write.

Block map:

Range Block
0x00–0x1f SCSI module
0x20–0x5f scratch RAM, 64 bytes, parity protected
0x60–0x6f sequencer control and ALU registers (0x70–0x7f unassigned on the 7880; TARG_OFFSET there exists only on parts with more SRAM)
0x80–0x9f host interface, DMA, interrupt, SCB pointer and queues, data FIFO
0xa0–0xbf the 32-byte SCB page selected by SCBPTR
0xc0–0xff reserved on the 7880 (the Ultra2 parts put the command channel and queue registers at 0xe0–0xff)

Rules the host must follow:

  • Any register the sequencer uses may only be accessed while the sequencer is paused. Exceptions that need no pause: HCNTRL; DSVENDID0/1, DSDEVID0/1; INTSTAT (read); CLRINT (write); ERROR (read); QOUTFIFO and QOUTCNT (read); all configuration space. SINDIR and DINDIR are sequencer-only.
  • An access to a shared register while the sequencer runs is serviced by Automatic Access Pause: the PCI cycle is stretched (TRDY# held off) while the sequencer is transparently paused for that one access, then it resumes. It is not latched. Linux relies on this (AHC_AUTOPAUSE) to ring its scratch-RAM doorbell without pausing [drv aic7xxx_core.c:641-650].
  • LHADDR/HHADDR, HCNT, DFWADDR, DFRADDR and DFDAT may only be accessed while HDMAEN and SDMAEN are inactive; writing HADDR or HCNT with HDMAEN set records ILLSADDR in ERROR [7770, via 86box].
  • Host reads of registers written by the sequencer are latched at the start of the read.
  • With neither ISPACEEN nor MSPACEEN set in the PCI command register no device register is reachable.
  • Undefined addresses read back the last value left on the internal data bus (bus hold); 0x8f, 0x96 and 0x98 read 0 after reset. HADDLDSEL = 2 or 3 makes 0x88–0x8b read stale data too.
  • Device registers are 8-bit: a PCI access with more than one byte enable is answered with a target abort (STA), except DWORD writes into the SCB page with SCBCNT.SCBAUTO set and writes to the external ROM. Configuration space accepts any byte-enable combination. Bursts are disconnected after the first data phase (except linear SCB DWORD bursts) [7870 p. 33–34, 178–179].

Configuration-space bytes a driver needs at run time are mirrored into device space: VENDORID → DSVENDID (0x80/0x81), DEVICEID → DSDEVID (0x82/0x83), COMMAND[3:0] → DSCOMMAND[3:0] (0x84), LATTIME → DSLATTIME (0x85), STATUS error bits → DSPCISTATUS[5:0] (0x86).

4.2 Pause, unpause, step and sleep

[7870 p. 98, 137–138, 152, 174–175; 7850 p. 5-7…5-9; 86box]

  • The host requests a pause by writing HCNTRL.PAUSE = 1 and polls HCNTRL until bit 2 reads 1 (PAUSEACK). While paused the sequencer holds at the current address (SEQADDR shows the next instruction) and all internal buses are available to the host. A read of HCNTRL after a write that changed PAUSE is stretched until the read value matches.
  • Hardware also sets PAUSE for SEQINT, SCSIINT and BRKADRINT, and on RST#/CHIPRST (HCNTRL resets to 0x05, so the sequencer powers up paused). CMDCMPLT does not pause. It is the event that pauses: a SEQINT write pauses even if the previous one is still pending; a SCSI condition pauses when it appears. Once stopped, only a host write of PAUSE = 0 releases it, so the sequencer stays stopped after the interrupt has been cleared until the driver unpauses, and a host that unpauses with the interrupt still standing gets a running sequencer.
  • "When PAUSE is cleared the sequencer always executes at least one instruction, even if some other event is active to pause it." Single stepping (SEQCTL.STEP = 1, then write PAUSE = 0) rests on this: one instruction runs and PAUSE is set again.
  • SEQCTL.PAUSEDIS, which the sequencer sets around critical sections, disables the host's PAUSE request but not interrupt or error pauses; it is cleared by SCSI interrupts, illegal-opcode and parity interrupts. The host cannot write it. Linux instead clears critical sections by single-stepping the sequencer out of a downloaded address range (ahc_clear_critical_section, [drv aic7xxx_core.c:1988-2078]).
  • A pause request is deferred while an instruction is stretched waiting for external SCB-RAM arbitration.
  • Sleep: the sequencer writes SLEEPCTL.SLP0 (wake on SELDO/SELDI) or SLP1 (wake on DMADONE/PHASEMIS) to stop itself until that status appears; any host write to HCNTRL clears SLP[1:0], so queuing work wakes it. SLEEPDIS makes the write a no-op. The Gibbs firmware does not use sleep.
  • Restart: pause, write SEQADDR0 then SEQADDR1, unpause. SEQCTL.SEQRESET forces the PC to 0.
  • Breakpoint: BRKADDR0/BRKADDR1[0] with BRKADDR1.BRKDIS = 0 pauses the sequencer when the PC reaches the address and sets INTSTAT.BRKADRINT; the pin is driven only if SEQCTL.BRKADRINTEN.
  • Write-then-read hazard: because an instruction executes in one clock, a status bit that reflects a control bit written by the previous instruction may not be updated yet. [7870 Table 5-5, p. 176] lists SDONE, DMADONE, SCSIPERR, the SCSIEN/SDMAEN/HDMAEN/DIRECTION/FIFOFLUSH acks, FIFOQWDEMP, MREQPEND, HDONE, DFTHRSH, FIFOFULL, FIFOEMP, DFCACHETH; firmware inserts NOPs. An emulator that updates them synchronously is safe for firmware that waits; firmware that relies on a stale read for exactly one instruction would differ.

4.3 Reset

[7870 p. 40, 131, 138, 167; 7850 p. 2-15, 4-67]

Event Effect
PCI RST# All outputs float; configuration and device registers return to their reset values; internal RAM (scratch, SCB, queues, program RAM, FIFO) is indeterminate. The internal power-on reset lasts two more CLKIN edges. Afterwards the chip clocks an 8-bit device-ID byte in on IDDAT (8 clocks at 20 MHz on LED#); 0xff keeps the default; PCI accesses meanwhile get Retry; the 4th clock samples RAMPS#.
HCNTRL.CHIPRST = 1 The same for device space only: configuration space, DEVCONFIG and STPWLEVEL are untouched. POR stays active 2–3 CLKIN. HCNTRL becomes 0x05 (PAUSE + CHIPRSTACK); bit 0 reads 1 until the host writes HCNTRL again with bit 0 clear. RAM contents survive (scratch, SCB array, program RAM) [86box, 7770]: a driver resetting the chip still finds the PROM's scratch settings.
Both SEQCTL → 0x90, SEQADDR/BRKADDR0 → 0, BRKADDR1 → 0x80, DFCNTRL → 0, DFSTATUS → 0x21, SBLKCTL → 0xc0 plus SELWIDE from the WIDEPS# strap, HCNTRL → 0x05, all CLRINT bits forced active (no interrupt pending), ILLOPCODE and STPWEN cleared, STPWCTL to its inactive level, SCSISEQ/SCSISIGO/SCSIRATE/SIMODE*/SSTAT* → 0, selection and other timers stopped.
SCSI bus reset (own SCSIRSTO or external) All SCSISEQ bits except SCSIRSTO cleared, all SCSISIGO bits cleared. SSTAT1.SCSIRSTI is set for a reset seen on the bus; the 7870/7880 report their own reset too (the BSD driver masks ENSCSIRST around a bus reset for that reason), the 7770 does not [86box].
Bus free SCSISIGO bits, ATN, SELDO, SELDI cleared.

4.4 Interrupts

[7870 p. 44, 141–144, 188–189; 7850 Table 5-5]

INTA# is asserted when HCNTRL.INTEN = 1, COMMAND.MASTEREN = 1 and HCNTRL.POWRDN = 0, for any of:

Cause Enable Pauses the sequencer INTSTAT bit ERROR bit Cleared by
Sequencer writes INTSTAT with bit 0 and a 4-bit code in bits 7:4 always yes, immediately (no instruction after the write) SEQINT — CLRINT.CLRSEQINT
Sequencer writes INTSTAT with bit 1 always no CMDCMPLT — CLRINT.CLRCMDINT
Any SSTAT0/SSTAT1 condition enabled in SIMODE0/SIMODE1 the SIMODE bit yes SCSIINT — clear the cause through CLRSINT0/1, then CLRINT.CLRSCSIINT; a second SCSI event while one is pending sets its status bit but raises no new interrupt
Breakpoint address reached BRKDIS = 0 (pin: BRKADRINTEN) yes BRKADRINT — CLRINT.CLRBRKADRINT
Illegal opcode FAILDIS = 0 yes BRKADRINT ILLOPCODE CHIPRST only
Sequencer RAM parity error PERRORDIS = 0 and FAILDIS = 0 yes BRKADRINT SQPARERR CLRINT.CLRPARERR
Internal RAM / data-path parity error MPARCKEN / DPARCKEN and FAILDIS = 0 yes BRKADRINT MPARERR / DPARERR CLRINT.CLRPARERR
PCI status error (DPE, SSE, RMA, RTA, STA, DPR; DPE/DPR also need PERRESPEN) FAILDIS = 0 yes — PCIERRSTAT CLRINT.CLRPARERR clears the latched interrupt; the config STATUS bits themselves are write-1-to-clear
HCNTRL.SWINT always (also needs ISPACEEN or MSPACEEN) no — — writing SWINT = 0

ERROR records the fault whether or not FAILDIS silences the interrupt; PAUSEDIS is cleared only when the interrupt is actually raised [86box]. BRKADRINT stays set while ERROR holds a cause that has not been cleared.

4.5 The data path: FIFO, counters and the DMA engines

[7870 p. 139–148, 157–161, 176–177, 184–187; 7850 p. 4-65…4-78, 5-15/16]

The data FIFO is 256 bytes organised as 32 quad-words (64-bit), dual ported with odd byte parity. Three agents use it: the PCI master (8 bytes at a time), the SCSI module (1 or 2 bytes) and the sequencer or host through the byte port DFDAT. Which agent reads and which writes is fixed by DFCNTRL:

DIRECTION HDMAEN SDMAEN Reads FIFO Writes FIFO
0 1 1 host SCSI
0 0 1 sequencer SCSI
0 1 0 host sequencer
x 0 0 sequencer sequencer
1 1 1 SCSI host
1 0 1 SCSI sequencer
1 1 0 sequencer host

DIRECTION = 1 is "into the FIFO from PCI, out of the FIFO to SCSI" (a SCSI write, or a host-to-chip copy); DIRECTION = 0 is the reverse. SCSIEN turns on the SCSI bus handshake into the 16-byte SCSI FIFO; SDMAEN moves bytes between the SCSI FIFO and the data FIFO; HDMAEN moves bytes between the data FIFO and PCI. Each of the three enables and DIRECTION reads back as an acknowledge: after clearing a bit the firmware must poll until it reads 0 before the transfer is guaranteed stopped. DIRECTION cannot change while any enable is set.

Host side. LHADDR[31:0] (0x88–0x8b with HADDLDSEL = 0) is the PCI address of the next byte and counts up; HHADDR[31:0] (same addresses, HADDLDSEL = 1) is the high address page, issued as a dual-address cycle if non-zero and DEVCONFIG.DACEN, otherwise storage; HCNT[23:0] (0x8c–0x8e) counts bytes down and inhibits PCI transfers at 0. Writing LHADDR also loads SHADDR. DFCNTRL.FIFORESET must be written after loading LHADDR0 for each new transfer: it marks the FIFO empty, zeroes both FIFO pointers and loads the byte-offset pointers from LHADDR[2:0], so that a transfer starting at an unaligned address lands in the right byte lanes [7870 Table 5-11, p. 185]. DFSTATUS.HDONE sets when HCNT has expired and the last host transfer, including internal staging, is complete.

SCSI side. STCNT[23:0] (0x08–0x0a) counts bytes down (ACKs as initiator, REQs as target), decremented only once the byte is safely transferred; SHADDR[31:0] (0x14–0x17, read-only) counts up alongside and is the address the firmware saves on SAVE DATA POINTERS, because HADDR runs ahead by the FIFO's prefetch. SSTAT0.SDONE sets when STCNT reaches 0 with SWRAPEN clear and SDMAEN (or SPIOEN) set; SSTAT0.DMADONE = HDONE AND SDONE. SXFRCTL0.CLRSTCNT clears STCNT and SHADDR; SXFRCTL1.SWRAPEN lets STCNT wrap past zero for 16 MB transfers (SSTAT0.SWRAP).

Wide transfers. With SCSIRATE.WIDEXFER the SCSI side moves two bytes per handshake; odd starting addresses and odd counts are handled in hardware [7870 Table 5-1, p. 166] and DFCNTRL.WIDEODD holds a trailing odd byte across a scatter/gather boundary (it must be clear for the last segment).

PCI master policy. The chip requests the bus (PREQ#) when MASTEREN and one of ISPACEEN/MSPACEEN are set, HDMAEN is set, HCNT ≠ 0, no RMA/RTA is latched, and: for memory→FIFO the FIFO has reached the DFTHRSH level of free space (or is empty, or with CACHETHEN has a cache line of space, DFCACHETH); for FIFO→memory it holds the DFTHRSH level of data, or the SCSI transfer has finished or a flush was requested, or the FIFO is full. DSPCISTATUS.DFTHRSH[1:0] selects 16 bytes / 50 % / 75 % / 100 % (3, 16, 24, 32 QWDs stored for writes; 29, 16, 8, 0 for reads) [7870 p. 136]; drivers set 100 %. Bursts continue while GNT# holds and data, space and count remain, then until the latency timer expires plus completion of a cache line. CACHESIZE (0, 4, 8, 16, 32 dwords) and COMMAND.MWRICEN, DEVCONFIG.MRDCEN select MRDL/MRDM/MWI commands; a cache-line command is only issued when the address is on a line boundary and a whole line of data, space and count is available. Master abort (no DEVSEL# by clock 6) sets RMA, target abort RTA; neither is retried, and clearing the bit with the transfer still pending retries it unless HDMAEN was cleared first. Retry and Disconnect from the target are resumed at the next address.

Automatic flush. When STCNT reaches 0 or the phase changes (PHASEMIS/SDONE) with data still in the FIFO on a SCSI read, the chip flushes it to memory by itself unless SBLKCTL.AUTOFLUSHDIS; otherwise the firmware writes DFCNTRL.FIFOFLUSH. A flush also tells the host and SCSI blocks to accept a partial quad-word written by the sequencer through DFDAT.

The byte port. DFDAT (0x99) reads or writes one byte at the current pointer (DFRADDR/DFWADDR, 0x97/0x95, 5-bit QWD pointers with a roll-over bit) and the byte offset carried from LHADDR[2:0]; the pointer advances after the high byte of a quad-word. The sequencer may use it whenever it is the designated reader or writer in the table above; two writers at once (sequencer writing while SDMAEN or HDMAEN also writes) cause BRKADRINT. The Gibbs firmware uses DFDAT for every non-data transfer: SCB download (host read into the FIFO, then 32 DFDAT pops into the SCB page), SCB upload and completion posting (push bytes through DFDAT, then HDMAEN | FIFOFLUSH), S/G element fetch and embedded-CDB send (§8.1). DFSTATUS flags: FIFOEMP, FIFOFULL, FIFOQWDEMP (no complete quad-word), DFTHRESH, MREQPEND (a PCI request is pending), HDONE, DFCACHETH.

4.6 SCB array, queues and scratch RAM

[7870 p. 59, 63–64, 153–156, 188, 193; 7850 p. 5-17…5-19]

  • SCB array. 16 pages of 32 bytes. SCBPTR (0x90) selects the page visible at 0xa0–0xbf to both host (paused) and sequencer. With external SRAM (RAMPSM) up to 256 pages exist; without it SCBPTR values above 15 alias the low 16 (Linux's ahc_probe_scbs depends on the aliasing to count 16), though SCBPTR always reads back what was written. The page's byte address comes from the access address, or from SCBCNT[4:0] when SCBCNT.SCBAUTO is set, in which case the host may stream DWORDs (or REP OUTSB) into the page with auto-increment.
  • Queues. QINFIFO (0x9b): the host writes an SCB number, the sequencer reads it. QOUTFIFO (0x9d): the sequencer writes a finished SCB number, the host reads it without pausing. QINCNT (0x9c) and QOUTCNT (0x9e) give the counts. Depth 16 without external SRAM (255 with it, when the internal SCB RAM becomes queue storage); writes to a full queue and reads from an empty one are ignored, an empty read returning the previous value [86box]. Bits 7:4 of a queue entry read 0 without external SRAM.
  • Scratch RAM. 64 bytes at 0x20–0x5f, free for firmware and driver. Parity is checked when MPARCKEN is set, so every byte must be written once after power-up before it is read.
  • The documented command flow (both data books): host pauses, saves SCBPTR, points it at a free page, writes the SCB, writes the page number to QINFIFO, restores SCBPTR, unpauses. The sequencer polls QINFIFO, starts the SCB unless it conflicts with an open command on the same target/LUN (then pushes it back), handles disconnect and reconnect by matching target/LUN/tag, writes the number to QOUTFIFO and sets CMDCMPLT, and raises SEQINT with a code when it needs the host. At most two untagged SCBs per target/LUN; up to 255 S/G elements of (address, count); MODIFY DATA POINTER honoured only with one element. The HIM follows this flow with host-memory SCBs (§8.2); the Gibbs firmware replaces the hardware queues with rings in host memory and uses the array only as a page cache (§8.1).

4.7 The SCSI engine

[7870 p. 72–97, 165–173, 191–192, 197; 7850 §4, §5]

  • Identity and mode. SCSIID.OID is the chip's own ID, TID the other party's. SSTAT0.TARGET says which role the last (re)selection left the chip in. The Gibbs firmware is initiator-only on the O2.
  • Selection out. Write SCSIID, then SCSISEQ with ENSELO (and ENAUTOATNO to raise ATN for the IDENTIFY message). The chip arbitrates, retrying until it wins, then selects TID: SSTAT0.SELINGO while waiting for BSY, SELDO on success, SSTAT1.SELTO on time-out if SXFRCTL1.ENSTIMER (period STIMESEL: 256, 128, 64 or 32 ms; without the timer SEL stays asserted until the sequencer gives up). SELINGO is cleared only by a successful selection or CLRSINT0.CLRSELINGO. TEMODEO turns the same sequence into a reselection by a target.
  • Selection in / reselection in. ENSELI/ENRSELI allow the chip to respond; SSTAT0.SELDI is set, SELID[7:4] holds the other device's ID (ONEBIT flags a selection without the initiator's ID), TARGET is set for a selection and cleared for a reselection, ENAUTOATNI raises ATN on reselection. Wide arbitration priority is 7…0 then 15…8.
  • Phases. As initiator, SCSISIGO.CDO/IOO/MSGO are the expected phase, not outputs: SSTAT1.PHASEMIS is set when a REQ arrives with a different phase (qualified by REQINIT), PHASECHG when the lines change at all. SCSISIGI reads the real pins. The firmware's phase_lock waits for REQINIT, copies SCSISIGI & 0xe0 into SCSISIGO and dispatches. As target the same bits drive the bus. ATNO only asserts (clear with CLRSINT1.CLRATNO or bus free), ACKO works only as initiator, REQO only as target.
  • Transfers. Three modes. Manual PIO: the host or sequencer drives SCSIDATL/H and the handshake lines itself. Automatic PIO (SXFRCTL0.SPIOEN): a read or write of SCSIDATL performs one REQ/ACK handshake (16-bit if SCSIDATH is accessed first); SSTAT0.SPIORDY says a byte is ready or wanted; SCSIBUSL/H read the live bus without acking, which is how firmware and driver peek at a message byte before accepting it. DMA (SCSIEN + SDMAEN): STCNT bytes through the SCSI FIFO, synchronous if SCSIRATE.SOFS ≠ 0 (offset 1–8 wide, 1–15 narrow; the SCSI FIFO is always armed in synchronous data-in), asynchronous otherwise. SCSIRATE applies to data phases only; command, status and message phases are always asynchronous. The 16-byte SCSI FIFO level is SSTAT2.SFCNT; SSTAT2.OVERRUN flags a REQ beyond the offset; SSTAT3 exposes the offset counters. SXFRCTL1.BITBUCKET accepts (or supplies zero) data without storing it, for overruns. SXFRCTL0.CLRCHN resets the SCSI FIFO and offset logic.
  • Synchronous rates. SCSIRATE.SXFR[2:0] sets the REQ/ACK period in 25 ns units: (4 + SXFR) × 25 ns, i.e. 10, 8.0, 6.7, 5.7, 5.0, 4.4, 4.0, 3.6 MHz for SXFR 0–7 [7870 p. 79]. With SXFRCTL0.FAST20 the unit halves: SXFR 0, 1, 2 give 20, 16 and 13.4 MHz (periods 50, 62.5, 75 ns) [drv aic7xxx_core.c:117-135, :2560-2577]; the firmware sets FAST20 per command from SCB_CONTROL.ULTRAENB. Below 3.6 MHz use asynchronous.
  • Parity. SXFRCTL1.ENSPCHK enables checking on (re)selection and information transfers; SSTAT1.SCSIPERR latches (upper byte only in wide data phases); SCSISEQ.ENAUTOATNP raises ATN automatically on an inbound parity error. ACTNEGEN enables active negation. Internal data-path and RAM parity are separate (DPARCKEN, MPARCKEN).
  • Bus free. SSTAT1.BUSFREE latches when BSY and SEL have been negated for 400 ns; it clears SCSISIGO, ATN, SELDO, SELDI and the SCSISEQ selection bits. Firmware enables ENBUSFREE only inside a connection so an expected bus free never interrupts.
  • Timers and filters. SELTIMER exposes the selection timer stages (÷256, ÷256, ÷10, ÷2, ÷2, ÷2 of CLKIN); SXFRCTL0.DFON/DFPEXP enable digital filtering of REQ/ACK (12.5–25 ns above 5 MB/s, 50–75 ns below).
  • Termination power. SXFRCTL1.STPWEN drives the STPWCTL pin at the polarity DEVCONFIG.STPWLEVEL selects; CHIPRST clears STPWEN (so drivers save and restore SXFRCTL1 around a reset).
  • SCAM. SXFRCTL0.SCAMEN gives raw control of the bus lines and runs the SELTIMER.CLKOUT 102.4 µs timer; SCAMCTL (0x1a) holds the level and default-ID controls. Unused on the O2.
  • Diagnostic LED. LED# follows SELINGO | SELDI | SELDO (or BSYO) unless SBLKCTL.DIAGLEDEN, in which case DIAGLEDON drives it.

4.8 The memory port: external SCB RAM, ROM and SEEPROM

[7870 p. 47–52, 161–163, 182–186; 7890 FlexPort chapter]

One 8-bit bus (MA[14:0], MD[7:0], MDP, MRW, RAMCS#, ROMCS#, SEECS) serves up to 8 KB of SCB SRAM (RAMPS# sampled at reset → DEVSTATUS.RAMPSM), a 64 KB expansion ROM (EXROMCTL) and a 93C46/56/66 serial EEPROM. EXTARBREQ#/EXTARBACK# arbitrate the port with an external owner; grounding EXTARBACK# makes it single-user (MPORTMODE). The SEEPROM is bit-banged through SEECTL: set SEEMS to request the port, wait for SEERDY (which thereafter also serves as an 800 ns timer after every SEECTL write), then drive SEECS, SEECK, SEEDO and sample SEEDI; BRDCTL drives MD[7:3] for board logic (termination control, cable sense) in the same mode. The O2 fits none of these: RAMPSM = 0, no ROM, no SEEPROM (§3.1); the only consequence for an emulator is that SEERDY must never come (or the data must fail its checksum) so that drivers fall back to defaults.

4.9 Power-down

HCNTRL.POWRDN gates CLKIN and most of PCLK, disables the SCSI inputs and INTA#, and restricts access to the host-only registers and configuration space (anything else is target-aborted). The sequencer must be paused and all DMA acks clear first; the hardware refuses a write that clears PAUSE and sets POWRDN together. Pending interrupts fire when it is cleared.

5. PCI configuration space

[7870 p. 106–130, Table 3-5 p. 62; 7850 p. 4-36…4-57; drv aic7xxx_pci.c]

Type 0 header, single function (AD[10:8] ignored), register from AD[7:2]. Reads return all 32 bits regardless of byte enables; writes honour byte enables; bursts are disconnected after one data phase. DEVSEL# is medium. Only RST# resets these registers. Bytes not listed read 0 and ignore writes.

Offset Register Access Reset Contents
0x00 Vendor ID R 0x9004 Adaptec
0x02 Device ID R 0x8078 AIC-7880. The high byte can be replaced through the IDDAT pin at reset (board IDs 0x81…0x88); 0xff keeps the default
0x04 Command R/W 0x0000 see below
0x06 Status R/W1C 0x0200 see below
0x08 Revision ID R 0x01 on the 7870; 7880 revisions 0 and ≥ 1 exist
0x09 Programming interface R 0x00
0x0a Subclass R 0x00 SCSI bus controller
0x0b Base class R 0x01 mass storage
0x0c Cache line size R/W 0x00 bits 5:2 writable (dwords); 0, 4, 8, 16, 32 meaningful, others round down
0x0d Latency timer R/W 0x00 bits 7:2 writable
0x0e Header type R 0x00
0x0f BIST R 0x00 absent
0x10 BAR0 R/W 0x0000_0001 I/O space, 256 bytes: bits 31:8 writable, bit 0 = 1
0x14 BAR1 R/W 0x0000_0000 memory space, 4 KB: bits 31:12 writable, bits 3:0 = 0 (32-bit, not prefetchable). The 256 registers repeat through the 4 KB
0x18–0x28 BAR2–5 R 0 none
0x2c Subsystem vendor/device R 0 not implemented on 9004-vendor parts; the 7880 has no subsystem ID of its own
0x30 Expansion ROM base R/W 0x0000_0000 bits 31:15 writable (64 KB max, bits 14:11 read 0), bit 0 enable. Reads of the ROM are four byte cycles on the memory port. Equal to BAR1 with enable set → target abort
0x3c Interrupt line R/W 0x00 scratch for firmware
0x3d Interrupt pin R 0x01 INTA#
0x3e Min grant R 0x08 (7870) / 0x04 (7850) units of 250 ns
0x3f Max latency R 0x08 / 0x04
0x40 DEVCONFIG R/W 0x00 device-specific, see below
0x41 DEVSTATUS R strap see below
0x42–0x43 R 0 0x43 is PCIERRGEN on the 7850 (test feature); on the 7880 Linux sets bit 31 of the dword, PCIERRGENDIS, to keep PCI error generation off

Command (0x04):

Bit Name Meaning
0 ISPACEEN respond to BAR0
1 MSPACEEN respond to BAR1 and the expansion ROM
2 MASTEREN bus mastering; also gates INTA#
3 SPCYCEN always 0
4 MWRICEN may issue Memory Write and Invalidate
5 VSNOOPEN always 0
6 PERRESPEN drive PERR#; required for DPE/DPR to interrupt
7 WAITCTLEN always 0
8 SERRESPEN drive SERR# on address parity errors (with PERRESPEN)
9 MFBTBEN always 0

Status (0x06): bit 7 TFBTBC = 1 (fast back-to-back capable as target), bits 10:9 DEVSEL timing = 01 (medium), bit 8 DPR data parity reported, bit 11 STA signalled target abort (wrong access width, SEEPROM mode conflict, access during power-down, ROM/BAR1 overlap), bit 12 RTA received target abort, bit 13 RMA received master abort, bit 14 SSE signalled system error, bit 15 DPE detected parity error. Each is cleared by writing 1. Linux reads them as the byte at 0x07 (DPE 0x80, SSE 0x40, RMA 0x20, RTA 0x10, STA 0x08, DPR 0x01) and writes the byte back [drv aic7xxx_pci.c:588-595, 1928-1992].

DEVCONFIG (0x40, 8 bits documented, drivers treat 0x40 as a 32-bit register):

Bit Name Meaning Source
0 DIFACTNEGEN differential active negation (external differential transceivers) [7870 p. 127]
1 STPWLEVEL polarity of STPWCTL: 0 active-high, 1 active-low; survives CHIPRST [7870]
2 DACEN allow dual-address cycles when HHADDR ≠ 0 [7870]
3 BERREN generate even (bad) parity on the data paths, test [7870]
4 EXTSCBPEN check parity on 9-bit external SCB SRAM [7870]
5 EXTSCBTIME double the external SCB SRAM cycle time [7870]
6 MRDCEN allow plain Memory Read and early burst release [7870]
7 spare R/W on the 7870; SCBRAMSEL in the Linux driver: 1 = internal SCB RAM [7870 p. 127; drv aic7xxx_pci.c:1049-1052]
8 VOLSENSE 1 = 5 V PCI signalling (read-only) [7870 p. 129]
9 RAMPSM external SCB SRAM present (RAMPS# low at reset; read-only) [7870]
10 MPORTMODE 1 = single-user memory port (EXTARBACK# low at reset; read-only) [7870]
12 REXTVALID Ultra chips: external precision resistor present, Ultra timing usable (read-only). Reads 0 on the O2 [drv aic7xxx_pci.c:865-873; NetBSD ahc_pci.c:1000-1013]
16 SCBSIZE32 1 = 32-byte SCB pages (written by Linux even on the 7880) [drv aic7xxx_pci.c:1042-1057]
31 PCIERRGENDIS disable the PCI error generation test feature (Linux always sets it) [drv aic7xxx_pci.c:761]

After Linux's initialisation the register holds the written value plus EXTSCBTIME | SCBRAMSEL | SCBSIZE32 | PCIERRGENDIS and the read-only sense bits, so the emulator must store what is written and return it, with RAMPSM = MPORTMODE = REXTVALID = 0 for the O2.

6. Device register map

Summary first, then every register's bits. "Reset" is the value after RST# or CHIPRST; "x" is indeterminate. Access letters: R, W, RW; np marks the host-only registers that need no pause. Sources for the summary: [7870 Tables 3-1…3-7, p. 58–63; reg; drv].

Addr Read Write Reset Block
0x00 SCSISEQ SCSISEQ 0x00 SCSI
0x01 SXFRCTL0 SXFRCTL0 0x00 SCSI
0x02 SXFRCTL1 SXFRCTL1 0x00 SCSI
0x03 SCSISIGI SCSISIGO x / — SCSI
0x04 SCSIRATE SCSIRATE 0x00 SCSI
0x05 SCSIID SCSIID 0x00 SCSI
0x06 SCSIDATL SCSIDATL x SCSI
0x07 SCSIDATH SCSIDATH x SCSI
0x08–0x0a STCNT0–2 STCNT0–2 0x00 SCSI
0x0b SSTAT0 CLRSINT0 0x00 SCSI
0x0c SSTAT1 CLRSINT1 0x00 SCSI
0x0d SSTAT2 — 0x00 SCSI
0x0e SSTAT3 — 0x00 SCSI
0x0f SCSITEST SCSITEST 0x00 SCSI (test)
0x10 SIMODE0 SIMODE0 0x00 SCSI
0x11 SIMODE1 SIMODE1 0x00 SCSI
0x12 SCSIBUSL — x SCSI
0x13 SCSIBUSH — x SCSI
0x14–0x17 SHADDR0–3 — 0x00 SCSI
0x18 SELTIMER — 0x00 SCSI
0x19 SELID (SELID) 0x00 SCSI
0x1a SCAMCTL SCAMCTL 0x00 SCSI
0x1b — — spare (SPIOCAP/TARGID on other parts)
0x1c SLEEPCTL SLEEPCTL 0x00 sequencer
0x1d BRDCTL BRDCTL 0x00 memory port
0x1e SEECTL SEECTL pins memory port
0x1f SBLKCTL SBLKCTL 0xc0 + strap SCSI
0x20–0x5f scratch RAM scratch RAM x RAM
0x60 SEQCTL SEQCTL 0x90 sequencer
0x61 SEQRAM SEQRAM x sequencer
0x62 SEQADDR0 SEQADDR0 0x00 sequencer
0x63 SEQADDR1 SEQADDR1 0x00 sequencer
0x64 ACCUM ACCUM 0x00 sequencer
0x65 SINDEX SINDEX 0x00 sequencer
0x66 DINDEX DINDEX 0x00 sequencer
0x67 BRKADDR0 BRKADDR0 0x00 sequencer
0x68 BRKADDR1 BRKADDR1 0x80 sequencer
0x69 ALLONES — 0xff sequencer
0x6a ALLZEROS NONE 0x00 sequencer
0x6b FLAGS — 0x00 sequencer
0x6c SINDIR — sequencer only
0x6d — DINDIR sequencer only
0x6e FUNCTION1 FUNCTION1 x sequencer
0x6f STACK — 0x00 sequencer
0x70–0x7f — — unassigned on the 7880
0x80–0x81 DSVENDID0/1 np — 0x04, 0x90 host
0x82–0x83 DSDEVID0/1 np — 0x78, 0x80 host
0x84 DSCOMMAND0 DSCOMMAND0 0x00 host
0x85 DSLATTIME (DSCOMMAND1) bits 1:0 0x00 host
0x86 DSPCISTATUS bits 7:6 0x00 host
0x87 HCNTRL np HCNTRL np 0x05 host
0x88–0x8b HADDR0–3 (LHADDR/HHADDR) same 0x00 host DMA
0x8c–0x8e HCNT0–2 HCNT0–2 0x00 host DMA
0x8f reads 0 — 0x00 reserved
0x90 SCBPTR SCBPTR 0x00 SCB
0x91 INTSTAT np INTSTAT (sequencer) 0x00 host
0x92 ERROR CLRINT np 0x00 host
0x93 DFCNTRL DFCNTRL 0x00 data FIFO
0x94 DFSTATUS — 0x21 data FIFO
0x95 DFWADDR DFWADDR 0x00 data FIFO
0x96 reserved 0x00
0x97 DFRADDR DFRADDR 0x00 data FIFO
0x98 reserved 0x00
0x99 DFDAT DFDAT x data FIFO
0x9a SCBCNT SCBCNT 0x00 SCB
0x9b QINFIFO QINFIFO x SCB queues
0x9c QINCNT — 0x00 SCB queues
0x9d QOUTFIFO np QOUTFIFO (sequencer) 0x00 SCB queues
0x9e QOUTCNT np — 0x00 SCB queues
0x9f SFUNCT SFUNCT 0x00 test
0xa0–0xbf SCB page SCB page x SCB array
0xc0–0xff — — reserved on the 7880

The 7870 book's Table 3-4 puts QOUTFIFO at 0x9c; its detailed pages, the 7850 book, the drivers and 86Box all agree on 0x9b QINFIFO, 0x9c QINCNT, 0x9d QOUTFIFO, 0x9e QOUTCNT. Use those.

6.1 SCSI module, 0x00–0x1f

SCSISEQ 0x00 RW, reset 0 — SCSI sequence control [7870 p. 72–73]. All bits but SCSIRSTO are cleared by a SCSI bus reset.

Bit Name Meaning
7 TEMODEO target-enable mode out: ENSELO performs a reselection (1) instead of a selection (0)
6 ENSELO start arbitration and (re)selection of SCSIID.TID; SELINGO while waiting for BSY; ends with SELDO or SELTO
5 ENSELI respond to a selection of our ID (sets SELDI, TARGET)
4 ENRSELI respond to a reselection of our ID (sets SELDI, clears TARGET)
3 ENAUTOATNO assert ATN during a selection out (Message Out expected)
2 ENAUTOATNI assert ATN when reselected
1 ENAUTOATNP assert ATN when a parity error is detected on an inbound byte (initiator, with ENSPCHK)
0 SCSIRSTO drive SCSI RST# until written 0, in any mode

SXFRCTL0 0x01 RW, reset 0 — transfer control 0 [7870 p. 74–75; reg].

Bit Name Meaning
7 DFON digital filtering of REQ/ACK
6 DFPEXP expand the filter period at ≤ 5 MB/s
5 FAST20 7880: Ultra timing, halves the synchronous period unit (§4.7). Reads 0 on the 7870
4 CLRSTCNT clear STCNT and SHADDR; self-clearing, reads 0
3 SPIOEN automatic PIO: SCSIDATL accesses handshake
2 SCAMEN SCAM level 1 mode
1 CLRCHN clear channel: reset SCSI FIFO and sync offset logic; self-clearing
0 — reads 0

SXFRCTL1 0x02 RW, reset 0 [7870 p. 75–76].

Bit Name Meaning
7 BITBUCKET accept inbound data (or send zeros) without touching the FIFO; initiator only
6 SWRAPEN let STCNT wrap past zero (SWRAP status)
5 ENSPCHK enable SCSI parity checking; SCSIPERR reads 0 when clear
4:3 STIMESEL selection time-out: 00 = 256 ms, 01 = 128 ms, 10 = 64 ms, 11 = 32 ms
2 ENSTIMER enable the selection timer (otherwise SEL stays asserted until software gives up)
1 ACTNEGEN active negation of REQ/ACK/data/parity
0 STPWEN termination power on; cleared by CHIPRST

SCSISIGI 0x03 R — the bus control lines as they are: 7 CDI, 6 IOI, 5 MSGI, 4 ATNI, 3 SELI, 2 BSYI, 1 REQI, 0 ACKI. Phase codes in bits 7:5 (PHASE_MASK 0xe0): 0x00 DATA OUT, 0x40 DATA IN, 0x80 COMMAND, 0xa0 MESSAGE OUT, 0xc0 STATUS, 0xe0 MESSAGE IN.

SCSISIGO 0x03 W — 7 CDO, 6 IOO, 5 MSGO, 4 ATNO, 3 SELO, 2 BSYO, 1 REQO, 0 ACKO. As initiator bits 7:5 are the expected phase (they feed PHASEMIS/PHASECHG); as target they drive the lines. ATNO = 1 asserts ATN, 0 does nothing (clear with CLRSINT1.CLRATNO). SELO/BSYO assert or negate the lines; BSYO also lights LED#. REQO works only as target, ACKO only as initiator. All bits are cleared by chip reset, SCSI bus reset and bus free. Drivers read SCSISIGI and write back SCSISIGI | ATNO to raise ATN.

SCSIRATE 0x04 RW, reset 0 [7870 p. 79].

Bit Name Meaning
7 WIDEXFER 16-bit data transfers (needs SBLKCTL.SELWIDE)
6:4 SXFR synchronous period: (4 + SXFR) × 25 ns, or × 12.5 ns with FAST20
3:0 SOFS REQ/ACK offset, 0 = asynchronous; 1–15 narrow, 1–8 wide

Rate table, FAST20 = 0: SXFR 0 10 MHz, 1 8.0, 2 6.7, 3 5.7, 4 5.0, 5 4.4, 6 4.0, 7 3.6. FAST20 = 1: SXFR 0 20 MHz, 1 16, 2 13.4; higher values are not used by any driver (Linux: aic7xxx_core.c:117-135; the HIM maps periods of 12, 16 and 20 to 0x00, 0x10 and 0x20 with FAST20 set).

SCSIID 0x05 RW, reset 0 — 7:4 TID the other device's ID, 3:0 OID our ID. Writing OID also loads differential latch 0. The O2 PROM and IRIX set OID = 0; the BSDs and Linux 7 unless the PROM's value is kept.

SCSIDATL 0x06 RW, SCSIDATH 0x07 RW — the data latches. With SPIOEN, a read or write of SCSIDATL performs one REQ/ACK handshake (initiator: read waits for and acknowledges a byte; write presents a byte and acknowledges). For a 16-bit handshake access SCSIDATH first. With SPIOEN clear a write merely places data on the bus (the HIM does this and asserts ACKO by hand).

STCNT0/1/2 0x08–0x0a RW, reset 0 — 24-bit SCSI transfer count, LSB first. Counts down per byte (per transfer in auto-PIO). 0 means 16 M with SWRAPEN, else 0. SDONE when it reaches 0.

CLRSINT0 0x0b W — write 1 to clear: 6 CLRSELDO, 5 CLRSELDI, 4 CLRSELINGO, 3 CLRSWRAP, 1 CLRSPIORDY.

SSTAT0 0x0b R, reset 0 [7870 p. 83–84].

Bit Name Meaning
7 TARGET we are a target in the current connection (status only)
6 SELDO our selection or reselection completed; cleared by bus free or CLRSELDO
5 SELDI we were selected or reselected; cleared by bus free or CLRSELDI
4 SELINGO arbitration won, selecting; cleared by SELDO or CLRSELINGO (not by a time-out)
3 SWRAP STCNT wrapped
2 SDONE STCNT = 0 and the last transfer done (also set with SPIORDY)
1 SPIORDY auto-PIO: a byte is ready (initiator, REQ seen) or wanted; cleared by the SCSIDATL access
0 DMADONE HDONE and SDONE

CLRSINT1 0x0c W — 7 CLRSELTIMEO, 6 CLRATNO (drops ATN; as target clears ATNTARG), 5 CLRSCSIRSTI, 3 CLRBUSFREE, 2 CLRSCSIPERR, 1 CLRPHASECHG, 0 CLRREQINIT.

SSTAT1 0x0c R, reset 0 [7870 p. 86–87].

Bit Name Meaning
7 SELTO selection timed out (ENSTIMER); SEL was dropped
6 ATNTARG as target: the initiator asserted ATN
5 SCSIRSTI SCSI reset seen on the bus (the 7870/7880 also report their own)
4 PHASEMIS initiator: a REQ arrived with a phase different from SCSISIGO's; cleared by writing the matching phase to SCSISIGO or when REQINIT clears
3 BUSFREE BSY and SEL negated for 400 ns; latched
2 SCSIPERR parity error on an inbound byte (sampled on REQ); latched with ENSPCHK
1 PHASECHG the phase lines changed away from SCSISIGO's phase, REQ or not
0 REQINIT initiator: REQ seen and not yet acknowledged (async), or offset count non-zero (sync); cleared by the ACK or CLRREQINIT

SSTAT2 0x0d R — 7 OVERRUN (a REQ beyond the maximum sync offset; cleared by CLRCHN), 4:0 SFCNT SCSI FIFO byte count 0–16. SSTAT3 0x0e R — 7:4 SCSICNT, 3:0 OFFCNT: the offset bookkeeping, valid only while transfers are stopped. SCSITEST 0x0f RW — test modes (DATALOOP 0x10, RQAKCNT 0x04, CNTRTEST 0x02, CMODE 0x01); unused by drivers.

SIMODE0 0x10 RW, reset 0 — interrupt enables for SSTAT0 bits 6..0: ENSELDO, ENSELDI, ENSELINGO, ENSWRAP, ENSDONE, ENSPIORDY, ENDMADONE. SIMODE1 0x11 RW, reset 0 — for SSTAT1 bits 7..0: ENSELTIMO, ENATNTARG, ENSCSIRST, ENPHASEMIS, ENBUSFREE, ENSCSIPERR, ENPHASECHG, ENREQINIT. Drivers leave SIMODE0 = 0 and set SIMODE1 = ENSELTIMO | ENSCSIRST | ENSCSIPERR (0xa4), with ENBUSFREE toggled by the firmware inside connections.

SCSIBUSL 0x12 R, SCSIBUSH 0x13 R — the live data bus, no handshake. Firmware and drivers read the first byte of an inbound message here before acknowledging it through SCSIDATL.

SHADDR0–3 0x14–0x17 R, reset 0 — SCSI-side address: loaded when LHADDR is written, counts up with each SCSI byte. Saved on SAVE DATA POINTERS; the base for MODIFY DATA POINTER.

SELTIMER 0x18 R — 7 CLKOUT (SCAM timer), 5..0 STAGE6..STAGE1 of the selection timer chain (÷2, ÷2, ÷2, ÷10, ÷256, ÷256 of CLKIN).

SELID 0x19 R (writable on the 7870/7880 per [86box]) — 7:4 the ID of the device that selected or reselected us, 3 ONEBIT (only one ID bit was on the bus: a selection without the initiator's ID).

SCAMCTL 0x1a RW — 7 ENSCAMSELO, 6 CLRSCAMSELID, 5 ALTSTIM, 4 DFLTTID, 1:0 SCAMLVL [reg].

SLEEPCTL 0x1c RW, reset 0 — 7 SLEEPDIS, 1 SLP1 (wake on DMADONE/PHASEMIS), 0 SLP0 (wake on SELDO/SELDI) [7870 p. 152].

BRDCTL 0x1d RW, reset 0 — board control through the memory port while SEEMS is active: 7:5 BRDDAT7..5 (data to or from MD[7:5]), 4 BRDSTB (1 drives MD4 low), 3 BRDCS (1 drives MD3 low), 2 BRDRW (0 = write, data out; drives MDP), 1:0 read 0. Linux uses it only when a SEEPROM was found; the HIM only on the 0x8178 option card. Nothing on the O2 answers.

SEECTL 0x1e RW [7870 p. 161–162; drv aic7xxx_93cx6.c].

Bit Name Meaning
7 EXTARBACK R: level of the EXTARBACK# pin
6 EXTARBREQ R: level of the EXTARBREQ# output
5 SEEMS request the memory port for serial-EEPROM mode; keep set while accessing
4 SEERDY R: port granted; afterwards goes 0 on every SEECTL write and 1 again 800 ns later
3 SEECS EEPROM chip select
2 SEECK EEPROM clock (MD2)
1 SEEDO data to the EEPROM (MD1)
0 SEEDI R: data from the EEPROM (MD0)

Linux's probe writes SEEMS and polls SEERDY for up to 1 s; on the O2 it never comes and the driver uses defaults (§9). Returning SEERDY = 1 with all-ones data also works (the checksum fails).

SBLKCTL 0x1f RW, reset 0xc0 | strap [7870 p. 96–97].

Bit Name Meaning
7 DIAGLEDEN LED# follows DIAGLEDON instead of bus activity (reset 1)
6 DIAGLEDON with DIAGLEDEN, light the LED (reset 1)
5 AUTOFLUSHDIS disable the automatic FIFO flush on phase change / count done
3 SELBUSB channel B select; reads 0 and ignores writes on single-channel parts (the 7880)
1 SELWIDE the SCSI channel is 16 bits wide; initialised from the WIDEPS# strap at reset, writable afterwards. Reads 1 on the O2's chips
4, 2, 0 — read 0 (XCVR, ENAB20, ENAB40 are Ultra2)

Drivers read SELWIDE after chip reset to decide 8 or 16 targets and clear the two LED bits.

6.2 Scratch RAM, 0x20–0x5f

64 bytes of RAM with no hardware meaning. Both firmwares keep their configuration and state here; their layouts are in §8.1 and §8.2. On the O2 the PROM's HIM layout is what a later kernel finds. Parity must be initialised by writing every byte before DSCOMMAND0.MPARCKEN is set.

6.3 Sequencer registers, 0x60–0x6f

SEQCTL 0x60 RW, reset 0x90 [7870 p. 98].

Bit Name Meaning
7 PERRORDIS disable sequencer RAM parity checking (reset 1; set while loading)
6 PAUSEDIS sequencer-only: ignore the host's PAUSE request; cleared by SCSI, illegal-opcode and parity interrupts
5 FAILDIS disable the BRKADRINT for parity, illegal opcode and PCI errors
4 FASTMODE sequencer clock CLKIN/4 instead of CLKIN/5 (reset 1)
3 BRKADRINTEN a breakpoint drives INTA# (it always sets BRKADRINT)
2 STEP single step: one instruction per release of PAUSE
1 SEQRESET reset the PC to 0; self-clearing; sequencer must be paused
0 LOADRAM route SEQRAM accesses to the program RAM; clear for normal operation, clear and set again between a write pass and a read pass

Linux loads with 0xb1, verifies nothing, then runs with SEQCTL = 0; the HIM loads with 0x81, reads the whole program back with 0x81 again and compares, then runs with 0x72 (FAILDIS | FASTMODE | SEQRESET) and BRKADDR1.BRKDIS set.

SEQRAM 0x61 RW — byte window into the 512 × 29-bit program RAM at SEQADDR. Bytes go least-significant first; after the fourth byte of a word SEQADDR increments. Reads work the same way. Writing SEQADDR resets the byte index. Four bytes are stored per word; bits 31:29 of the host's word are dropped (the chip holds 29 bits plus parity).

SEQADDR0 0x62 RW, SEQADDR1 0x63 RW (bit 0 only), reset 0 — the 9-bit address of the next instruction to execute, or the load pointer under LOADRAM. Write SEQADDR0 then SEQADDR1 while paused to set an entry point. A sequencer write to SEQADDR0 is an indirect jump within the current 256-word page (Linux's firmware uses add SEQADDR0, A as a computed forward jump); a write to SEQADDR1 switches pages.

ACCUM 0x64 RW — the accumulator A; also the implicit second operand when an instruction's immediate field is 0 (§7). SINDEX 0x65 RW — source index, and the argument register loaded by every JMP/CALL. DINDEX 0x66 RW — destination index.

BRKADDR0 0x67 RW, reset 0; BRKADDR1 0x68 RW, reset 0x80 — breakpoint address bits 7:0 and bit 0 = address bit 8; BRKADDR1 bit 7 BRKDIS disables the comparison (reset: disabled).

ALLONES 0x69 R reads 0xff. ALLZEROS 0x6a R reads 0x00. NONE 0x6a W discards writes. FLAGS 0x6b R — bit 1 ZERO, bit 0 CARRY.

SINDIR 0x6c R, DINDIR 0x6d W — sequencer only: read the byte at [SINDEX] then SINDEX++; write the byte at [DINDEX] then DINDEX++.

FUNCTION1 0x6e RW — write a value, read back 1 << (value >> 4 & 7): a 1-of-8 decoder the firmware uses to turn a target ID into a bit mask.

STACK 0x6f R — the four-entry return stack. Each entry is read as two bytes, low then high; the stack pointer advances after the high byte, so eight reads return all four entries and restore the pointer. Entries are 9-bit addresses in 16 bits.

6.4 Host interface, 0x80–0x9f

DSVENDID0/1 0x80/0x81 R = 0x04, 0x90; DSDEVID0/1 0x82/0x83 R = 0x78, 0x80 (device ID bytes, big-endian order of the 16-bit ID); readable without pause.

DSCOMMAND0 0x84 RW, reset 0 (BCTL on the 7770) [7870 p. 133–135; reg].

Bit Name Meaning
7 CACHETHEN request the PCI bus on DFCACHETH (whole cache lines) instead of DFTHRSH; must stay 0 on 7880 rev 0 (AHC_CACHETHEN_BUG)
6 DPARCKEN check internal data-path parity (DPARERR)
5 MPARCKEN check scratch/SCB/queue RAM parity (MPARERR)
4 EXTREQLCK hold EXTARBREQ# once asserted
3:0 read-only copies of COMMAND bits SERRESPEN, PERRESPEN, MWRICEN, MASTEREN

Bits 3:0 named INTSCBRAMSEL, RAMPS, USCBSIZE32, CIOPARCKEN in [reg] belong to the Ultra2 parts.

DSLATTIME 0x85 — 7:2 read-only copy of LATTIME[7:2]; 1:0 HADDLDSEL: 0 = 0x88–0x8b are LHADDR (and load SHADDR), 1 = HHADDR, 2–3 reserved. Linux calls it DSCOMMAND1 and touches it only for 39-bit addressing, never on the 7880.

DSPCISTATUS 0x86 — 7:6 DFTHRSH (RW: 00 16 bytes, 01 50 %, 10 75 %, 11 100 %; drivers write 0xc0, the HIM 0x80), 5:0 read-only mirrors of the PCI status error bits DPR, DPE, SSE, RMA, RTA, STA (an interrupt is latched on each leading edge and cleared by CLRPARERR; the HIM ignores a lone RMA).

HCNTRL 0x87 RW, reset 0x05, no pause needed [7870 p. 137–138].

Bit Name Meaning
6 POWRDN power down (§4.9)
4 SWINT software interrupt: drives INTA# without touching INTSTAT
3 IRQMS on the EISA part, level vs edge; a spare RW bit on PCI parts, never set by drivers
2 PAUSE / PAUSEACK write: request a pause; read: the sequencer is stopped (also set by SEQINT, SCSIINT, BRKADRINT, reset)
1 INTEN enable INTA#
0 CHIPRST / CHIPRSTACK write 1: reset device space (§4.3); reads 1 from then until the host writes it 0

Rules drivers depend on: a read after a write that changed PAUSE returns the new state (the chip stretches the read); after CHIPRST bit 0 reads 1 until written 0, and PAUSE reads 1; a write with PAUSE = 0 while a pausing interrupt is still pending runs the sequencer (Linux and the HIM both avoid it, so an emulator may also keep it paused); IRQMS and the undefined bits read back as written.

HADDR0–3 0x88–0x8b RW, reset 0 — LHADDR[31:0], the PCI address of the next host byte, least-significant byte first; counts up as bytes move. Writing it also loads SHADDR. Must not be written while HDMAEN is set (ILLSADDR). The Gibbs firmware fills HADDR0..3 and HCNT0..2 with one 7-byte indirect copy. HCNT0–2 0x8c–0x8e RW, reset 0 — 24-bit host byte count, counts down; no PCI transfer at 0.

SCBPTR 0x90 RW, reset 0 — selects the SCB page at 0xa0–0xbf. Values ≥ 16 alias the low 16 on a 7880 without external SRAM; the register reads back what was written.

INTSTAT 0x91 — read by the host without pause, written by the sequencer [7870 p. 141–142].

Bit Name Meaning
7:4 INTCODE the sequencer's reason code, valid with SEQINT; firmware-defined (§8)
3 BRKADRINT breakpoint or hard error (§4.4)
2 SCSIINT an enabled SCSI status condition
1 CMDCMPLT the sequencer posted a completion; does not pause
0 SEQINT the sequencer needs the host; it is paused

A sequencer write sets the bits written in 3:0 and replaces 7:4; it never clears an interrupt. Linux normally does not even read INTSTAT for completions: it watches its completion ring in memory.

CLRINT 0x92 W, no pause needed — 4 CLRPARERR (clears SQPARERR, MPARERR, DPARERR and the latched PCI-status interrupt), 3 CLRBRKADRINT, 2 CLRSCSIINT, 1 CLRCMDINT, 0 CLRSEQINT. ILLOPCODE needs CHIPRST. The HIM writes 0x0f and 0x1f wholesale.

ERROR 0x92 R, reset 0 — 6 PCIERRSTAT (OR of the PCI status error bits), 5 MPARERR, 4 DPARERR, 3 SQPARERR, 2 ILLOPCODE (an undefined instruction was fetched; cleared only by CHIPRST), 1 ILLSADDR (the sequencer addressed a register that does not exist, or HADDR/HCNT were written during DMA), 0 ILLHADDR (the host accessed a register that needs a paused sequencer; the 7770 book's rule, not confirmed for the 7880). The HIM reads ERROR after every interrupt and resets the bus if anything but PCIERRSTAT with RMA is set, so it must read 0 in normal operation.

DFCNTRL 0x93 RW, reset 0 [7870 p. 145–146].

Bit Name Meaning
7 PRELOADEN Ultra2 only, reads 0
6 WIDEODD hold a trailing odd byte of a wide transfer for the next segment
5 SCSIEN / SCSIENACK enable the SCSI bus ↔ SCSI FIFO transfer; reads back as acknowledge
4 SDMAEN / SDMAENACK enable SCSI FIFO ↔ data FIFO
3 HDMAEN / HDMAENACK enable PCI ↔ data FIFO
2 DIRECTION 1: PCI → FIFO → SCSI (SCSI write, host read); 0: SCSI → FIFO → PCI; cannot change while 5:3 are set
1 FIFOFLUSH push the FIFO's remaining bytes to PCI (or accept a partial quad-word from the sequencer); self-clearing; reads 1 while a flush is pending
0 FIFORESET empty the FIFO and load the byte-offset pointers from LHADDR[2:0]; self-clearing

Both firmwares write the enables and then spin until the acknowledge bits read 0 after clearing them; a model that clears them synchronously is correct, one that leaves them set hangs the sequencer.

DFSTATUS 0x94 R, reset 0x21 — 7 PRELOAD_AVAIL (Ultra2), 6 DFCACHETH (a cache line of data or space), 5 FIFOQWDEMP (no complete quad-word; 1–7 bytes do not clear it), 4 MREQPEND (a PCI master request is pending), 3 HDONE (HCNT expired and the last host transfer completed), 2 DFTHRESH (the threshold level is reached), 1 FIFOFULL, 0 FIFOEMP. FIFORESET, CHIPRST and RST# force 0x21.

DFWADDR 0x95 RW, DFRADDR 0x97 RW — 4:0 the quad-word write and read pointers, 5 the roll-over bits that distinguish full from empty, bit 7 of DFWADDR CACHETHLA and of DFRADDR DFSDH are read-only level flags. DFDAT 0x99 RW — the byte port into the FIFO at the current pointer and byte offset; the pointer advances after the high byte of a quad-word. 0x96 and 0x98 are reserved.

SCBCNT 0x9a RW, reset 0 — 7 SCBAUTO: the page byte address comes from 4:0 SCBCNT and auto-increments per byte, so the host may stream the page (DWORD writes allowed). 6:5 reserved.

QINFIFO 0x9b RW — write: append an SCB number; read: pop the head (reading an empty queue returns the previous value and does not pop; writing a full one is ignored). QINCNT 0x9c R — entries queued (0–16; bits 7:5 roll over). The HIM pops and re-pushes to move a REQUEST SENSE to the head, so the count must be exact. QOUTFIFO 0x9d — written by the sequencer, popped by the host without pause. QOUTCNT 0x9e R. Bits 7:4 of an entry read 0 without external SRAM. Neither O2 firmware uses the out-queue; the HIM uses the in-queue, the Gibbs firmware neither.

SFUNCT 0x9f RW, reset 0 — 7:5 SFUNCT test selector (usable as software flags when 4:0 are 0; ALT_MODE on later parts), 4 TESTRAM, 3 TESTHOST, 2 TESTSEQ, 1 TESTFIFO, 0 TESTSCSI.

6.5 The SCB page, 0xa0–0xbf

32 bytes of RAM per page, 16 pages, selected by SCBPTR; the hardware attaches no meaning to any byte. The firmware's field layouts are in §8. Linux's self-test writes 0xaa 0x55 0xa5 0x5a to 0xa0–0xa3 of page 0 and reads them back; its SCB probe writes i to byte 0 of page i for i = 0.. and stops when page 0's byte changes (aliasing) or the byte does not stick, expecting 16; both firmwares use byte 31 of page t as the busy marker of target t (0xff = free).

7. The sequencer

[7870 p. 4, 57, 98–105, 174–176; drv aicasm/aicasm_insformat.h, aicasm_gram.y, aic7xxx_core.c:6996-7119; the HIM's sequencer image, disassembled; 86box]

Neither data book prints the instruction set (both promise it in the application-notes chapter and stop short). What follows is the encoding the Linux assembler emits for the pre-Ultra2 parts and the Linux driver writes into the chip, cross-checked against the HIM's 1994 image and 86Box's interpreter, which runs Adaptec's own option-ROM firmware on it. Behaviours inferred from firmware idioms rather than stated by a document are marked inferred.

7.1 Execution model

  • 512 words of program RAM, 29 bits plus byte parity each; the host writes 32-bit words whose top three bits are zero. 9-bit program counter (SEQADDR), 4-entry return stack of 9-bit addresses, 8-bit accumulator A (ACCUM), two 8-bit index registers SINDEX/DINDEX, two flags ZERO and CARRY.
  • One instruction per sequencer clock (10 or 8 MHz). Every instruction reads one source register, combines it with an 8-bit operand and writes one destination register, or branches. There are no general-purpose registers: the register file is the device registers, scratch RAM and the current SCB page.
  • The sequencer sees the full 256-byte device space. Addresses above 0xff do not exist on this part (the 9-bit source/destination fields of the Ultra2 encoding are compressed to 8 bits for download).

7.2 Instruction encoding

Little-endian 32-bit word in SEQRAM, byte 0 first:

ALU / shift (opcodes 0–6):
  bits  7:0   immediate (ALU) or shift control (ROL)
  bits 15:8   source register address
  bits 23:16  destination register address
  bit  24     RET: pop the stack into the PC after this instruction
  bits 28:25  opcode
  bits 31:29  0

Branch (opcodes 8–15):
  bits  7:0   immediate
  bits 15:8   source register address
  bits 24:16  9-bit target address
  bits 28:25  opcode
  bits 31:29  0

[drv aic7xxx_core.c:7094-7108; 86box; the HIM image decodes identically, e.g. its first word 00 65 07 10 = 0x10076500 = opcode 8 JMP to 0x007 with source SINDEX.]

Opcode Mnemonic Operation Flags
0 OR dst = src | op Z
1 AND dst = src & op Z
2 XOR dst = src ^ op Z
3 ADD dst = src + op Z, C = carry out of bit 7
4 ADC dst = src + op + C Z, C
5 ROL dst = rotate/shift(src) by the shift control Z, C = last bit shifted out
6 BMOV block move of imm bytes (command-channel parts only; the Linux driver rewrites it to AND dst, 0xff, src before download) Z
7 — undefined on this part (MVI16 on aic79xx) → ILLOPCODE
8 JMP SINDEX = src | imm; PC = target Z
9 JC same, branch if C Z
10 JNC same, branch if !C Z
11 CALL same, push PC + 1, branch Z
12 JNE branch if src != op Z
13 JNZ branch if (src & op) != 0 Z
14 JE branch if src == op Z
15 JZ branch if (src & op) == 0 Z

op, the second operand: the immediate, except that an immediate of 0 means the accumulator for opcodes 0–4 and 12–15. For JMP, JC, JNC and CALL the immediate is used literally (0 is 0), because those four deliver src | imm to SINDEX as the callee's argument and the firmware depends on passing a literal 0 (mov ARG_1 call dma_scb, mvi 0 call post_byte_setup) [inferred from aicasm_gram.y:940-962 and both firmwares; 86box agrees]. A plain jmp label is encoded with source SINDEX and immediate 0, which leaves SINDEX unchanged.

Flag rules [inferred from firmware, confirmed by 86box]: ADD, ADC and ROL write both flags; the logical operations and the compare/test branches write ZERO and leave CARRY alone, which the 32-bit add chains in both firmwares (add/mov/adc/clr/adc sequences) require. A compare is an exclusive-or, a test an and; ZERO reflects the result. CARRY for ADD is the unsigned carry out, so subtraction by adding a two's complement borrows correctly (add lo, -8; adc hi, 0xff).

ROL shift control [inferred from aicasm_gram.y:1727-1786 and the HIM's ROL ..., 0x4c]: bits 2:0 rotate-left count, bit 3 "mask from the right" (a right shift), bits 7:4 how many result bits the mask keeps (0xf = all). The assembler emits SHL n = (n<<4)|n (8 → 0xf0), SHR n = (n<<4)|(8-n)|8 (8 → 0xf8), ROL n = n & 7, ROR n = (8-n)|8. So 0x4c rotates left by 4 and keeps the low 4 bits: a logical shift right by 4, which is how both firmwares extract a target ID from the high nibble. The carry becomes the bit shifted out on each step.

RET (bit 24) applies to ALU opcodes only; a taken branch does not also return. The assembler synthesises:

Source Encoded as
mov dst, src AND dst, 0xff, src (via BMOV, rewritten)
mvi dst, imm OR dst, imm, ALLZEROS (imm 0: AND dst, 0xff, ALLZEROS)
clr dst AND dst, 0xff, ALLZEROS
nop / ret AND NONE, 0xff, ALLZEROS (+ RET)
not, inc, dec XOR dst, 0xff, ADD dst, 1, ADD dst, 0xff
clc / stc ADD NONE, 0xff, ALLZEROS / ADD NONE, 1, ALLONES
test src, imm jz L JZ with imm; cmp src, imm je L → JE
mov src jmp L, mvi imm call L JMP/CALL with src, or with ALLZEROS and imm

Download-time constants: the Linux assembler marks an immediate that names a download const with bit 31 of its internal format; the driver substitutes the value and clears the bit before compressing the word (aic7xxx_core.c:7067-7070). The chip never sees it.

7.3 Special registers in the file

Register Role in instructions
ACCUM 0x64 the accumulator: implicit operand when imm = 0, and an ordinary register otherwise (mov A, QINPOS)
SINDEX 0x65 argument register of JMP/CALL; pointer for SINDIR
DINDEX 0x66 pointer for DINDIR
SINDIR 0x6c reads [SINDEX], then SINDEX++; mov DINDIR, SINDIR copies a byte and advances both
DINDIR 0x6d writes [DINDEX], then DINDEX++; mov DINDIR, DFDAT pops the FIFO into consecutive registers
ALLONES 0x69, ALLZEROS 0x6a, NONE 0x6a constants and the write sink
FUNCTION1 0x6e write v, read 1 << ((v >> 4) & 7): target ID to bit mask
FLAGS 0x6b Z and C as a readable byte
STACK 0x6f debugging read-out of the return stack
SEQADDR0 0x62 writable by the sequencer: a computed jump within the page
INTSTAT 0x91 written by the sequencer to raise SEQINT (with a code) or CMDCMPLT

7.4 Loading, verifying and running a program

  1. Pause (HCNTRL.PAUSE, wait for the acknowledge).
  2. SEQCTL = PERRORDIS | LOADRAM (Linux adds FAILDIS | FASTMODE: 0xb1; the HIM writes 0x81).
  3. SEQADDR0 = 0, SEQADDR1 = 0.
  4. Write 4 bytes per instruction to SEQRAM, least-significant byte first, consecutively; the address auto-increments. Linux writes 441 instructions for an Ultra-wide rev ≥ 1 7880 (438 without Ultra, 449 for rev 0), the HIM 427 (1708 bytes), the PROM's build 424 (1696 bytes).
  5. Optionally verify: SEQCTL = PERRORDIS, then PERRORDIS | LOADRAM again, SEQADDR = 0, read 4 bytes per instruction back and compare (the HIM fails the attach on any mismatch; Linux does not verify).
  6. SEQCTL = running value with LOADRAM clear (Linux 0x00, the HIM 0x72 = FAILDIS | FASTMODE | SEQRESET).
  7. Set the entry point: SEQADDR0/SEQADDR1 = 0 (or let SEQRESET do it), then write HCNTRL with PAUSE clear (and INTEN set).

Program RAM survives CHIPRST (drivers reload anyway). An address that holds no valid instruction, or an opcode of 7, raises ILLOPCODE and BRKADRINT.

7.5 Interaction with the host

  • Interrupting: mov INTSTAT, SINDEX (or mvi INTSTAT, code|1) with bit 0 set stops the sequencer at once; the host reads the code from INTSTAT[7:4], services it, writes CLRINT.CLRSEQINT, and restarts with HCNTRL. Scratch RAM and the current SCB page carry the arguments. mvi INTSTAT, CMDCMPLT posts a completion without stopping.
  • Critical sections: the Linux driver keeps a table of program ranges during which the sequencer must not be interrupted by a host pause and steps it out of them with SEQCTL.STEP before touching shared state; the HIM instead sets PAUSEDIS from inside the program. Both need STEP to execute exactly one instruction per PAUSE release and SEQADDR to read the next PC.
  • Entry points: Linux always restarts at 0. The HIM restarts at 0 (idle loop) after errors and at instruction 2 (the phase dispatcher) after it has driven a negotiation by hand; it computes SEQADDR0 = byte_offset >> 2, SEQADDR1 = byte_offset >> 10.
  • Shared RAM atomicity: the host's byte writes to scratch RAM while the sequencer runs (Linux's doorbell) rely on Automatic Access Pause; an emulator must not let an instruction read a half-written multi-byte value, which with byte-wide host access only matters if the host writes several bytes the sequencer reads together (it does not: KERNEL_QINPOS is one byte).

7.6 Timing an emulator should respect

The real sequencer runs at 10 MHz; the firmware's polling loops (test SSTAT0, SELDO jnz, test DFSTATUS, HDONE jz .) spin for as long as the hardware takes, which is microseconds for DMA and up to 256 ms for a selection time-out. Completion and status latency therefore comes from the SCSI side and the host DMA, not from instruction count; a model may execute the program as fast as it likes provided the status bits it polls change only when the modelled event has happened, and provided host-visible side effects (the completion byte DMA before CMDCMPLT, for instance) keep their order. The HIM additionally relies on a dummy register read to flush a posted DMA write before re-reading its completion array, i.e. a register read must not complete before earlier DMA writes are visible.

8. The downloaded programs

8.1 Gibbs aic7xxx.seq (NetBSD, OpenBSD, FreeBSD, Linux)

[drv aic7xxx.seq, aic7xxx.reg, aic7xxx_seq.h_shipped, aic7xxx_core.c; line numbers into the Linux copy]

The source is 880 instructions covering the whole family; if scopes are compiled into a patch table and the driver drops the scopes whose condition is false for the chip at hand, relocating branch targets. For an initiator- only 7880 the true conditions are PAGESCBS, !DT, INITIATORROLE, ULTRA (if REXTVALID or overridden), !ULTRA2, TMODE_WIDEODD_BUG (inside target code, no effect), PCI_2_1_RETRY_BUG (rev ≥ 1), WIDE, !QUEUE_REGS, !CMD_CHAN, giving the 441-instruction image. Seven critical sections survive at download addresses (7,12), (15,21), (313,329), (423,426), (426,432), (434,436), (436,438) for that build. NetBSD ships a slightly older build of the same source (889 source instructions).

Scratch RAM layout (aic7xxx.reg, scratch_ram blocks):

Offset Name Contents
0x20–0x2f BUSY_TARGETS / TARG_SCSIRATE per target: the tag of the untagged command connected or disconnected (0xff = none). The BIOS/PROM leaves per-target SCSIRATE values here, which the driver reads once at attach
0x30–0x31 ULTRA_ENB → CMDSIZE_TABLE BIOS: bit vector of Ultra-enabled targets; after init, CDB length by group code: 5, 9, 9, 0, 15, 11, 0, 0 (0x30–0x37)
0x32–0x33 DISC_DSB BIOS: bit vector of disconnect-disabled targets
0x38 MWI_RESIDUAL rev 0 only: bytes past a cache-line end moved as an extra segment
0x39 NEXT_QUEUED_SCB tag of the host SCB the sequencer will fetch next
0x3a MSG_OUT message byte to send: 0x80 build IDENTIFY, 0xff HOST_MSG let the host drive, else the byte
0x3b DMAPARAMS the DFCNTRL value for the current data phase
0x3c SEQ_FLAGS NOT_IDENTIFIED 0x80, NO_CDB_SENT 0x40, DPHASE 0x20, target-mode bits, NO_DISCONNECT 0x01
0x3d SAVED_SCSIID target ID of the current nexus
0x3e SAVED_LUN its LUN
0x3f LASTPHASE last phase seen (SCSISIGI & 0xe0), 0x01 = bus free
0x40 WAITING_SCBH head of the list of SCBs awaiting selection
0x41 DISCONNECTED_SCBH head of the disconnected list
0x42 FREE_SCBH head of the free list of hardware SCB pages
0x43 COMPLETE_SCBH
0x44–0x47 HSCB_ADDR bus address of the host's hardware-SCB array (64-byte stride), LSB first
0x48–0x4b SHARED_DATA_ADDR bus address of the shared block: 256-byte completion ring, then the 256-byte host-side in-queue history
0x4c KERNEL_QINPOS the doorbell: host's producer index
0x4d QINPOS sequencer's consumer index
0x4e QOUTPOS sequencer's completion-ring write index
0x4f, 0x50 KERNEL_TQINPOS, TQINPOS target mode
0x51 ARG_1 / RETURN_1 argument/return byte: SEND_SENSE 0x40, EXIT_MSG_LOOP 0x08, CONT_MSG_LOOP 0x04, …
0x52 ARG_2 / RETURN_2
0x53 LAST_MSG copy of the last message sent
0x54 SCSISEQ_TEMPLATE SCSISEQ value the host permits: `ENSELO
0x56 HA_274_BIOSGLOBAL EISA leftovers
0x57 SEQ_FLAGS2 SCB_DMA 0x01, TARGET_MSG_PENDING 0x02
0x5a SCSICONF TERM_ENB 0x80, RESET_SCSI 0x40, ENSPCHK 0x20, our ID in 3:0; written by the driver from its defaults (0x67)
0x5c, 0x5d, 0x5f INTDEF, HOSTCONF, HA_274_BIOSCTRL EISA only

The hardware SCB (32 bytes in the page, 64 in host memory, little-endian):

Offset Name Contents
0–11 SCB_CDB_STORE / SCB_CDB_PTR the CDB if ≤ 12 bytes, else a 4-byte pointer to the 32-byte CDB at host offset 32. Reused on the way back as SCB_RESIDUAL_DATACNT (0–3), SCB_RESIDUAL_SGPTR (4–7), SCB_SCSI_STATUS (8), target-mode bytes (9–11)
12–15 SCB_DATAPTR first segment's bus address
16–19 SCB_DATACNT first segment's length in 23:0; byte 3: SG_LAST_SEG 0x80 and address bits 32–38
20–23 SCB_SGPTR bus address of the second S/G element (8-byte aligned); byte 0 also holds SG_RESID_VALID 0x04, SG_FULL_RESID 0x02, SG_LIST_NULL 0x01 (no data)
24 SCB_CONTROL TARGET_SCB/STATUS_RCVD 0x80, DISCENB 0x40, TAG_ENB 0x20, MK_MESSAGE 0x10, ULTRAENB 0x08, DISCONNECTED 0x04, SCB_TAG_TYPE 1:0
25 SCB_SCSIID target in 7:4, our ID in 3:0 — written straight into SCSIID
26 SCB_LUN LUN in 5:0, SCB_XFERLEN_ODD 0x80
27 SCB_TAG the host SCB index, also used as the queue tag
28 SCB_CDB_LEN
29 SCB_SCSIRATE value for SCSIRATE
30 SCB_SCSIOFFSET Ultra2 only
31 SCB_NEXT link: next tag in the host's queue chain, or next page in the waiting/disconnected/free lists

An S/G element is { u32 addr; u32 len; } little-endian; len bits 23:0 count, 30:24 address bits 32–38, bit 31 LAST_SEG. The first element is copied into the SCB and SGPTR points at the second; a command without data has SGPTR = SG_LIST_NULL and zero DATAPTR/DATACNT. Segments are at most 16 MB and 128 per command.

Host → chip protocol. The host never uses QINFIFO: it copies the new command into the "next" host SCB whose tag the sequencer already knows (NEXT_QUEUED_SCB), links the following free tag into byte 31, and writes its producer index to KERNEL_QINPOS (one byte, no pause, relying on AAP). The sequencer compares QINPOS with KERNEL_QINPOS, takes a free page (or pages a disconnected one out to the host), DMAs the 32 bytes from HSCB_ADDR + tag*64 (host read: HADDR, HCNT = 32, DFCNTRL = HDMAEN | DIRECTION | FIFORESET, wait HDONE, clear HDMAEN, wait for the ack, then 32 × mov DINDIR, DFDAT into 0xa0), checks that byte 27 still matches, advances NEXT_QUEUED_SCB from byte 31, pushes the page on the waiting list and increments QINPOS. Selection: SCSIID = byte 25, SCSISEQ = template with ENSELO, poll SSTAT0.SELDO.

Information transfer. phase_lock waits for REQINIT, checks SCSIPERR, writes SCSISIGI & 0xe0 to SCSISIGO and LASTPHASE, then dispatches: COMMAND sends the CDB from the page through DFDAT with DFCNTRL = SCSIEN | SDMAEN | DIRECTION | FIFORESET and STCNT = length (or from host memory with HDMAEN too for long CDBs), waiting for SDONE; DATA runs the loop in §4.5 with DMAPARAMS = WIDEODD | SCSIEN | SDMAEN | HDMAEN | FIFORESET plus DIRECTION for data out, HADDR/HCNT from SCB_DATAPTR/DATACNT, STCNT = HCNT, fetching each further element as an 8-byte host read into the FIFO and popping it into HADDR/HCNT; STATUS reads SCSIDATL into byte 8; MESSAGE OUT sends IDENTIFY (+ queue tag + tag) or hands over to the host; MESSAGE IN peeks SCSIBUSL, handles DISCONNECT, SAVE/RESTORE POINTERS, COMMAND COMPLETE, IGNORE WIDE RESIDUE and NOP itself and acknowledges with a dummy SCSIDATL read, and hands anything else (SDTR, WDTR, REJECT, …) to the host through the message loop.

Completion. With good status and no residual the page is freed (SCB_TAG = 0xff, pushed on FREE_SCBH) and the tag is written into the completion ring: HADDR = SHARED_DATA_ADDR + QOUTPOS, HCNT = 1, DFCNTRL = FIFORESET, DFDAT = tag, DFCNTRL |= HDMAEN | FIFOFLUSH, wait HDONE, then mvi INTSTAT, CMDCMPLT. The host finds the tag in memory (it does not read INTSTAT for completions), writes CLRINT.CLRCMDINT, and refills consumed ring slots with 0xff four at a time. A non-zero status or a residual first uploads the 32-byte page back to the host (SG_RESID_VALID set) and raises SEQINT BAD_STATUS; the host may rewrite the same host SCB as a REQUEST SENSE, requeue it and answer RETURN_1 = SEND_SENSE.

SEQINT codes (INTSTAT[7:4], the whole byte shown):

Code Name Raised when Host does
0x01 BAD_PHASE a phase that is none of the six print and continue
0x11 SEND_REJECT (not generated by this build)
0x21 PROTO_VIOLATION data/command/status/complete/disconnect before IDENTIFY or CDB bus reset or abort message
0x31 NO_MATCH a reselection's IDENTIFY/tag matched no SCB BUS DEVICE RESET via the message loop
0x41 IGN_WIDE_RES IGNORE WIDE RESIDUE mid-transfer adjust SCB_RESIDUAL_* and SHADDR-derived pointers
0x51 PDATA_REINIT re-entering data phase after a non-data phase recompute HADDR/HCNT/STCNT from the residual
0x61 HOST_MSG_LOOP a message phase the host must drive §8.1 message loop
0x71 BAD_STATUS non-zero SCSI status auto REQUEST SENSE
0x81 PERR_DETECTED parity error while waiting for REQ in PIO bit-bucket the phase or ack the byte
0x91 DATA_OVERRUN S/G list exhausted in data phase freeze the device
0xa1 MKMSG_FAILED MK_MESSAGE still set at completion recovery bookkeeping
0xb1 MISSED_BUSFREE REQ seen where bus free was expected ahc_restart
0xc1, 0xd1, 0xe1 SCB_MISMATCH, NO_FREE_SCB, OUT_OF_RANGE debug / resource panics panic

The host message loop. On HOST_MSG_LOOP the host reads SCSISIGI for the phase; for MESSAGE OUT it builds IDENTIFY/tag/SDTR/WDTR/ABORT/BDR, clears MK_MESSAGE in the page's SCB_CONTROL, and sends each byte with CLRSINT1 = CLRREQINIT then a write to SCSIDATL (dropping ATN with CLRATNO before the last byte); for MESSAGE IN it peeks SCSIBUSL, parses, and acknowledges with CLRREQINIT plus a read of SCSIDATL. It then sets RETURN_1 to CONT_MSG_LOOP or EXIT_MSG_LOOP, clears SEQINT and unpauses; the firmware loops through phase_lock and raises the code again until told to exit. The whole SDTR/WDTR negotiation therefore happens in the host with the sequencer stopped between bytes.

SCSI interrupts the host handles (SIMODE1 = ENSELTIMO | ENSCSIRST | ENSCSIPERR, plus ENBUSFREE inside connections): SELTO → SCSISEQ = 0, CLRSINT1 = CLRSELTIMEO | CLRBUSFREE | CLRSCSIPERR, CLRSINT0 = CLRSELINGO, complete the SCB at WAITING_SCBH with a selection time-out, ahc_restart; BUSFREE → expected after ABORT/BDR/negotiation messages, otherwise "unexpected bus free" and the nexus is aborted; SCSIPERR → choose INITIATOR DETECTED ERROR / MESSAGE PARITY ERROR, MSG_OUT = that; SCSIRSTI → ahc_reset_channel without pulsing the bus.

Initialisation (the exact order is in aic7xxx_core.c:5084-5268): chip reset; DSCOMMAND0 |= MPARCKEN | CACHETHEN; SEEPROM probe; SBLKCTL &= ~(DIAGLEDEN|DIAGLEDON); DSPCISTATUS = 0xc0; SCSICONF = id | ENSPCHK | RESET_SCSI; SCB probe (16); SEQ_FLAGS/SEQ_FLAGS2 = 0; SCSIID = our ID; SXFRCTL1 = ENSTIMER | ACTNEGEN | STPWEN | (SCSICONF & 0x38); SIMODE1 = 0xa4; SXFRCTL0 = DFON | SPIOEN; busy table 0xff; HSCB_ADDR, SHARED_DATA_ADDR; CMDSIZE_TABLE; queue positions 0; list heads 0xff; MSG_OUT = NOP; SCSISEQ_TEMPLATE = 0x5a; every page filled with 0xff then CONTROL 0, NEXT chained, TAG/SCSIID/LUN 0xff; FREE_SCBH = 0; NEXT_QUEUED_SCB; program download; ahc_restart (SCSISIGO = 0, LASTPHASE = bus free, SAVED_SCSIID/LUN = 0xff, SCSISEQ = template & (ENSELI|ENRSELI|ENAUTOATNP) = 0x12, CLRINT = CLRSEQINT, SEQCTL = 0, SEQADDR = 0, unpause); finally a bus reset: SCSISEQ |= SCSIRSTO, 25 µs, clear, CLRSINT1 = 0xef, CLRSINT0 = 0x70, CLRINT = CLRSCSIINT.

8.2 Adaptec's HIM (the O2 PROM and IRIX)

[him; obs. The 427-instruction image was disassembled for this document; the decoder is clanker/devices/aic7880-seqdis.py.]

The PROM and IRIX drive the chip through Adaptec's Hardware Interface Module in its "OPTIMA" access mode. The sequencer image the kernel downloads is 1708 bytes, 427 instructions ("OPTIMA mode sequencer", 1994), loaded unpatched; the PROM's build is 1696 bytes. Unlike the Gibbs firmware it uses the hardware QINFIFO, keeps the host's SCBs in host memory and copies them into the page RAM on demand, and lets the host do every negotiation by hand.

What the driver configures. Two controllers (0x8078), controller number = PCI device − 1; 0x8178 would be an option card. Registers through BAR1 only, 8-bit accesses at offset ^ 3. Host ID 0 (the PROM's scsihostid variable can change it). 16 SCBs, 2 untagged per target, 16 targets, Fast-20 enabled unconditionally on the on-board chips (DEVCONFIG is only read for 0x8178). SBLKCTL, SEECTL, BRDCTL are never touched on the on-board chips. The controller-0 probe at boot asks only targets 0–4.

Initialisation, as the register trace shows it: HCNTRL = PAUSE, wait; allocate the SCB pointer array (16 dwords) and the 256-byte completion array (256-byte aligned, used uncached); download and verify the program; SCSIID = 0; SCSISEQ = 0; CLRSINT0 = 0xff; CLRSINT1 = 0xff; SXFRCTL0 = CLRSTCNT | CLRCHN; SXFRCTL1 = ENSTIMER | ACTNEGEN | ENSPCHK | STPWEN (0x27, 256 ms time-out); DFCNTRL = FIFORESET; SIMODE1 = ENSCSIPERR | ENSELTIMO | ENSCSIRST (0xa4); busy bytes cleared (SCBPTR = 0..127, byte 31 = 0xff); scratch RAM set up (table below); SEQCTL = FAILDIS | FASTMODE | SEQRESET (0x72); BRKADDR1 = BRKDIS; DSPCISTATUS = 0x80 (75 % threshold); SXFRCTL0 = DFON; DISC_OPTION bytes; HCNTRL = INTEN (unpause, PC 0). Then a 70 ms SCSI bus reset (SCSISEQ = SCSIRSTO, SIMODE0/1 = 0 and CLRINT = 0x0f around it) and a 1 s quiet period.

Scratch RAM layout (the HIM's names):

Offset Name Contents
0x20–0x2f XFER_OPTION[t] the agreed SCSIRATE byte per target; 0x8f = negotiation needed
0x30, 0x31 FAST20_LOW/HIGH bit map of targets running Ultra
0x32, 0x33 DISCON_OPTION bit map of targets that may not disconnect
0x34–0x39 firmware temporaries S/G cursor: 0x34 "more segments" flag, 0x35–0x38 element pointer
0x3a WAITING_SCB SCB number being selected (0xff none)
0x3b ACTIVE_SCB SCB number connected (0xff none)
0x3c PASS_TO_DRIVER argument byte of a SEQINT: SCSI status, message length, reselecting ID
0x3d–0x40 SCRATCH_SCB_PTR_ARRAY bus address (native view) of the 16-entry array of SCB bus addresses, LSB first
0x41 SCRATCH_QIN_CNT
0x42–0x45 SCRATCH_QIN_PTR_ARRAY placeholder 0x0bad0001, unused by the firmware
0x46–0x55 NEXT_SCB_ARRAY[16] per target: an SCB parked behind a busy target (0x7f none; bit 7 set = ready to run)
0x56–0x59 SCRATCH_QOUT_PTR_ARRAY bus address (native view) of the completion array; the low byte doubles as the write cursor
0x5a–0x5d SCRATCH_BUSY_PTR_ARRAY placeholder 0x0bad0003, unused

The SCB (32 bytes; 28 are downloaded). Byte offsets as the chip sees them; in IRIX's big-endian memory the byte fields of each 32-bit word are declared in reverse so that the word-preserving native view delivers this order:

Byte Field Contents
0 Tarlun target << 4 | channel 0x08 | LUN
1 control REJECT_MDP 0x80, DIS_ENABLE 0x40, TAG_ENABLE 0x20, 0x10 "last segment loaded" (firmware), SpecFunc 0x08, SDISCON 0x04, TAG_TYPE 1:0
2 CDBLen
3 SegCnt always at least 1; the firmware overwrites it with its more-segments flag
4–7 SegPtr address of the S/G list, native view (bit 30 set)
8–11 CDBPtr address of the CDB, byte view (bit 30 clear)
12 TargStat SCSI status, filled by the host from PASS_TO_DRIVER
13 chain control Holdoff 0x01, Concurrent 0x02, Abort 0x04, Aborted 0x08
14, 15 NextPtr, Offshoot unused
16–19 ResCnt residual count, byte 16 least significant; 19–22 double as the saved S/G pointer
20–23 reserved 23 = "data phase started" flag
24–27 Address current data address
28–30 Length current count
31 HaStat not downloaded; byte 31 of page t is target t's busy marker

S/G element { u32 data_ptr; u32 data_len; }, data_len bit 31 = SG_LAST_ELEMENT, count in 23:0; lists physically contiguous; one element {0, 0x80000000} for a command without data; data buffers in the byte view. The sense buffer and its length form a one-element list used for automatic REQUEST SENSE.

Host → chip. The driver builds the SCB and CDB, writes them back from the cache, stores the SCB's native-view address in SCB_PTR_ARRAY[n], and writes n to QINFIFO, with no pause. It puts a REQUEST SENSE at the head by popping and re-pushing the queue (QINCNT − 1 rotations), which needs exact FIFO semantics. Completions are read from the completion array before any register: QOUT_PTR_ARRAY[idx ^ 3] with idx starting at 4 and stepping down by 4, re-read once after a dummy register read if it shows 0xff; then CLRINT = CLRCMDINT and one more scan.

The firmware (instruction addresses from the disassembly):

  • Idle loop (7–0x1a): ACTIVE_SCB = WAITING_SCB; SELDO → selection done; SELDI → reselected; ENSELO still set → wait; scan NEXT_SCB_ARRAY for a parked SCB with bit 7 set and run it; QINCNT = 0 → wait; else SCBPTR = QINFIFO (pop), fetch the SCB, dispatch. Busy check: page t byte 31 = 0xff → select, else park the number in NEXT_SCB_ARRAY[t].
  • SCB fetch (0x17c–0x190, 0x19a): two host reads with DFCNTRL = HDMAEN | DIRECTION | FIFORESET (0x0d), wait HDONE, clear HDMAEN, pop DFDAT: 4 bytes at SCRATCH_SCB_PTR_ARRAY + n*4 become HADDR, then 28 bytes into page bytes 0–27.
  • Selection (0x4a–0x5c): page t byte 31 = n; WAITING_SCB = n; SCSIID = (SCSIID & 0x0f) | t << 4; DFCNTRL = 0; SXFRCTL0 |= CLRSTCNT | SPIOEN; CLRSINT1 = CLRSCSIRSTI; SCSISEQ = 0x5a; back to idle until SELDO. Then bytes 19–22 = bytes 4–7 (save the list pointer), CLRSINT1 = CLRBUSFREE, SCSISEQ = 0x12, SIMODE1 |= ENBUSFREE, CLRSINT0 = CLRSELDO.
  • Message out (0x5d–0x7b): wait REQINIT; phase from SCSISIGI & 0xe0 written back to SCSISIGO; IDENTIFY = 0x80 | LUN | 0x40 if disconnect allowed (the target's bit decoded through FUNCTION1 against DISCON_OPTION); with TAG_ENABLE the queue-tag message from byte 1 and the tag = SCB number; SCSIRATE = XFER_OPTION[t] and SXFRCTL0.FAST20 from the Ultra map; if XFER_OPTION[t] = 0x8f ATN stays asserted so the target returns to MESSAGE OUT and the firmware raises SEQINT 0; else CLRSINT1 = CLRATNO before the last byte. Bytes go out by writing SCSIDATL under SPIOEN.
  • Command (0x82–0x8c): HADDR = bytes 8–11, HCNT = STCNT = byte 2, DFCNTRL = 0x3d; done on SDONE; a PHASEMIS first means STATUS is acceptable, anything else CDB_XFER_PROBLEM.
  • S/G prefetch (0x90–0x9b), right after the CDB: copy bytes 3–7 to scratch 0x34–0x38, DMA the 8-byte element (native view), HADDR/HCNT from it, 0x34 = data_len[31:24] ^ 0x80 (0 = last), STCNT = HCNT, save into bytes 24–30 and 3–7; on the last element byte 1 |= 0x10 and bytes 16–18 = HCNT.
  • Data (0xaf–0xc8): DFCNTRL = 0x39 (in) or 0x3d (out) plus WIDEODD while more segments follow; wait DMADONE or PHASEMIS; next element on DMADONE; on PHASEMIS mid-transfer wait FIFOEMP and !MREQPEND, clear the enables and wait for the acks, FIFORESET, bytes 16–18 = STCNT, 19–22 = the list cursor. SAVE DATA POINTERS (0x110) saves SHADDR into 24–27 and STCNT into 28–30; DISCONNECT (0x117) zeroes SCSIRATE, clears FAST20, masks ENBUSFREE, acks, waits for BUSFREE. Resumption after a reselect reloads HADDR/HCNT/STCNT from bytes 24–30.
  • Reselection (0x20–0x49): ACTIVE_SCB = 0xff, CLRSINT1 = CLRBUSFREE, SIMODE1 |= ENBUSFREE, CLRSINT0 = CLRSELDI; expects IDENTIFY; PASS_TO_DRIVER = SELID | LUN; the busy byte of page t names the SCB, or the queue tag does; byte 23 decides whether to resume data.
  • Status and completion (0xcc–0xe6): residual check (DATA_OVERRUN if bytes 16–18 ≠ 0 or byte 1 bit 4 clear); status into PASS_TO_DRIVER; non-zero status → CHECK_CONDX with the bus left in MESSAGE IN, COMMAND COMPLETE not acknowledged (the host acks it by hand); good → ack, SCSIRATE = 0, mask ENBUSFREE, wait BUSFREE; a parked SCB for the target is marked runnable; then the completion write: one byte 0xff DMA'd to the completion array at cursor P, P += 4, the SCB number DMA'd to P, P += 0xf8 (net −4, no carry out of the low byte), INTSTAT = CMDCMPLT, busy byte = 0xff. The host, reading through the word-preserving view, finds entries at idx ^ 3 for idx = 4, 0, 0xfc, …
  • Message in (0x109): SAVE DATA POINTERS, DISCONNECT (rejected if not allowed), EXTENDED (a 5-byte MODIFY DATA POINTER is applied in firmware: HADDR = SHADDR + offset, CLRCHN; anything else → EXTENDED_MSG), RESTORE POINTERS, NOP; others → UNKNOWN_MSG.

SEQINT codes (INTSTAT[7:4]):

Code Name Raised Host
0 SYNC_NEGO_NEEDED target back in MESSAGE OUT after IDENTIFY because ATN was held negotiate: WDTR then SDTR by PIO, restart at instruction 2
1 CDB_XFER_PROBLEM phase mismatch during the CDB, next phase not STATUS bus reset
2 HANDLE_MSG_OUT MESSAGE OUT during reselection or in the data loop send the second half of a negotiation, or MESSAGE 05/08/abort
3 DATA_OVERRUN target wants more data, or left data phase early residual from bytes 16–19, or BITBUCKET until PHASEMIS
4 UNKNOWN_MSG unhandled message reject (or abort the target if it rejected IDENTIFY/tag)
5 CHECK_CONDX status ≠ 0, in PASS_TO_DRIVER ack COMMAND COMPLETE by hand, auto REQUEST SENSE through the same SCB at the queue head
6 PHASE_ERROR REQ where bus free was expected bus reset unless a BUSFREE is pending
7 EXTENDED_MSG an extended message other than MDP; length in PASS_TO_DRIVER read the rest by PIO
8 ABORT_TARGET abort the target
9 NO_ID_MSG reselection without IDENTIFY abort the target

The host's interrupt path pauses before reading INTSTAT if the chip is not already paused (a documented workaround), clears SEQINT before dispatching and then drives the bus by hand, so clearing an interrupt must not restart the sequencer. After every interrupt it reads ERROR and resets the bus if anything other than PCIERRSTAT with a lone RMA is set. On SELTO the SCB is WAITING_SCB; on other SCSI interrupts ACTIVE_SCB; if that is 0xff the driver clears the interrupts and returns without unpausing.

Negotiation is entirely host-driven: after SEQINT 0 the host restarts the sequencer at instruction 2, clears XFER_OPTION[t], SCSIRATE and the target's Ultra bit, sends WDTR (01 02 03 width) if wide is allowed, then SDTR (01 03 01 period offset) with period 4 × rate_index + 12 (Ultra; index 0 → 12 = 48 ns = 20 MHz) or 6 × index + 25, offset 15 narrow or 8 wide; the reply is parsed and the agreed SCSIRATE value (WIDEXFER | SXFR | offset, with FAST20 recorded for periods below 25) is stored in XFER_OPTION[t]. Each byte is sent by writing SCSIDATL then waiting for ACKI to drop and REQINIT; inbound bytes are read from SCSIBUSL and acknowledged by asserting ACKO in SCSISIGO by hand until REQI drops. A target that never answers a negotiation is marked asynchronous/narrow.

Timing the host enforces: a 2 s timer polls the interrupt handler and times out commands (10 s for the probe INQUIRY) with a bus reset; 70 ms RST assertion; 1 s quiet after reset; 250 ms between INQUIRY retries.

9. The serial EEPROM

[drv aic7xxx_93cx6.c, aic7xxx.h:773-853; AHA-2940UW manual appendix; 7890 FlexPort chapter]

Not fitted on the O2, but the register interface is part of the chip. A 93C46 (64 × 16, 6 address bits) or 93C56/66 (8 address bits) is read with SEECTL: write SEEMS, wait for SEERDY; for each access SEECS high, clock the start bit and the read opcode (1, 1, 0) and the address on SEEDO with SEECK pulses (poll SEERDY after every write for the 800 ns), then clock 17 bits in from SEEDI; release with SEECTL = 0. Adaptec's 32-word configuration block:

Word Field Bits
0–15 device_flags[16] 2:0 sync rate index, 3 CFSYNCH, 4 CFDISC, 5 CFWIDEB, 6 CFSYNCHISULTRA, 7 CFSYNCSINGLE, 8 CFSTART, 9 CFINCBIOS, 10 CFRNFOUND, 11 CFMULTILUNDEV, 14 CFWBCACHEENB
16 bios_control 0 CFSUPREM, 1 CFSUPREMB, 2 CFBIOSEN, 3 CFBIOS_BUSSCAN, 4 CFSM2DRV/CFSTPWLEVEL, 5 CFCTRL_A, 6 CFTERM_MENU, 7 CFEXTEND, 8 CFSCAMEN, 10:9 CFMSG_LEVEL, 11 CFBOOTCD
17 adapter_control 0 CFAUTOTERM, 1 CFULTRAEN, 2 CFSTERM, 3 CFWSTERM, 4 CFSPARITY, 5 CFMULTILUN, 6 CFRESETB, 7 CFCLUSTERENB, 9:8 CFBOOTCHAN, 10 CFSEAUTOTERM, 11 CFSELOWTERM, 12 CFSEHIGHTERM, 14 CFENABLEDV
18 brtime_id 3:0 host adapter SCSI ID, 15:8 bus release time
19 max_targets 7:0 maximum targets, 11:8 boot LUN, 15:12 boot ID
20–29 reserved
30 signature 0x0250 or 0x0300
31 checksum 16-bit sum of words 0–30; a sum of 0 is invalid

Without a valid block the drivers assume ID 7, termination on, all targets sync/wide/disconnect/Ultra capable and a bus reset at boot; if the PROM left SCSISEQ non-zero they keep its SCSIID instead.

10. Timing and electrical facts

Fact Value Source
CLKIN 40 MHz nominal (≥ 25 ns period) [7870 p. 53, 220]
PCLK ≤ 33.3 MHz [7870 p. 36]
Sequencer clock CLKIN/4 or /5 [7870 p. 98]
Synchronous periods (4 + SXFR) × 25 ns; × 12.5 ns with FAST20 [7870 p. 79; drv]
Maximum offset 15 narrow, 8 wide [7870 p. 79]
Selection time-out 256 / 128 / 64 / 32 ms [7870 p. 76]
Bus-free detection BSY and SEL negated 400 ns [7870 p. 86]
REQ/ACK filter 12.5–25 ns above 5 MB/s; 50–62.5 or 62.5–75 ns below [7870 p. 74]
SEERDY 800 ns after a SEECTL write [7870 p. 162]
Reset RST# ≥ 8 PCLK; POR + 2 CLKIN; CHIPRST POR 2–3 CLKIN; IDDAT 8 clocks at 20 MHz [7870 p. 40, 138, 221, 224]
PCI target DEVSEL# medium; TRDY# ≥ 1 PCLK after; disconnect after > 8 wait states; retry on a long internal wait [7870 p. 32, 43]
Master abort no DEVSEL# by clock 6 (7 for DAC) [7870 p. 35]
Data FIFO 256 B; thresholds 3/16/24/32 QWD write, 29/16/8/0 read; cache-line flag at 16/32/64/128 B [7870 p. 136, 147]
SCSI FIFO 16 bytes [7870 p. 88]
Bus reset by drivers 25 µs (Gibbs), 70 ms (HIM); HIM waits 1 s afterwards [drv; obs]
Supply ~50 mA active, 36 mA paused, 5 mA powered down (7870) [7870 p. 210]

11. Family differences that matter to this part

Feature 7850 7870 7880 7890/7896 (Ultra2)
Device ID 0x5078 0x7078/0x7178/0x7870 0x8078 + board IDs 0x001f… (vendor 0x9005)
SCSI 8-bit Fast 8/16-bit Fast 8/16-bit Fast-20 (FAST20, REXTVALID) LVD Ultra2, SXFRCTL2, SCSIID_ULTRA2, 127 offset
SCBs 3 (SCBPTR[1:0]) 16 (+ external up to 256) 16 (+ external) 16/32 + command channel, 64-byte SCBs
Queues 3-bit entries 16 deep 16 deep queue registers HNSCB_QOFF etc.
Memory port / SEEPROM / BRDCTL none yes yes yes (SPIOCAP on 7855/60)
Data FIFO 128 B 256 B 256 B 256 B + preload
DSCOMMAND0 BCTL-style as §6.4 as §6.4 adds INTSCBRAMSEL, RAMPS, USCBSIZE32, CIOPARCKEN
DEVCONFIG extras PCIERRGEN at 0x43 bits 0–7 + REXTVALID, SCBSIZE32 + PCI64BIT, DACEN used
Errata flags — AHC_PCI_2_1_RETRY_BUG rev 0: CACHETHEN_BUG, PCI_MWI_BUG; rev ≥ 1: PCI_2_1_RETRY_BUG AHC_SCBCHAN_UPLOAD_BUG etc.
Sequencer, instruction set, scratch, 0x00–0x9f map same same same same sequencer; BMOV real; host side reorganised

Register-level consequences of the 7880 errata: on rev 0 the driver keeps DSCOMMAND0.CACHETHEN clear and the firmware splits segments at cache-line boundaries (MWI_RESIDUAL); on rev ≥ 1 the chip cannot issue a PCI retry while the data FIFO is non-empty, so the driver writes a cache-line size of 0 when it was 4 and the firmware pops DFDAT while waiting for HDMAEN to drop (dma_halt) and drains the FIFO in 8-byte steps during SCB downloads (dma_scb_hang_*), finishing with a computed jump through SEQADDR0. A model whose host reads complete instantly makes those loops take their short path.

12. Open questions

  1. The native view's word size. The CRIME text says sub-64-bit references in the reverse-endian view are swapped and the native view passes bytes through; the HIM's byte reads use idx ^ 3, which is a 32-bit pass-through. Whether a 64-bit master would see ^ 7 is not established and does not matter for the 32-bit 7880.
  2. The O2 chips' PCI revision ID, and therefore which Linux bug flags apply on real hardware. IRIX only reports it. hinv output from a real machine would settle it.
  3. ILLHADDR. The 7770 book defines it as a host access to a register that needs the sequencer paused; the 7870 book keeps the bit but, read literally, the PCI parts service such accesses by Automatic Access Pause. 86Box disables the check for the 7870/7880. We treat it as never set.
  4. SELID writability and the exact SELTIMER tap for each STIMESEL value are stated inconsistently in the 7870 book.
  5. The PROM's build of the HIM image is 12 bytes shorter than IRIX's; the difference has not been disassembled.
  6. 40 MHz SCSI clock on the O2 is assumed from the Fast-20 requirement; no board document states it.

13. References

  • Adaptec, AIC-7870 PCI Bus Master Single-Chip SCSI Host Adapter Data Book, 1994. docs/datasheets/scsi/AIC-7870_Data_Book.pdf.
  • Adaptec, AIC-7850 PCI Bus Master Single-Chip SCSI Host Adapter Data Book, 1995. docs/datasheets/scsi/AIC-7850_Data_Book.pdf.
  • Adaptec, AIC-7890A/7891 PCI Bus Master Ultra2 Host Adapter Chip Data Book, Rev B, August 1998, stock 511683-00. https://ftp.mirrorservice.org/sites/www.bitsavers.org/pdf/adaptec/asic/51163-00rB_AIC-7890A_PCI_Bus_Master_Ultra2_Host_Adapter_Chip_Aug98.pdf
  • Adaptec, AIC-7770 Data Book. https://bitsavers.org/pdf/adaptec/asic/AIC-7770_Data_Book.pdf
  • No AIC-7880 data book, product brief or errata sheet is publicly available (bitsavers, archive.org, the datasheet archives and the retro hardware sites were searched in October 2026). Wind River's VxWorks aic7880Lib manual cites an "AIC-7880 Data Book", an "AIC-7880 Design In Handbook" and the "Adaptec Hardware Interface Module (HIM) Specification".
  • Justin T. Gibbs, Adaptec Inc., aic7xxx driver: aic7xxx.reg, aic7xxx.seq, aicasm/, aic7xxx_core.c, aic7xxx_pci.c, aic7xxx_93cx6.c (Linux drivers/scsi/aic7xxx/, NetBSD sys/dev/ic/aic7xxx*, sys/dev/microcode/aic7xxx/).
  • SGI, MACE I/O ASIC Specification, chip rev 2.0, 1996. docs/datasheets/o2/mace.pdf. SGI, CRIME 1.5 Specification rev 0.3, 1997. docs/datasheets/o2/crime1_5.pdf.
  • SGI, IRIX Device Driver Programming Guide, IRIX 6.3 for O2, 007-3443-002, chapter 15 "PCI Device Drivers".
  • NetBSD sys/arch/sgimips/mace/pci_mace.c, sgimips/autoconf.c; Linux arch/mips/sgi-ip32/, arch/mips/pci/pci-ip32.c, fixup-ip32.c, ops-mace.c; OpenBSD sys/arch/sgi/pci/macepcibridge.c (Attic).
  • 86Box, src/scsi/scsi_aic7xxx.c (2026): an independent register-level model of the 7770/7870/7880 that executes Adaptec's option-ROM firmware.
  • gxemul src/devices/dev_ahc.cc: a register stub, useful only for the NetBSD probe messages it quotes from real hardware.
  • Adaptec, AHA-2940UW/OF User's Manual, appendix "Initial Program Load Data" (the SEEPROM word layout).