|
| 1 | +// SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | + |
| 3 | +//! EFI Shell Protocol v2.2 |
| 4 | +
|
| 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 | + pub f_link: *mut ListEntry<'a>, |
| 18 | + pub b_link: *mut ListEntry<'a>, |
| 19 | +} |
| 20 | + |
| 21 | +/// ShellFileInfo for File Lists |
| 22 | +#[derive(Debug)] |
| 23 | +#[repr(C)] |
| 24 | +pub struct ShellFileInfo<'a> { |
| 25 | + pub link: ListEntry<'a>, |
| 26 | + pub status: Status, |
| 27 | + pub full_name: *mut Char16, |
| 28 | + pub file_name: *mut Char16, |
| 29 | + pub shell_file_handle: Handle, |
| 30 | + pub file_info: FileInfo, |
| 31 | +} |
| 32 | + |
| 33 | +/// Used to specify where component names should be taken from |
| 34 | +pub type ShellDeviceNameFlags = u32; |
| 35 | +pub const DEVICE_NAME_USE_COMPONENT_NAME: u32 = 0x0000001; |
| 36 | +pub const DEVICE_NAME_USE_DEVICE_PATH: u32 = 0x0000002; |
| 37 | + |
| 38 | +/// Shell Protocol |
| 39 | +#[derive(Debug)] |
| 40 | +#[repr(C)] |
| 41 | +pub struct ShellProtocol { |
| 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, |
| 78 | + |
| 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, |
| 90 | + |
| 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, |
| 102 | + |
| 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, |
| 146 | + |
| 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, |
| 155 | + |
| 156 | + pub execution_break: Event, |
| 157 | + |
| 158 | + pub major_version: u32, |
| 159 | + pub minor_version: u32, |
| 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, |
| 168 | +} |
| 169 | + |
| 170 | +impl ShellProtocol { |
| 171 | + pub const GUID: Guid = guid!("6302d008-7f9b-4f30-87ac-60c9fef5da4e"); |
| 172 | +} |
0 commit comments