-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove lease limit from qspi_read
#1911
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,11 +241,11 @@ impl FlashDriver { | |
|
||
/// Reads data from the given address into a `BufWriter` | ||
/// | ||
/// This function will only return an error if it fails to read from a | ||
/// This function will only return an error if it fails to write to a | ||
/// provided lease; when given a slice, it is infallible. | ||
fn flash_read( | ||
&mut self, | ||
offset: u32, | ||
mut offset: u32, | ||
dest: &mut dyn idol_runtime::BufWriter<'_>, | ||
) -> Result<(), ()> { | ||
loop { | ||
|
@@ -269,6 +269,7 @@ impl FlashDriver { | |
} | ||
} | ||
} | ||
offset += len as u32; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we be doing something to avoid a panic site from the overflow check here? |
||
} | ||
Ok(()) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,14 +505,21 @@ impl idl::InOrderHostFlashImpl for ServerImpl { | |
fn read( | ||
&mut self, | ||
_: &RecvMessage, | ||
addr: u32, | ||
dest: LenLimit<Leased<W, [u8]>, PAGE_SIZE_BYTES>, | ||
mut addr: u32, | ||
dest: Leased<W, [u8]>, | ||
) -> Result<(), RequestError<HfError>> { | ||
self.check_muxed_to_sp()?; | ||
self.qspi.read_memory(addr, &mut self.block[..dest.len()]); | ||
let mut offset = 0; | ||
for i in (0..dest.len()).step_by(self.block.len()) { | ||
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: While looking at my folly, I noticed that it seems like It's a shame that such a useful API drops code off a (probably minor) cliff :( I hope this at least is interesting and potentially useful information to you. |
||
let n = (dest.len() - i).min(self.block.len()); | ||
|
||
dest.write_range(0..dest.len(), &self.block[..dest.len()]) | ||
.map_err(|_| RequestError::Fail(ClientError::WentAway))?; | ||
self.qspi.read_memory(addr, &mut self.block[..n]); | ||
|
||
dest.write_range(offset..offset + n, &self.block[..n]) | ||
.map_err(|_| RequestError::Fail(ClientError::WentAway))?; | ||
addr += n as u32; | ||
offset += n; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops :P