lumine
UEFI x86_64 bootloader for linux kernel images
src/boot/linux/Kernel.zig
891 bytes raw
1const std = @import("std");
2const uefi = std.os.uefi;
3const log = std.log;
4
5const Chainload = @import("../Chainload.zig");
6
7const luefi = @import("../../luefi.zig");
8const Path = @import("../../Config.zig").Path;
9
10const Kernel = @This();
11
12chainload: Chainload,
13
14pub fn load(path: Path) !Kernel {
15 log.info("loading kernel {f}", .{path});
16 return .{ .chainload = try .load(path) };
17}
18
19pub fn deinit(self: Kernel) void {
20 self.chainload.deinit();
21}
22
23pub fn start(self: Kernel, cmdline: []const u8) !uefi.Status {
24 const allocator = uefi.pool_allocator;
25
26 const cmdline_utf16 = try std.unicode.utf8ToUtf16LeAllocZ(allocator, cmdline);
27 defer allocator.free(cmdline_utf16);
28
29 self.chainload.img_loaded.load_options = @ptrCast(cmdline_utf16);
30 self.chainload.img_loaded.load_options_size = @intCast(cmdline_utf16.len * @sizeOf(u16));
31
32 return self.chainload.start();
33}