Skip to content

docs(adr): 0008 — the microcode-boot harness (Phase 2 criterion 2) - #46

Merged
doublegate merged 4 commits into
mainfrom
docs/adr-microcode-boot-harness
Jul 22, 2026
Merged

docs(adr): 0008 — the microcode-boot harness (Phase 2 criterion 2)#46
doublegate merged 4 commits into
mainfrom
docs/adr-microcode-boot-harness

Conversation

@doublegate

Copy link
Copy Markdown
Owner

Motivation

Phase 2's first exit criterion (RSP category Failed: 0) is met and merged
(#41#45). This ADR settles the design for the second criterion — "a real
graphics microcode boots and emits a plausible RDP command list" — before the
multi-PR implementation, per the owner's direction: a real microcode
(libdragon rdpq), with a golden reference grounded in hardware documentation,
never another emulator
.

Key findings the ADR records

  • rdpq is not standalone — it is an overlay on libdragon's RSPQ
    command-queue kernel (#include <rsp_queue.inc>). Booting the real microcode
    means running the rspq kernel, reproducing the DMEM boot state libdragon's C
    normally sets up, and feeding an RSPQ command list. The DPC register file (feat(rdp): DPC command-register file — completes the RSP-category Phase 2 criterion #44)
    is the seam the emitted RDP commands flow through.
  • Toolchain: rsp.ld lays the microcode out as DMEM+IMEM (what our RSP
    loads); assembly needs stock mips64-elf binutils (the RSP vector opcodes are
    assembler macros, so no patched assembler). None is installed today; AUR has
    mips64-elf-gcc 14.4.0 + mips64-elf-binutils.
  • libdragon is Unlicense (public domain) — vendoring is unrestricted.

Decision (summary)

Committed golden-vector harness on the vendored real microcode, assembled from
source with a committed blob + CI reassembly-checksum (no toolchain needed to
run tests), boot state reproduced in Rust (self-contained, no emulator
dependency), fixture RSPQ command list, and the golden derived from the
documented RDP command encoding
. Three-stage plan (vendor+assemble+boot →
feed+capture → golden compare), each its own PR.

Owner action

The ADR ends with the toolchain install command (paru -S mips64-elf-binutils mips64-elf-gcc). Stage 1 proceeds once it is on PATH.

Note on review authority

This is a new ADR (not touching docs/architecture.md, not superseding an
existing ADR). Design-only; no code or behaviour change. markdownlint green.

🤖 Generated with Claude Code

Records the design for Phase 2's second exit criterion ("a real graphics
microcode boots and emits a plausible RDP command list"), settling the approach
before the multi-PR implementation.

Decision: a committed golden-vector harness on the real, vendored libdragon
rspq+rdpq microcode, assembled from source (mips64-elf), with the expected RDP
command stream derived from hardware documentation (N64brew Commands page +
libdragon's rdpq_macros.h layouts) — never another emulator. rdpq is an overlay
on the RSPQ command-queue kernel, so booting it means reproducing the rspq boot
state in Rust and feeding an RSPQ command list; the DPC register file (#44) is
the seam the emitted commands flow through.

Includes the options analysis (why not a toy microcode, an opaque libdragon
snapshot, an emulator diff, or CI-only assembly), the consequences, a three-stage
plan, and the mips64-elf toolchain the owner needs to install.

markdownlint green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Added an architectural decision record for validating real graphics microcode boot by producing a plausible RDP command list.
    • Documented a reproducible, non-emulator-based golden reference approach, including boot/witness validation and byte-level comparison.
    • Included a staged rollout plan and instructions for regenerating required artifacts with the appropriate local toolchain.

Walkthrough

Adds ADR 0008, defining the real graphics microcode boot criterion, the vendored libdragon-based harness design, staged implementation plan, release gate, and mips64-elf toolchain requirement.

Changes

Microcode boot harness

Layer / File(s) Summary
Criterion and harness design
docs/adr/0008-microcode-boot-harness.md
Defines RSPQ/RDPQ boot validation, microcode assembly requirements, Rust boot-state reconstruction, fixed command execution, golden RDP encoding, witness assertions, and rejected alternatives.
Delivery plan and toolchain
docs/adr/0008-microcode-boot-harness.md
Documents vendored artefacts, release gating, the three-stage implementation plan, and mips64-elf installation requirements.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • doublegate/RustyN64#40: Defines the same real microcode boot and deterministic RDP command comparison criterion.
🚥 Pre-merge checks | ✅ 9 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The prefix matches the required Conventional Commits shape, but the subject is not imperative and uses prose with an em dash. Rewrite as an imperative Conventional Commit, e.g. "docs(adr): add ADR 0008 microcode-boot harness".
✅ Passed checks (9 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly about the ADR and its Phase 2 microcode-boot harness design, so it is on-topic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Oracle Number Is Stated ✅ Passed Docs-only ADR change; no emulation behaviour changed, so the oracle-count requirement does not apply. docs/STATUS.md remains the source of truth.
Docs-As-Spec Sync ✅ Passed Only docs/adr/0008-microcode-boot-harness.md changed; no chip-crate code or observable behaviour changed, and the PR says design-only with no code changes.
Changelog Entry For User-Visible Changes ✅ Passed PASS: only docs/adr/0008 changed, and the ADR says “Design-only; no code or behavior changes,” so a CHANGELOG entry is not required.
Measured, Never Tuned ✅ Passed PASS: no uncited hardware constant/timing value was added; the numeric literals are layout/toolchain notes, and the relevant SP/DP facts are covered in docs/rdp.md, docs/rsp.md, and accuracy-ledger...
Unsafe Stays Out Of The Chip Crates ✅ Passed PASS: HEAD~1..HEAD only changes docs/adr/0008-microcode-boot-harness.md; scans found no unsafe blocks and no #![forbid(unsafe_code)] removals outside the frontend.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/adr/0008-microcode-boot-harness.md`:
- Around line 21-27: The ADR’s claims about rdpq provenance and the golden
reference need explicit, reproducible citations. Update the relevant bullets in
the microcode boot harness ADR to cite the exact N64brew page/section and pinned
libdragon commit plus source paths, including src/rdpq/rsp_rdpq.S and
ref-proj/libdragon/LICENSE.md; also label the “only permissively-licensed” claim
as documented, inferred, or unverified and record the search scope/date.
- Around line 92-94: Define the witness pre-run baseline in ADR 0008 by
resetting DPC_END and clearing the output buffer before execution, then assert
the exact idle observable after the run. Update the witness success/failure flow
to use an unreachable failure target so both paths cannot converge, while
retaining the IMEM execution and non-empty output checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bd02e6a9-a7fc-4d56-b01c-0b05c688b969

📥 Commits

Reviewing files that changed from the base of the PR and between 237b937 and 963bf0e.

📒 Files selected for processing (1)
  • docs/adr/0008-microcode-boot-harness.md

Comment thread docs/adr/0008-microcode-boot-harness.md Outdated
Comment thread docs/adr/0008-microcode-boot-harness.md
Adopts CodeRabbit's two comments on PR #46.

- Cites the exact sources: libdragon `src/rdpq/rsp_rdpq.S` (Unlicense per
  ref-proj/libdragon/LICENSE.md), the N64brew Reality Display Processor/Commands
  page for the RDP encoding, and qualifies the "only vendorable graphics
  microcode" line as reasoned (proprietary Nintendo microcodes excluded; nothing
  else on ref-proj's licence table) rather than exhaustively surveyed.
- Pins the Stage-1 witness: a defined pre-run baseline (zero DPC_END/CURRENT +
  the output buffer), then a specific idle observable (SP_STATUS HALTED|BROKE
  with the PC at the kernel idle handler), chosen so a microcode that never ran
  fails it — the success and failure states must not converge.

markdownlint green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/adr/0008-microcode-boot-harness.md`:
- Around line 142-149: Update the microcode boot harness witness setup to
initialize SP status and PC to unreachable baseline values before launch,
alongside the existing DPC and RDP resets. After execution, assert the
documented idle state—SP_STATUS.HALTED|BROKE with the PC at the kernel idle
handler—so the pre-run and successful states cannot converge and a no-run path
fails.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6a4e5fcd-17cf-424e-92bd-1517fcbbac73

📥 Commits

Reviewing files that changed from the base of the PR and between 963bf0e and 8f6213b.

📒 Files selected for processing (1)
  • docs/adr/0008-microcode-boot-harness.md

Comment thread docs/adr/0008-microcode-boot-harness.md Outdated
…le baseline

Adopts CodeRabbit's follow-up on PR #46. Resetting only DPC state left a hole:
if the SP began HALTED|BROKE at the idle PC, the post-run idle assertion passed
without the kernel ever executing (success and never-ran states converge).

The witness now starts from a baseline that is itself unreachable as a pass —
SP_STATUS running (HALTED/BROKE clear), PC at the kernel entry, not the idle
handler — and asserts the *transition* (BROKE set, PC advanced to the idle/BREAK
site), optionally plus a DMEM cell the boot path writes. A microcode that never
ran stays not-BROKE at entry and fails.

markdownlint green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/adr/0008-microcode-boot-harness.md`:
- Around line 143-154: Do not modify the accepted ADR 0008. Create a new
sequentially numbered ADR documenting the stronger microcode boot harness
contract, explicitly superseding and cross-linking ADR 0008, or otherwise make
this change the original ADR’s acceptance commit before merging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5070684d-a350-4468-9e21-1c746df168f3

📥 Commits

Reviewing files that changed from the base of the PR and between 8f6213b and 7e9df59.

📒 Files selected for processing (1)
  • docs/adr/0008-microcode-boot-harness.md

Comment thread docs/adr/0008-microcode-boot-harness.md
Adopts (with modification) CodeRabbit's comment on PR #46. The immutability rule
is for *landed* ADRs; 0008 is new and still being refined in its own creation
PR, so superseding it would be nonsensical. Per the comment's own alternative,
the status is now Proposed — accepted on merge of this PR, immutable thereafter —
so the pre-merge refinements are the acceptance process, not a rewrite of an
accepted record.

markdownlint green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/adr/0008-microcode-boot-harness.md (1)

124-126: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include mips64-elf-gcc in the Stage 1 tool list. The ADR already says assembling rsp_*.S needs the C preprocessor and that n64.mk assembles with mips64-elf-gcc, so listing only mips64-elf-as / ld / objcopy leaves the regeneration contract incomplete.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/adr/0008-microcode-boot-harness.md` around lines 124 - 126, Update the
Stage 1 tool list in docs/adr/0008-microcode-boot-harness.md at lines 124-126 to
include mips64-elf-gcc alongside the existing mips64-elf toolchain tools,
reflecting the C preprocessor and n64.mk assembly requirements. Apply the same
tool-list correction at lines 172-176; both sites require direct updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@docs/adr/0008-microcode-boot-harness.md`:
- Around line 124-126: Update the Stage 1 tool list in
docs/adr/0008-microcode-boot-harness.md at lines 124-126 to include
mips64-elf-gcc alongside the existing mips64-elf toolchain tools, reflecting the
C preprocessor and n64.mk assembly requirements. Apply the same tool-list
correction at lines 172-176; both sites require direct updates.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f7b5e8e-7b26-425c-8baa-a4b905270c7d

📥 Commits

Reviewing files that changed from the base of the PR and between 7e9df59 and 61dcf7b.

📒 Files selected for processing (1)
  • docs/adr/0008-microcode-boot-harness.md

@doublegate
doublegate merged commit bb2be02 into main Jul 22, 2026
9 checks passed
@doublegate
doublegate deleted the docs/adr-microcode-boot-harness branch July 22, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant