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
impl Descriptor
Sourcepub const fn dpl(self) -> PrivilegeLevel
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.
Sourcepub const fn kernel_code_segment() -> Descriptor
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
.
Sourcepub const fn kernel_data_segment() -> Descriptor
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
.
Sourcepub const fn user_data_segment() -> Descriptor
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
.
Sourcepub const fn user_code_segment() -> Descriptor
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
.
Sourcepub fn tss_segment(tss: &'static TaskStateSegment) -> Descriptor
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).
Sourcepub unsafe fn tss_segment_unchecked(tss: *const TaskStateSegment) -> Descriptor
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
impl Clone for Descriptor
Source§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more