1use core::ffi::c_void;
6
7use crate::{Boolean, Char8, Char16, Event, Guid, Handle, Status, guid};
8
9use super::device_path::DevicePathProtocol;
10use super::file_system::FileInfo;
11use super::shell_params::ShellFileHandle;
12
13use bitflags::bitflags;
14
15#[derive(Debug)]
17#[repr(C)]
18pub struct ListEntry {
19 pub f_link: *mut Self,
20 pub b_link: *mut Self,
21}
22
23#[derive(Debug)]
25#[repr(C)]
26pub struct ShellFileInfo {
27 pub link: ListEntry,
28 pub status: Status,
29 pub full_name: *mut Char16,
30 pub file_name: *mut Char16,
31 pub handle: ShellFileHandle,
32 pub info: FileInfo,
33}
34
35bitflags! {
36 #[repr(transparent)]
38 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
39 pub struct ShellDeviceNameFlags: u32 {
40 const USE_COMPONENT_NAME = 0x0000001;
42 const USE_DEVICE_PATH = 0x0000002;
44 }
45}
46
47#[derive(Debug)]
49#[repr(C)]
50pub struct ShellProtocol {
51 pub execute: unsafe extern "efiapi" fn(
52 parent_image_handle: *const Handle,
53 command_line: *const Char16,
54 environment: *const *const Char16,
55 status_code: *mut Status,
56 ) -> Status,
57 pub get_env: unsafe extern "efiapi" fn(name: *const Char16) -> *const Char16,
58 pub set_env: unsafe extern "efiapi" fn(
59 name: *const Char16,
60 value: *const Char16,
61 volatile: Boolean,
62 ) -> Status,
63 pub get_alias:
64 unsafe extern "efiapi" fn(alias: *const Char16, volatile: Boolean) -> *const Char16,
65 pub set_alias: unsafe extern "efiapi" fn(
66 command: *const Char16,
67 alias: *const Char16,
68 replace: Boolean,
69 volatile: Boolean,
70 ) -> Status,
71 pub get_help_text: unsafe extern "efiapi" fn(
72 command: *const Char16,
73 sections: *const Char16,
74 help_text: *mut *mut Char16,
75 ) -> Status,
76 pub get_device_path_from_map:
77 unsafe extern "efiapi" fn(mapping: *const Char16) -> *const DevicePathProtocol,
78 pub get_map_from_device_path:
79 unsafe extern "efiapi" fn(device_path: *mut *mut DevicePathProtocol) -> *const Char16,
80 pub get_device_path_from_file_path:
81 unsafe extern "efiapi" fn(path: *const Char16) -> *const DevicePathProtocol,
82 pub get_file_path_from_device_path:
83 unsafe extern "efiapi" fn(path: *const DevicePathProtocol) -> *const Char16,
84 pub set_map: unsafe extern "efiapi" fn(
85 device_path: *const DevicePathProtocol,
86 mapping: *const Char16,
87 ) -> Status,
88
89 pub get_cur_dir: unsafe extern "efiapi" fn(file_system_mapping: *const Char16) -> *const Char16,
90 pub set_cur_dir:
91 unsafe extern "efiapi" fn(file_system: *const Char16, dir: *const Char16) -> Status,
92 pub open_file_list: unsafe extern "efiapi" fn(
93 path: *const Char16,
94 open_mode: u64,
95 file_list: *mut *mut ShellFileInfo,
96 ) -> Status,
97 pub free_file_list: unsafe extern "efiapi" fn(file_list: *const *const ShellFileInfo) -> Status,
98 pub remove_dup_in_file_list:
99 unsafe extern "efiapi" fn(file_list: *const *const ShellFileInfo) -> Status,
100
101 pub batch_is_active: unsafe extern "efiapi" fn() -> Boolean,
102 pub is_root_shell: unsafe extern "efiapi" fn() -> Boolean,
103 pub enable_page_break: unsafe extern "efiapi" fn(),
104 pub disable_page_break: unsafe extern "efiapi" fn(),
105 pub get_page_break: unsafe extern "efiapi" fn() -> Boolean,
106 pub get_device_name: unsafe extern "efiapi" fn(
107 device_handle: Handle,
108 flags: ShellDeviceNameFlags,
109 language: *const Char8,
110 best_device_name: *mut *mut Char16,
111 ) -> Status,
112
113 pub get_file_info: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> *const FileInfo,
114 pub set_file_info: unsafe extern "efiapi" fn(
115 file_handle: ShellFileHandle,
116 file_info: *const FileInfo,
117 ) -> Status,
118 pub open_file_by_name: unsafe extern "efiapi" fn(
119 file_name: *const Char16,
120 file_handle: *mut ShellFileHandle,
121 open_mode: u64,
122 ) -> Status,
123 pub close_file: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> Status,
124 pub create_file: unsafe extern "efiapi" fn(
125 file_name: *const Char16,
126 file_attribs: u64,
127 file_handle: *mut ShellFileHandle,
128 ) -> Status,
129 pub read_file: unsafe extern "efiapi" fn(
130 file_handle: ShellFileHandle,
131 read_size: *mut usize,
132 buffer: *mut c_void,
133 ) -> Status,
134 pub write_file: unsafe extern "efiapi" fn(
135 file_handle: ShellFileHandle,
136 buffer_size: *mut usize,
137 buffer: *mut c_void,
138 ) -> Status,
139 pub delete_file: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> Status,
140 pub delete_file_by_name: unsafe extern "efiapi" fn(file_name: *const Char16) -> Status,
141 pub get_file_position:
142 unsafe extern "efiapi" fn(file_handle: ShellFileHandle, position: *mut u64) -> Status,
143 pub set_file_position:
144 unsafe extern "efiapi" fn(file_handle: ShellFileHandle, position: u64) -> Status,
145 pub flush_file: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> Status,
146 pub find_files: unsafe extern "efiapi" fn(
147 file_pattern: *const Char16,
148 file_list: *mut *mut ShellFileInfo,
149 ) -> Status,
150 pub find_files_in_dir: unsafe extern "efiapi" fn(
151 file_dir_handle: ShellFileHandle,
152 file_list: *mut *mut ShellFileInfo,
153 ) -> Status,
154 pub get_file_size:
155 unsafe extern "efiapi" fn(file_handle: ShellFileHandle, size: *mut u64) -> Status,
156
157 pub open_root: unsafe extern "efiapi" fn(
158 device_path: *const DevicePathProtocol,
159 file_handle: *mut ShellFileHandle,
160 ) -> Status,
161 pub open_root_by_handle: unsafe extern "efiapi" fn(
162 device_handle: Handle,
163 file_handle: *mut ShellFileHandle,
164 ) -> Status,
165
166 pub execution_break: Event,
167
168 pub major_version: u32,
169 pub minor_version: u32,
170 pub register_guid_name:
171 unsafe extern "efiapi" fn(guid: *const Guid, guid_name: *const Char16) -> Status,
172 pub get_guid_name:
173 unsafe extern "efiapi" fn(guid: *const Guid, guid_name: *mut *mut Char16) -> Status,
174 pub get_guid_from_name:
175 unsafe extern "efiapi" fn(guid_name: *const Char16, guid: *mut Guid) -> Status,
176 pub get_env_ex:
177 unsafe extern "efiapi" fn(name: *const Char16, attributes: *mut u32) -> *const Char16,
178}
179
180impl ShellProtocol {
181 pub const GUID: Guid = guid!("6302d008-7f9b-4f30-87ac-60c9fef5da4e");
182}