Repository navigation
mx4sio: read and write buffers that are not word aligned - #959
Open
rickgaiser wants to merge 1 commit into
Open
rickgaiser wants to merge 1 commit into
rickgaiser wants to merge 1 commit into
Conversation
FatFs passes the caller's buffer to the block device, at any offset: a read from an odd position in a file gives an odd address. The SIO2 DMA and reverse_buffer work on words, so such a buffer ended in an address error exception on the IOP, repeated forever. Take those a sector at a time through an aligned buffer. Aligned buffers are transferred as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
mx4sio_bdcrashes the IOP when a block read or write gets a buffer that is not word aligned.FatFs passes the caller's buffer straight to the block device for whole sectors, at any offset, so a read from an odd position in a file gives an odd buffer address. The SIO2 DMA and
reverse_bufferwork on words, which ends in an address error exception, repeated forever.Reads and writes with such a buffer now go a sector at a time through an aligned buffer. Aligned buffers take the same path as before, so normal transfers keep their speed.
How to reproduce
Run a program from MX4SIO that reads a file at unaligned positions. Hexen II crashed this way while loading its data:
ioptrapreported an address error inmx4siowith an odd address in$a0. USB mass storage handles the same reads without trouble.Testing
On a real PS2, with
sio2man,padman,mcman,bdmandbdmfs_fatfsbuilt from this tree, on an exFAT card:Note
#958 changes adjacent lines in the same file. The two do not depend on each other.
🤖 Generated with Claude Code