mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-28 22:18:22 +00:00
all: use root boot info pointer
This commit is contained in:
+2
-2
@@ -13,10 +13,10 @@ const fbconsole = @import("../dev/fbconsole.zig");
|
||||
|
||||
export fn kmain(boot_info: *r.BootInfo) callconv(.c) void {
|
||||
ke.init(boot_info);
|
||||
mm.init(boot_info);
|
||||
mm.init();
|
||||
ps.init();
|
||||
|
||||
pl.late_init(boot_info);
|
||||
pl.late_init();
|
||||
mm.late_init();
|
||||
ke.sched.late_init();
|
||||
exp.workqueue.init() catch @panic("e");
|
||||
|
||||
+2
-3
@@ -11,12 +11,11 @@ var stack: [r.kib(16)]u8 align(16) = undefined;
|
||||
|
||||
pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
r.boot_info = boot_info;
|
||||
|
||||
ke.ncpus = 1;
|
||||
ki.impl.early_init();
|
||||
ki.tunable.init(boot_info);
|
||||
ki.tunable.init();
|
||||
std.log.info("Welcome to the machine", .{});
|
||||
pl.early_init(boot_info);
|
||||
pl.early_init();
|
||||
ki.log.init();
|
||||
ki.cpu.init_cpu(0);
|
||||
ki.turnstile.init_turnstiles();
|
||||
|
||||
@@ -42,8 +42,8 @@ pub fn Tunable(comptime T: type, comptime default: T, comptime name: []const u8)
|
||||
};
|
||||
}
|
||||
|
||||
pub fn init(boot_info: *r.BootInfo) void {
|
||||
const cmdline = boot_info.cmdline orelse return;
|
||||
pub fn init() void {
|
||||
const cmdline = r.boot_info.cmdline orelse return;
|
||||
|
||||
const elems = set.elems();
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ const mm = r.mm;
|
||||
const mi = mm.private;
|
||||
const config = @import("config");
|
||||
|
||||
pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
mi.phys.init(boot_info);
|
||||
pub fn init() linksection(r.init) void {
|
||||
mi.phys.init();
|
||||
mi.zone.early_init();
|
||||
mi.vmem.init();
|
||||
mi.heap.init();
|
||||
|
||||
+14
-7
@@ -139,16 +139,16 @@ pub fn free_batch(head: *mm.Page, tail: *mm.Page, count: usize) void {
|
||||
list_lock.release(ipl);
|
||||
}
|
||||
|
||||
pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
memory_map = &boot_info.memory_map;
|
||||
pub fn init() linksection(r.init) void {
|
||||
memory_map = &r.boot_info.memory_map;
|
||||
free_list.init();
|
||||
free_page_event.init(.Notification);
|
||||
|
||||
var total_usable_memory: usize = boot_info.memory_map.loader_memory_used;
|
||||
var total_usable_memory: usize = memory_map.loader_memory_used;
|
||||
log.info("physical memory map:", .{});
|
||||
|
||||
for (0..boot_info.memory_map.entry_count) |i| {
|
||||
const entry = boot_info.memory_map.entries[i];
|
||||
for (0..memory_map.entry_count) |i| {
|
||||
const entry = memory_map.entries[i];
|
||||
|
||||
log.info("[{x:0>16}-{x:0>16}] {s}", .{ entry.base, entry.base + entry.size, @tagName(entry.type) });
|
||||
|
||||
@@ -157,7 +157,9 @@ pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
}
|
||||
}
|
||||
|
||||
const pfndb_size_required = @sizeOf(mm.Page) * (std.math.divCeil(usize, total_usable_memory, mm.page_size) catch unreachable);
|
||||
const pfndb_size_required = @sizeOf(mm.Page) *
|
||||
(std.math.divCeil(usize, total_usable_memory, mm.page_size) catch unreachable);
|
||||
|
||||
log.info("using {} KiB for pfndb ({} bytes per page)", .{ pfndb_size_required / 1024, @sizeOf(mm.Page) });
|
||||
|
||||
// Get the kernel pagemap from the loader,
|
||||
@@ -168,7 +170,12 @@ pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
// this formula is from Linux and does not grow linearly; it would be wasteful
|
||||
// to take a fixed percentage of memory from a large server.
|
||||
// We clamp this between 128 KiB and 256 MiB.
|
||||
const min_free_kb = std.math.clamp(std.math.sqrt((usable_memory.load(.monotonic) / 1024) * 16), 128, 256 * 1024);
|
||||
const min_free_kb = std.math.clamp(
|
||||
std.math.sqrt((usable_memory.load(.monotonic) / 1024) * 16),
|
||||
128,
|
||||
256 * 1024,
|
||||
);
|
||||
|
||||
min_memory_threshold = min_free_kb / 4;
|
||||
|
||||
const total_usable_pages = total_usable_memory / mm.page_size;
|
||||
|
||||
@@ -322,8 +322,8 @@ fn enumerate_tables() void {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
const rsdp_addr = boot_info.rsdp orelse return;
|
||||
pub fn init() linksection(r.init) void {
|
||||
const rsdp_addr = r.boot_info.rsdp orelse return;
|
||||
|
||||
const rsdp: *Rsdp = @ptrFromInt(rsdp_addr);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ fn com1_write(c: u8) void {
|
||||
amd64.outb(com1, c);
|
||||
}
|
||||
|
||||
pub fn early_init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
pub fn early_init() linksection(r.init) void {
|
||||
com1_init();
|
||||
|
||||
const f = amd64.cpu_features;
|
||||
@@ -58,7 +58,6 @@ pub fn early_init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
if (amd64.hypervisor.info) |h| {
|
||||
log.info("running on hypervisor {s}", .{@tagName(h.vendor)});
|
||||
}
|
||||
_ = boot_info;
|
||||
}
|
||||
|
||||
fn init_hypervisor(hv: amd64.hypervisor.Info) void {
|
||||
@@ -79,12 +78,12 @@ pub fn init_ap() void {
|
||||
apic.init_local();
|
||||
}
|
||||
|
||||
pub fn late_init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
pub fn late_init() linksection(r.init) void {
|
||||
if (amd64.hypervisor.info) |hv| {
|
||||
init_hypervisor(hv);
|
||||
}
|
||||
|
||||
pl.acpi.init(boot_info);
|
||||
pl.acpi.init();
|
||||
|
||||
tsc.init();
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ pub const impl = switch (config.arch) {
|
||||
pub const acpi = @import("acpi/root.zig");
|
||||
|
||||
/// Early platform-specific initialization, called before anything else.
|
||||
pub inline fn early_init(boot_info: *r.BootInfo) void {
|
||||
return impl.early_init(boot_info);
|
||||
pub inline fn early_init() void {
|
||||
return impl.early_init();
|
||||
}
|
||||
|
||||
/// Late platform init. Memory allocator is available at this point.
|
||||
/// SMP bringup must be done after this returns.
|
||||
pub inline fn late_init(boot_info: *r.BootInfo) void {
|
||||
return impl.late_init(boot_info);
|
||||
pub inline fn late_init() void {
|
||||
return impl.late_init();
|
||||
}
|
||||
|
||||
/// Write a single character to the debug console.
|
||||
|
||||
Reference in New Issue
Block a user