Trait kernel::Platform

source ·
pub trait Platform: Sized + 'static {
    type PageTableSize: FrameSize;
    type PageTable: PageTable<Self::PageTableSize> + Send;
    type PerCpu: PerCpu<Self>;

    fn kernel_page_table(&mut self) -> &mut Self::PageTable;
    fn per_cpu<'a>() -> Pin<&'a mut Self::PerCpu>;
    unsafe fn initialize_task_stacks(
        kernel_stack: &Stack,
        user_stack: &Stack,
        task_entry_point: VAddr
    ) -> (VAddr, VAddr); unsafe fn context_switch(
        current_kernel_stack: *mut VAddr,
        new_kernel_stack: VAddr
    ); unsafe fn drop_into_userspace() -> !; }

Required Associated Types§

Required Methods§

source

fn kernel_page_table(&mut self) -> &mut Self::PageTable

source

fn per_cpu<'a>() -> Pin<&'a mut Self::PerCpu>

Get the per-CPU info for the current CPU. To make this safe, the per-CPU info must be installed before the Platform implementation is created.

source

unsafe fn initialize_task_stacks(
    kernel_stack: &Stack,
    user_stack: &Stack,
    task_entry_point: VAddr
) -> (VAddr, VAddr)

Often, the platform will need to put stuff on either the kernel or the user stack before a task is run for the first time. task_entry_point is the virtual address that should be jumped to in usermode when the task is run for the first time.

The return value is of the form (kernel_stack_pointer, user_stack_pointer).

source

unsafe fn context_switch(
    current_kernel_stack: *mut VAddr,
    new_kernel_stack: VAddr
)

Do the final part of a context switch: save all the state that needs to be to the current kernel stack, switch to a new kernel stack, and restore all the state from that stack.

source

unsafe fn drop_into_userspace() -> !

Do the actual drop into usermode. This assumes that the task’s page tables have already been installed, and that an initial frame has been put into the task’s kernel stack that this will use to enter userspace.

Implementors§