diff options
author | 2019-08-09 12:13:25 +0300 | |
---|---|---|
committer | 2019-08-09 12:15:35 +0300 | |
commit | 12d30ca3792ae41a7b0b1a2bdaacb428b9688625 (patch) | |
tree | 6ecc108e670aaca8b36adcc217067a3490cf84c0 | |
parent | 604d259b367fcd9e1752d9e46a047fea455d7b59 (diff) | |
download | rust-x86-12d30ca3792ae41a7b0b1a2bdaacb428b9688625.tar.gz rust-x86-12d30ca3792ae41a7b0b1a2bdaacb428b9688625.tar.zst rust-x86-12d30ca3792ae41a7b0b1a2bdaacb428b9688625.zip |
Added function to return the current value of the task register
Currently it can only be loaded with load_tr(), provide a function
that can also read it.
-rw-r--r-- | src/task.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/task.rs b/src/task.rs index a7637f2..e71ea8f 100644 --- a/src/task.rs +++ b/src/task.rs @@ -3,7 +3,14 @@ pub use crate::segmentation; -/// Load the task state register. +/// Returns the current value of the task register. +pub fn tr() -> segmentation::SegmentSelector { + let segment: u16; + unsafe { asm!("str $0" : "=r" (segment) ) }; + segmentation::SegmentSelector::from_raw(segment) +} + +/// Loads the task register. pub unsafe fn load_tr(sel: segmentation::SegmentSelector) { asm!("ltr $0" :: "r" (sel.bits())); } |