From 62c6da3ac5aa6854de24fa315f63cf157727073a Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Tue, 19 Nov 2024 16:27:32 +0800 Subject: [PATCH] replace explicit cast with addr_of/addr_of_mut --- experiments/src/main.rs | 2 +- libsupport_zynq/src/boot.rs | 4 ++-- szl/src/main.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/experiments/src/main.rs b/experiments/src/main.rs index 96583f6..535ecc1 100644 --- a/experiments/src/main.rs +++ b/experiments/src/main.rs @@ -71,7 +71,7 @@ interrupt_handler!(IRQ, irq, __irq_stack0_start, __irq_stack1_start, { if id.0 == 0 { gic.end_interrupt(id); asm::exit_irq(); - SP.write(&mut __stack1_start as *mut _ as u32); + SP.write(addr_of_mut!(__stack1_start) as u32); asm::enable_irq(); CORE1_RESTART.store(false, Ordering::Relaxed); notify_spin_lock(); diff --git a/libsupport_zynq/src/boot.rs b/libsupport_zynq/src/boot.rs index 79b35f7..66bc70a 100644 --- a/libsupport_zynq/src/boot.rs +++ b/libsupport_zynq/src/boot.rs @@ -1,5 +1,5 @@ use r0::zero_bss; -use core::ptr::write_volatile; +use core::ptr::{addr_of_mut, write_volatile}; use core::arch::asm; use libregister::{ VolatileCell, @@ -43,7 +43,7 @@ unsafe extern "C" fn boot_core0() -> ! { let mpcore = mpcore::RegisterBlock::mpcore(); mpcore.scu_invalidate.invalidate_all_cores(); - zero_bss(&mut __bss_start, &mut __bss_end); + zero_bss(addr_of_mut!(__bss_start), addr_of_mut!(__bss_end)); let mmu_table = mmu::L1Table::get() .setup_flat_layout(); diff --git a/szl/src/main.rs b/szl/src/main.rs index fc91b7e..096e0e7 100644 --- a/szl/src/main.rs +++ b/szl/src/main.rs @@ -7,7 +7,7 @@ extern crate log; mod netboot; use alloc::rc::Rc; -use core::mem; +use core::{mem, ptr::{addr_of, addr_of_mut}}; use core_io::{Read, Seek}; use libboard_zynq::{ self as zynq, @@ -116,18 +116,18 @@ pub fn main_core0() { unsafe { let max_len = - &__runtime_end as *const usize as usize - &__runtime_start as *const usize as usize; + addr_of!(__runtime_end) as usize - addr_of!(__runtime_start) as usize; match slcr::RegisterBlock::unlocked(|slcr| slcr.boot_mode.read().boot_mode_pins()) { slcr::BootModePins::Jtag => netboot::netboot( &mut bootgen_file, config, - &mut __runtime_start as *mut usize as *mut u8, + addr_of_mut!(__runtime_start).cast(), max_len, ), slcr::BootModePins::SdCard => { if boot_sd( &mut bootgen_file, - &mut __runtime_start as *mut usize as *mut u8, + addr_of_mut!(__runtime_start).cast(), max_len, ) .is_err() @@ -137,7 +137,7 @@ pub fn main_core0() { netboot::netboot( &mut bootgen_file, config, - &mut __runtime_start as *mut usize as *mut u8, + addr_of_mut!(__runtime_start).cast(), max_len, ) } @@ -148,7 +148,7 @@ pub fn main_core0() { netboot::netboot( &mut bootgen_file, config, - &mut __runtime_start as *mut usize as *mut u8, + addr_of_mut!(__runtime_start).cast(), max_len, ) }