x86_64::structures::gdt

Enum Descriptor

Source
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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>,

Source§

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>,

Source§

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.