1use crate::time::Time;
4use crate::{guid, Char16, Event, Guid, Status};
5use bitflags::bitflags;
6use core::ffi::c_void;
7
8#[derive(Debug)]
9#[repr(C)]
10pub struct SimpleFileSystemProtocol {
11 pub revision: u64,
12 pub open_volume:
13 unsafe extern "efiapi" fn(this: *mut Self, root: *mut *mut FileProtocolV1) -> Status,
14}
15
16impl SimpleFileSystemProtocol {
17 pub const GUID: Guid = guid!("964e5b22-6459-11d2-8e39-00a0c969723b");
18}
19
20newtype_enum! {
21 pub enum FileProtocolRevision: u64 => {
22 REVISION_1 = 0x00010000,
23 REVISION_2 = 0x00020000,
24 }
25}
26
27#[derive(Debug)]
28#[repr(C)]
29pub struct FileProtocolV1 {
30 pub revision: FileProtocolRevision,
31 pub open: unsafe extern "efiapi" fn(
32 this: *mut Self,
33 new_handle: *mut *mut Self,
34 file_name: *const Char16,
35 open_mode: FileMode,
36 attributes: FileAttribute,
37 ) -> Status,
38 pub close: unsafe extern "efiapi" fn(this: *mut Self) -> Status,
39 pub delete: unsafe extern "efiapi" fn(this: *mut Self) -> Status,
40 pub read: unsafe extern "efiapi" fn(
41 this: *mut Self,
42 buffer_size: *mut usize,
43 buffer: *mut c_void,
44 ) -> Status,
45 pub write: unsafe extern "efiapi" fn(
46 this: *mut Self,
47 buffer_size: *mut usize,
48 buffer: *const c_void,
49 ) -> Status,
50 pub get_position: unsafe extern "efiapi" fn(this: *const Self, position: *mut u64) -> Status,
51 pub set_position: unsafe extern "efiapi" fn(this: *mut Self, position: u64) -> Status,
52 pub get_info: unsafe extern "efiapi" fn(
53 this: *mut Self,
54 information_type: *const Guid,
55 buffer_size: *mut usize,
56 buffer: *mut c_void,
57 ) -> Status,
58 pub set_info: unsafe extern "efiapi" fn(
59 this: *mut Self,
60 information_type: *const Guid,
61 buffer_size: usize,
62 buffer: *const c_void,
63 ) -> Status,
64 pub flush: unsafe extern "efiapi" fn(this: *mut Self) -> Status,
65}
66
67#[derive(Debug)]
68#[repr(C)]
69pub struct FileProtocolV2 {
70 pub v1: FileProtocolV1,
71 pub open_ex: unsafe extern "efiapi" fn(
72 this: *mut Self,
73 new_handle: *mut *mut Self,
74 file_name: *const Char16,
75 open_mode: FileMode,
76 attributes: FileAttribute,
77 token: *mut FileIoToken,
78 ) -> Status,
79 pub read_ex: unsafe extern "efiapi" fn(this: *mut Self, token: *mut FileIoToken) -> Status,
80 pub write_ex: unsafe extern "efiapi" fn(this: *mut Self, token: *mut FileIoToken) -> Status,
81 pub flush_ex: unsafe extern "efiapi" fn(this: *mut Self, token: *mut FileIoToken) -> Status,
82}
83
84#[derive(Debug)]
85#[repr(C)]
86pub struct FileIoToken {
87 pub event: Event,
88 pub status: Status,
89 pub buffer_size: usize,
90 pub buffer: *mut c_void,
91}
92
93bitflags! {
94 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
96 #[repr(transparent)]
97 pub struct FileAttribute: u64 {
98 const READ_ONLY = 0x0000000000000001;
100
101 const HIDDEN = 0x0000000000000002;
103
104 const SYSTEM = 0x0000000000000004;
106
107 const DIRECTORY = 0x0000000000000010;
109
110 const ARCHIVE = 0x0000000000000020;
112
113 const VALID_ATTR = 0x0000000000000037;
115 }
116}
117
118bitflags! {
119 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
120 #[repr(transparent)]
121 pub struct FileMode: u64 {
122 const READ = 0x0000000000000001;
123 const WRITE = 0x0000000000000002;
124 const CREATE = 0x8000000000000000;
125 }
126}
127
128#[derive(Debug)]
129#[repr(C)]
130pub struct FileInfo {
131 pub size: u64,
132 pub file_size: u64,
133 pub physical_size: u64,
134 pub create_time: Time,
135 pub last_access_time: Time,
136 pub modification_time: Time,
137 pub attribute: FileAttribute,
138
139 pub file_name: [Char16; 0],
146}
147
148impl FileInfo {
149 pub const ID: Guid = guid!("09576e92-6d3f-11d2-8e39-00a0c969723b");
150}
151
152#[derive(Debug)]
153#[repr(C)]
154pub struct FileSystemInfo {
155 pub size: u64,
156 pub read_only: u8,
157 pub volume_size: u64,
158 pub free_space: u64,
159 pub block_size: u32,
160
161 pub volume_label: [Char16; 0],
167}
168
169impl FileSystemInfo {
170 pub const ID: Guid = guid!("09576e93-6d3f-11d2-8e39-00a0c969723b");
171}
172
173#[derive(Debug)]
174#[repr(C)]
175pub struct FileSystemVolumeLabel {
176 pub volume_label: [Char16; 0],
182}
183
184impl FileSystemVolumeLabel {
185 pub const ID: Guid = guid!("db47d7d3-fe81-11d3-9a35-0090273fc14d");
186}