|
2 | 2 |
|
3 | 3 | //! EFI Shell Protocol v2.2
|
4 | 4 |
|
5 |
| -use crate::{Event, Guid, guid}; |
| 5 | +use core::ffi::c_void; |
| 6 | + |
| 7 | +use crate::{Char8, Char16, Event, Guid, Handle, Status, guid}; |
| 8 | + |
| 9 | +use super::device_path::DevicePathProtocol; |
| 10 | +use super::file_system::FileInfo; |
| 11 | +use super::shell_params::ShellFileHandle; |
| 12 | + |
| 13 | +/// List Entry for File Lists |
| 14 | +#[derive(Debug)] |
| 15 | +#[repr(C)] |
| 16 | +pub struct ListEntry<'a> { |
| 17 | + f_link: *mut ListEntry<'a>, |
| 18 | + b_link: *mut ListEntry<'a>, |
| 19 | +} |
| 20 | + |
| 21 | +/// ShellFileInfo for File Lists |
| 22 | +#[derive(Debug)] |
| 23 | +#[repr(C)] |
| 24 | +pub struct ShellFileInfo<'a> { |
| 25 | + link: ListEntry<'a>, |
| 26 | + status: Status, |
| 27 | + full_name: *mut Char16, |
| 28 | + file_name: *mut Char16, |
| 29 | + shell_file_handle: Handle, |
| 30 | + file_info: FileInfo, |
| 31 | +} |
| 32 | + |
| 33 | +/// Used to specify where component names should be taken from |
| 34 | +pub type ShellDeviceNameFlags = u32; |
| 35 | +pub static DEVICE_NAME_USE_COMPONENT_NAME: u32 = 0x0000001; |
| 36 | +pub static DEVICE_NAME_USE_DEVICE_PATH: u32 = 0x0000002; |
6 | 37 |
|
7 | 38 | /// Shell Protocol
|
8 | 39 | #[derive(Debug)]
|
9 | 40 | #[repr(C)]
|
10 | 41 | pub struct ShellProtocol {
|
11 |
| - pub execute: usize, |
12 |
| - pub get_env: usize, |
13 |
| - pub set_env: usize, |
14 |
| - pub get_alias: usize, |
15 |
| - pub set_alias: usize, |
16 |
| - pub get_help_text: usize, |
17 |
| - pub get_device_path_from_map: usize, |
18 |
| - pub get_map_from_device_path: usize, |
19 |
| - pub get_device_path_from_file_path: usize, |
20 |
| - pub get_file_path_from_device_path: usize, |
21 |
| - pub set_map: usize, |
| 42 | + pub execute: unsafe extern "efiapi" fn( |
| 43 | + parent_image_handle: *const Handle, |
| 44 | + command_line: *const Char16, |
| 45 | + environment: *const *const Char16, |
| 46 | + status_code: *mut Status, |
| 47 | + ) -> Status, |
| 48 | + pub get_env: unsafe extern "efiapi" fn(name: *const Char16) -> *const Char16, |
| 49 | + pub set_env: unsafe extern "efiapi" fn( |
| 50 | + name: *const Char16, |
| 51 | + value: *const Char16, |
| 52 | + volatile: bool, |
| 53 | + ) -> Status, |
| 54 | + pub get_alias: unsafe extern "efiapi" fn(alias: *const Char16, volatile: bool) -> *const Char16, |
| 55 | + pub set_alias: unsafe extern "efiapi" fn( |
| 56 | + command: *const Char16, |
| 57 | + alias: *const Char16, |
| 58 | + replace: bool, |
| 59 | + volatile: bool, |
| 60 | + ) -> Status, |
| 61 | + pub get_help_text: unsafe extern "efiapi" fn( |
| 62 | + command: *const Char16, |
| 63 | + sections: *const Char16, |
| 64 | + help_text: *mut *mut Char16, |
| 65 | + ) -> Status, |
| 66 | + pub get_device_path_from_map: |
| 67 | + unsafe extern "efiapi" fn(mapping: *const Char16) -> DevicePathProtocol, |
| 68 | + pub get_map_from_device_path: |
| 69 | + unsafe extern "efiapi" fn(device_path: *mut *mut DevicePathProtocol) -> *const Char16, |
| 70 | + pub get_device_path_from_file_path: |
| 71 | + unsafe extern "efiapi" fn(path: *const Char16) -> DevicePathProtocol, |
| 72 | + pub get_file_path_from_device_path: |
| 73 | + unsafe extern "efiapi" fn(path: *const DevicePathProtocol) -> *const Char16, |
| 74 | + pub set_map: unsafe extern "efiapi" fn( |
| 75 | + device_path: DevicePathProtocol, |
| 76 | + mapping: *const Char16, |
| 77 | + ) -> Status, |
22 | 78 |
|
23 |
| - pub get_cur_dir: usize, |
24 |
| - pub set_cur_dir: usize, |
25 |
| - pub open_file_list: usize, |
26 |
| - pub free_file_list: usize, |
27 |
| - pub remove_dup_in_file_list: usize, |
| 79 | + pub get_cur_dir: unsafe extern "efiapi" fn(file_system_mapping: *const Char16) -> *const Char16, |
| 80 | + pub set_cur_dir: |
| 81 | + unsafe extern "efiapi" fn(file_system: *const Char16, dir: *const Char16) -> Status, |
| 82 | + pub open_file_list: unsafe extern "efiapi" fn( |
| 83 | + path: Char16, |
| 84 | + open_mode: u64, |
| 85 | + file_list: *mut *mut ShellFileInfo, |
| 86 | + ) -> Status, |
| 87 | + pub free_file_list: unsafe extern "efiapi" fn(file_list: *const *const ShellFileInfo) -> Status, |
| 88 | + pub remove_dup_in_file_list: |
| 89 | + unsafe extern "efiapi" fn(file_list: *const *const ShellFileInfo) -> Status, |
28 | 90 |
|
29 |
| - pub batch_is_active: usize, |
30 |
| - pub is_root_shell: usize, |
31 |
| - pub enable_page_break: usize, |
32 |
| - pub disable_page_break: usize, |
33 |
| - pub get_page_break: usize, |
34 |
| - pub get_device_name: usize, |
| 91 | + pub batch_is_active: unsafe extern "efiapi" fn() -> bool, |
| 92 | + pub is_root_shell: unsafe extern "efiapi" fn() -> bool, |
| 93 | + pub enable_page_break: unsafe extern "efiapi" fn(), |
| 94 | + pub disable_page_break: unsafe extern "efiapi" fn(), |
| 95 | + pub get_page_break: unsafe extern "efiapi" fn() -> bool, |
| 96 | + pub get_device_name: unsafe extern "efiapi" fn( |
| 97 | + device_handle: Handle, |
| 98 | + flags: ShellDeviceNameFlags, |
| 99 | + language: *const Char8, |
| 100 | + best_device_name: *mut *mut Char16, |
| 101 | + ) -> Status, |
35 | 102 |
|
36 |
| - pub get_file_info: usize, |
37 |
| - pub set_file_info: usize, |
38 |
| - pub open_file_by_name: usize, |
39 |
| - pub close_file: usize, |
40 |
| - pub create_file: usize, |
41 |
| - pub read_file: usize, |
42 |
| - pub write_file: usize, |
43 |
| - pub delete_file: usize, |
44 |
| - pub delete_file_by_name: usize, |
45 |
| - pub get_file_position: usize, |
46 |
| - pub set_file_position: usize, |
47 |
| - pub flush_file: usize, |
48 |
| - pub find_files: usize, |
49 |
| - pub find_files_in_dir: usize, |
50 |
| - pub get_file_size: usize, |
| 103 | + pub get_file_info: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> FileInfo, |
| 104 | + pub set_file_info: unsafe extern "efiapi" fn( |
| 105 | + file_handle: ShellFileHandle, |
| 106 | + file_info: *const FileInfo, |
| 107 | + ) -> Status, |
| 108 | + pub open_file_by_name: unsafe extern "efiapi" fn( |
| 109 | + file_name: *const Char16, |
| 110 | + file_handle: *mut ShellFileHandle, |
| 111 | + open_mode: u64, |
| 112 | + ) -> Status, |
| 113 | + pub close_file: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> Status, |
| 114 | + pub create_file: unsafe extern "efiapi" fn( |
| 115 | + file_name: *const Char16, |
| 116 | + file_attribs: u64, |
| 117 | + file_handle: *mut ShellFileHandle, |
| 118 | + ) -> Status, |
| 119 | + pub read_file: unsafe extern "efiapi" fn( |
| 120 | + file_handle: ShellFileHandle, |
| 121 | + read_size: *mut usize, |
| 122 | + buffer: *mut c_void, |
| 123 | + ) -> Status, |
| 124 | + pub write_file: unsafe extern "efiapi" fn( |
| 125 | + file_handle: ShellFileHandle, |
| 126 | + buffer_size: *mut usize, |
| 127 | + buffer: *mut c_void, |
| 128 | + ) -> Status, |
| 129 | + pub delete_file: unsafe extern "efiapi" fn(file_name: *const Char16) -> Status, |
| 130 | + pub delete_file_by_name: unsafe extern "efiapi" fn(file_name: *const Char16) -> Status, |
| 131 | + pub get_file_position: |
| 132 | + unsafe extern "efiapi" fn(file_handle: ShellFileHandle, position: *mut u64) -> Status, |
| 133 | + pub set_file_position: |
| 134 | + unsafe extern "efiapi" fn(file_handle: ShellFileHandle, position: u64) -> Status, |
| 135 | + pub flush_file: unsafe extern "efiapi" fn(file_handle: ShellFileHandle) -> Status, |
| 136 | + pub find_files: unsafe extern "efiapi" fn( |
| 137 | + file_pattern: *const Char16, |
| 138 | + file_list: *mut *mut ShellFileInfo, |
| 139 | + ) -> Status, |
| 140 | + pub find_files_in_dir: unsafe extern "efiapi" fn( |
| 141 | + file_dir_handle: ShellFileHandle, |
| 142 | + file_list: *mut *mut ShellFileInfo, |
| 143 | + ) -> Status, |
| 144 | + pub get_file_size: |
| 145 | + unsafe extern "efiapi" fn(file_handle: ShellFileHandle, size: *mut u64) -> Status, |
51 | 146 |
|
52 |
| - pub open_root: usize, |
53 |
| - pub open_root_by_handle: usize, |
| 147 | + pub open_root: unsafe extern "efiapi" fn( |
| 148 | + device_path: *const DevicePathProtocol, |
| 149 | + file_handle: *mut ShellFileHandle, |
| 150 | + ) -> Status, |
| 151 | + pub open_root_by_handle: unsafe extern "efiapi" fn( |
| 152 | + device_handle: Handle, |
| 153 | + file_handle: *mut ShellFileHandle, |
| 154 | + ) -> Status, |
54 | 155 |
|
55 | 156 | pub execution_break: Event,
|
56 | 157 |
|
57 | 158 | pub major_version: u32,
|
58 | 159 | pub minor_version: u32,
|
59 |
| - pub register_guid_name: usize, |
60 |
| - pub get_guid_name: usize, |
61 |
| - pub get_guid_from_name: usize, |
62 |
| - pub get_env_ex: usize, |
| 160 | + pub register_guid_name: |
| 161 | + unsafe extern "efiapi" fn(guid: *const Guid, guid_name: *const Char16) -> Status, |
| 162 | + pub get_guid_name: |
| 163 | + unsafe extern "efiapi" fn(guid: *const Guid, guid_name: *mut *mut Char16) -> Status, |
| 164 | + pub get_guid_from_name: |
| 165 | + unsafe extern "efiapi" fn(guid_name: *const Char16, guid: *mut Guid) -> Status, |
| 166 | + pub get_env_ex: |
| 167 | + unsafe extern "efiapi" fn(name: *const Char16, attributes: *mut u32) -> *const Char16, |
63 | 168 | }
|
64 | 169 |
|
65 | 170 | impl ShellProtocol {
|
|
0 commit comments