Skip to main content

r_efi/protocols/
shell.rs

1//! Shell Protocol
2//!
3//! Provides shell services to UEFI applications.
4
5pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields(
6    0x6302d008,
7    0x7f9b,
8    0x4f30,
9    0x87,
10    0xac,
11    &[0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e],
12);
13
14pub const MAJOR_VERSION: u32 = 0x00000002;
15pub const MINOR_VERSION: u32 = 0x00000002;
16
17pub type FileHandle = *mut core::ffi::c_void;
18
19pub type DeviceNameFlags = u32;
20pub const DEVICE_NAME_USE_COMPONENT_NAME: DeviceNameFlags = 0x00000001;
21pub const DEVICE_NAME_USE_DEVICE_PATH: DeviceNameFlags = 0x00000002;
22
23#[repr(C)]
24pub struct ListEntry {
25    pub flink: *mut ListEntry,
26    pub blink: *mut ListEntry,
27}
28
29#[repr(C)]
30pub struct FileInfo {
31    pub link: ListEntry,
32    pub status: crate::base::Status,
33    pub full_name: *mut crate::base::Char16,
34    pub file_name: *mut crate::base::Char16,
35    pub handle: FileHandle,
36    pub info: *mut crate::protocols::file::Info,
37}
38
39pub type Execute = unsafe extern "efiapi" fn(
40    *mut crate::base::Handle,
41    *mut crate::base::Char16,
42    *mut *mut crate::base::Char16,
43    *mut crate::base::Status,
44) -> crate::base::Status;
45
46pub type GetEnv = unsafe extern "efiapi" fn(
47    *mut crate::base::Char16,
48) -> *mut crate::base::Char16;
49
50pub type SetEnv = unsafe extern "efiapi" fn(
51    *mut crate::base::Char16,
52    *mut crate::base::Char16,
53    crate::base::Boolean,
54) -> crate::base::Status;
55
56pub type GetAlias = unsafe extern "efiapi" fn(
57    *mut crate::base::Char16,
58    *mut crate::base::Boolean,
59) -> *mut crate::base::Char16;
60
61pub type SetAlias = unsafe extern "efiapi" fn(
62    *mut crate::base::Char16,
63    *mut crate::base::Char16,
64    crate::base::Boolean,
65    crate::base::Boolean,
66) -> crate::base::Status;
67
68pub type GetHelpText = unsafe extern "efiapi" fn(
69    *mut crate::base::Char16,
70    *mut crate::base::Char16,
71    *mut *mut crate::base::Char16,
72) -> crate::base::Status;
73
74pub type GetDevicePathFromMap = unsafe extern "efiapi" fn(
75    *mut crate::base::Char16,
76) -> *mut crate::protocols::device_path::Protocol;
77
78pub type GetMapFromDevicePath = unsafe extern "efiapi" fn(
79    *mut *mut crate::protocols::device_path::Protocol,
80) -> *mut crate::base::Char16;
81
82pub type GetDevicePathFromFilePath = unsafe extern "efiapi" fn(
83    *mut crate::base::Char16,
84) -> *mut crate::protocols::device_path::Protocol;
85
86pub type GetFilePathFromDevicePath = unsafe extern "efiapi" fn(
87    *mut crate::protocols::device_path::Protocol,
88) -> *mut crate::base::Char16;
89
90pub type SetMap = unsafe extern "efiapi" fn(
91    *mut crate::protocols::device_path::Protocol,
92    *mut crate::base::Char16,
93) -> crate::base::Status;
94
95pub type GetCurDir = unsafe extern "efiapi" fn(
96    *mut crate::base::Char16,
97) -> *mut crate::base::Char16;
98
99pub type SetCurDir = unsafe extern "efiapi" fn(
100    *mut crate::base::Char16,
101    *mut crate::base::Char16,
102) -> crate::base::Status;
103
104pub type OpenFileList = unsafe extern "efiapi" fn(
105    *mut crate::base::Char16,
106    u64,
107    *mut *mut FileInfo,
108) -> crate::base::Status;
109
110pub type FreeFileList = unsafe extern "efiapi" fn(
111    *mut *mut FileInfo,
112) -> crate::base::Status;
113
114pub type RemoveDupInFileList = unsafe extern "efiapi" fn(
115    *mut *mut FileInfo,
116) -> crate::base::Status;
117
118pub type BatchIsActive = unsafe extern "efiapi" fn() -> crate::base::Boolean;
119
120pub type IsRootShell = unsafe extern "efiapi" fn() -> crate::base::Boolean;
121
122pub type EnablePageBreak = unsafe extern "efiapi" fn();
123
124pub type DisablePageBreak = unsafe extern "efiapi" fn();
125
126pub type GetPageBreak = unsafe extern "efiapi" fn() -> crate::base::Boolean;
127
128pub type GetDeviceName = unsafe extern "efiapi" fn(
129    crate::base::Handle,
130    DeviceNameFlags,
131    *mut crate::base::Char8,
132    *mut *mut crate::base::Char16,
133) -> crate::base::Status;
134
135pub type GetFileInfo = unsafe extern "efiapi" fn(
136    FileHandle,
137) -> *mut crate::protocols::file::Info;
138
139pub type SetFileInfo = unsafe extern "efiapi" fn(
140    FileHandle,
141    *mut crate::protocols::file::Info
142) -> crate::base::Status;
143
144pub type OpenFileByName = unsafe extern "efiapi" fn(
145    *mut crate::base::Char16,
146    *mut FileHandle,
147    u64,
148) -> crate::base::Status;
149
150pub type CloseFile = unsafe extern "efiapi" fn(
151    FileHandle,
152) -> crate::base::Status;
153
154pub type CreateFile = unsafe extern "efiapi" fn(
155    *mut crate::base::Char16,
156    u64,
157    *mut FileHandle,
158) -> crate::base::Status;
159
160pub type ReadFile = unsafe extern "efiapi" fn(
161    FileHandle,
162    *mut usize,
163    *mut core::ffi::c_void,
164) -> crate::base::Status;
165
166pub type WriteFile = unsafe extern "efiapi" fn(
167    FileHandle,
168    *mut usize,
169    *mut core::ffi::c_void,
170) -> crate::base::Status;
171
172pub type DeleteFile = unsafe extern "efiapi" fn(
173    FileHandle,
174) -> crate::base::Status;
175
176pub type DeleteFileByName = unsafe extern "efiapi" fn(
177    *mut crate::base::Char16,
178) -> crate::base::Status;
179
180pub type GetFilePosition = unsafe extern "efiapi" fn(
181    FileHandle,
182    *mut u64,
183) -> crate::base::Status;
184
185pub type SetFilePosition = unsafe extern "efiapi" fn(
186    FileHandle,
187    u64,
188) -> crate::base::Status;
189
190pub type FlushFile = unsafe extern "efiapi" fn(
191    FileHandle,
192) -> crate::base::Status;
193
194pub type FindFiles = unsafe extern "efiapi" fn(
195    *mut crate::base::Char16,
196    *mut *mut FileInfo,
197) -> crate::base::Status;
198
199pub type FindFilesInDir = unsafe extern "efiapi" fn(
200    FileHandle,
201    *mut *mut FileInfo,
202) -> crate::base::Status;
203
204pub type GetFileSize = unsafe extern "efiapi" fn(
205    FileHandle,
206    *mut u64,
207) -> crate::base::Status;
208
209pub type OpenRoot = unsafe extern "efiapi" fn(
210    *mut crate::protocols::device_path::Protocol,
211    *mut FileHandle,
212) -> crate::base::Status;
213
214pub type OpenRootByHandle = unsafe extern "efiapi" fn(
215    crate::base::Handle,
216    *mut FileHandle,
217) -> crate::base::Status;
218
219pub type RegisterGuidName = unsafe extern "efiapi" fn(
220    *mut crate::base::Guid,
221    *mut crate::base::Char16,
222) -> crate::base::Status;
223
224pub type GetGuidName = unsafe extern "efiapi" fn(
225    *mut crate::base::Guid,
226    *mut *mut crate::base::Char16,
227) -> crate::base::Status;
228
229pub type GetGuidFromName = unsafe extern "efiapi" fn(
230    *mut crate::base::Char16,
231    *mut crate::base::Guid,
232) -> crate::base::Status;
233
234pub type GetEnvEx = unsafe extern "efiapi" fn(
235    *mut crate::base::Char16,
236    *mut u32,
237) -> *mut crate::base::Char16;
238
239#[repr(C)]
240pub struct Protocol {
241    pub execute: Execute,
242    pub get_env: GetEnv,
243    pub set_env: SetEnv,
244    pub get_alias: GetAlias,
245    pub set_alias: SetAlias,
246    pub get_help_text: GetHelpText,
247    pub get_device_path_from_map: GetDevicePathFromMap,
248    pub get_map_from_device_path: GetMapFromDevicePath,
249    pub get_device_path_from_file_path: GetDevicePathFromFilePath,
250    pub get_file_path_from_device_path: GetFilePathFromDevicePath,
251    pub set_map: SetMap,
252
253    pub get_cur_dir: GetCurDir,
254    pub set_cur_dir: SetCurDir,
255    pub open_file_list: OpenFileList,
256    pub free_file_list: FreeFileList,
257    pub remove_dup_in_file_list: RemoveDupInFileList,
258
259    pub batch_is_active: BatchIsActive,
260    pub is_root_shell: IsRootShell,
261    pub enable_page_break: EnablePageBreak,
262    pub disable_page_break: DisablePageBreak,
263    pub get_page_break: GetPageBreak,
264    pub get_device_name: GetDeviceName,
265
266    pub get_file_info: GetFileInfo,
267    pub set_file_info: SetFileInfo,
268    pub open_file_by_name: OpenFileByName,
269    pub close_file: CloseFile,
270    pub create_file: CreateFile,
271    pub read_file: ReadFile,
272    pub write_file: WriteFile,
273    pub delete_file: DeleteFile,
274    pub delete_file_by_name: DeleteFileByName,
275    pub get_file_position: GetFilePosition,
276    pub set_file_position: SetFilePosition,
277    pub flush_file: FlushFile,
278    pub find_files: FindFiles,
279    pub find_files_in_dir: FindFilesInDir,
280    pub get_file_size: GetFileSize,
281
282    pub open_root: OpenRoot,
283    pub open_root_by_handle: OpenRootByHandle,
284
285    pub execution_break: crate::base::Event,
286
287    pub major_version: u32,
288    pub minor_version: u32,
289    pub register_guid_name: RegisterGuidName,
290    pub get_guid_name: GetGuidName,
291    pub get_guid_from_name: GetGuidFromName,
292
293    // Shell 2.1
294    pub get_env_ex: GetEnvEx,
295}