Repository navigation
fix(runtime): mirror D_ENABLEW into D_ENABLER and reset it to 0x1201 - #284
Open
luisbraganca wants to merge 1 commit into
Open
luisbraganca wants to merge 1 commit into
luisbraganca wants to merge 1 commit into
Conversation
D_ENABLEW (0x1000F590) and D_ENABLER (0x1000F520) are the write and read ports of the single DMAC enable register, but PS2Memory kept them as two unrelated I/O slots, so a write to one was never visible at the other. Any guest that suspends the DMAC and polls for the CPND bit therefore spun forever; Ridge Racer V does this around its DMAC interrupt handler and frame kick and froze after loading its IOP modules. writeIORegister now stores a D_ENABLEW write into both slots, which covers every access width (write8/16 merge into the 32-bit slot, write64/128 split into write32, recompiled stores arrive through PS2Runtime::Store32). initialize seeds both slots with 0x1201, the value the hardware reports at boot, with CPND clear. Matches PCSX2's dmacWrite32 and hwReset. Channel kicks are still executed immediately while CPND is set: the runtime has no queued-DMA model, and a kick with D_CTRL.DMAE clear is dropped today, so gating on suspend would lose transfers. Adds three PS2Memory cases: the reset value, sw/sh writes to D_ENABLEW reading back at D_ENABLER (including the byte read PCSX2 polls), and the suspend/resume spin loops terminating. They fail on main. ps2x_tests: 440 passed, 0 failed (437 before). Fixes ran-j#257
Author
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.
Closes #257
Problem
D_ENABLEW(0x1000F590) andD_ENABLER(0x1000F520) are the write and read ports of the single DMAC enable register.PS2Memorykept them as two unrelatedm_ioRegistersslots, so a guest that suspends the DMAC and polls for the CPND bit never sees it:Ridge Racer V does exactly this around its DMAC interrupt handler and frame kick (
0x0021FDD8/0x0021FE30), so it froze after loading its IOP modules and clearing both framebuffers.Change
ps2xRuntime/src/lib/ps2_memory.cppwriteIORegister: a store toD_ENABLEWlands in both slots. Every access width reaches it:write8/16merge into the 32-bit slot and callwriteIORegister,write64/128split intowrite32, and a recompiledswgoes throughPS2Runtime::Store32because the I/O range is a special address.initialize: both slots start at0x1201, the value the hardware reports at boot; bit 16 is clear, so the DMAC starts enabled.Nothing else changes. Channel kicks are still performed immediately while CPND is set: the runtime has no queued-DMA model (a kick with
D_CTRL.DMAE = 0is dropped today), and suspend should not start dropping transfers. Stores toD_ENABLERkeep the generic I/O-register behaviour, as in PCSX2.References
pcsx2/Dmac.cpp,dmacWrite32,case DMAC_ENABLEW:psHu32(DMAC_ENABLEW) = value; psHu32(DMAC_ENABLER) = value;pcsx2/Hw.cpp,hwReset:psHu32(DMAC_ENABLEW) = 0x1201; psHu32(DMAC_ENABLER) = 0x1201;psHu8(DMAC_ENABLER + 2) == 1(byte 2 = bit 16), which is why the test also checks the byte read.1000F520h D_ENABLER - DMAC disabled status (R),1000F590h D_ENABLEW - DMAC disable (W), bit 16 "DMAC disabled", "SCPH-39001 seems to expect D_ENABLER to be set to 1201h upon boot".Verification
ps2xTest/src/ps2_memory_tests.cpp, suitePS2Memory, three new cases:DMAC D_ENABLER reads 0x1201 after reset with CPND clearDMAC D_ENABLEW writes are visible at D_ENABLER—sw, thenshto the upper half, thenlbof byte 2DMAC suspend and resume polls through D_ENABLEW and D_ENABLER terminate— the Ridge Racer V loops with a poll capOn
main(2c5fbb9) with only the tests applied: 440 total, 437 passed, 3 failed — the three cases above. With the fix:ps2x_tests440/440.Host: macOS on Apple Silicon, AppleClang, Release,
-DPS2X_ENABLE_FFMPEG=OFF -DPS2X_BUILD_STUDIO=OFF. No game ELF is available here, so the Ridge Racer V spin is reproduced by the third test rather than by running the title.