mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
loader: pass more things to the kernel
This commit is contained in:
@@ -748,4 +748,5 @@ pub const IdtEntry = extern struct {
|
|||||||
|
|
||||||
pub const BootInfo = struct {
|
pub const BootInfo = struct {
|
||||||
cpu_features: CpuFeatures,
|
cpu_features: CpuFeatures,
|
||||||
|
hypervisor_info: ?hypervisor.Info,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ extern var __percpu_start: u8;
|
|||||||
|
|
||||||
pub fn early_init() linksection(r.init) void {
|
pub fn early_init() linksection(r.init) void {
|
||||||
amd64.cpu_features = r.boot_info.arch_info.cpu_features;
|
amd64.cpu_features = r.boot_info.arch_info.cpu_features;
|
||||||
|
amd64.hypervisor.info = r.boot_info.arch_info.hypervisor_info;
|
||||||
early_cpu_init();
|
early_cpu_init();
|
||||||
|
|
||||||
impl.cpu_offsets = &initial_offsets;
|
impl.cpu_offsets = &initial_offsets;
|
||||||
|
|||||||
@@ -114,4 +114,5 @@ pub fn debug_write(c: u8) void {
|
|||||||
pub fn init() void {
|
pub fn init() void {
|
||||||
amd64.detect_cpu_features();
|
amd64.detect_cpu_features();
|
||||||
r.loader_info.arch_info.cpu_features = amd64.cpu_features;
|
r.loader_info.arch_info.cpu_features = amd64.cpu_features;
|
||||||
|
r.loader_info.arch_info.hypervisor_info = amd64.hypervisor.info;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ pub fn get_image_layout() r.ImageLayout {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cmdline: [256]u8 = undefined;
|
||||||
|
|
||||||
export fn loader_entry() callconv(.c) void {
|
export fn loader_entry() callconv(.c) void {
|
||||||
var kernel: ?*anyopaque = null;
|
var kernel: ?*anyopaque = null;
|
||||||
var module_start: usize = 0;
|
var module_start: usize = 0;
|
||||||
@@ -148,7 +150,17 @@ export fn loader_entry() callconv(.c) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmdline_request.response) |resp| {
|
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.?);
|
r.main(kernel.?);
|
||||||
|
|||||||
Reference in New Issue
Block a user