From 4d2e66feca27bd41bca1e4764d767bbe791a68a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 4 Dec 2024 17:23:53 +0000 Subject: [PATCH] load_itcm: use zst --- src/hardware/setup.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hardware/setup.rs b/src/hardware/setup.rs index 6fa89c235..60047ae82 100644 --- a/src/hardware/setup.rs +++ b/src/hardware/setup.rs @@ -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 @@ -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);