jakethompson1 wrote on Today, 01:42:
Perhaps with a card like the one earlier in the thread that connects the DMARQ and DMACK lines, presumably to DRQ5 and DACK5 on the ISA slot, but with a custom disk BIOS.
Well , maybe some day I can retire from the day job and spend a week making a hacked up ISA card, a month learning to program a 8237, and then a year writing a Win 3.1 device driver for a small multi tasking gain.
Here is what I got from Claude. The task looks pretty sickeningly hard. Maybe start from an open source floppy driver and twist it into a VxD. Maybe I'd work on some other projects first. Like writing a util to test disk transfers under load for data corruption, because I'd almost certainly corrupt the file system 1000 times before getting it right.
1. Confirm the drive supports it.
Issue IDENTIFY DEVICE (ATA command 0xEC) and check word 62 — the field reporting which single word DMA modes (0/1/2) the drive supports and which is currently active. This is a read-only query, standard on any ATA-1+ drive.
2. Negotiate the mode with the drive
Issue SET FEATURES (command 0xEF) with feature register 0x03 ("Set Transfer Mode") and the sector count register loaded with the mode value (0x00-0x02 for SDMA 0-2, per the ATA-1 encoding). The drive acknowledges by updating its status register.
3. Program the 8237 for this specific channel. This is the real firmware work, and it's a fixed sequence:
Write the mode register (I/O port 0x0B for DMA channels 0-3, 0xD6 for channels 4-7) selecting: this channel, single-transfer mode (not block or demand mode — SDMA maps to single-transfer specifically), and read or write direction matching the ATA command about to be issued.
Write the address registers: the low byte and high byte of the starting memory address to the channel's address port (e.g., port 0x00 for channel 0), plus the page register (port 0x87 for channel 0) for the upper address bits, since the 8237 only handles 16 bits of address itself.
Write the count register: transfer count minus one, to the channel's word-count port.
Clear the channel's mask bit (port 0x0A, or 0xD4 for the second controller) so it can respond to DREQ.
4. Issue the actual ATA DMA command
Send READ DMA (0xC8) or WRITE DMA (0xCA) to the drive's command register. The drive then asserts DREQ when its buffer has data ready (or is ready to accept it).
5. Let single-transfer mode do its thing, one word at a time
Because SDMA maps to the 8237's single-transfer mode: the DMA controller responds to DREQ, does one fly-by word transfer, then releases HOLD back to the CPU — and the drive must re-assert DREQ for every subsequent word. Critically, this means the 8237 doesn't run the whole sector autonomously; BIOS/firmware code has to sit in a loop watching for either the terminal count (TC) signal or the drive's completion status, since control bounces back to the CPU after every single word.
6. Handle the 64KB constraints
The 8237's word-count register maxes at 64KB, and — this one's easy to trip over — a transfer cannot cross a 64KB physical page boundary, since the page register doesn't auto-increment when the low 16 bits wrap. For anything beyond one page, firmware has to split the transfer into page-aligned chunks and reprogram the 8237 between chunks.
7. Detect completion and errors
Poll (or take an interrupt on) the drive's status register for DRQ clearing and BSY dropping, and separately watch the 8237's status register (port 0x08 or 0xD0) for the TC bit on this channel, to confirm the DMA side finished cleanly.
Why this is the hard part relative to bus-master DMA: in the PCI bus-master case, you build one PRD table describing the whole transfer's scatter-gather layout and let the controller run autonomously to completion, interrupting once at the end. Here, because single-transfer mode releases the bus after every word, your firmware loop is far more exposed to timing — and depending on how tightly your DREQ-servicing loop is written, it's plausible you'd bottleneck well below even 2.1MB/s (SDMA-0's nominal max) if the code polling for the next transfer isn't tight. That's a real engineering risk, not just busywork, and part of why period BIOS/firmware teams apparently decided it wasn't worth building.