acphal: reuse freed APU heap blocks and report the 20-byte heap state #410
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/410"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-28T20:43:53Z.
Summary
The APU heap only ever grew.
ApuFreeandAcpHalReleaseShapeContextsreturned success without freeing anything, andApuHeapGetStatewrote twou32counters.ApuFreenow returns a block to a first-fit free list and merges it with its free neighbours.AcpHalReleaseShapeContextsgives the XMA context array back to the heap.ApuHeapGetStatefills the 20-byte heap state: free, allocated and lost bytes, the largest free block, and the allocation count.ApuCreateHeapsizes the heap from both of its size arguments, cached and non-cached.ApuIsVirtualAddressValidchecks the range against live allocations.AcpHalAllocateShapeContextstreats the SHAPE context record as0x60bytes and also writes the XMA array's 32-bit APU address at offset0x58.The record and state layouts come from a clean-room comparison with the GDKX 2026.10 headers. No retail trace has confirmed them yet, so the README still marks DSP/XMA decoding as incomplete. The README now describes the free list and the release path.
Tests are in
runtime/acphal/src/tests/lib.rsandruntime/xapu/src/tests/commands.rs. They cover merging adjacent free blocks, the state layout and alignment, the SHAPE record writes, and both completion paths. Each fails onmain, where the functions or fields it checks don't exist.Tested
runtime/" needs its suite on any card.No Lanes scenario: Lanes doesn't load AcpHal or xapu. The
xapuverify suite covers xapu, and acphal has no guest suite.GPU, driver and backend: NVIDIA GeForce RTX 2070 SUPER, driver 620.73.04, GE-Proton11-14
Commands run and their results:
AI use: Claude Code ported this from a local branch, moved the tests into
src/tests, wrote the README change and ran the checks above. glovepost published it.🤖 Generated with Claude Code