pub enum Descriptor {
    UserSegment(u64),
    SystemSegment(u64, u64),
}
Expand description

A 64-bit mode segment descriptor.

Segmentation is no longer supported in 64-bit mode, so most of the descriptor contents are ignored.

Variants§

§

UserSegment(u64)

Descriptor for a code or data segment.

Since segmentation is no longer supported in 64-bit mode, almost all of code and data descriptors is ignored. Only some flags are still used.

§

SystemSegment(u64, u64)

A system segment descriptor such as a LDT or TSS descriptor.

Implementations§

source§

impl Descriptor

source

pub const fn dpl(self) -> PrivilegeLevel

Returns the Descriptor Privilege Level (DPL). When using this descriptor via a SegmentSelector, the RPL and Current Privilege Level (CPL) must less than or equal to the DPL, except for stack segments where the RPL, CPL, and DPL must all be equal.

source

pub const fn kernel_code_segment() -> Descriptor

Creates a segment descriptor for a 64-bit kernel code segment. Suitable for use with syscall or 64-bit sysenter.

source

pub const fn kernel_data_segment() -> Descriptor

Creates a segment descriptor for a kernel data segment (32-bit or 64-bit). Suitable for use with syscall or sysenter.

source

pub const fn user_data_segment() -> Descriptor

Creates a segment descriptor for a ring 3 data segment (32-bit or 64-bit). Suitable for use with sysret or sysexit.

source

pub const fn user_code_segment() -> Descriptor

Creates a segment descriptor for a 64-bit ring 3 code segment. Suitable for use with sysret or sysexit.

source

pub fn tss_segment(tss: &'static TaskStateSegment) -> Descriptor

Creates a TSS system descriptor for the given TSS.

While it is possible to create multiple Descriptors that point to the same TSS, this generally isn’t recommended, as the TSS usually contains per-CPU information such as the RSP and IST pointers. Instead, there should be exactly one TSS and one corresponding TSS Descriptor per CPU. Then, each of these descriptors should be placed in a GDT (which can either be global or per-CPU).

source

pub unsafe fn tss_segment_unchecked(tss: *const TaskStateSegment) -> Descriptor

Similar to Descriptor::tss_segment, but unsafe since it does not enforce a lifetime constraint on the provided TSS.

§Safety

The caller must ensure that the passed pointer is valid for as long as the descriptor is being used.

Trait Implementations§

source§

impl Clone for Descriptor

source§

fn clone(&self) -> Descriptor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Descriptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for Descriptor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.