Add FX
This commit is contained in:
parent
dd05c0e2ec
commit
79f7e09230
|
@ -9,5 +9,5 @@ io = { path = "../../drivers/io" }
|
||||||
spin = "*"
|
spin = "*"
|
||||||
|
|
||||||
[dependencies.x86]
|
[dependencies.x86]
|
||||||
version = "0.7.1"
|
version = "*"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
|
@ -8,6 +8,10 @@ pub static CONTEXT_SWITCH_LOCK: AtomicBool = ATOMIC_BOOL_INIT;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
|
/// FX valid?
|
||||||
|
loadable: bool,
|
||||||
|
/// FX location
|
||||||
|
fx: usize,
|
||||||
/// Page table pointer
|
/// Page table pointer
|
||||||
cr3: usize,
|
cr3: usize,
|
||||||
/// RFLAGS register
|
/// RFLAGS register
|
||||||
|
@ -31,6 +35,8 @@ pub struct Context {
|
||||||
impl Context {
|
impl Context {
|
||||||
pub fn new() -> Context {
|
pub fn new() -> Context {
|
||||||
Context {
|
Context {
|
||||||
|
loadable: false,
|
||||||
|
fx: 0,
|
||||||
cr3: 0,
|
cr3: 0,
|
||||||
rflags: 0,
|
rflags: 0,
|
||||||
rbx: 0,
|
rbx: 0,
|
||||||
|
@ -47,6 +53,10 @@ impl Context {
|
||||||
self.cr3
|
self.cr3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_fx(&mut self, address: usize) {
|
||||||
|
self.fx = address;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_page_table(&mut self, address: usize) {
|
pub fn set_page_table(&mut self, address: usize) {
|
||||||
self.cr3 = address;
|
self.cr3 = address;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +70,6 @@ impl Context {
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[naked]
|
#[naked]
|
||||||
pub unsafe fn switch_to(&mut self, next: &mut Context) {
|
pub unsafe fn switch_to(&mut self, next: &mut Context) {
|
||||||
/*
|
|
||||||
asm!("fxsave [$0]" : : "r"(self.fx) : "memory" : "intel", "volatile");
|
asm!("fxsave [$0]" : : "r"(self.fx) : "memory" : "intel", "volatile");
|
||||||
self.loadable = true;
|
self.loadable = true;
|
||||||
if next.loadable {
|
if next.loadable {
|
||||||
|
@ -68,7 +77,6 @@ impl Context {
|
||||||
}else{
|
}else{
|
||||||
asm!("fninit" : : : "memory" : "intel", "volatile");
|
asm!("fninit" : : : "memory" : "intel", "volatile");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
asm!("mov $0, cr3" : "=r"(self.cr3) : : "memory" : "intel", "volatile");
|
asm!("mov $0, cr3" : "=r"(self.cr3) : : "memory" : "intel", "volatile");
|
||||||
if next.cr3 != self.cr3 {
|
if next.cr3 != self.cr3 {
|
||||||
|
|
Loading…
Reference in a new issue