From d990a4d3b27f349939a06f1a03035cc720909338 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 20 Jan 2024 17:45:36 +0800 Subject: [PATCH] xous is now a Rust target, so we have to specify baremetal explicitly --- libs/xous-pio/Cargo.toml | 2 ++ libs/xous-pio/src/lib.rs | 16 ++++++++-------- libs/xous-pl230/Cargo.toml | 1 + libs/xous-pl230/src/lib.rs | 8 ++++---- libs/xous-pl230/src/pl230_tests/mod.rs | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libs/xous-pio/Cargo.toml b/libs/xous-pio/Cargo.toml index b9dcfd888..f584be371 100644 --- a/libs/xous-pio/Cargo.toml +++ b/libs/xous-pio/Cargo.toml @@ -22,6 +22,8 @@ rp2040 = ["defmt"] precursor = [] hosted = [] renode = [] +# may be activated in conjunction with "cramium-soc", "rp2040" targets when not running Xous +baremetal = [] tests = [] default = ["tests", "cramium-soc"] diff --git a/libs/xous-pio/src/lib.rs b/libs/xous-pio/src/lib.rs index 48477fb7d..471204b42 100644 --- a/libs/xous-pio/src/lib.rs +++ b/libs/xous-pio/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_std)] +#![cfg_attr(feature = "baremetal", no_std)] use pio::Program; use pio::RP2040_MAX_PROGRAM_SIZE; @@ -134,7 +134,7 @@ pub struct PioSharedState { used_machines: [bool; 4], } impl PioSharedState { - #[cfg(all(not(target_os = "xous"), not(feature = "rp2040")))] + #[cfg(all(feature = "baremetal", not(feature = "rp2040")))] pub fn new() -> Self { PioSharedState { pio: CSR::new(rp_pio::HW_RP_PIO_BASE as *mut u32), @@ -143,13 +143,13 @@ impl PioSharedState { } } - #[cfg(all(not(target_os = "xous"), feature = "rp2040"))] + #[cfg(all(feature = "baremetal", feature = "rp2040"))] pub fn new() -> Self { crate::pio_tests::report_api(0x5020_0000); PioSharedState { pio: CSR::new(0x5020_0000 as *mut u32), used_mask: 0, used_machines: [false; 4] } } - #[cfg(target_os = "xous")] + #[cfg(not(feature = "baremetal"))] pub fn new() -> Self { // Note: this requires a memory region window to be manually specified in create-image // so that the loader maps the pages for the PIO block. This is because the PIO block is @@ -210,7 +210,7 @@ impl PioSharedState { }; self.used_machines[sm] = true; - #[cfg(target_os = "xous")] + #[cfg(not(feature = "baremetal"))] let csr = xous::syscall::map_memory( xous::MemoryAddress::new(rp_pio::HW_RP_PIO_BASE), None, @@ -218,11 +218,11 @@ impl PioSharedState { xous::MemoryFlags::R | xous::MemoryFlags::W, ) .unwrap(); - #[cfg(target_os = "xous")] + #[cfg(not(feature = "baremetal"))] let pio = CSR::new(csr.as_mut_ptr() as *mut u32); - #[cfg(all(not(target_os = "xous"), not(feature = "rp2040")))] + #[cfg(all(feature = "baremetal", not(feature = "rp2040")))] let pio = CSR::new(rp_pio::HW_RP_PIO_BASE as *mut u32); - #[cfg(all(not(target_os = "xous"), feature = "rp2040"))] + #[cfg(all(feature = "baremetal", feature = "rp2040"))] let pio = CSR::new(0x5020_0000 as *mut u32); Ok(PioSm { pio, sm: sm_bit, config: SmConfig::default() }) diff --git a/libs/xous-pl230/Cargo.toml b/libs/xous-pl230/Cargo.toml index b7043d280..0306e720b 100644 --- a/libs/xous-pl230/Cargo.toml +++ b/libs/xous-pl230/Cargo.toml @@ -24,6 +24,7 @@ hosted = [] renode = [] pio = ["xous-pio"] dma-mainram = [] +baremetal = [] tests = ["pio"] default = ["tests", "pio"] diff --git a/libs/xous-pl230/src/lib.rs b/libs/xous-pl230/src/lib.rs index 1d6648079..5f5d8bbe3 100644 --- a/libs/xous-pl230/src/lib.rs +++ b/libs/xous-pl230/src/lib.rs @@ -1,6 +1,6 @@ -#![cfg_attr(target_os = "none", no_std)] +#![cfg_attr(feature = "baremetal", no_std)] -#[cfg(not(any(target_os = "xous")))] +#[cfg(feature = "baremetal")] mod debug; #[cfg(feature = "tests")] @@ -30,7 +30,7 @@ pub struct Pl230 { } impl Pl230 { - #[cfg(not(any(target_os = "xous")))] + #[cfg(feature = "baremetal")] pub fn new() -> Self { Pl230 { csr: CSR::new(utralib::HW_PL230_BASE as *mut u32), @@ -38,7 +38,7 @@ impl Pl230 { } } - #[cfg(target_os = "xous")] + #[cfg(not(feature = "baremetal"))] pub fn new() -> Self { let csr = xous::syscall::map_memory( xous::MemoryAddress::new(utralib::HW_PL230_BASE), diff --git a/libs/xous-pl230/src/pl230_tests/mod.rs b/libs/xous-pl230/src/pl230_tests/mod.rs index 7b834b43e..47e6dfe0e 100644 --- a/libs/xous-pl230/src/pl230_tests/mod.rs +++ b/libs/xous-pl230/src/pl230_tests/mod.rs @@ -1,13 +1,13 @@ pub mod units; pub fn report_api(desc: &str, d: u32) { - #[cfg(not(any(target_os = "xous")))] + #[cfg(feature = "baremetal")] { use core::fmt::Write; let mut uart = crate::debug::Uart {}; writeln!(uart, "pl230: [{}] 0x{:x}", desc, d).ok(); } - #[cfg(target_os = "xous")] + #[cfg(not(feature = "baremetal"))] log::info!("pl230: [{}] 0x{:x}", desc, d); }