aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Gerd Zellweger <mail@gerdzellweger.com> 2019-01-08 01:44:45 -0800
committerGravatar GitHub <noreply@github.com> 2019-01-08 01:44:45 -0800
commit187a1edd5cc464e9702f65810a1f53ca72cde296 (patch)
treef097d2fa4a02396547233fa0c8087b89940514d6 /src
parenta0ebbd3cc50d2a7e41b91ddb1cfaf7b9850ad8c7 (diff)
parent88099ed80ebdf89115f649105a1aee3a2c716a50 (diff)
downloadrust-x86-187a1edd5cc464e9702f65810a1f53ca72cde296.tar.gz
rust-x86-187a1edd5cc464e9702f65810a1f53ca72cde296.tar.zst
rust-x86-187a1edd5cc464e9702f65810a1f53ca72cde296.zip
Merge pull request #44 from hermitcore/cr2_write
add cr2_write, for example to reset CR2
Diffstat (limited to 'src')
-rw-r--r--src/controlregs.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/controlregs.rs b/src/controlregs.rs
index b09a48a..1445eab 100644
--- a/src/controlregs.rs
+++ b/src/controlregs.rs
@@ -77,6 +77,11 @@ pub unsafe fn cr2() -> usize {
ret
}
+/// Write cr2, for instance to reset cr2
+pub unsafe fn cr2_write(val: u64) {
+ asm!("mov $0, %cr2" :: "r" (val) : "memory");
+}
+
/// Contains page-table root pointer.
pub unsafe fn cr3() -> u64 {
let ret: u64;