[][src]Struct sunrise_kernel::i386::stack::KernelStack

pub struct KernelStack {
    stack_address: VirtualAddress,
}

A structure representing a kernel stack.

Fields

stack_address: VirtualAddress

The aligned address at the beginning of the stack.

It falls in the page guard.

Implementations

impl KernelStack[src]

pub fn allocate_stack() -> Result<KernelStack, KernelError>[src]

Allocates the kernel stack of a process.

fn align_to_stack_bottom(esp: usize) -> usize[src]

Aligns down a pointer to what would be the beginning of the stack, by anding with STACK_ALIGNMENT.

This is the value usually stored in KernelStack.stack_address.

Result falls in the page guard.

extern "C" fn get_current_stack_bottom() -> usize[src]

Gets the bottom of the stack by anding $esp with STACK_ALIGNMENT.

This is the value usually stored in KernelStack.stack_address.

Result falls in the page guard.

pub unsafe fn get_current_stack() -> KernelStack[src]

Retrieves the current stack from $esp.

Should be used only to retrieve the KernelStack that was given to us by the bootstrap.

Safety

Unsafe because it creates duplicates of the stack structure, whose only owner should be the ProcessStruct it belongs to. This enables having several mut references pointing to the same underlying memory. Caller has to make sure no references to the stack exists when calling this function.

The safe method of getting the stack is by getting current ProcessStruct, lock it, and use its pstack.

const STACK_POISON_SIZE: usize[src]

We keep 2 poison pointers for fake saved ebp and saved eip at the base of the stack.

unsafe fn create_poison_pointers(&mut self)[src]

Puts two poisons pointers at the base of the stack for the saved ebp and saved eip.

pub fn get_stack_start(&self) -> usize[src]

Get the address of the beginning of usable stack.

Used for initializing $esp and $ebp of a newborn process.

Points to the last poison pointer, for saved $ebp.

pub fn dump_current_stack<'a>(
    elf_symbols: Option<(&ElfFile<'a>, &'a [Entry32])>
)
[src]

Dumps the stack, displaying it in a frame-by-frame format.

It can accepts an elf symbols which will be used to enhance the stack dump.

Trait Implementations

impl Debug for KernelStack[src]

impl Drop for KernelStack[src]

fn drop(&mut self)[src]

We deallocate the stack when it is dropped

Auto Trait Implementations

impl RefUnwindSafe for KernelStack

impl Send for KernelStack

impl Sync for KernelStack

impl Unpin for KernelStack

impl UnwindSafe for KernelStack

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.