boot.zig
1 const builtin = @import("builtin"); 2 const config = @import("options").config; 3 4 const RiscvBootInfo = @import("riscv/BootInfo.zig"); 5 6 /// Info provided at boot. 7 pub const Info = switch (builtin.cpu.arch) { 8 .riscv64, .riscv32 => if (config.riscv.standard_args) RiscvBootInfo else RiscvBootInfo.Embedded, 9 else => @compileError("Unsupported architecture"), 10 }; 11 12 const main = @import("main.zig").main; 13 14 /// Prepare the correct state for the kernel to run. 15 pub fn setup(info: Info) void { 16 var bss_start = @extern([*]u8, .{ .name = "__bss_start" }); 17 const bss_end: usize = @intFromPtr(@extern(*u8, .{ .name = "__bss_end" })); 18 19 const bss = bss_start[0 .. bss_end - (@as(usize, @intFromPtr(bss_start)))]; 20 21 @memset(bss, 0); 22 23 main(info) catch |err| @panic(@errorName(err)); 24 }