interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / uefi-raw / src / protocol / file_system.rs

186 lines · 5545 bytes Raw Blame History
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use crate::time::Time;
4use crate::{Boolean, Char16, Event, Guid, Status, guid, newtype_enum};
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 /// File attributes.
95 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
96 #[repr(transparent)]
97 pub struct FileAttribute: u64 {
98 /// The file cannot be opened for modification.
99 const READ_ONLY = 0x0000000000000001;
100
101 /// The file is hidden from normal directory views.
102 const HIDDEN = 0x0000000000000002;
103
104 /// The file belongs to the system and must not be physically moved.
105 const SYSTEM = 0x0000000000000004;
106
107 /// The file is a directory.
108 const DIRECTORY = 0x0000000000000010;
109
110 /// The file is marked for archival by backup software.
111 const ARCHIVE = 0x0000000000000020;
112
113 /// Mask combining all the valid attributes.
114 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 /// The null-terminated name of the file. For a root directory, this is an
140 /// empty string.
141 ///
142 /// Note that this field is actually a variable-length array. In order to
143 /// avoid making this struct a DST, the field is represented as a
144 /// zero-length array here.
145 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: Boolean,
157 pub volume_size: u64,
158 pub free_space: u64,
159 pub block_size: u32,
160
161 /// The null-terminated label of the volume.
162 ///
163 /// Note that this field is actually a variable-length array. In order to
164 /// avoid making this struct a DST, the field is represented as a
165 /// zero-length array here.
166 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 /// The null-terminated label of the volume.
177 ///
178 /// Note that this field is actually a variable-length array. In order to
179 /// avoid making this struct a DST, the field is represented as a
180 /// zero-length array here.
181 pub volume_label: [Char16; 0],
182}
183
184impl FileSystemVolumeLabel {
185 pub const ID: Guid = guid!("db47d7d3-fe81-11d3-9a35-0090273fc14d");
186}