pub struct ControlRegister0(/* private fields */);
Available on x86 or x86-64 only.
Expand description

CR0: System control register with flags affecting protection, paging, and FPU behavior.

Getters and setters for this structure only access a value in memory, not the register itself. Use the get and set methods to work with the actual register.

Implementations§

source§

impl ControlRegister0

source

pub fn paging(&self) -> bool

CR0.PG: Enable paging. Requires protected_mode.

source

pub fn cache_disabled(&self) -> bool

CR0.CD: Disable all memory caching.

source

pub fn cache_not_write_through(&self) -> bool

CR0.NW: Disable write-back/write-through caching.

source

pub fn alignment_check_mask(&self) -> bool

CR0.AM: Enables strict alignment checks for memory access, in combination with FlagRegister::alignment_check_or_access_control.

source

pub fn write_protect(&self) -> bool

CR0.WP: Enforce read-only pages even in privilege levels 0–2. They are always enforced in level 3.

source

pub fn native_fpu_error(&self) -> bool

CR0.NE: Use internal error mechanism for FPU errors, rather than DOS-style.

source

pub fn fpu_extension_type(&self) -> bool

CR0.ET: On 386/486, 387 FPU instructions are supported if set. Always set on modern processors.

source

pub fn task_switched_without_fpu_state(&self) -> bool

CR0.TS: Set by processor when task was switched but FPU context has not been saved yet.

Used to save work when the new task does not alter the FPU state. When an FPU instruction is executed with this flag set, the processor raises an exception that allows the OS to save the FPU state. This behavior can be altered by other flags. See monitor_fpu_state.

source

pub fn fpu_emulation(&self) -> bool

CR0.EM: Trigger an exception on all FPU instructions. Used to support software emulation.

source

pub fn monitor_fpu(&self) -> bool

CR0.MP: Enable exception behavior described for the CR0.TS flag for the (F)WAIT instruction.

source

pub fn protected_mode(&self) -> bool

Enable protected mode. Does not enable paging on its own. See paging.

source

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

CR0.PG: Enable paging. Requires protected_mode.

source

pub fn with_paging(&mut self, value: bool) -> Self

CR0.PG: Enable paging. Requires protected_mode.

source

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

CR0.CD: Disable all memory caching.

source

pub fn with_cache_disabled(&mut self, value: bool) -> Self

CR0.CD: Disable all memory caching.

source

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

CR0.NW: Disable write-back/write-through caching.

source

pub fn with_cache_not_write_through(&mut self, value: bool) -> Self

CR0.NW: Disable write-back/write-through caching.

source

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

CR0.AM: Enables strict alignment checks for memory access, in combination with FlagRegister::alignment_check_or_access_control.

source

pub fn with_alignment_check_mask(&mut self, value: bool) -> Self

CR0.AM: Enables strict alignment checks for memory access, in combination with FlagRegister::alignment_check_or_access_control.

source

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

CR0.WP: Enforce read-only pages even in privilege levels 0–2. They are always enforced in level 3.

source

pub fn with_write_protect(&mut self, value: bool) -> Self

CR0.WP: Enforce read-only pages even in privilege levels 0–2. They are always enforced in level 3.

source

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

CR0.NE: Use internal error mechanism for FPU errors, rather than DOS-style.

source

pub fn with_native_fpu_error(&mut self, value: bool) -> Self

CR0.NE: Use internal error mechanism for FPU errors, rather than DOS-style.

source

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

CR0.ET: On 386/486, 387 FPU instructions are supported if set. Always set on modern processors.

source

pub fn with_fpu_extension_type(&mut self, value: bool) -> Self

CR0.ET: On 386/486, 387 FPU instructions are supported if set. Always set on modern processors.

source

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

CR0.TS: Set by processor when task was switched but FPU context has not been saved yet.

Used to save work when the new task does not alter the FPU state. When an FPU instruction is executed with this flag set, the processor raises an exception that allows the OS to save the FPU state. This behavior can be altered by other flags. See monitor_fpu_state.

source

pub fn with_task_switched_without_fpu_state(&mut self, value: bool) -> Self

CR0.TS: Set by processor when task was switched but FPU context has not been saved yet.

Used to save work when the new task does not alter the FPU state. When an FPU instruction is executed with this flag set, the processor raises an exception that allows the OS to save the FPU state. This behavior can be altered by other flags. See monitor_fpu_state.

source

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

CR0.EM: Trigger an exception on all FPU instructions. Used to support software emulation.

source

pub fn with_fpu_emulation(&mut self, value: bool) -> Self

CR0.EM: Trigger an exception on all FPU instructions. Used to support software emulation.

source

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

CR0.MP: Enable exception behavior described for the CR0.TS flag for the (F)WAIT instruction.

source

pub fn with_monitor_fpu(&mut self, value: bool) -> Self

CR0.MP: Enable exception behavior described for the CR0.TS flag for the (F)WAIT instruction.

source

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

Enable protected mode. Does not enable paging on its own. See paging.

source

pub fn with_protected_mode(&mut self, value: bool) -> Self

Enable protected mode. Does not enable paging on its own. See paging.

source§

impl ControlRegister0

source

pub fn get() -> Self

Retrieve the current value of this register

source

pub unsafe fn set(value: Self)

Update the register to the given value.

§Safety

Altering certain system flags can have dramatic effects on the execution of this and other programs, including memory safety.

source§

impl ControlRegister0

source

pub unsafe fn clear_task_switched_without_fpu_state()

Directly clear the task_switched_without_fpu_state flag in this register using a single instruction.

§Safety

Clearing this flag when inappropriate may clobber FPU state and potentially affect memory safety.

Trait Implementations§

source§

impl Bitfield<usize> for ControlRegister0

§

fn new(value: T) -> Self

Construct a new bitfield type from its underlying representation
§

fn value(self) -> T

Unwrap the bitfield into its underlying representation
source§

impl Clone for ControlRegister0

source§

fn clone(&self) -> ControlRegister0

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 ControlRegister0

source§

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

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

impl Default for ControlRegister0

source§

fn default() -> ControlRegister0

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

impl From<ControlRegister0> for usize

source§

fn from(val: ControlRegister0) -> Self

Converts to this type from the input type.
source§

impl From<usize> for ControlRegister0

source§

fn from(val: usize) -> Self

Converts to this type from the input type.
source§

impl PartialEq for ControlRegister0

source§

fn eq(&self, other: &ControlRegister0) -> 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 ControlRegister0

source§

impl Eq for ControlRegister0

source§

impl StructuralPartialEq for ControlRegister0

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.