Skip to content
Browse files

Reorder switch_to

  • Loading branch information...
1 parent 61ff56e commit cd9cf2c5839966b0c32e8dbb6d815c556cd7cb09 @jackpot51 jackpot51 committed
Showing with 30 additions and 32 deletions.
  1. +1 −1 i386-unknown-redox.json
  2. +28 −30 kernel/arch/context.rs
  3. +1 −1 x86_64-unknown-redox.json
View
2 i386-unknown-redox.json
@@ -13,7 +13,7 @@
"relocation-model": "static",
"code-model": "kernel",
"disable-redzone": true,
- "eliminate_frame_pointer": true,
+ "eliminate-frame-pointer": true,
"exe-suffix": ".bin",
"has-rpath": false,
"no-compiler-rt": true,
View
58 kernel/arch/context.rs
@@ -668,19 +668,6 @@ impl Context {
#[cold]
#[inline(never)]
pub unsafe fn switch_to(&mut self, next: &mut Context) {
- asm!("pushfd
- pop $0"
- : "=r"(self.flags)
- :
- : "memory"
- : "intel", "volatile");
-
- asm!(""
- : "={esp}"(self.sp)
- :
- : "memory"
- : "intel", "volatile");
-
asm!("fxsave [$0]"
:
: "r"(self.fx)
@@ -697,39 +684,38 @@ impl Context {
: "intel", "volatile");
}
- asm!(""
+ asm!("pushfd
+ pop $0"
+ : "=r"(self.flags)
:
- : "{esp}"(next.sp)
: "memory"
: "intel", "volatile");
-
asm!("push $0
popfd"
:
: "r"(next.flags)
: "memory"
: "intel", "volatile");
- }
- // This function must not push or pop
- #[cfg(target_arch = "x86_64")]
- #[cold]
- #[inline(never)]
- pub unsafe fn switch_to(&mut self, next: &mut Context) {
- asm!("pushfq
- pop $0"
- : "=r"(self.flags)
+ asm!("mov $0, esp"
+ : "=r"(self.sp)
:
: "memory"
: "intel", "volatile");
- asm!(""
- : "={rsp}"(self.sp)
+ asm!("mov esp, $0"
:
+ : "r"(next.sp)
: "memory"
: "intel", "volatile");
+ }
+ // This function must not push or pop
+ #[cfg(target_arch = "x86_64")]
+ #[cold]
+ #[inline(never)]
+ pub unsafe fn switch_to(&mut self, next: &mut Context) {
asm!("fxsave [$0]"
:
: "r"(self.fx)
@@ -746,19 +732,31 @@ impl Context {
: "intel", "volatile");
}
- asm!(""
+ asm!("pushfq
+ pop $0"
+ : "=r"(self.flags)
:
- : "{rsp}"(next.sp)
: "memory"
: "intel", "volatile");
-
asm!("push $0
popfq"
:
: "r"(next.flags)
: "memory"
: "intel", "volatile");
+
+ asm!("mov $0, rsp"
+ : "=r"(self.sp)
+ :
+ : "memory"
+ : "intel", "volatile");
+
+ asm!("mov rsp, $0"
+ :
+ : "r"(next.sp)
+ : "memory"
+ : "intel", "volatile");
}
}
View
2 x86_64-unknown-redox.json
@@ -13,7 +13,7 @@
"relocation-model": "static",
"code-model": "kernel",
"disable-redzone": true,
- "eliminate_frame_pointer": true,
+ "eliminate-frame-pointer": true,
"exe-suffix": ".bin",
"has-rpath": false,
"no-compiler-rt": true,

0 comments on commit cd9cf2c

Please sign in to comment.
Something went wrong with that request. Please try again.