Basic physical memory management

This commit is contained in:
2025-03-17 13:36:49 +02:00
parent aeb5950e56
commit 4437a66025
10 changed files with 344 additions and 57 deletions
+6 -5
View File
@@ -8,15 +8,15 @@ pub const thread = @import("thread.zig");
pub const log = debug.log;
pub const vmm = mem.vmm;
pub const TRACE_PHYSICAL_ALLOCATOR: bool = false;
const std = @import("std");
fn f0(arg: usize) callconv(.C) noreturn {
log.write("\x1B[2J", .{});
var c: usize = 0;
while (true) {
f1(arg, c);
c += 1;
thread.yield();
}
}
@@ -28,7 +28,8 @@ pub export fn kernel_main() callconv(.C) noreturn {
var a = arena.Arena.setup(256 * 0x1000) orelse @panic("Could not setup kernel arena");
const pc = @intFromPtr(&f0);
for (0..8) |i| {
// log.write("\x1B[2J", .{});
for (0..32) |i| {
const t = thread.Thread.create(&a, pc, i);
thread.addThread(t);
}
@@ -44,8 +45,8 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, retu
const ra = return_address orelse @returnAddress();
log.err("!!! Kernel panic !!!", .{});
log.err(" Reason: {s}", .{ msg });
log.err(" At: 0x{x}", .{ ra });
log.err(" Reason: {s}", .{msg});
log.err(" At: 0x{x}", .{ra});
arch.halt();
}