Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. kernel
  6. ThreadState

ThreadState

Trait ThreadState 

Source
pub trait ThreadState: 'static + Sized {
    type MemoryConfig: MemoryConfig;

    const NEW: Self;

    // Required methods
    unsafe fn initialize_kernel_state(
        &mut self,
        kernel_stack: Stack,
        memory_config: *const Self::MemoryConfig,
        initial_function: extern "C" fn(usize, usize, usize),
        args: (usize, usize, usize),
    );
    unsafe fn initialize_user_state(
        &mut self,
        kernel_stack: Stack,
        memory_config: *const Self::MemoryConfig,
        initial_sp: usize,
        initial_pc: usize,
        args: (usize, usize, usize),
    ) -> Result<()>;
}

Required Associated Constants§

Source

const NEW: Self

Required Associated Types§

Source

type MemoryConfig: MemoryConfig

Required Methods§

Source

unsafe fn initialize_kernel_state( &mut self, kernel_stack: Stack, memory_config: *const Self::MemoryConfig, initial_function: extern "C" fn(usize, usize, usize), args: (usize, usize, usize), )

Initialize the default frame of a kernel thread

Arranges for the thread to start at initial_function with arguments passed in the first two argument slots. The stack pointer of the thread is set to the top of the kernel stack.

§Safety

Caller guarantees that the memory_config pointer remains valid for the lifetime of the thread.

§Implementation Note

The implementation is responsible for ensuring that initial_function is called with interrupts enabled and without the scheduler lock held. This call must initialize the ThreadLocalState returned by thread_local_state().

Source

unsafe fn initialize_user_state( &mut self, kernel_stack: Stack, memory_config: *const Self::MemoryConfig, initial_sp: usize, initial_pc: usize, args: (usize, usize, usize), ) -> Result<()>

Initialize the default frame of a user thread

Arranges for the thread to start at initial_function with arguments passed in the first two argument slots

§Safety

Caller guarantees that the memory_config pointer remains valid for the lifetime of the thread.

§Implementation Note

The implementation is responsible for ensuring that initial_function is called with interrupts enabled, memory_config enabled, non-privileged mode, and without the scheduler lock held. This call must initialize the ThreadLocalState returned by thread_local_state().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§