diff --git a/Cargo.lock b/Cargo.lock index 7daff32f29..7533abdfd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,7 +209,7 @@ dependencies = [ "bindgen", "flatten_objects", "lazy_static", - "spin 0.9.8", + "spin", "static_assertions", ] @@ -217,6 +217,10 @@ dependencies = [ name = "arm_gic" version = "0.1.0" dependencies = [ + "cfg-if", + "lazy_static", + "log", + "spin", "tock-registers", ] @@ -341,7 +345,7 @@ version = "0.1.0" dependencies = [ "axfs_vfs", "log", - "spin 0.9.8", + "spin", ] [[package]] @@ -350,7 +354,7 @@ version = "0.1.0" dependencies = [ "axfs_vfs", "log", - "spin 0.9.8", + "spin", ] [[package]] @@ -441,7 +445,7 @@ dependencies = [ "lazy_init", "log", "smoltcp", - "spin 0.9.8", + "spin", ] [[package]] @@ -880,7 +884,7 @@ dependencies = [ "driver_common", "ixgbe-driver", "log", - "spin 0.9.8", + "spin", ] [[package]] @@ -1029,7 +1033,7 @@ dependencies = [ "atomic-polyfill", "hash32", "rustc_version", - "spin 0.9.8", + "spin", "stable_deref_trait", ] @@ -1133,11 +1137,11 @@ version = "0.1.0" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin", ] [[package]] @@ -1273,7 +1277,7 @@ dependencies = [ "cfg-if", "kernel_guard", "percpu_macros", - "spin 0.9.8", + "spin", "x86", ] @@ -1623,12 +1627,6 @@ dependencies = [ "managed", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" diff --git a/crates/arm_gic/Cargo.toml b/crates/arm_gic/Cargo.toml index c1ba48bcac..59348e3009 100644 --- a/crates/arm_gic/Cargo.toml +++ b/crates/arm_gic/Cargo.toml @@ -2,7 +2,7 @@ name = "arm_gic" version = "0.1.0" edition = "2021" -authors = ["Yuekai Jia "] +authors = ["Yuekai Jia ", "Luoyuan Xiao "] description = "ARM Generic Interrupt Controller (GIC) register definitions and basic operations" license = "GPL-3.0-or-later OR Apache-2.0" homepage = "https://github.com/rcore-os/arceos" @@ -17,4 +17,4 @@ cfg-if = "1.0" log = "0.4" [features] -hyper = [] +hyper = [] \ No newline at end of file diff --git a/crates/arm_gic/src/gic_v3.rs b/crates/arm_gic/src/gic_v3.rs index 720cd05591..674133d044 100644 --- a/crates/arm_gic/src/gic_v3.rs +++ b/crates/arm_gic/src/gic_v3.rs @@ -1129,18 +1129,19 @@ impl GicState { } }} // cfg_if! -// ? Todo -#[linkage = "weak"] -#[export_name = "PLATFORM_GICD_BASE"] -pub static PLATFORM_GICD_BASE: usize = 0xffff000008000000; +extern "C" { +#[link_name = "PLATFORM_GICD_BASE"] +pub static GICD_BASE: usize; -#[linkage = "weak"] -#[export_name = "PLATFORM_GICR_BASE"] -pub static PLATFORM_GICR_BASE: usize = 0xffff0000080a0000; +#[link_name = "PLATFORM_GICR_BASE"] +pub static GICR_BASE: usize; +} +lazy_static::lazy_static! { // SAFETY: GICD & GICR are GICv3 mmio device regions -pub static GICD: DeviceRef = DeviceRef::new(PLATFORM_GICD_BASE as *const GicDistributor); -pub static GICR: DeviceRef = DeviceRef::new(PLATFORM_GICR_BASE as *const GicRedistributor); +pub static ref GICD: DeviceRef<'static, GicDistributor> = DeviceRef::new(unsafe{ GICD_BASE as *const GicDistributor }); +pub static ref GICR: DeviceRef<'static, GicRedistributor> = DeviceRef::new(unsafe { GICR_BASE as *const GicRedistributor }); +} pub static GICC: GicCpuInterface = GicCpuInterface; #[cfg(feature = "hyper")] @@ -1157,8 +1158,8 @@ impl DeviceRef<'_, T> { /// # Safety /// - `ptr` must be aligned, non-null, and dereferencable as `T`. /// - `*ptr` must be valid for the program duration. - pub const fn new<'a>(ptr: *const T) -> DeviceRef<'a, T> { - //info!("DeviceRef new @ {:#x}", ptr as usize); + pub fn new<'a>(ptr: *const T) -> DeviceRef<'a, T> { + info!("DeviceRef new @ {:#x}", ptr as usize); // SAFETY: `ptr` is non-null as promised by the caller. DeviceRef { @@ -1209,8 +1210,7 @@ pub fn gic_max_spi() -> usize { } pub fn gic_glb_init() { - // Initialize gic glb - info!("Init gic v3, GICD@{:#x}, GICR@{:#x}", PLATFORM_GICD_BASE, PLATFORM_GICR_BASE); + info!("gic_glb_init gic v3, GICD@{:#x}, GICR@{:#x}", unsafe{ GICD_BASE }, unsafe{ GICR_BASE }); #[cfg(feature = "hyper")] set_gic_lrs(gich_lrs_num()); diff --git a/modules/axhal/src/platform/aarch64_common/gic.rs b/modules/axhal/src/platform/aarch64_common/gic.rs index efe459fb36..8c712649a8 100644 --- a/modules/axhal/src/platform/aarch64_common/gic.rs +++ b/modules/axhal/src/platform/aarch64_common/gic.rs @@ -27,10 +27,10 @@ use arm_gic::gic_v3::{GICD, gicc_get_current_irq, gicc_clear_current_irq, gic_gl #[cfg(feature = "gicv3")] #[export_name = "PLATFORM_GICD_BASE"] -pub static PLATFORM_GICD_BASE: usize = axconfig::PHYS_VIRT_OFFSET + axconfig::GICD_PADDR; +pub static GICD_BASE: usize = axconfig::PHYS_VIRT_OFFSET + axconfig::GICD_PADDR; #[cfg(feature = "gicv3")] #[export_name = "PLATFORM_GICR_BASE"] -pub static PLATFORM_GICR_BASE: usize = axconfig::PHYS_VIRT_OFFSET + axconfig::GICR_PADDR; +pub static GICR_BASE: usize = axconfig::PHYS_VIRT_OFFSET + axconfig::GICR_PADDR; /// Enables or disables the given IRQ. pub fn set_enable(irq_num: usize, enabled: bool) {