aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include/x86
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2007-11-23 16:23:28 +0000
committerKeir Fraser <keir.fraser@citrix.com>2007-11-23 16:23:28 +0000
commitfd2f80c255acc5edf0cea58053c81f392042bf51 (patch)
treec15b47372749e83f1e36d0cbc3674d66c60777d8 /extras/mini-os/include/x86
parenta222af2ef1f49e5c232466ab162fd606732a9d05 (diff)
downloadxen-fd2f80c255acc5edf0cea58053c81f392042bf51.tar.gz
xen-fd2f80c255acc5edf0cea58053c81f392042bf51.tar.bz2
xen-fd2f80c255acc5edf0cea58053c81f392042bf51.zip
[Mini-OS] Fix x86 arch_switch_thread
Fix x86 arch_switch_thread by making it pure assembly. There were missing general register clobbers for x86_64, and BP should theorically be clobbered too, but gcc does not believe that, so the only simple safe solution is to use pure assembly. Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
Diffstat (limited to 'extras/mini-os/include/x86')
-rw-r--r--extras/mini-os/include/x86/arch_sched.h39
1 files changed, 2 insertions, 37 deletions
diff --git a/extras/mini-os/include/x86/arch_sched.h b/extras/mini-os/include/x86/arch_sched.h
index 7bf0036fac..35a4344efd 100644
--- a/extras/mini-os/include/x86/arch_sched.h
+++ b/extras/mini-os/include/x86/arch_sched.h
@@ -15,44 +15,9 @@ static inline struct thread* get_current(void)
return *current;
}
-#ifdef __i386__
-#define arch_switch_threads(prev, next) do { \
- unsigned long esi,edi; \
- __asm__ __volatile__("pushfl\n\t" \
- "pushl %%ebp\n\t" \
- "movl %%esp,%0\n\t" /* save ESP */ \
- "movl %4,%%esp\n\t" /* restore ESP */ \
- "movl $1f,%1\n\t" /* save EIP */ \
- "pushl %5\n\t" /* restore EIP */ \
- "ret\n\t" \
- "1:\t" \
- "popl %%ebp\n\t" \
- "popfl" \
- :"=m" (prev->sp),"=m" (prev->ip), \
- "=S" (esi),"=D" (edi) \
- :"m" (next->sp),"m" (next->ip), \
- "2" (prev), "d" (next)); \
-} while (0)
-#elif __x86_64__
-#define arch_switch_threads(prev, next) do { \
- unsigned long rsi,rdi; \
- __asm__ __volatile__("pushfq\n\t" \
- "pushq %%rbp\n\t" \
- "movq %%rsp,%0\n\t" /* save RSP */ \
- "movq %4,%%rsp\n\t" /* restore RSP */ \
- "movq $1f,%1\n\t" /* save RIP */ \
- "pushq %5\n\t" /* restore RIP */ \
- "ret\n\t" \
- "1:\t" \
- "popq %%rbp\n\t" \
- "popfq" \
- :"=m" (prev->sp),"=m" (prev->ip), \
- "=S" (rsi),"=D" (rdi) \
- :"m" (next->sp),"m" (next->ip), \
- "2" (prev), "d" (next)); \
-} while (0)
-#endif
+extern void __arch_switch_threads(unsigned long *prevctx, unsigned long *nextctx);
+#define arch_switch_threads(prev,next) __arch_switch_threads(&(prev)->sp, &(next)->sp)