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