loader: pass more things to the kernel

This commit is contained in:
Loïc Grégoire
2026-10-04 11:11:25 -04:00
parent 72ff4882e8
commit cbe823ce6e
4 changed files with 16 additions and 1 deletions
+1
View File
@@ -748,4 +748,5 @@ pub const IdtEntry = extern struct {
pub const BootInfo = struct {
cpu_features: CpuFeatures,
hypervisor_info: ?hypervisor.Info,
};
+1
View File
@@ -109,6 +109,7 @@ extern var __percpu_start: u8;
pub fn early_init() linksection(r.init) void {
amd64.cpu_features = r.boot_info.arch_info.cpu_features;
amd64.hypervisor.info = r.boot_info.arch_info.hypervisor_info;
early_cpu_init();
impl.cpu_offsets = &initial_offsets;
+1
View File
@@ -114,4 +114,5 @@ pub fn debug_write(c: u8) void {
pub fn init() void {
amd64.detect_cpu_features();
r.loader_info.arch_info.cpu_features = amd64.cpu_features;
r.loader_info.arch_info.hypervisor_info = amd64.hypervisor.info;
}
+13 -1
View File
@@ -62,6 +62,8 @@ pub fn get_image_layout() r.ImageLayout {
};
}
var cmdline: [256]u8 = undefined;
export fn loader_entry() callconv(.c) void {
var kernel: ?*anyopaque = null;
var module_start: usize = 0;
@@ -148,7 +150,17 @@ export fn loader_entry() callconv(.c) void {
}
if (cmdline_request.response) |resp| {
r.loader_info.cmdline = std.mem.span(resp.cmdline);
if (resp.cmdline) |c| {
const span = std.mem.span(c);
if (span.len > cmdline.len) {
r.loader_info.cmdline = "TOOLONG";
} else {
std.mem.copyForwards(u8, &cmdline, span);
r.loader_info.cmdline = cmdline[0..span.len];
}
} else {
r.loader_info.cmdline = &.{};
}
}
r.main(kernel.?);