mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
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 <sean@xobs.io>
This commit is contained in:
parent
bd99f33761
commit
49083081c3
5 changed files with 11 additions and 15 deletions
|
|
@ -7,7 +7,7 @@ description = "Core kernel for Xous, including task switching and memory managem
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2.1"
|
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 }
|
stats_alloc = { version = "0.1.8", optional = true }
|
||||||
sha3 = { default-features = false, version = "0.8.2" }
|
sha3 = { default-features = false, version = "0.8.2" }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@ bitflags = "1.2.1"
|
||||||
# will not be implemented. This should only be set by the kernel.
|
# will not be implemented. This should only be set by the kernel.
|
||||||
forget-memory-messages = []
|
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 = []
|
default = []
|
||||||
|
|
||||||
[target.'cfg(any(windows,unix))'.dependencies]
|
[target.'cfg(any(windows,unix))'.dependencies]
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,13 @@ pub struct ProcessInit {
|
||||||
pub key: ProcessKey,
|
pub key: ProcessKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
pub struct ProcessArgsAsThread<F: FnOnce()> {
|
pub struct ProcessArgsAsThread<F: FnOnce()> {
|
||||||
main: F,
|
main: F,
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
impl<F> ProcessArgsAsThread<F>
|
impl<F> ProcessArgsAsThread<F>
|
||||||
where
|
where
|
||||||
F: FnOnce(),
|
F: FnOnce(),
|
||||||
|
|
@ -46,12 +46,12 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
pub struct ProcessHandleAsThread(std::thread::JoinHandle<()>);
|
pub struct ProcessHandleAsThread(std::thread::JoinHandle<()>);
|
||||||
|
|
||||||
/// If no connection exists, create a new connection to the server. This means
|
/// If no connection exists, create a new connection to the server. This means
|
||||||
/// our parent PID will be PID1. Otherwise, reuse the same connection.
|
/// 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<F>(
|
pub fn create_process_pre_as_thread<F>(
|
||||||
_args: &ProcessArgsAsThread<F>,
|
_args: &ProcessArgsAsThread<F>,
|
||||||
) -> core::result::Result<ProcessInit, crate::Error>
|
) -> core::result::Result<ProcessInit, crate::Error>
|
||||||
|
|
@ -70,7 +70,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
pub fn create_process_post_as_thread<F>(
|
pub fn create_process_post_as_thread<F>(
|
||||||
args: ProcessArgsAsThread<F>,
|
args: ProcessArgsAsThread<F>,
|
||||||
init: ProcessInit,
|
init: ProcessInit,
|
||||||
|
|
@ -109,7 +109,7 @@ where
|
||||||
Ok(ProcessHandleAsThread(thread_main.0))
|
Ok(ProcessHandleAsThread(thread_main.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
pub fn wait_process_as_thread(joiner: ProcessHandleAsThread) -> crate::SysCallResult {
|
pub fn wait_process_as_thread(joiner: ProcessHandleAsThread) -> crate::SysCallResult {
|
||||||
joiner.0.join().map(|_| Result::Ok).map_err(|_x| {
|
joiner.0.join().map(|_| Result::Ok).map_err(|_x| {
|
||||||
// panic!("wait error: {:?}", x);
|
// panic!("wait error: {:?}", x);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub use definitions::*;
|
||||||
pub use messages::*;
|
pub use messages::*;
|
||||||
pub use syscall::*;
|
pub use syscall::*;
|
||||||
|
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
pub use arch::ProcessArgsAsThread;
|
pub use arch::ProcessArgsAsThread;
|
||||||
|
|
||||||
/// Convert a four-letter string into a 32-bit int.
|
/// Convert a four-letter string into a 32-bit int.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
// use num_derive::FromPrimitive;
|
// use num_derive::FromPrimitive;
|
||||||
// use num_traits::FromPrimitive;
|
// use num_traits::FromPrimitive;
|
||||||
|
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(not(baremetal))]
|
||||||
use crate::ProcessArgsAsThread;
|
use crate::ProcessArgsAsThread;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
|
@ -890,7 +890,7 @@ pub fn wait_thread<T>(joiner: crate::arch::WaitHandle<T>) -> SysCallResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new process by running it in its own thread
|
/// 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<F>(
|
pub fn create_process_as_thread<F>(
|
||||||
args: ProcessArgsAsThread<F>,
|
args: ProcessArgsAsThread<F>,
|
||||||
) -> core::result::Result<crate::arch::ProcessHandleAsThread, Error>
|
) -> core::result::Result<crate::arch::ProcessHandleAsThread, Error>
|
||||||
|
|
@ -908,7 +908,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for a thread to finish
|
/// 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 {
|
pub fn wait_process_as_thread(joiner: crate::arch::ProcessHandleAsThread) -> SysCallResult {
|
||||||
crate::arch::wait_process_as_thread(joiner)
|
crate::arch::wait_process_as_thread(joiner)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue