Kernel: Allow Processor compilation for i386 targets

This is achieved by rewriting some inline assembly and changing
ProcessorID to be 32 bit value. For some reason if processor id
is 8 bits gcc runs out of 8 bit registers on i386.
This commit is contained in:
2024-03-22 13:33:13 +02:00
parent 0424082e7b
commit 7f029b2713
2 changed files with 19 additions and 18 deletions

View File

@@ -13,14 +13,13 @@ namespace Kernel
static ProcessorID read_processor_id()
{
uint8_t id;
uint32_t id;
asm volatile(
"movl $1, %%eax;"
"cpuid;"
"shrl $24, %%ebx;"
"movb %%bl, %0;"
: "=rm"(id)
:: "eax", "ebx", "ecx", "edx"
: "=b"(id)
:: "eax", "ecx", "edx"
);
return id;
}
@@ -55,7 +54,9 @@ namespace Kernel
// set gs base to pointer to this processor
uint64_t ptr = reinterpret_cast<uint64_t>(&processor);
asm volatile("wrmsr" :: "d"(ptr >> 32), "a"(ptr), "c"(MSR_IA32_GS_BASE));
uint32_t ptr_hi = ptr >> 32;
uint32_t ptr_lo = ptr & 0xFFFFFFFF;
asm volatile("wrmsr" :: "d"(ptr_hi), "a"(ptr_lo), "c"(MSR_IA32_GS_BASE));
ASSERT(processor.m_gdt);
processor.gdt().load();