feat(runtime): add generic guest-memory write boundary (IGuestMemoryWriter) - #361
Conversation
…riter) Adds `IGuestMemoryWriter` and a default `GuestMemoryWriter`, the write-side mirror of the existing `IGuestMemoryReader`/`GuestMemoryReader` (PR #350). Both share `Ps1AddressTranslation.TryTranslate` for the canonical KUSEG/KSEG0/KSEG1 rule and the same RAM-only bound (`Ps1MemoryMap.RamSize`); the writer never touches the reader class directly, so each depends only on the shared translation helper. This closes the capability gap PR #358 (ADR-014 amendment "B0:56 GetC0Table / B0:57 GetB0Table evaluated, not registered") identified: no boundary in this Runtime could write to guest memory at all. It is deliberately generic and title-agnostic, not scoped to any single BIOS service, and is intentionally left unwired into `BiosHleRuntime` — no registered service needs it yet, mirroring the precedent the read boundary and the output sink both set (landed unwired, wired once a concrete consumer existed). This does not by itself unblock `GetC0Table`/`GetB0Table`: their documented behavior needs a guest-visible, dispatch-connected jump-table representation whose canonical address, entry format, and initial contents remain unconfirmed in this repository's authoritative sources. That capability is tracked separately in #360. ADR-014 gains an amendment recording this boundary, and docs/runtime/bios-hle-evidence.md's support matrix, per-service table, and open-questions list are updated to reflect it. Verification: - dotnet test src/PSXRecomp.Tests --filter FullyQualifiedName~GuestMemory: 60 passed - dotnet test src/PSXRecomp.Tests/PSXRecomp.Tests.csproj -c Release: 1450 passed, 0 failed, 14 skipped (pre-existing, real-ROM local-fixture tests) - Native/ctest: not applicable, no native code touched - scripts/ci/check-artifact-policy.ps1: passed, no violations - git diff --check: clean Closes #359 Refs #279 Refs #360 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TYUNZnNGEsvo97erGQUs2U
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds ChangesGuest memory write boundary
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The guest-memory write boundary is bounded, tested, and intentionally remains unwired, so it does not alter existing BIOS service behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 40.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
CodeRabbit review result (HEAD
|
Summary
Adds
IGuestMemoryWriterand a defaultGuestMemoryWriter— the write-sidemirror of the existing
IGuestMemoryReader/GuestMemoryReader(PR #350).This is Issue #359, filed as a follow-up to PR #358 (ADR-014 amendment
"B0:56 GetC0Table / B0:57 GetB0Table evaluated, not registered"), which found
that no boundary in this Runtime could write to guest memory at all.
This PR implements only the generic write boundary. It does not register
GetC0Table/GetB0Table,gets, or any other BIOS service, and does notmodel the A0/B0/C0 jump-table layout — those remain gated by Issue #360
(guest-visible BIOS kernel jump-table state abstraction), which is
independently blocked on unconfirmed canonical-address evidence.
What changed
IGuestMemoryWriter/GuestMemoryWriter(PSXRecomp.Core.Runtime):Try-style single-byte write, sharing
Ps1AddressTranslation.TryTranslate(KUSEG/KSEG0/KSEG1) and the RAM-only bound (
Ps1MemoryMap.RamSize) with thereader. The writer depends on the shared translation helper directly, not
on the reader class, so the two boundaries stay independent.
BiosHleRuntime. No registered service needsit yet — this mirrors the precedent the guest-memory read boundary and the
output sink both set (landed unwired, wired only once a concrete consumer
existed).
docs/adr/014-bios-hle-runtime-contract.md— new amendment "Runtimeguest-memory write boundary".
docs/runtime/bios-hle-evidence.md— support matrix, per-service table(
gets,GetC0Table,GetB0Tablerows), and open questions 6/9 updated;open question 10 added recording this boundary as done.
src/PSXRecomp.Tests/Runtime/GuestMemoryWriterTests.cs— new tests.Tests
stores never share state)
physical byte
without reaching the physical write path
IGuestMemoryReaderboundaryVerification
dotnet test src/PSXRecomp.Tests --filter FullyQualifiedName~GuestMemorydotnet test src/PSXRecomp.Tests/PSXRecomp.Tests.csproj -c Releaserom/dir)cmake/ctest)scripts/ci/check-artifact-policy.ps1git diff --checkSelf-review
requires (ADR-014, evidence inventory). No existing service's registration
or behavior changes (
BiosHleRuntime's registry is untouched:(A0, 0x3C),(A0, 0x3E),(B0, 0x3F)).GuestMemoryReader.TryTranslate(a reader-class wrapper); fixed duringself-review to call
Ps1AddressTranslation.TryTranslatedirectly, so thewriter doesn't depend on the reader class for translation.
Remaining work
canonical-address evidence — not resolved by this PR.
Related
Closes #359. Refs #279, #360.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TYUNZnNGEsvo97erGQUs2U
Summary by CodeRabbit