rstubs::arch::gdt

Struct Descriptor

source
#[repr(transparent)]
pub struct Descriptor(u64);
Expand description

Describes the structure of segment descriptors

A data structure that contains size, position, access rights, and purpose of any segment. Segment descriptors are used in both the GDT, as well as in LDTs.

  • ISDMv3, 3.4.5; Segment Descriptors
  • AAPMv2, 4.7 Legacy Segment Descriptors

Tuple Fields§

§0: u64

Implementations§

source§

impl Descriptor

source

const LIMIT_LOW_BITS: usize = 16usize

source

const LIMIT_LOW_OFFSET: usize = 0usize

source

const BASE_LOW_BITS: usize = 24usize

source

const BASE_LOW_OFFSET: usize = 16usize

source

const KIND_BITS: usize = 4usize

source

const KIND_OFFSET: usize = 40usize

source

const DESCRIPTOR_KIND_BITS: usize = 1usize

source

const DESCRIPTOR_KIND_OFFSET: usize = 44usize

source

const RING_BITS: usize = 2usize

source

const RING_OFFSET: usize = 45usize

source

const PRESENT_BITS: usize = 1usize

source

const PRESENT_OFFSET: usize = 47usize

source

const LIMIT_HIGH_BITS: usize = 4usize

source

const LIMIT_HIGH_OFFSET: usize = 48usize

source

const AVAILABLE_BITS: usize = 1usize

source

const AVAILABLE_OFFSET: usize = 52usize

source

const CUSTOM_BITS: usize = 2usize

source

const CUSTOM_OFFSET: usize = 53usize

source

const PAGES_BITS: usize = 1usize

source

const PAGES_OFFSET: usize = 55usize

source

const BASE_HIGH_BITS: usize = 8usize

source

const BASE_HIGH_OFFSET: usize = 56usize

source

pub const fn new() -> Self

Creates a new default initialized bitfield.

source

pub const fn from_bits(bits: u64) -> Self

Convert from bits.

source

pub const fn into_bits(self) -> u64

Convert into bits.

source

const fn limit_low(&self) -> u32

Least-significant bits of segment size (influenced by Self::pages!)

Bits: 0..16

source

const fn with_limit_low_checked(self, value: u32) -> Result<Self, ()>

Least-significant bits of segment size (influenced by Self::pages!)

Bits: 0..16

source

const fn with_limit_low(self, value: u32) -> Self

Least-significant bits of segment size (influenced by Self::pages!)

Bits: 0..16

source

fn set_limit_low(&mut self, value: u32)

Least-significant bits of segment size (influenced by Self::pages!)

Bits: 0..16

source

fn set_limit_low_checked(&mut self, value: u32) -> Result<(), ()>

Least-significant bits of segment size (influenced by Self::pages!)

Bits: 0..16

source

const fn base_low(&self) -> u32

Least-significant bits of base address

Bits: 16..40

source

const fn with_base_low_checked(self, value: u32) -> Result<Self, ()>

Least-significant bits of base address

Bits: 16..40

source

const fn with_base_low(self, value: u32) -> Self

Least-significant bits of base address

Bits: 16..40

source

fn set_base_low(&mut self, value: u32)

Least-significant bits of base address

Bits: 16..40

source

fn set_base_low_checked(&mut self, value: u32) -> Result<(), ()>

Least-significant bits of base address

Bits: 16..40

source

pub const fn kind(&self) -> u8

Type: defines which kind code/data/system descriptor this is. This depends on Self::descriptor_kind.

Bits: 40..44

source

pub const fn with_kind_checked(self, value: u8) -> Result<Self, ()>

Type: defines which kind code/data/system descriptor this is. This depends on Self::descriptor_kind.

Bits: 40..44

source

pub const fn with_kind(self, value: u8) -> Self

Type: defines which kind code/data/system descriptor this is. This depends on Self::descriptor_kind.

Bits: 40..44

source

pub fn set_kind(&mut self, value: u8)

Type: defines which kind code/data/system descriptor this is. This depends on Self::descriptor_kind.

Bits: 40..44

source

pub fn set_kind_checked(&mut self, value: u8) -> Result<(), ()>

Type: defines which kind code/data/system descriptor this is. This depends on Self::descriptor_kind.

Bits: 40..44

source

pub const fn descriptor_kind(&self) -> bool

Descriptor type: if true code or data, else system

Bits: 44..45

source

pub const fn with_descriptor_kind_checked(self, value: bool) -> Result<Self, ()>

Descriptor type: if true code or data, else system

Bits: 44..45

source

pub const fn with_descriptor_kind(self, value: bool) -> Self

Descriptor type: if true code or data, else system

Bits: 44..45

source

pub fn set_descriptor_kind(&mut self, value: bool)

Descriptor type: if true code or data, else system

Bits: 44..45

source

pub fn set_descriptor_kind_checked(&mut self, value: bool) -> Result<(), ()>

Descriptor type: if true code or data, else system

Bits: 44..45

source

pub const fn ring(&self) -> Ring

Ring for this segment

Bits: 45..47

source

pub const fn with_ring_checked(self, value: Ring) -> Result<Self, ()>

Ring for this segment

Bits: 45..47

source

pub const fn with_ring(self, value: Ring) -> Self

Ring for this segment

Bits: 45..47

source

pub fn set_ring(&mut self, value: Ring)

Ring for this segment

Bits: 45..47

source

pub fn set_ring_checked(&mut self, value: Ring) -> Result<(), ()>

Ring for this segment

Bits: 45..47

source

pub const fn present(&self) -> bool

Entry is ignored if set to false

Bits: 47..48

source

pub const fn with_present_checked(self, value: bool) -> Result<Self, ()>

Entry is ignored if set to false

Bits: 47..48

source

pub const fn with_present(self, value: bool) -> Self

Entry is ignored if set to false

Bits: 47..48

source

pub fn set_present(&mut self, value: bool)

Entry is ignored if set to false

Bits: 47..48

source

pub fn set_present_checked(&mut self, value: bool) -> Result<(), ()>

Entry is ignored if set to false

Bits: 47..48

source

const fn limit_high(&self) -> u32

Most-significant bits of segment size

Bits: 48..52

source

const fn with_limit_high_checked(self, value: u32) -> Result<Self, ()>

Most-significant bits of segment size

Bits: 48..52

source

const fn with_limit_high(self, value: u32) -> Self

Most-significant bits of segment size

Bits: 48..52

source

fn set_limit_high(&mut self, value: u32)

Most-significant bits of segment size

Bits: 48..52

source

fn set_limit_high_checked(&mut self, value: u32) -> Result<(), ()>

Most-significant bits of segment size

Bits: 48..52

source

pub const fn available(&self) -> bool

Bit which can be freely used for other purposes

Bits: 52..53

source

pub const fn with_available_checked(self, value: bool) -> Result<Self, ()>

Bit which can be freely used for other purposes

Bits: 52..53

source

pub const fn with_available(self, value: bool) -> Self

Bit which can be freely used for other purposes

Bits: 52..53

source

pub fn set_available(&mut self, value: bool)

Bit which can be freely used for other purposes

Bits: 52..53

source

pub fn set_available_checked(&mut self, value: bool) -> Result<(), ()>

Bit which can be freely used for other purposes

Bits: 52..53

source

pub const fn custom(&self) -> u8

The meaning of these bits are related to Self::descriptor_kind and Self::kind

Bits: 53..55

source

pub const fn with_custom_checked(self, value: u8) -> Result<Self, ()>

The meaning of these bits are related to Self::descriptor_kind and Self::kind

Bits: 53..55

source

pub const fn with_custom(self, value: u8) -> Self

The meaning of these bits are related to Self::descriptor_kind and Self::kind

Bits: 53..55

source

pub fn set_custom(&mut self, value: u8)

The meaning of these bits are related to Self::descriptor_kind and Self::kind

Bits: 53..55

source

pub fn set_custom_checked(&mut self, value: u8) -> Result<(), ()>

The meaning of these bits are related to Self::descriptor_kind and Self::kind

Bits: 53..55

source

pub const fn pages(&self) -> bool

Uses page granularity for the segment limit (instead of bytes)

Bits: 55..56

source

pub const fn with_pages_checked(self, value: bool) -> Result<Self, ()>

Uses page granularity for the segment limit (instead of bytes)

Bits: 55..56

source

pub const fn with_pages(self, value: bool) -> Self

Uses page granularity for the segment limit (instead of bytes)

Bits: 55..56

source

pub fn set_pages(&mut self, value: bool)

Uses page granularity for the segment limit (instead of bytes)

Bits: 55..56

source

pub fn set_pages_checked(&mut self, value: bool) -> Result<(), ()>

Uses page granularity for the segment limit (instead of bytes)

Bits: 55..56

source

const fn base_high(&self) -> u8

Most-significant bits of base address

Bits: 56..64

source

const fn with_base_high_checked(self, value: u8) -> Result<Self, ()>

Most-significant bits of base address

Bits: 56..64

source

const fn with_base_high(self, value: u8) -> Self

Most-significant bits of base address

Bits: 56..64

source

fn set_base_high(&mut self, value: u8)

Most-significant bits of base address

Bits: 56..64

source

fn set_base_high_checked(&mut self, value: u8) -> Result<(), ()>

Most-significant bits of base address

Bits: 56..64

source§

impl Descriptor

source

pub const fn segment( memory: RangeInclusive<u32>, code: bool, ring: Ring, ) -> Self

Create a code/data segment descriptor

source

pub fn tss(tss: *const TaskStateSegment) -> Self

Creates a new task state segment descriptor for the Global Descriptor Table.

source

pub const fn base(&self) -> u32

Base/starting address

source

pub const fn with_base(self, v: u32) -> Self

Base/starting address

source

pub const fn limit(&self) -> u32

Segment size minus one

source

pub const fn with_limit(self, v: u32) -> Self

Segment size minus one

Trait Implementations§

source§

impl Clone for Descriptor

source§

fn clone(&self) -> Descriptor

Returns a copy of the value. Read more
1.0.0§

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 Default for Descriptor

source§

fn default() -> Self

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

impl From<Descriptor> for u64

source§

fn from(v: Descriptor) -> u64

Converts to this type from the input type.
source§

impl From<u64> for Descriptor

source§

fn from(v: u64) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Descriptor

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

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

impl Copy for Descriptor

source§

impl Eq for Descriptor

source§

impl StructuralPartialEq for Descriptor

Auto Trait Implementations§

§

impl Freeze for Descriptor

§

impl RefUnwindSafe for Descriptor

§

impl Send for Descriptor

§

impl Sync for Descriptor

§

impl Unpin for Descriptor

§

impl UnwindSafe for Descriptor

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> CloneToUninit for T
where T: Clone,

§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.