initial commit

This commit is contained in:
Loïc Grégoire
2026-03-21 22:46:54 -04:00
parent cf7df37498
commit 9e065ee023
45 changed files with 4430 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
const std = @import("std");
const b = @import("base");
const pl = b.pl;
const ke = b.ke;
const ki = ke.private;
var thread0: ke.Thread = undefined;
fn idle(_: ?*anyopaque) void {
while (true) {
std.atomic.spinLoopHint();
}
}
var stack: [8192]u8 align(16) = undefined;
fn handler(_: ?*anyopaque) void {
std.log.info("Hi! CPU {}", .{ke.curcpu().id});
while (true) {}
}
fn make_thread(entry: *const fn (?*anyopaque) void, td: *ke.Thread) void {
const _stack = std.heap.page_allocator.alloc(u8, 16384) catch @panic("wtf");
td.init(@intFromPtr(_stack.ptr), 16384, entry, null);
}
var threads: [10]ke.Thread = undefined;
pub fn init(boot_info: *pl.BootInfo) linksection(b.init) void {
pl.early_init();
ki.bootstrap_cpu.init(&thread0);
thread0.init(@intFromPtr(&stack), 8192, idle, null);
thread0.priority = 0;
thread0.priority_class = .Idle;
std.log.info("hello, world", .{});
std.log.info("Zag for {s}, cmdline is {?s}", .{ pl.name, boot_info.cmdline });
pl.late_init();
_ = ke.ipl.raise(.Dispatch);
for (0..10) |i| {
make_thread(handler, &threads[i]);
ke.sched.enqueue(&threads[i]);
}
ke.ipl.lower(.Zero);
while (true) {}
}