Skip to content

Commit

Permalink
load_itcm: use zst
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Dec 13, 2024
1 parent a914757 commit 4d2e66f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/hardware/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ static mut DES_RING: MaybeUninit<
/// this method is undefined.
fn load_itcm() {
extern "C" {
static mut __sitcm: u32;
static mut __eitcm: u32;
static mut __siitcm: u32;
// ZST (`()`: not layout-stable. empty/zst struct in `repr(C)``: not "proper" C)
static mut __sitcm: [u32; 0];
static mut __eitcm: [u32; 0];
static mut __siitcm: [u32; 0];
}
// NOTE(unsafe): Assuming the address symbols from the linker as well as
// the source instruction data are all valid, this is safe as it only
Expand All @@ -170,9 +171,9 @@ fn load_itcm() {
// Ensure ITCM is enabled before loading.
atomic::fence(Ordering::SeqCst);

let sitcm = core::ptr::addr_of_mut!(__sitcm);
let eitcm = core::ptr::addr_of_mut!(__eitcm);
let siitcm = core::ptr::addr_of_mut!(__siitcm);
let sitcm = core::ptr::addr_of_mut!(__sitcm) as *mut u32;
let eitcm = core::ptr::addr_of!(__eitcm) as *const u32;
let siitcm = core::ptr::addr_of!(__siitcm) as *const u32;

let len = eitcm.offset_from(sitcm) as usize;
let dst = slice::from_raw_parts_mut(sitcm, len);
Expand Down

0 comments on commit 4d2e66f

Please sign in to comment.