Tweak identifiers and comments

This commit is contained in:
Dániel Buga
2023-08-12 22:42:50 +02:00
parent d5e66f6f87
commit 6ab0d71d92
6 changed files with 50 additions and 47 deletions

View File

@ -11,27 +11,22 @@ mod thread {
use crate::thread::ThreadContext;
#[export_name = "__thread_mode_pender"]
fn __thread_mode_pender(_core_id: OpaqueThreadContext) {
fn __thread_mode_pender(_context: OpaqueThreadContext) {
unsafe { core::arch::asm!("sev") }
}
/// TODO
// Name pending
#[derive(Default)] // Default enables Executor::new
pub struct CortexMThreadContext;
pub struct Context;
impl ThreadContext for CortexMThreadContext {
impl ThreadContext for Context {
#[cfg(feature = "thread-context")]
fn context(&self) -> OpaqueThreadContext {
// Enabling thread-context is not incorrect, just wasteful.
OpaqueThreadContext(0)
}
#[cfg(not(feature = "thread-context"))]
fn context(&self) -> OpaqueThreadContext {
OpaqueThreadContext(())
}
fn wait(&mut self) {
unsafe { core::arch::asm!("wfe") }
}
@ -39,7 +34,7 @@ mod thread {
/// TODO
// Type alias for backwards compatibility
pub type Executor = crate::thread::ThreadModeExecutor<CortexMThreadContext>;
pub type Executor = crate::thread::ThreadModeExecutor<Context>;
}
// None of this has to be public, I guess?

View File

@ -17,27 +17,22 @@ mod thread {
static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false);
#[export_name = "__thread_mode_pender"]
fn __thread_mode_pender(_core_id: OpaqueThreadContext) {
fn __thread_mode_pender(_context: OpaqueThreadContext) {
SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst);
}
/// TODO
// Name pending
#[derive(Default)] // Default enables Executor::new
pub struct RiscVThreadContext;
pub struct Context;
impl ThreadContext for RiscVThreadContext {
impl ThreadContext for Context {
#[cfg(feature = "thread-context")]
fn context(&self) -> OpaqueThreadContext {
// Enabling thread-context is not incorrect, just wasteful.
OpaqueThreadContext(0)
}
#[cfg(not(feature = "thread-context"))]
fn context(&self) -> OpaqueThreadContext {
OpaqueThreadContext(())
}
fn wait(&mut self) {
// We do not care about race conditions between the load and store operations,
// interrupts will only set this value to true.
@ -60,5 +55,5 @@ mod thread {
/// TODO
// Type alias for backwards compatibility
pub type Executor = crate::thread::ThreadModeExecutor<RiscVThreadContext>;
pub type Executor = crate::thread::ThreadModeExecutor<Context>;
}

View File

@ -18,11 +18,11 @@ mod thread {
/// TODO
// Name pending
pub struct StdThreadCtx {
pub struct Context {
signaler: &'static Signaler,
}
impl Default for StdThreadCtx {
impl Default for Context {
fn default() -> Self {
Self {
signaler: &*Box::leak(Box::new(Signaler::new())),
@ -30,7 +30,7 @@ mod thread {
}
}
impl ThreadContext for StdThreadCtx {
impl ThreadContext for Context {
fn context(&self) -> OpaqueThreadContext {
OpaqueThreadContext(self.signaler as *const _ as usize)
}
@ -41,8 +41,8 @@ mod thread {
}
#[export_name = "__thread_mode_pender"]
fn __thread_mode_pender(core_id: OpaqueThreadContext) {
let signaler: &'static Signaler = unsafe { std::mem::transmute(core_id) };
fn __thread_mode_pender(context: OpaqueThreadContext) {
let signaler: &'static Signaler = unsafe { std::mem::transmute(context) };
signaler.signal()
}
@ -76,5 +76,5 @@ mod thread {
/// TODO
// Type alias for backwards compatibility
pub type Executor = crate::thread::ThreadModeExecutor<StdThreadCtx>;
pub type Executor = crate::thread::ThreadModeExecutor<Context>;
}

View File

@ -15,27 +15,22 @@ mod thread {
static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false);
#[export_name = "__thread_mode_pender"]
fn __thread_mode_pender(_core_id: OpaqueThreadContext) {
fn __thread_mode_pender(_context: OpaqueThreadContext) {
SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst);
}
/// TODO
// Name pending
#[derive(Default)] // Default enables Executor::new
pub struct XtensaThreadContext;
pub struct Context;
impl ThreadContext for XtensaThreadContext {
impl ThreadContext for Context {
#[cfg(feature = "thread-context")]
fn context(&self) -> OpaqueThreadContext {
// Enabling thread-context is not incorrect, just wasteful.
OpaqueThreadContext(0)
}
#[cfg(not(feature = "thread-context"))]
fn context(&self) -> OpaqueThreadContext {
OpaqueThreadContext(())
}
fn wait(&mut self) {
unsafe {
// Manual critical section implementation that only masks interrupts handlers.
@ -66,5 +61,5 @@ mod thread {
/// TODO
// Type alias for backwards compatibility
pub type Executor = crate::thread::ThreadModeExecutor<XtensaThreadContext>;
pub type Executor = crate::thread::ThreadModeExecutor<Context>;
}