Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ ordered-toml = { git = "https://github.com/oxidecomputer/ordered-toml", default-
pmbus = { git = "https://github.com/oxidecomputer/pmbus", default-features = false }
salty = { version = "0.3", default-features = false }
spd = { git = "https://github.com/oxidecomputer/spd", default-features = false }
tlvc = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.3.1" }
tlvc = { git = "https://github.com/oxidecomputer/tlvc", rev = "refs/pull/9/head", default-features = false, version = "0.3.1" }
tlvc-text = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.3.0" }
transceiver-messages = { git = "https://github.com/oxidecomputer/transceiver-control/", default-features = false }
vsc7448-pac = { git = "https://github.com/oxidecomputer/vsc7448", default-features = false }
Expand Down
21 changes: 11 additions & 10 deletions drv/auxflash-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,19 @@ where
let mut inner_reader = outer_chunk.read_as_chunks();
while let Ok(Some(inner_chunk)) = inner_reader.next() {
if inner_chunk.header().tag == tag {
// At this point, the inner reader is positioned *after*
// our target chunk. We back off by the full length of
// the chunk (including the header), then offset by the
// header size to get to the beginning of the blob data.
let (_, inner_offset, _) = inner_reader.into_inner();
let pos = inner_offset
- inner_chunk.header().total_len_in_bytes() as u64
+ core::mem::size_of::<tlvc::ChunkHeader>() as u64;
let pos = u32::try_from(inner_chunk.body_position())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I was looking at the original code here and became convinced that this just wants the body_position from inner_chunk. There's still a chance I'm wrong, I didn't drag a comb through the code to really, truly convince myself of it but definitely the inner_offset is the position of the next chunk, and offsetting that by the total size - header size should give us the previous chunk's body position.

It seems prudent to just add an API to expose that location to tlvc; I have added that API to the PR that I have open in tlvc.

.map_err(|_| {
AuxFlashError::TlvcReaderBeginFailed
})?;
return Ok(AuxFlashBlob {
slot,
start: pos as u32,
end: (pos + inner_chunk.len()) as u32,
start: pos,
// SAFETY: chunk length is encoded in a U32 so len
// is always a valid u32, and the body_position +
// body_length are checked to be valid.
end: unsafe {
pos.unchecked_add(inner_chunk.len() as u32)
},
});
}
}
Expand Down
Loading
Loading