ke: rework kernel initialization

This commit is contained in:
Loïc Grégoire
2026-08-05 16:10:37 -04:00
parent 4aaae63349
commit 2a09642f4d
11 changed files with 58 additions and 31 deletions
+5 -1
View File
@@ -26,6 +26,7 @@ const ThreadFrame = extern struct {
extern fn asm_thread_entry() void;
extern fn do_context_switch(old: *ThreadContext, new: *ThreadContext, lock: *u8, switching: *bool) callconv(.c) void;
extern fn do_context_load(td: *ThreadContext) callconv(.c) void;
pub const ThreadContext = extern struct {
rsp: u64 align(1),
@@ -35,7 +36,6 @@ pub const ThreadContext = extern struct {
const entry_fn: *const fn (?*anyopaque) void = @ptrFromInt(entry);
ke.ipl.lower(.Passive);
entry_fn(@ptrFromInt(arg));
// TODO: This shouldn't be reached!!!
}
pub fn init(stack: r.VAddr, stack_size: usize, entry: *const fn (?*anyopaque) void, arg: ?*anyopaque) @This() {
@@ -62,6 +62,10 @@ pub const ThreadContext = extern struct {
const thread: *ke.Thread = @alignCast(@fieldParentPtr("context", self));
do_context_switch(self, new, &thread.lock.inner.locked.raw, &thread.switching.raw);
}
pub fn load(self: *ThreadContext) callconv(.c) void {
do_context_load(self);
}
};
inline fn percpu_ptr_for(variable: anytype, cpu: u32) @TypeOf(variable) {