Skip to content

feat(drivers): bitfield register structs for 8237 DMA + FDC DOR#434

Merged
bboe merged 1 commit into
mainfrom
bboe/cc-bitfield-dma-fdc-dor
May 20, 2026
Merged

feat(drivers): bitfield register structs for 8237 DMA + FDC DOR#434
bboe merged 1 commit into
mainfrom
bboe/cc-bitfield-dma-fdc-dor

Conversation

@bboe
Copy link
Copy Markdown
Owner

@bboe bboe commented May 20, 2026

Summary

  • Adds struct dma_mask, struct dma_mode, and struct fdc_dor to src/include/registers.h covering the 8237A single-channel mask (port 0x0A/0xD4), the 8237A mode register (port 0x0B/0xD6), and the 82077AA floppy digital output register (port 0x3F2).
  • Ports every magic-byte kernel_outb in fdc.c and sb16.c that touches those ports — DMA channel mask/unmask, channel mode bytes (0x46 / 0x4A for floppy, 0x59 for audio), and the FDC reset DOR sequence — to designated-init struct literals with datasheet field names. Each literal still folds to a single mov byte [ebp-K], <const> via the existing bitfield-collapse peephole.
  • Kernel size: 40,662 → 40,750 bytes (+88).

Test plan

  • tests/test_bboefs.py (exercises fdc_read_sector / fdc_write_sector end-to-end via bbfs)
  • tests/test_asm.py (full boot path including fdc_init's DOR reset)
  • tests/test_programs.py
  • SB16 audio path — no automated coverage in CI; manual smoke recommended before merge if audio behavior is in question

🤖 Generated with Claude Code

Adds typed bitfield-struct definitions for the 8237A single-channel
mask register (port 0x0A / 0xD4), the 8237A mode register
(port 0x0B / 0xD6), and the 82077AA floppy digital output register
(port 0x3F2) to src/include/registers.h.

fdc and sb16 — the only drivers that touch the shared DMA
controller — replace every magic-byte kernel_outb on those ports
with named-field literals:

    struct dma_mode m = { .channel = 1, .transfer = 2,
                          .autoinit = 1, .mode = 1 };
    kernel_outb(0x0B, *(uint8_t *)&m);

fdc_init's DOR reset sequence now uses struct fdc_dor literals
instead of the bare 0 / 0x0C bytes, and fdc_read_sector /
fdc_write_sector construct dma_mode locals at the call site (0x46
for floppy-read, 0x4A for floppy-write).  sb16_open / sb16_close
drop the multi-line bit-table comment that documented 0x59 — every
field now reads as its datasheet name.

Each designated init folds to a single ``mov byte [ebp-K], <const>``
via the bitfield const-fold peepholes from the previous release, so
there's no codegen regression versus the magic-byte form.

Tests:

- tests/test_bboefs.py (exercises fdc_read_sector / fdc_write_sector
  end-to-end through bbfs)
- tests/test_asm.py (full boot path including fdc_init's DOR reset)
- tests/test_programs.py
@bboe bboe merged commit f2886d0 into main May 20, 2026
27 checks passed
@bboe bboe deleted the bboe/cc-bitfield-dma-fdc-dor branch May 20, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant