| ... | ... | @@ -0,0 +1,87 @@ |
| 1 | const uefi = @import("std").os.uefi; |
| 2 | const Guid = uefi.Guid; |
| 3 | const Time = uefi.Time; |
| 4 | |
| 5 | const FileProtocol = extern struct { |
| 6 | revision: u64, |
| 7 | _open: extern fn (*const FileProtocol, **const FileProtocol, *u16, u64, u64) usize, |
| 8 | _close: extern fn (*const FileProtocol) usize, |
| 9 | _delete: extern fn (*const FileProtocol) usize, |
| 10 | _read: extern fn (*const FileProtocol, *usize, *c_void) usize, |
| 11 | _write: extern fn (*const FileProtocol, *usize, *c_void) usize, |
| 12 | _get_info: extern fn (*const FileProtocol, *Guid, *usize, *c_void) usize, |
| 13 | _set_info: extern fn (*const FileProtocol, *Guid, usize, *c_void) usize, |
| 14 | _flush: extern fn (*const FileProtocol) usize, |
| 15 | |
| 16 | pub fn open(self: *const FileProtocol, new_handle: **const FileProtocol, file_name: *u16, open_mode: u64, attributes: u64) usize { |
| 17 | return self._open(self, new_handle, file_name, open_mode, attributes); |
| 18 | } |
| 19 | |
| 20 | pub fn close(self: *const FileProtocol) usize { |
| 21 | return self._close(self); |
| 22 | } |
| 23 | |
| 24 | pub fn delete(self: *const FileProtocol) usize { |
| 25 | return self._delete(self); |
| 26 | } |
| 27 | |
| 28 | pub fn read(self: *const FileProtocol, buffer_size: *usize, buffer: *c_void) usize { |
| 29 | return self._read(self, buffer_size, buffer); |
| 30 | } |
| 31 | |
| 32 | pub fn write(self: *const FileProtocol, buffer_size: *usize, buffer: *c_void) usize { |
| 33 | return self._write(self, buffer_size, buffer); |
| 34 | } |
| 35 | |
| 36 | pub fn get_info(self: *const FileProtocol, information_type: *Guid, buffer_size: *usize, buffer: *c_void) usize { |
| 37 | return self._get_info(self, information_type, buffer_size, buffer); |
| 38 | } |
| 39 | |
| 40 | pub fn set_info(self: *const FileProtocol, information_type: *Guid, buffer_size: usize, buffer: *c_void) usize { |
| 41 | return self._set_info(self, information_type, buffer_size, buffer); |
| 42 | } |
| 43 | |
| 44 | pub fn flush(self: *const FileProtocol) usize { |
| 45 | return self._flush(self); |
| 46 | } |
| 47 | |
| 48 | pub const guid align(8) = Guid{ |
| 49 | .time_low = 0x09576e92, |
| 50 | .time_mid = 0x6d3f, |
| 51 | .time_high_and_version = 0x11d2, |
| 52 | .clock_seq_high_and_reserved = 0x8e, |
| 53 | .clock_seq_low = 0x39, |
| 54 | .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }, |
| 55 | }; |
| 56 | |
| 57 | pub const efi_file_mode_read: u64 = 0x0000000000000001; |
| 58 | pub const efi_file_mode_write: u64 = 0x0000000000000002; |
| 59 | pub const efi_file_mode_create: u64 = 0x8000000000000000; |
| 60 | |
| 61 | pub const efi_file_read_only: u64 = 0x0000000000000001; |
| 62 | pub const efi_file_hidden: u64 = 0x0000000000000002; |
| 63 | pub const efi_file_system: u64 = 0x0000000000000004; |
| 64 | pub const efi_file_reserved: u64 = 0x0000000000000008; |
| 65 | pub const efi_file_directory: u64 = 0x0000000000000010; |
| 66 | pub const efi_file_archive: u64 = 0x0000000000000020; |
| 67 | pub const efi_file_valid_attr: u64 = 0x0000000000000037; |
| 68 | }; |
| 69 | |
| 70 | const FileInfo = extern struct { |
| 71 | size: u64, |
| 72 | file_size: u64, |
| 73 | physical_size: u64, |
| 74 | create_time: Time, |
| 75 | last_access_time: Time, |
| 76 | modification_time: Time, |
| 77 | attribute: u64, |
| 78 | file_name: [100:0]u16, |
| 79 | |
| 80 | pub const efi_file_read_only: u64 = 0x0000000000000001; |
| 81 | pub const efi_file_hidden: u64 = 0x0000000000000002; |
| 82 | pub const efi_file_system: u64 = 0x0000000000000004; |
| 83 | pub const efi_file_reserved: u64 = 0x0000000000000008; |
| 84 | pub const efi_file_directory: u64 = 0x0000000000000010; |
| 85 | pub const efi_file_archive: u64 = 0x0000000000000020; |
| 86 | pub const efi_file_valid_attr: u64 = 0x0000000000000037; |
| 87 | }; |