rework entry point

This commit is contained in:
Loïc Grégoire
2026-07-17 21:26:13 -04:00
parent a79c7a07cb
commit 3c72101228
7 changed files with 8 additions and 25 deletions
+2 -1
View File
@@ -11,7 +11,8 @@ const rtl = @import("rtl");
// XXX
const fbconsole = @import("../dev/fbconsole.zig");
pub fn init(boot_info: *r.BootInfo) void {
export fn kmain(boot_info: *r.BootInfo) callconv(.c) void {
ke.init(boot_info);
mm.init(boot_info);
ps.init();
-16
View File
@@ -1,16 +0,0 @@
const std = @import("std");
const r = @import("root");
const pl = r.pl;
const ke = r.ke;
const ki = ke.private;
pub const std_options = r.std_options;
pub const panic = r.panic;
export fn kmain(info: *r.BootInfo) callconv(.c) void {
ke.ncpus = 1;
ki.init(info);
}
+1 -2
View File
@@ -10,6 +10,7 @@ var thread0: ke.Thread = undefined;
var stack: [r.kib(16)]u8 align(16) = undefined;
pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
ke.ncpus = 1;
ki.impl.early_init();
ki.tunable.init(boot_info);
std.log.info("Welcome to the machine", .{});
@@ -27,6 +28,4 @@ pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
ki.sched.percpu.local().current_thread = &thread0;
std.log.info("Zag for {s} ({s}), cmdline is \"{?s}\"", .{ pl.name, arch.name, boot_info.cmdline });
ex.private.init(boot_info);
}
+1
View File
@@ -24,6 +24,7 @@ pub const Tunable = p.tunable.Tunable;
// === Exported Interfaces ===
pub const panic = p.panic.panic;
pub const init = p.init;
pub const ipl = struct {
pub const raise = p.ipl.raise;
+2 -2
View File
@@ -57,8 +57,8 @@ extern fn jump_to_kernel(loader_info: usize, stack: usize, entry: usize) void;
pub fn loader_main(kernel: *anyopaque) void {
r.mem.init();
const entry = load_kernel(kernel);
const stack = r.mem.alloc(1024 * 32);
const stack = r.mem.alloc(1024 * 16);
std.log.info("jumping to {x} with stack {x}", .{ entry, stack });
jump_to_kernel(@intFromPtr(&r.loader_info), stack + (1024 * 32), entry);
jump_to_kernel(@intFromPtr(&r.loader_info), stack + (1024 * 16), entry);
}
+1 -3
View File
@@ -17,9 +17,7 @@ pub var tsc_timer: ke.TimeCounter = .{
};
pub fn init() linksection(r.init) void {
const features = amd64.cpu_features;
if (!features.invariant_tsc) {
if (!amd64.cpu_features.invariant_tsc) {
log.info("invariant TSC not supported (get a new PC), using fallback", .{});
if (ke.time.best()) |best| {
log.info("using {s} as timecounter source", .{best.name});
+1 -1
View File
@@ -60,5 +60,5 @@ pub const panic = std.debug.FullPanic(ke.panic);
comptime {
// Ensure the entry point is linked in.
_ = @import("kern/entry.zig");
_ = @import("ex/init.zig");
}