fixup! WIP - extend trezorhal translations interface

pull/3491/head
matejcik 5 months ago
parent 30aae199fa
commit 959d2f235c

@ -1,8 +1,8 @@
use super::ffi;
// SAFETY: Returned slice is valid and immutable until a call to `erase()` and/or `set_blob()`.
// Caller is responsible for disposing of all references to the slice before touching
// the flash contents.
// SAFETY: Returned slice is valid and immutable until a call to `erase()`
// and/or `set_blob()`. Caller is responsible for disposing of all references to
// the slice before touching the flash contents.
pub unsafe fn get_blob<'a>() -> &'a [u8] {
let mut len: u32 = 0;
let ptr = unsafe { ffi::translations_read(&mut len, 0) };
@ -13,7 +13,8 @@ pub unsafe fn get_blob<'a>() -> &'a [u8] {
unsafe { core::slice::from_raw_parts(ptr, len as usize) }
}
// SAFETY: This call invalidates the reference to the blob returned by `get_blob()`.
// SAFETY: This call invalidates the reference to the blob returned by
// `get_blob()`.
pub unsafe fn erase() {
unsafe { ffi::translations_erase() };
}
@ -23,7 +24,8 @@ pub fn area_bytesize() -> usize {
unsafe { ffi::translations_area_bytesize() as usize }
}
// SAFETY: This call may invalidate the reference to the blob returned by `get_blob()`.
// SAFETY: This call may invalidate the reference to the blob returned by
// `get_blob()`.
pub unsafe fn write(data: &[u8], offset: usize) {
unsafe { ffi::translations_write(data.as_ptr(), offset as u32, data.len() as u32) };
}

Loading…
Cancel
Save