diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index 2b892ae2d3..8df08cf889 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -19,7 +19,13 @@ namespace Kernel ALWAYS_INLINE static void load_temp_stack() { +#if ARCH(x86_64) asm volatile("movq %0, %%rsp" :: "rm"(Processor::current_stack_top())); +#elif ARCH(i386) + asm volatile("movl %0, %%esp" :: "rm"(Processor::current_stack_top())); +#else + #error +#endif } BAN::ErrorOr Scheduler::initialize() @@ -209,11 +215,21 @@ namespace Kernel #if __enable_sse if (current != Thread::sse_thread()) { +#if ARCH(x86_64) asm volatile( "movq %cr0, %rax;" "orq $(1 << 3), %rax;" "movq %rax, %cr0" ); +#elif ARCH(i386) + asm volatile( + "movl %cr0, %eax;" + "orl $(1 << 3), %eax;" + "movl %eax, %cr0" + ); +#else + #error +#endif } #endif diff --git a/kernel/kernel/Thread.cpp b/kernel/kernel/Thread.cpp index 7e44db5ea9..3552088b2d 100644 --- a/kernel/kernel/Thread.cpp +++ b/kernel/kernel/Thread.cpp @@ -99,16 +99,33 @@ namespace Kernel : m_tid(tid), m_process(process) { #if __enable_sse + #if ARCH(x86_64) uintptr_t cr0; asm volatile( "movq %%cr0, %%rax;" - "movq %%rax, %%rbx;" + "movq %%rax, %[cr0];" "andq $~(1 << 3), %%rax;" "movq %%rax, %%cr0;" - : "=b"(cr0) + : [cr0]"=r"(cr0) + :: "rax" ); save_sse(); asm volatile("movq %0, %%cr0" :: "r"(cr0)); + #elif ARCH(i386) + uintptr_t cr0; + asm volatile( + "movl %%cr0, %%eax;" + "movl %%eax, %[cr0];" + "andl $~(1 << 3), %%eax;" + "movl %%eax, %%cr0;" + : [cr0]"=r"(cr0) + :: "eax" + ); + save_sse(); + asm volatile("movl %0, %%cr0" :: "r"(cr0)); + #else + #error + #endif #endif }