ke+loader: rework kernel entry

oops, didn't test last commit on debug runs. Now this starts the kernel on its 16
kib stack.
This commit is contained in:
Loïc Grégoire
2026-10-05 13:03:16 -04:00
parent f53a596fb9
commit 5317cb54b4
2 changed files with 9 additions and 5 deletions
+8 -2
View File
@@ -1,3 +1,6 @@
//! Kernel initialization.
const config = @import("config");
const std = @import("std"); const std = @import("std");
const r = @import("root"); const r = @import("root");
const pl = r.pl; const pl = r.pl;
@@ -6,7 +9,6 @@ const arch = r.arch;
const kep = ke.private; const kep = ke.private;
const ex = r.ex; const ex = r.ex;
const bv = r.bv; const bv = r.bv;
const config = @import("config");
var thread0: ke.Thread = undefined; var thread0: ke.Thread = undefined;
@@ -22,7 +24,7 @@ export fn kmain(boot_info: *r.BootInfo) callconv(.c) void {
// Immediately initialize the context of what will eventually become // Immediately initialize the context of what will eventually become
// our idle thread. At this point we're already running on the kernel stack. // our idle thread. At this point we're already running on the kernel stack.
thread0.init(.{ thread0.init(.{
.stack = boot_info.kernel_stack + boot_info.kernel_stack_size, .stack = 0,
.priority = .IdleThread, .priority = .IdleThread,
.entry = undefined, .entry = undefined,
// Shouldn't block // Shouldn't block
@@ -32,6 +34,10 @@ export fn kmain(boot_info: *r.BootInfo) callconv(.c) void {
thread0.continuation = null; thread0.continuation = null;
thread0.pinned = true; thread0.pinned = true;
thread0.context = .init_with_stack(
boot_info.kernel_stack + boot_info.kernel_stack_size,
);
init(); init();
} }
+1 -3
View File
@@ -81,8 +81,6 @@ fn cmp_entries(ctx: void, a: Entry, b: Entry) bool {
return a.base < b.base; return a.base < b.base;
} }
var bootstrap_stack: [4096]u8 = undefined;
pub fn loader_main(kernel: *anyopaque) void { pub fn loader_main(kernel: *anyopaque) void {
r.arch.init(); r.arch.init();
r.mem.init(); r.mem.init();
@@ -105,6 +103,6 @@ pub fn loader_main(kernel: *anyopaque) void {
jump_to_kernel( jump_to_kernel(
@intFromPtr(&r.loader_info), @intFromPtr(&r.loader_info),
entry, entry,
@intFromPtr(&bootstrap_stack) + bootstrap_stack.len, stack + stack_size,
); );
} }