mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
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:
+8
-2
@@ -1,3 +1,6 @@
|
||||
//! Kernel initialization.
|
||||
|
||||
const config = @import("config");
|
||||
const std = @import("std");
|
||||
const r = @import("root");
|
||||
const pl = r.pl;
|
||||
@@ -6,7 +9,6 @@ const arch = r.arch;
|
||||
const kep = ke.private;
|
||||
const ex = r.ex;
|
||||
const bv = r.bv;
|
||||
const config = @import("config");
|
||||
|
||||
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
|
||||
// our idle thread. At this point we're already running on the kernel stack.
|
||||
thread0.init(.{
|
||||
.stack = boot_info.kernel_stack + boot_info.kernel_stack_size,
|
||||
.stack = 0,
|
||||
.priority = .IdleThread,
|
||||
.entry = undefined,
|
||||
// Shouldn't block
|
||||
@@ -32,6 +34,10 @@ export fn kmain(boot_info: *r.BootInfo) callconv(.c) void {
|
||||
thread0.continuation = null;
|
||||
thread0.pinned = true;
|
||||
|
||||
thread0.context = .init_with_stack(
|
||||
boot_info.kernel_stack + boot_info.kernel_stack_size,
|
||||
);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -81,8 +81,6 @@ fn cmp_entries(ctx: void, a: Entry, b: Entry) bool {
|
||||
return a.base < b.base;
|
||||
}
|
||||
|
||||
var bootstrap_stack: [4096]u8 = undefined;
|
||||
|
||||
pub fn loader_main(kernel: *anyopaque) void {
|
||||
r.arch.init();
|
||||
r.mem.init();
|
||||
@@ -105,6 +103,6 @@ pub fn loader_main(kernel: *anyopaque) void {
|
||||
jump_to_kernel(
|
||||
@intFromPtr(&r.loader_info),
|
||||
entry,
|
||||
@intFromPtr(&bootstrap_stack) + bootstrap_stack.len,
|
||||
stack + stack_size,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user