feat(drivers): bitfield register structs for 8237 DMA + FDC DOR#434
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
struct dma_mask,struct dma_mode, andstruct fdc_dortosrc/include/registers.hcovering the 8237A single-channel mask (port 0x0A/0xD4), the 8237A mode register (port 0x0B/0xD6), and the 82077AA floppy digital output register (port 0x3F2).kernel_outbinfdc.candsb16.cthat 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 singlemov byte [ebp-K], <const>via the existing bitfield-collapse peephole.Test plan
tests/test_bboefs.py(exercisesfdc_read_sector/fdc_write_sectorend-to-end via bbfs)tests/test_asm.py(full boot path includingfdc_init's DOR reset)tests/test_programs.py🤖 Generated with Claude Code