#[repr(C)]
pub struct SegmentDescriptor { pub flags: SegmentDescriptorFlags, /* private fields */ }
Available on x86 or x86-64 only.
Expand description

An entry in a segment descriptor table that defines a new segment. This includes code, data, task state (TSS), and local descriptor table (LDT) segments.

Notes on the size of this structure:

  • In 32-bit mode, this structure is always 8 bytes and contains a 32-bit base address.
  • In 64-bit mode:
    • Task state and local descriptor table segment descriptors are expanded to 16 bytes with 64-bit base addresses.
    • From the processor’s perspective, code and data segments remain 8 bytes and the address and limit are both ignored. However, this structure is still defined as 16 bytes. This is fine, since the first 8 bytes are compatible and the rest will be ignored.

Fields§

§flags: SegmentDescriptorFlags

Common segment descriptor settings.

Implementations§

source§

impl SegmentDescriptor

source

pub const LIMIT_MAX: u32 = 1_048_575u32

The maximum supported value of the limit field (20 bits).

source

pub const fn new() -> Self

Create a zero-initialized descriptor

source

pub fn address(self) -> usize

Base virtual address of the segment, to which offsets are added.

In 64-bit mode, this is ignored and assumed to be 0 for code and data segments, but it still applies to task state and local descriptor table segments.

source

pub fn set_address(&mut self, address: usize)

Update the base address.

source

pub fn limit(self) -> u32

The “limit” of the segment, which is a maximum or minimum offset from the base address.

If this is a stack-like data segment (data_expand_down), then this value is the exclusive minimum offset value. Otherwise, this is the inclusive maximum offset value (i.e., size - 1).

This value may be in bytes or in 4KB units, depending on flags.granularity.

In 64-bit mode, this is ignored (all limit checks are disabled) for code and data segments, but it still applies to task state and local descriptor table segments.

source

pub fn set_limit(&mut self, limit: u32)

Update the segment limit.

§Panics

Panics if the limit is greater than LIMIT_MAX.

Trait Implementations§

source§

impl Clone for SegmentDescriptor

source§

fn clone(&self) -> SegmentDescriptor

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 SegmentDescriptor

source§

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

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

impl Default for SegmentDescriptor

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for SegmentDescriptor

source§

fn eq(&self, other: &SegmentDescriptor) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for SegmentDescriptor

source§

impl Eq for SegmentDescriptor

source§

impl StructuralPartialEq for SegmentDescriptor

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.