summaryrefslogtreecommitdiffstats
path: root/vendor/r-efi/src/protocols/shell.rs
blob: 01b6b2c68bfc5d18bf2cf7dacd3b2948be099f1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
//! Shell Protocol
//!
//! Provides shell services to UEFI applications.

pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields(
    0x6302d008,
    0x7f9b,
    0x4f30,
    0x87,
    0xac,
    &[0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e],
);

pub const MAJOR_VERSION: u32 = 0x00000002;
pub const MINOR_VERSION: u32 = 0x00000002;

pub type FileHandle = *mut core::ffi::c_void;

pub type DeviceNameFlags = u32;
pub const DEVICE_NAME_USE_COMPONENT_NAME: DeviceNameFlags = 0x00000001;
pub const DEVICE_NAME_USE_DEVICE_PATH: DeviceNameFlags = 0x00000002;

#[repr(C)]
pub struct ListEntry {
    pub flink: *mut ListEntry,
    pub blink: *mut ListEntry,
}

#[repr(C)]
pub struct FileInfo {
    pub link: ListEntry,
    pub status: crate::base::Status,
    pub full_name: *mut crate::base::Char16,
    pub file_name: *mut crate::base::Char16,
    pub handle: FileHandle,
    pub info: *mut crate::protocols::file::Info,
}

pub type Execute = eficall! {fn(
    *mut crate::base::Handle,
    *mut crate::base::Char16,
    *mut *mut crate::base::Char16,
    *mut crate::base::Status,
) -> crate::base::Status};

pub type GetEnv = eficall! {fn(
    *mut crate::base::Char16,
) -> *mut crate::base::Char16};

pub type SetEnv = eficall! {fn(
    *mut crate::base::Char16,
    *mut crate::base::Char16,
    crate::base::Boolean,
) -> crate::base::Status};

pub type GetAlias = eficall! {fn(
    *mut crate::base::Char16,
    *mut crate::base::Boolean,
) -> *mut crate::base::Char16};

pub type SetAlias = eficall! {fn(
    *mut crate::base::Char16,
    *mut crate::base::Char16,
    crate::base::Boolean,
    crate::base::Boolean,
) -> crate::base::Status};

pub type GetHelpText = eficall! {fn(
    *mut crate::base::Char16,
    *mut crate::base::Char16,
    *mut *mut crate::base::Char16,
) -> crate::base::Status};

pub type GetDevicePathFromMap = eficall! {fn(
    *mut crate::base::Char16,
) -> *mut crate::protocols::device_path::Protocol};

pub type GetMapFromDevicePath = eficall! {fn(
    *mut *mut crate::protocols::device_path::Protocol,
) -> *mut crate::base::Char16};

pub type GetDevicePathFromFilePath = eficall! {fn(
    *mut crate::base::Char16,
) -> *mut crate::protocols::device_path::Protocol};

pub type GetFilePathFromDevicePath = eficall! {fn(
    *mut crate::protocols::device_path::Protocol,
) -> *mut crate::base::Char16};

pub type SetMap = eficall! {fn(
    *mut crate::protocols::device_path::Protocol,
    *mut crate::base::Char16,
) -> crate::base::Status};

pub type GetCurDir = eficall! {fn(
    *mut crate::base::Char16,
) -> *mut crate::base::Char16};

pub type SetCurDir = eficall! {fn(
    *mut crate::base::Char16,
    *mut crate::base::Char16,
) -> crate::base::Status};

pub type OpenFileList = eficall! {fn(
    *mut crate::base::Char16,
    u64,
    *mut *mut FileInfo,
) -> crate::base::Status};

pub type FreeFileList = eficall! {fn(
    *mut *mut FileInfo,
) -> crate::base::Status};

pub type RemoveDupInFileList = eficall! {fn(
    *mut *mut FileInfo,
) -> crate::base::Status};

pub type BatchIsActive = eficall! {fn() -> crate::base::Boolean};

pub type IsRootShell = eficall! {fn() -> crate::base::Boolean};

pub type EnablePageBreak = eficall! {fn()};

pub type DisablePageBreak = eficall! {fn()};

pub type GetPageBreak = eficall! {fn() -> crate::base::Boolean};

pub type GetDeviceName = eficall! {fn(
    crate::base::Handle,
    DeviceNameFlags,
    *mut crate::base::Char8,
    *mut *mut crate::base::Char16,
) -> crate::base::Status};

pub type GetFileInfo = eficall! {fn(
    FileHandle,
) -> *mut crate::protocols::file::Info};

pub type SetFileInfo = eficall! {fn(
    FileHandle,
    *mut crate::protocols::file::Info
) -> crate::base::Status};

pub type OpenFileByName = eficall! {fn(
    *mut crate::base::Char16,
    *mut FileHandle,
    u64,
) -> crate::base::Status};

pub type CloseFile = eficall! {fn(
    FileHandle,
) -> crate::base::Status};

pub type CreateFile = eficall! {fn(
    *mut crate::base::Char16,
    u64,
    *mut FileHandle,
) -> crate::base::Status};

pub type ReadFile = eficall! {fn(
    FileHandle,
    *mut usize,
    *mut core::ffi::c_void,
) -> crate::base::Status};

pub type WriteFile = eficall! {fn(
    FileHandle,
    *mut usize,
    *mut core::ffi::c_void,
) -> crate::base::Status};

pub type DeleteFile = eficall! {fn(
    FileHandle,
) -> crate::base::Status};

pub type DeleteFileByName = eficall! {fn(
    *mut crate::base::Char16,
) -> crate::base::Status};

pub type GetFilePosition = eficall! {fn(
    FileHandle,
    *mut u64,
) -> crate::base::Status};

pub type SetFilePosition = eficall! {fn(
    FileHandle,
    u64,
) -> crate::base::Status};

pub type FlushFile = eficall! {fn(
    FileHandle,
) -> crate::base::Status};

pub type FindFiles = eficall! {fn(
    *mut crate::base::Char16,
    *mut *mut FileInfo,
) -> crate::base::Status};

pub type FindFilesInDir = eficall! {fn(
    FileHandle,
    *mut *mut FileInfo,
) -> crate::base::Status};

pub type GetFileSize = eficall! {fn(
    FileHandle,
    *mut u64,
) -> crate::base::Status};

pub type OpenRoot = eficall! {fn(
    *mut crate::protocols::device_path::Protocol,
    *mut FileHandle,
) -> crate::base::Status};

pub type OpenRootByHandle = eficall! {fn(
    crate::base::Handle,
    *mut FileHandle,
) -> crate::base::Status};

pub type RegisterGuidName = eficall! {fn(
    *mut crate::base::Guid,
    *mut crate::base::Char16,
) -> crate::base::Status};

pub type GetGuidName = eficall! {fn(
    *mut crate::base::Guid,
    *mut *mut crate::base::Char16,
) -> crate::base::Status};

pub type GetGuidFromName = eficall! {fn(
    *mut crate::base::Char16,
    *mut crate::base::Guid,
) -> crate::base::Status};

pub type GetEnvEx = eficall! {fn(
    *mut crate::base::Char16,
    *mut u32,
) -> *mut crate::base::Char16};

#[repr(C)]
pub struct Protocol {
    pub execute: Execute,
    pub get_env: GetEnv,
    pub set_env: SetEnv,
    pub get_alias: GetAlias,
    pub set_alias: SetAlias,
    pub get_help_text: GetHelpText,
    pub get_device_path_from_map: GetDevicePathFromMap,
    pub get_map_from_device_path: GetMapFromDevicePath,
    pub get_device_path_from_file_path: GetDevicePathFromFilePath,
    pub get_file_path_from_device_path: GetFilePathFromDevicePath,
    pub set_map: SetMap,

    pub get_cur_dir: GetCurDir,
    pub set_cur_dir: SetCurDir,
    pub open_file_list: OpenFileList,
    pub free_file_list: FreeFileList,
    pub remove_dup_in_file_list: RemoveDupInFileList,

    pub batch_is_active: BatchIsActive,
    pub is_root_shell: IsRootShell,
    pub enable_page_break: EnablePageBreak,
    pub disable_page_break: DisablePageBreak,
    pub get_page_break: GetPageBreak,
    pub get_device_name: GetDeviceName,

    pub get_file_info: GetFileInfo,
    pub set_file_info: SetFileInfo,
    pub open_file_by_name: OpenFileByName,
    pub close_file: CloseFile,
    pub create_file: CreateFile,
    pub read_file: ReadFile,
    pub write_file: WriteFile,
    pub delete_file: DeleteFile,
    pub delete_file_by_name: DeleteFileByName,
    pub get_file_position: GetFilePosition,
    pub set_file_position: SetFilePosition,
    pub flush_file: FlushFile,
    pub find_files: FindFiles,
    pub find_files_in_dir: FindFilesInDir,
    pub get_file_size: GetFileSize,

    pub open_root: OpenRoot,
    pub open_root_by_handle: OpenRootByHandle,

    pub execution_break: crate::base::Event,

    pub major_version: u32,
    pub minor_version: u32,
    pub register_guid_name: RegisterGuidName,
    pub get_guid_name: GetGuidName,
    pub get_guid_from_name: GetGuidFromName,

    // Shell 2.1
    pub get_env_ex: GetEnvEx,
}