pub struct CS;
Expand description

Code Segment

While most fields in the Code-Segment Descriptor are unused in 64-bit long mode, some of them must be set to a specific value. The EXECUTABLE, USER_SEGMENT, and LONG_MODE bits must be set, while the DEFAULT_SIZE bit must be unset.

The DPL_RING_3 field can be used to change privilege level. The PRESENT bit can be used to make a segment present or not present.

All other fields (like the segment base and limit) are ignored by the processor and setting them has no effect.

Trait Implementations§

source§

impl Debug for CS

source§

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

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

impl Segment for CS

Available on crate feature instructions only.
source§

unsafe fn set_reg(sel: SegmentSelector)

Note this is special since we cannot directly move to CS; x86 requires the instruction pointer and CS to be set at the same time. To do this, we push the new segment selector and return value onto the stack and use a “far return” (retfq) to reload CS and continue at the end of our function.

Note we cannot use a “far call” (lcall) or “far jmp” (ljmp) to do this because then we would only be able to jump to 32-bit instruction pointers. Only Intel implements support for 64-bit far calls/jumps in long-mode, AMD does not.

source§

fn get_reg() -> SegmentSelector

Returns the current value of the segment register.

Auto Trait Implementations§

§

impl Freeze for CS

§

impl RefUnwindSafe for CS

§

impl Send for CS

§

impl Sync for CS

§

impl Unpin for CS

§

impl UnwindSafe for CS

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.