| 1 | const std = @import("std"); |
| 2 | const uefi = std.os.uefi; |
| 3 | const Guid = uefi.Guid; |
| 4 | const File = uefi.protocol.File; |
| 5 | const Status = uefi.Status; |
| 6 | const cc = uefi.cc; |
| 7 | |
| 8 | pub const SimpleFileSystem = extern struct { |
| 9 | revision: u64, |
| 10 | _open_volume: *const fn (*const SimpleFileSystem, **File) callconv(cc) Status, |
| 11 | |
| 12 | pub const OpenVolumeError = uefi.UnexpectedError || error{ |
| 13 | Unsupported, |
| 14 | NoMedia, |
| 15 | DeviceError, |
| 16 | VolumeCorrupted, |
| 17 | AccessDenied, |
| 18 | OutOfResources, |
| 19 | MediaChanged, |
| 20 | }; |
| 21 | |
| 22 | pub fn openVolume(self: *const SimpleFileSystem) OpenVolumeError!*File { |
| 23 | var root: *File = undefined; |
| 24 | switch (self._open_volume(self, &root)) { |
| 25 | .success => return root, |
| 26 | .unsupported => return error.Unsupported, |
| 27 | .no_media => return error.NoMedia, |
| 28 | .device_error => return error.DeviceError, |
| 29 | .volume_corrupted => return error.VolumeCorrupted, |
| 30 | .access_denied => return error.AccessDenied, |
| 31 | .out_of_resources => return error.OutOfResources, |
| 32 | .media_changed => return error.MediaChanged, |
| 33 | else => |status| return uefi.unexpectedStatus(status), |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | pub const guid align(8) = Guid{ |
| 38 | .time_low = 0x0964e5b22, |
| 39 | .time_mid = 0x6459, |
| 40 | .time_high_and_version = 0x11d2, |
| 41 | .clock_seq_high_and_reserved = 0x8e, |
| 42 | .clock_seq_low = 0x39, |
| 43 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, |
| 44 | }; |
| 45 | }; |