From 49083081c3e8725666b16b0c8a76b454fd4fca37 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 6 Aug 2020 23:25:28 +0800 Subject: [PATCH] xous: replace `processes-as-threads` with baremetal check This gets it working on baremetal, and keeps processes-as-threads available for running in hosted mode. Signed-off-by: Sean Cross --- kernel/Cargo.toml | 2 +- xous-rs/Cargo.toml | 4 ---- xous-rs/src/arch/hosted.rs | 12 ++++++------ xous-rs/src/lib.rs | 2 +- xous-rs/src/syscall.rs | 6 +++--- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 7ceeec5c7..76a4827a5 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -7,7 +7,7 @@ description = "Core kernel for Xous, including task switching and memory managem [dependencies] bitflags = "1.2.1" -xous = { path = "../xous-rs", features = ["forget-memory-messages", "processes-as-threads"] } +xous = { path = "../xous-rs", features = ["forget-memory-messages"] } stats_alloc = { version = "0.1.8", optional = true } sha3 = { default-features = false, version = "0.8.2" } diff --git a/xous-rs/Cargo.toml b/xous-rs/Cargo.toml index 893fe1fad..79e9ff1a2 100644 --- a/xous-rs/Cargo.toml +++ b/xous-rs/Cargo.toml @@ -13,10 +13,6 @@ bitflags = "1.2.1" # will not be implemented. This should only be set by the kernel. forget-memory-messages = [] -# If this is set, create_process() will instead create a thread in -# the current process. This is used by the test suite. -processes-as-threads = [] - default = [] [target.'cfg(any(windows,unix))'.dependencies] diff --git a/xous-rs/src/arch/hosted.rs b/xous-rs/src/arch/hosted.rs index 08d96d786..313e1ea98 100644 --- a/xous-rs/src/arch/hosted.rs +++ b/xous-rs/src/arch/hosted.rs @@ -28,13 +28,13 @@ pub struct ProcessInit { pub key: ProcessKey, } -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub struct ProcessArgsAsThread { main: F, name: String, } -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] impl ProcessArgsAsThread where F: FnOnce(), @@ -46,12 +46,12 @@ where } } } -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub struct ProcessHandleAsThread(std::thread::JoinHandle<()>); /// If no connection exists, create a new connection to the server. This means /// our parent PID will be PID1. Otherwise, reuse the same connection. -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub fn create_process_pre_as_thread( _args: &ProcessArgsAsThread, ) -> core::result::Result @@ -70,7 +70,7 @@ where }) } -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub fn create_process_post_as_thread( args: ProcessArgsAsThread, init: ProcessInit, @@ -109,7 +109,7 @@ where Ok(ProcessHandleAsThread(thread_main.0)) } -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub fn wait_process_as_thread(joiner: ProcessHandleAsThread) -> crate::SysCallResult { joiner.0.join().map(|_| Result::Ok).map_err(|_x| { // panic!("wait error: {:?}", x); diff --git a/xous-rs/src/lib.rs b/xous-rs/src/lib.rs index fdc176e72..9268dd9a4 100644 --- a/xous-rs/src/lib.rs +++ b/xous-rs/src/lib.rs @@ -15,7 +15,7 @@ pub use definitions::*; pub use messages::*; pub use syscall::*; -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub use arch::ProcessArgsAsThread; /// Convert a four-letter string into a 32-bit int. diff --git a/xous-rs/src/syscall.rs b/xous-rs/src/syscall.rs index 0efa5d5ab..25112f1f7 100644 --- a/xous-rs/src/syscall.rs +++ b/xous-rs/src/syscall.rs @@ -6,7 +6,7 @@ use crate::{ // use num_derive::FromPrimitive; // use num_traits::FromPrimitive; -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] use crate::ProcessArgsAsThread; #[derive(Debug, PartialEq)] @@ -890,7 +890,7 @@ pub fn wait_thread(joiner: crate::arch::WaitHandle) -> SysCallResult { } /// Create a new process by running it in its own thread -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub fn create_process_as_thread( args: ProcessArgsAsThread, ) -> core::result::Result @@ -908,7 +908,7 @@ where } /// Wait for a thread to finish -#[cfg(feature = "processes-as-threads")] +#[cfg(not(baremetal))] pub fn wait_process_as_thread(joiner: crate::arch::ProcessHandleAsThread) -> SysCallResult { crate::arch::wait_process_as_thread(joiner) }