mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-16 04:29:08 +00:00
fixup! WIP - extend trezorhal translations interface
This commit is contained in:
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…
Reference in New Issue
Block a user