| 1 |
//! File Protocol |
| 2 |
//! |
| 3 |
//! Provides an interface to interact with both files and directories. This protocol is typically |
| 4 |
//! obtained via an EFI_SIMPLE_FILE_SYSTEM protocol or via another EFI_FILE_PROTOCOL. |
| 5 |
|
| 6 |
pub const REVISION: u64 = 0x0000_0000_0001_0000u64; |
| 7 |
pub const REVISION2: u64 = 0x0000_0000_0002_0000u64; |
| 8 |
pub const LATEST_REVISION: u64 = REVISION2; |
| 9 |
|
| 10 |
pub const MODE_READ: u64 = 0x0000000000000001u64; |
| 11 |
pub const MODE_WRITE: u64 = 0x0000000000000002u64; |
| 12 |
pub const MODE_CREATE: u64 = 0x8000000000000000u64; |
| 13 |
|
| 14 |
pub const READ_ONLY: u64 = 0x0000000000000001u64; |
| 15 |
pub const HIDDEN: u64 = 0x0000000000000002u64; |
| 16 |
pub const SYSTEM: u64 = 0x0000000000000004u64; |
| 17 |
pub const RESERVED: u64 = 0x0000000000000008u64; |
| 18 |
pub const DIRECTORY: u64 = 0x0000000000000010u64; |
| 19 |
pub const ARCHIVE: u64 = 0x0000000000000020u64; |
| 20 |
pub const VALID_ATTR: u64 = 0x0000000000000037u64; |
| 21 |
|
| 22 |
pub const INFO_ID: crate::base::Guid = crate::base::Guid::from_fields( |
| 23 |
0x09576e92, |
| 24 |
0x6d3f, |
| 25 |
0x11d2, |
| 26 |
0x8e, |
| 27 |
0x39, |
| 28 |
&[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], |
| 29 |
); |
| 30 |
pub const SYSTEM_INFO_ID: crate::base::Guid = crate::base::Guid::from_fields( |
| 31 |
0x09576e93, |
| 32 |
0x6d3f, |
| 33 |
0x11d2, |
| 34 |
0x8e, |
| 35 |
0x39, |
| 36 |
&[0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b], |
| 37 |
); |
| 38 |
pub const SYSTEM_VOLUME_LABEL_ID: crate::base::Guid = crate::base::Guid::from_fields( |
| 39 |
0xdb47d7d3, |
| 40 |
0xfe81, |
| 41 |
0x11d3, |
| 42 |
0x9a, |
| 43 |
0x35, |
| 44 |
&[0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d], |
| 45 |
); |
| 46 |
|
| 47 |
#[repr(C)] |
| 48 |
#[derive(Clone, Copy, Debug)] |
| 49 |
pub struct IoToken { |
| 50 |
pub event: crate::base::Event, |
| 51 |
pub status: crate::base::Status, |
| 52 |
pub buffer_size: usize, |
| 53 |
pub buffer: *mut core::ffi::c_void, |
| 54 |
} |
| 55 |
|
| 56 |
#[repr(C)] |
| 57 |
#[derive(Clone, Copy, Debug)] |
| 58 |
pub struct Info<const N: usize = 0> { |
| 59 |
pub size: u64, |
| 60 |
pub file_size: u64, |
| 61 |
pub physical_size: u64, |
| 62 |
pub create_time: crate::system::Time, |
| 63 |
pub last_access_time: crate::system::Time, |
| 64 |
pub modification_time: crate::system::Time, |
| 65 |
pub attribute: u64, |
| 66 |
pub file_name: [crate::base::Char16; N], |
| 67 |
} |
| 68 |
|
| 69 |
#[repr(C)] |
| 70 |
#[derive(Clone, Copy, Debug)] |
| 71 |
pub struct SystemInfo<const N: usize = 0> { |
| 72 |
pub size: u64, |
| 73 |
pub read_only: crate::base::Boolean, |
| 74 |
pub volume_size: u64, |
| 75 |
pub free_space: u64, |
| 76 |
pub block_size: u32, |
| 77 |
pub volume_label: [crate::base::Char16; N], |
| 78 |
} |
| 79 |
|
| 80 |
#[repr(C)] |
| 81 |
#[derive(Clone, Copy, Debug)] |
| 82 |
pub struct SystemVolumeLabel<const N: usize = 0> { |
| 83 |
pub volume_label: [crate::base::Char16; N], |
| 84 |
} |
| 85 |
|
| 86 |
pub type ProtocolOpen = eficall! {fn( |
| 87 |
*mut Protocol, |
| 88 |
*mut *mut Protocol, |
| 89 |
*mut crate::base::Char16, |
| 90 |
u64, |
| 91 |
u64, |
| 92 |
) -> crate::base::Status}; |
| 93 |
|
| 94 |
pub type ProtocolClose = eficall! {fn( |
| 95 |
*mut Protocol, |
| 96 |
) -> crate::base::Status}; |
| 97 |
|
| 98 |
pub type ProtocolDelete = eficall! {fn( |
| 99 |
*mut Protocol, |
| 100 |
) -> crate::base::Status}; |
| 101 |
|
| 102 |
pub type ProtocolRead = eficall! {fn( |
| 103 |
*mut Protocol, |
| 104 |
*mut usize, |
| 105 |
*mut core::ffi::c_void, |
| 106 |
) -> crate::base::Status}; |
| 107 |
|
| 108 |
pub type ProtocolWrite = eficall! {fn( |
| 109 |
*mut Protocol, |
| 110 |
*mut usize, |
| 111 |
*mut core::ffi::c_void, |
| 112 |
) -> crate::base::Status}; |
| 113 |
|
| 114 |
pub type ProtocolGetPosition = eficall! {fn( |
| 115 |
*mut Protocol, |
| 116 |
*mut u64, |
| 117 |
) -> crate::base::Status}; |
| 118 |
|
| 119 |
pub type ProtocolSetPosition = eficall! {fn( |
| 120 |
*mut Protocol, |
| 121 |
u64, |
| 122 |
) -> crate::base::Status}; |
| 123 |
|
| 124 |
pub type ProtocolGetInfo = eficall! {fn( |
| 125 |
*mut Protocol, |
| 126 |
*mut crate::base::Guid, |
| 127 |
*mut usize, |
| 128 |
*mut core::ffi::c_void, |
| 129 |
) -> crate::base::Status}; |
| 130 |
|
| 131 |
pub type ProtocolSetInfo = eficall! {fn( |
| 132 |
*mut Protocol, |
| 133 |
*mut crate::base::Guid, |
| 134 |
usize, |
| 135 |
*mut core::ffi::c_void, |
| 136 |
) -> crate::base::Status}; |
| 137 |
|
| 138 |
pub type ProtocolFlush = eficall! {fn( |
| 139 |
*mut Protocol, |
| 140 |
) -> crate::base::Status}; |
| 141 |
|
| 142 |
pub type ProtocolOpenEx = eficall! {fn( |
| 143 |
*mut Protocol, |
| 144 |
*mut *mut Protocol, |
| 145 |
*mut crate::base::Char16, |
| 146 |
u64, |
| 147 |
u64, |
| 148 |
*mut IoToken, |
| 149 |
) -> crate::base::Status}; |
| 150 |
|
| 151 |
pub type ProtocolReadEx = eficall! {fn( |
| 152 |
*mut Protocol, |
| 153 |
*mut IoToken, |
| 154 |
) -> crate::base::Status}; |
| 155 |
|
| 156 |
pub type ProtocolWriteEx = eficall! {fn( |
| 157 |
*mut Protocol, |
| 158 |
*mut IoToken, |
| 159 |
) -> crate::base::Status}; |
| 160 |
|
| 161 |
pub type ProtocolFlushEx = eficall! {fn( |
| 162 |
*mut Protocol, |
| 163 |
*mut IoToken, |
| 164 |
) -> crate::base::Status}; |
| 165 |
|
| 166 |
#[repr(C)] |
| 167 |
pub struct Protocol { |
| 168 |
pub revision: u64, |
| 169 |
pub open: ProtocolOpen, |
| 170 |
pub close: ProtocolClose, |
| 171 |
pub delete: ProtocolDelete, |
| 172 |
pub read: ProtocolRead, |
| 173 |
pub write: ProtocolWrite, |
| 174 |
pub get_position: ProtocolGetPosition, |
| 175 |
pub set_position: ProtocolSetPosition, |
| 176 |
pub get_info: ProtocolGetInfo, |
| 177 |
pub set_info: ProtocolSetInfo, |
| 178 |
pub flush: ProtocolFlush, |
| 179 |
pub open_ex: ProtocolOpenEx, |
| 180 |
pub read_ex: ProtocolReadEx, |
| 181 |
pub write_ex: ProtocolWriteEx, |
| 182 |
pub flush_ex: ProtocolFlushEx, |
| 183 |
} |