runtime: test ACP address and memory mapping sequence #1000

Manually merged
github merged 1 commit from gh-pr/1000/head into gh-pr/1000/base 2026-11-26 22:34:07 +00:00
Owner

@⁠Holastor on GitHub · 2026-11-23 20:37 UTC · original
Holastor:audio/acp-address-memory → main · +617 −3 · 6 files · 1 commits · merged 2026-11-23 20:54 UTC

Add a source-built caller (tests/cpu/apu_address_caller.asm) and controlled test recording provider (tests/cpu/apu_address_provider.cpp) exercising the ACP address and memory mapping exports from acphal.dll:

  • acphal.dll!ApuAlloc (MIT Microsoft/DirectXTK12 call shape)
  • acphal.dll!ApuFree (MIT Microsoft/DirectXTK12 call shape)
  • acphal.dll!ApuMapVirtualAddress
  • acphal.dll!ApuMapApuAddress
  • acphal.dll!ApuIsVirtualAddressValid

Fixture contract qualification

  • Call shapes and evidence: While ApuAlloc and ApuFree call shapes are taken from public MIT call sites in Microsoft/DirectXTK12 (SoundEffect.cpp, WaveBankReader.cpp, SoundStreamInstance.cpp), the three mapping and query signatures (ApuMapVirtualAddress, ApuMapApuAddress, and ApuIsVirtualAddressValid) and the address translation behavior tested here are the recording provider's fixture contract (proposed test-provider policy) rather than verification against an original or production console provider.
  • Milestone distinction: This milestone establishes that a source-built caller, controlled provider, and loaders (Windows native loader and pe_map) can exercise, record, and verify bidirectional address translation, linear offset preservation, validity query lifecycle, and failure/withholding controls. Verification against an original console provider remains open.

Verified behaviors

  1. Bidirectional mapping identity: ApuMapVirtualAddress translates an allocated CPU virtual pointer to an APU device address (APU_ADDRESS / UINT64), and ApuMapApuAddress translates it back to the exact identical CPU pointer (ApuMapApuAddress(ApuMapVirtualAddress(ptr)) == ptr).
  2. Linear offset preservation: Verified that offsets inside an allocation translate consistently (ApuMapVirtualAddress(ptr + offset) == apu_addr + offset and ApuMapApuAddress(apu_addr + offset) == ptr + offset).
  3. Validity query lifecycle: ApuIsVirtualAddressValid(ptr) returns TRUE (1) while the block is live, and returns FALSE (0) after ApuFree(ptr).
  4. Data access: Memory written through the mapped pointer is verified byte-for-byte upon readback.
  5. Refusal controls: Null pointers, stack addresses, and out-of-range APU addresses are refused (ApuIsVirtualAddressValid returns FALSE, ApuMapVirtualAddress returns 0, ApuMapApuAddress returns nullptr).
  6. Faulty provider negative control: A faulty provider build (APU_TEST_FAULTY) where mapping returns nullptr causes the caller to abort at Step 4 (0xF04).
  7. Withholding negative controls: Withholding any of ApuMapVirtualAddress, ApuMapApuAddress, or ApuIsVirtualAddressValid stops pe_map at import resolution before entry with STATUS["unresolved"] naming the missing export.

Verification

cmake --build --preset dev --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller
ctest --preset dev --no-tests=error -R '^cpu_native_apu_address$' -V
test 321: cpu_native_apu_address ........... Passed (0.18 sec)
caller imports: {'acphal.dll': ['ApuAlloc', 'ApuFree', 'ApuIsVirtualAddressValid', 'ApuMapApuAddress', 'ApuMapVirtualAddress', 'get_apu_unmapped_refusals'], 'cpu_exe_io.dll': ['finish_exe']}
native and mapped exit 0x8a1; all address translation assertions passed
faulty provider: native and mapped exit 0xf04 at Step 4
before entry: unresolved import acphal.dll!ApuMapVirtualAddress
before entry: unresolved import acphal.dll!ApuMapApuAddress
before entry: unresolved import acphal.dll!ApuIsVirtualAddressValid
100% tests passed, 0 tests failed out of 1

Release build:

cmake --build --preset release --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller
ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V
100% tests passed, 0 tests failed out of 1 (0.17 sec)

Documentation and hygiene checks:

.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py

All passed.

Refs #870.

**@⁠Holastor** on GitHub · 2026-11-23 20:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1000) `Holastor:audio/acp-address-memory` → `main` · +617 −3 · 6 files · 1 commits · merged 2026-11-23 20:54 UTC Add a source-built caller (`tests/cpu/apu_address_caller.asm`) and controlled test recording provider (`tests/cpu/apu_address_provider.cpp`) exercising the ACP address and memory mapping exports from `acphal.dll`: - `acphal.dll!ApuAlloc` (MIT Microsoft/DirectXTK12 call shape) - `acphal.dll!ApuFree` (MIT Microsoft/DirectXTK12 call shape) - `acphal.dll!ApuMapVirtualAddress` - `acphal.dll!ApuMapApuAddress` - `acphal.dll!ApuIsVirtualAddressValid` ### Fixture contract qualification - **Call shapes and evidence**: While `ApuAlloc` and `ApuFree` call shapes are taken from public MIT call sites in Microsoft/DirectXTK12 (`SoundEffect.cpp`, `WaveBankReader.cpp`, `SoundStreamInstance.cpp`), the three mapping and query signatures (`ApuMapVirtualAddress`, `ApuMapApuAddress`, and `ApuIsVirtualAddressValid`) and the address translation behavior tested here are the recording provider's **fixture contract** (proposed test-provider policy) rather than verification against an original or production console provider. - **Milestone distinction**: This milestone establishes that a source-built caller, controlled provider, and loaders (Windows native loader and `pe_map`) can exercise, record, and verify bidirectional address translation, linear offset preservation, validity query lifecycle, and failure/withholding controls. Verification against an original console provider remains open. ### Verified behaviors 1. **Bidirectional mapping identity**: `ApuMapVirtualAddress` translates an allocated CPU virtual pointer to an APU device address (`APU_ADDRESS` / `UINT64`), and `ApuMapApuAddress` translates it back to the exact identical CPU pointer (`ApuMapApuAddress(ApuMapVirtualAddress(ptr)) == ptr`). 2. **Linear offset preservation**: Verified that offsets inside an allocation translate consistently (`ApuMapVirtualAddress(ptr + offset) == apu_addr + offset` and `ApuMapApuAddress(apu_addr + offset) == ptr + offset`). 3. **Validity query lifecycle**: `ApuIsVirtualAddressValid(ptr)` returns `TRUE` (`1`) while the block is live, and returns `FALSE` (`0`) after `ApuFree(ptr)`. 4. **Data access**: Memory written through the mapped pointer is verified byte-for-byte upon readback. 5. **Refusal controls**: Null pointers, stack addresses, and out-of-range APU addresses are refused (`ApuIsVirtualAddressValid` returns `FALSE`, `ApuMapVirtualAddress` returns 0, `ApuMapApuAddress` returns `nullptr`). 6. **Faulty provider negative control**: A faulty provider build (`APU_TEST_FAULTY`) where mapping returns `nullptr` causes the caller to abort at Step 4 (`0xF04`). 7. **Withholding negative controls**: Withholding any of `ApuMapVirtualAddress`, `ApuMapApuAddress`, or `ApuIsVirtualAddressValid` stops `pe_map` at import resolution before entry with `STATUS["unresolved"]` naming the missing export. ### Verification ```powershell cmake --build --preset dev --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller ctest --preset dev --no-tests=error -R '^cpu_native_apu_address$' -V ``` ``` test 321: cpu_native_apu_address ........... Passed (0.18 sec) caller imports: {'acphal.dll': ['ApuAlloc', 'ApuFree', 'ApuIsVirtualAddressValid', 'ApuMapApuAddress', 'ApuMapVirtualAddress', 'get_apu_unmapped_refusals'], 'cpu_exe_io.dll': ['finish_exe']} native and mapped exit 0x8a1; all address translation assertions passed faulty provider: native and mapped exit 0xf04 at Step 4 before entry: unresolved import acphal.dll!ApuMapVirtualAddress before entry: unresolved import acphal.dll!ApuMapApuAddress before entry: unresolved import acphal.dll!ApuIsVirtualAddressValid 100% tests passed, 0 tests failed out of 1 ``` Release build: ```powershell cmake --build --preset release --target cpu_apu_address_provider cpu_apu_address_provider_faulty cpu_apu_address_caller ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V ``` ``` 100% tests passed, 0 tests failed out of 1 (0.17 sec) ``` Documentation and hygiene checks: ```powershell .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py ``` All passed. Refs #870.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:34:05 +00:00
github manually merged commit 5f0aa847ca into gh-pr/1000/base 2026-11-26 22:34:07 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 20:43 UTC · original

Independent Windows Release run of 5f0aa84 passed ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V (1/1). Native and pe_map returned 0x8a1, the faulty provider returned 0xf04 in both, and withholding each mapping/query import failed before entry. The three mapping/query signatures and address behavior in this patch are the recording provider's fixture contract. Please carry that qualification into the PR summary so readers can distinguish this milestone from verification against the original provider.

**@⁠R0Y00** on GitHub · 2026-11-23 20:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1000#issuecomment-7113471941) Independent Windows Release run of `5f0aa84` passed `ctest --preset release --no-tests=error -R '^cpu_native_apu_address$' -V` (1/1). Native and pe_map returned `0x8a1`, the faulty provider returned `0xf04` in both, and withholding each mapping/query import failed before entry. The three mapping/query signatures and address behavior in this patch are the recording provider's fixture contract. Please carry that qualification into the PR summary so readers can distinguish this milestone from verification against the original provider.
Author
Owner

@⁠Holastor on GitHub · 2026-11-23 20:48 UTC · original

Thanks @⁠R0Y00, that qualification is important and makes complete sense. Updated the PR summary accordingly:

  • Added an explicit Fixture contract qualification section distinguishing the test-provider policy and recording provider's fixture contract (for ApuMapVirtualAddress, ApuMapApuAddress, ApuIsVirtualAddressValid, and synthetic address translation) from verified behavior against an original/production console provider.
  • Clarified that this milestone establishes caller, loader, and failure isolation contracts under source-built inputs, while verification against the original console provider remains open.
**@⁠Holastor** on GitHub · 2026-11-23 20:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1000#issuecomment-7113587840) Thanks @⁠R0Y00, that qualification is important and makes complete sense. Updated the PR summary accordingly: - Added an explicit **Fixture contract qualification** section distinguishing the test-provider policy and recording provider's fixture contract (for `ApuMapVirtualAddress`, `ApuMapApuAddress`, `ApuIsVirtualAddressValid`, and synthetic address translation) from verified behavior against an original/production console provider. - Clarified that this milestone establishes caller, loader, and failure isolation contracts under source-built inputs, while verification against the original console provider remains open.
This discussion has been locked. Commenting is limited to contributors.
No description provided.