SDCard performance improvements#107
Merged
breakintoprogram merged 2 commits intobreakintoprogram:mainfrom Nov 10, 2023
Merged
Conversation
1. Replace spi.c with spi.asm
Maximise performance as much as possible by structuring the code so
that:
a) The SPI transmission is initiated as quickly as possible
b) When transferring multiple bytes, minimising the time between
the the first byte being sent/received and the next transmission
being initiated.
c) Do as much as possible whilst the SPI byte is being transmitted
Introduces spi_read() and spi_write() functions to reduce overhead
of transmitting multiple bytes.
2. Replace sd.c with sd.asm
Maximimise performance by:
a) Using spi_read() and spi_write() where possible.
b) Create static buffers for SD command sequences that are fixed
c) Make the byte swapping of the sector address as efficient as
possible
d) Avoid martialing parameters off and on the stack by using non-C
calling conventions and referencing the parameters on the
calling function's stack
Uses timer functions and macros instead of counted loops. This also
makes the code to do things until a timeout occurs simpler and
quicker. We also use compile-time convertion of milliseconds to
number of timer counts to avoid unnecessary arithmetic.
Whilst testing, I had been exporting some of the functions that are part of the internal interface, remove those exports now.
Owner
|
Okay, makes sense. The original goal of MOS was to demonstrate how to write a simple OS layer, and C seemed like the best way to do that. Think that goalpost has moved somewhat now. Will merge later. |
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.
This is work done by @leighbb - I've just made sure it can merge with and run with the latest MOS codebase.
In testing this provides significant performance improvements for SD card access, allowing reads to happen up to twice as fast as they had with the previous C-based code.
SD card access speed had become a bottleneck, which gets hilit by tools that do things like upload bitmaps to the VDP, which this addresses.