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: VirtualAddress
    ) -> (VirtualAddress, VirtualAddress); unsafe fn context_switch(
        current_kernel_stack: *mut VirtualAddress,
        new_kernel_stack: VirtualAddress
    ); unsafe fn drop_into_userspace() -> !; }

Required Associated Types

Required Methods

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.

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).

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.

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