| 1 | const std = @import("std"); |
| 2 | const uefi = std.os.uefi; |
| 3 | const Guid = uefi.Guid; |
| 4 | const Handle = uefi.Handle; |
| 5 | const Status = uefi.Status; |
| 6 | const SystemTable = uefi.tables.SystemTable; |
| 7 | const MemoryType = uefi.tables.MemoryType; |
| 8 | const DevicePath = uefi.protocol.DevicePath; |
| 9 | const cc = uefi.cc; |
| 10 | |
| 11 | pub const LoadedImage = extern struct { |
| 12 | revision: u32, |
| 13 | parent_handle: Handle, |
| 14 | system_table: *SystemTable, |
| 15 | device_handle: ?Handle, |
| 16 | file_path: *DevicePath, |
| 17 | reserved: *anyopaque, |
| 18 | load_options_size: u32, |
| 19 | load_options: ?*anyopaque, |
| 20 | image_base: [*]u8, |
| 21 | image_size: u64, |
| 22 | image_code_type: MemoryType, |
| 23 | image_data_type: MemoryType, |
| 24 | _unload: *const fn (*LoadedImage, Handle) callconv(cc) Status, |
| 25 | |
| 26 | pub const UnloadError = uefi.UnexpectedError || error{InvalidParameter}; |
| 27 | |
| 28 | /// Unloads an image from memory. |
| 29 | pub fn unload(self: *LoadedImage, handle: Handle) UnloadError!void { |
| 30 | switch (self._unload(self, handle)) { |
| 31 | .success => {}, |
| 32 | .invalid_parameter => return error.InvalidParameter, |
| 33 | else => |status| return uefi.unexpectedStatus(status), |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | pub const guid align(8) = Guid{ |
| 38 | .time_low = 0x5b1b31a1, |
| 39 | .time_mid = 0x9562, |
| 40 | .time_high_and_version = 0x11d2, |
| 41 | .clock_seq_high_and_reserved = 0x8e, |
| 42 | .clock_seq_low = 0x3f, |
| 43 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, |
| 44 | }; |
| 45 | |
| 46 | pub const device_path_guid align(8) = Guid{ |
| 47 | .time_low = 0xbc62157e, |
| 48 | .time_mid = 0x3e33, |
| 49 | .time_high_and_version = 0x4fec, |
| 50 | .clock_seq_high_and_reserved = 0x99, |
| 51 | .clock_seq_low = 0x20, |
| 52 | .node = [_]u8{ 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf }, |
| 53 | }; |
| 54 | }; |