[][src]Struct sunrise_kernel::i386::gdt::GdtManager

pub struct GdtManager {
    table_a: DescriptorTable,
    table_b: DescriptorTable,
    table_selector: bool,
}

Safety wrapper that manages the lifetime of GDT tables.

Although Intel's guide doesn't really say much about it, modifying a GDT "live" is probably a terrible idea. To work around this, the GdtManager keeps two copies of the DescriptorTable, one being the currently active one (loaded in the GDTR), and the other being where the changes to the GDT go to until they are committed.

When commit is called, the internal GDT and current GDTR are swapped.

This struct's implementation of Deref and DerefMut will always give a reference to the table currently not in use, so you can make modifications to it, and call commit afterwards.

Fields

table_a: DescriptorTable

One of the two tables.

table_b: DescriptorTable

One of the two tables.

table_selector: bool

The table currently pointed to by GDTR. 0 is table_a, 1 is table_b.

Implementations

impl GdtManager[src]

pub fn commit(
    &mut self,
    new_cs: Option<SegmentSelector>,
    new_ds: Option<SegmentSelector>,
    new_es: Option<SegmentSelector>,
    new_fs: Option<SegmentSelector>,
    new_gs: Option<SegmentSelector>,
    new_ss: Option<SegmentSelector>
)
[src]

Commit the changes in the currently unloaded table, and update segment registers.

Selectors

To make a segment register point to a new descriptor, pass Some(selector) to this function.

If None is passed, the register will be reloaded from its current value. This is what you want if you only updated the content of the descriptor. We always perform a reload of all registers to make sure they reflect the state of the GDT, in case the user modified it.

Methods from Deref<Target = DescriptorTable>

fn load_global(
    &mut self,
    new_cs: Option<SegmentSelector>,
    new_ds: Option<SegmentSelector>,
    new_es: Option<SegmentSelector>,
    new_fs: Option<SegmentSelector>,
    new_gs: Option<SegmentSelector>,
    new_ss: Option<SegmentSelector>
)
[src]

Load this descriptor table into the GDTR, and reload the segment registers.

Trait Implementations

impl Debug for GdtManager[src]

impl Default for GdtManager[src]

impl Deref for GdtManager[src]

type Target = DescriptorTable

The resulting type after dereferencing.

fn deref(&self) -> &DescriptorTable[src]

Deref always returns a reference to the table not in use, so it can be modified, before being committed.

impl DerefMut for GdtManager[src]

fn deref_mut(&mut self) -> &mut DescriptorTable[src]

DerefMut always returns a reference to the table not in use, so it can be modified, before being committed.

Auto Trait Implementations

impl RefUnwindSafe for GdtManager

impl Send for GdtManager

impl Sync for GdtManager

impl Unpin for GdtManager

impl UnwindSafe for GdtManager

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.