Kernel: Scheduler/Thread add inline assembly for i386

This commit is contained in:
Bananymous 2024-03-22 12:59:35 +02:00
parent d920785256
commit c0dff5e203
2 changed files with 35 additions and 2 deletions

View File

@ -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<void> 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

View File

@ -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
}