Struct rstubs::arch::gdt::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

pub const fn new() -> Self

Creates a new default initialized bitfield.

source

const LIMIT_LOW_BITS: usize = 16usize

source

const LIMIT_LOW_OFFSET: usize = 0usize

source

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

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

Bits: 0..16

source

const fn limit_low(&self) -> u32

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

Bits: 0..16

source

fn set_limit_low(&mut self, value: u32)

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

Bits: 0..16

source

const BASE_LOW_BITS: usize = 24usize

source

const BASE_LOW_OFFSET: usize = 16usize

source

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

Least-significant bits of base address

Bits: 16..40

source

const fn base_low(&self) -> u32

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

const KIND_BITS: usize = 4usize

source

const KIND_OFFSET: usize = 40usize

source

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

Meaning of those 4 bits depends on kind_code_data below

Bits: 40..44

source

pub const fn kind(&self) -> u8

Meaning of those 4 bits depends on kind_code_data below

Bits: 40..44

source

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

Meaning of those 4 bits depends on kind_code_data below

Bits: 40..44

source

const DESCRIPTOR_KIND_BITS: usize = 1usize

source

const DESCRIPTOR_KIND_OFFSET: usize = 44usize

source

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

Descriptor type (influences the meaning of the 3 bits above)

Bits: 44..45

source

pub const fn descriptor_kind(&self) -> bool

Descriptor type (influences the meaning of the 3 bits above)

Bits: 44..45

source

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

Descriptor type (influences the meaning of the 3 bits above)

Bits: 44..45

source

const RING_BITS: usize = 2usize

source

const RING_OFFSET: usize = 45usize

source

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

Ring for this segment

Bits: 45..47

source

pub const fn ring(&self) -> u8

Ring for this segment

Bits: 45..47

source

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

Ring for this segment

Bits: 45..47

source

const PRESENT_BITS: usize = 1usize

source

const PRESENT_OFFSET: usize = 47usize

source

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

Entry is valid iff set to true

Bits: 47..48

source

pub const fn present(&self) -> bool

Entry is valid iff set to true

Bits: 47..48

source

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

Entry is valid iff set to true

Bits: 47..48

source

const LIMIT_HIGH_BITS: usize = 4usize

source

const LIMIT_HIGH_OFFSET: usize = 48usize

source

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

Most-significant bits of segment size

Bits: 48..52

source

const fn limit_high(&self) -> u32

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

const AVAILABLE_BITS: usize = 1usize

source

const AVAILABLE_OFFSET: usize = 52usize

source

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

Bit which can be used for other purposes (in software)

Bits: 52..53

source

pub const fn available(&self) -> bool

Bit which can be used for other purposes (in software)

Bits: 52..53

source

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

Bit which can be used for other purposes (in software)

Bits: 52..53

source

const CUSTOM_BITS: usize = 2usize

source

const CUSTOM_OFFSET: usize = 53usize

source

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

Meaning of those 2 bits relate to descriptor_kind and kind

Bits: 53..55

source

pub const fn custom(&self) -> u8

Meaning of those 2 bits relate to descriptor_kind and kind

Bits: 53..55

source

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

Meaning of those 2 bits relate to descriptor_kind and kind

Bits: 53..55

source

const PAGES_BITS: usize = 1usize

source

const PAGES_OFFSET: usize = 55usize

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 const fn pages(&self) -> bool

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

const BASE_HIGH_BITS: usize = 8usize

source

const BASE_HIGH_OFFSET: usize = 56usize

source

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

most-significant bits of base address

Bits: 56..64

source

const fn base_high(&self) -> u8

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§

impl Descriptor

source

pub const fn segment( memory: RangeInclusive<u32>, code: bool, user: bool ) -> Descriptor

Create a code/data segment descriptor

source

pub fn tss(tss: &TaskStateSegment) -> Descriptor

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

source

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

Segment size

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

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

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 Descriptor

source§

impl Eq for Descriptor

source§

impl StructuralEq for Descriptor

source§

impl StructuralPartialEq for Descriptor

Auto Trait Implementations§

§

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
§

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
§

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.

§

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.