Small fixes

This commit is contained in:
2026-10-18 21:20:50 +02:00
parent 32f1ff25f7
commit 692d67e3cf
10 changed files with 46 additions and 4 deletions
-1
View File
@@ -1,4 +1,3 @@
#include <zinnia/types.h>
#include <arch/mem.h>
#include <stddef.h>
#include <stdint.h>
-1
View File
@@ -14,7 +14,6 @@ kernel_sources += files(
'mem.c',
'percpu.c',
'pmap.c',
'pmap.c',
'random.c',
'sched.c',
'serial.c',
+11
View File
@@ -11,6 +11,7 @@
#include <bits/sched.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <x86_64/apic.h>
#include <x86_64/asm.h>
#include <x86_64/defs.h>
@@ -93,6 +94,11 @@ struct task* arch_sched_switch(struct task* from, struct task* to) {
return perform_switch(&from_ctx->rsp, to_ctx->rsp, from);
}
constexpr size_t FPU_FCW_OFFSET = 0;
constexpr size_t FPU_MXCSR_OFFSET = 24;
constexpr uint16_t FPU_DEFAULT_FCW = 0x37F;
constexpr uint32_t FPU_DEFAULT_MXCSR = 0x1F80;
// Calls task_entry with the correct parameters.
[[__naked]]
void task_entry_thunk() {
@@ -142,6 +148,11 @@ errno_t arch_task_init(
context->fpu_region = (void*)fpu_base;
context->fpu_phys = pages;
const uint16_t fcw = FPU_DEFAULT_FCW;
const uint32_t mxcsr = FPU_DEFAULT_MXCSR;
memcpy((uint8_t*)fpu_base + FPU_FCW_OFFSET, &fcw, sizeof(fcw));
memcpy((uint8_t*)fpu_base + FPU_MXCSR_OFFSET, &mxcsr, sizeof(mxcsr));
context->ds = asm_read_ds();
context->es = asm_read_es();
context->fs = asm_read_fs();
+1 -1
View File
@@ -148,7 +148,7 @@ static void smp_trampoline() {
[kernel64_cs] "i"(offsetof(struct gdt, kernel_code64)),
[kernel64_ds] "i"(offsetof(struct gdt, kernel_data64)),
[cr0] "i"(CR0_PE | CR0_ET),
[cr0_pg] "i"(CR0_PG),
[cr0_pg] "i"((uint32_t)CR0_PG),
[cr4_pae] "i"(CR4_PAE),
[msr_efer] "i"(MSR_EFER),
[efer_lme] "i"(MSR_EFER_LME),