1 /** 2 EFI Shell protocol as defined in the UEFI Shell Specification 2.2. 3 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 6 SPDX-License-Identifier: BSD-2-Clause-Patent 7 8 This file is based on MdePkg/Include/Protocol/Shell.h from EDK2 9 Ported to gnu-efi by Jiaqing Zhao <jiaqing.zhao@intel.com> 10 **/ 11 12 #ifndef _EFI_SHELL_H 13 #define _EFI_SHELL_H 14 15 #include "efilink.h" 16 17 #define EFI_SHELL_PROTOCOL_GUID \ 18 { 0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } } 19 20 INTERFACE_DECL(_EFI_SHELL_PROTOCOL); 21 22 typedef enum { 23 SHELL_SUCCESS = 0, 24 SHELL_LOAD_ERROR = 1, 25 SHELL_INVALID_PARAMETER = 2, 26 SHELL_UNSUPPORTED = 3, 27 SHELL_BAD_BUFFER_SIZE = 4, 28 SHELL_BUFFER_TOO_SMALL = 5, 29 SHELL_NOT_READY = 6, 30 SHELL_DEVICE_ERROR = 7, 31 SHELL_WRITE_PROTECTED = 8, 32 SHELL_OUT_OF_RESOURCES = 9, 33 SHELL_VOLUME_CORRUPTED = 10, 34 SHELL_VOLUME_FULL = 11, 35 SHELL_NO_MEDIA = 12, 36 SHELL_MEDIA_CHANGED = 13, 37 SHELL_NOT_FOUND = 14, 38 SHELL_ACCESS_DENIED = 15, 39 SHELL_TIMEOUT = 18, 40 SHELL_NOT_STARTED = 19, 41 SHELL_ALREADY_STARTED = 20, 42 SHELL_ABORTED = 21, 43 SHELL_INCOMPATIBLE_VERSION = 25, 44 SHELL_SECURITY_VIOLATION = 26, 45 SHELL_NOT_EQUAL = 27 46 } SHELL_STATUS; 47 48 typedef VOID *SHELL_FILE_HANDLE; 49 50 typedef struct { 51 EFI_LIST_ENTRY Link; 52 EFI_STATUS Status; 53 CONST CHAR16 *FullName; 54 CONST CHAR16 *FileName; 55 SHELL_FILE_HANDLE Handle; 56 EFI_FILE_INFO *Info; 57 } EFI_SHELL_FILE_INFO; 58 59 typedef 60 BOOLEAN 61 (EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) ( 62 VOID 63 ); 64 65 typedef 66 EFI_STATUS 67 (EFIAPI *EFI_SHELL_CLOSE_FILE) ( 68 IN SHELL_FILE_HANDLE FileHandle 69 ); 70 71 typedef 72 EFI_STATUS 73 (EFIAPI *EFI_SHELL_CREATE_FILE) ( 74 IN CONST CHAR16 *FileName, 75 IN UINT64 FileAttribs, 76 OUT SHELL_FILE_HANDLE *FileHandle 77 ); 78 79 typedef 80 EFI_STATUS 81 (EFIAPI *EFI_SHELL_DELETE_FILE) ( 82 IN SHELL_FILE_HANDLE FileHandle 83 ); 84 85 typedef 86 EFI_STATUS 87 (EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME) ( 88 IN CONST CHAR16 *FileName 89 ); 90 91 typedef 92 VOID 93 (EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) ( 94 VOID 95 ); 96 97 typedef 98 VOID 99 (EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) ( 100 VOID 101 ); 102 103 typedef 104 EFI_STATUS 105 (EFIAPI *EFI_SHELL_EXECUTE) ( 106 IN EFI_HANDLE *ParentImageHandle, 107 IN CHAR16 *CommandLine OPTIONAL, 108 IN CHAR16 **Environment OPTIONAL, 109 OUT EFI_STATUS *StatusCode OPTIONAL 110 ); 111 112 typedef 113 EFI_STATUS 114 (EFIAPI *EFI_SHELL_FIND_FILES) ( 115 IN CONST CHAR16 *FilePattern, 116 OUT EFI_SHELL_FILE_INFO **FileList 117 ); 118 119 typedef 120 EFI_STATUS 121 (EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR) ( 122 IN SHELL_FILE_HANDLE FileDirHandle, 123 OUT EFI_SHELL_FILE_INFO **FileList 124 ); 125 126 typedef 127 EFI_STATUS 128 (EFIAPI *EFI_SHELL_FLUSH_FILE) ( 129 IN SHELL_FILE_HANDLE FileHandle 130 ); 131 132 typedef 133 EFI_STATUS 134 (EFIAPI *EFI_SHELL_FREE_FILE_LIST) ( 135 IN EFI_SHELL_FILE_INFO **FileList 136 ); 137 138 typedef 139 CONST CHAR16 * 140 (EFIAPI *EFI_SHELL_GET_ALIAS) ( 141 IN CONST CHAR16 *Alias, 142 OUT BOOLEAN *Volatile OPTIONAL 143 ); 144 145 typedef 146 CONST CHAR16 * 147 (EFIAPI *EFI_SHELL_GET_CUR_DIR) ( 148 IN CONST CHAR16 *FileSystemMapping OPTIONAL 149 ); 150 151 typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS; 152 #define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001 153 #define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002 154 155 typedef 156 EFI_STATUS 157 (EFIAPI *EFI_SHELL_GET_DEVICE_NAME) ( 158 IN EFI_HANDLE DeviceHandle, 159 IN EFI_SHELL_DEVICE_NAME_FLAGS Flags, 160 IN CHAR8 *Language, 161 OUT CHAR16 **BestDeviceName 162 ); 163 164 typedef 165 CONST EFI_DEVICE_PATH_PROTOCOL * 166 (EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) ( 167 IN CONST CHAR16 *Mapping 168 ); 169 170 typedef 171 EFI_DEVICE_PATH_PROTOCOL * 172 (EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) ( 173 IN CONST CHAR16 *Path 174 ); 175 176 typedef 177 CONST CHAR16 * 178 (EFIAPI *EFI_SHELL_GET_ENV) ( 179 IN CONST CHAR16 *Name 180 ); 181 182 typedef 183 CONST CHAR16 * 184 (EFIAPI *EFI_SHELL_GET_ENV_EX) ( 185 IN CONST CHAR16 *Name, 186 OUT UINT32 *Attributes OPTIONAL 187 ); 188 189 typedef 190 EFI_FILE_INFO * 191 (EFIAPI *EFI_SHELL_GET_FILE_INFO) ( 192 IN SHELL_FILE_HANDLE FileHandle 193 ); 194 195 typedef 196 CHAR16 * 197 (EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) ( 198 IN CONST EFI_DEVICE_PATH_PROTOCOL *Path 199 ); 200 201 typedef 202 EFI_STATUS 203 (EFIAPI *EFI_SHELL_GET_FILE_POSITION) ( 204 IN SHELL_FILE_HANDLE FileHandle, 205 OUT UINT64 *Position 206 ); 207 208 typedef 209 EFI_STATUS 210 (EFIAPI *EFI_SHELL_GET_FILE_SIZE) ( 211 IN SHELL_FILE_HANDLE FileHandle, 212 OUT UINT64 *Size 213 ); 214 215 typedef 216 EFI_STATUS 217 (EFIAPI *EFI_SHELL_GET_GUID_FROM_NAME) ( 218 IN CONST CHAR16 *GuidName, 219 OUT EFI_GUID *Guid 220 ); 221 222 typedef 223 EFI_STATUS 224 (EFIAPI *EFI_SHELL_GET_GUID_NAME)( 225 IN CONST EFI_GUID *Guid, 226 OUT CONST CHAR16 **GuidName 227 ); 228 229 typedef 230 EFI_STATUS 231 (EFIAPI *EFI_SHELL_GET_HELP_TEXT) ( 232 IN CONST CHAR16 *Command, 233 IN CONST CHAR16 *Sections, 234 OUT CHAR16 **HelpText 235 ); 236 237 typedef 238 CONST CHAR16 * 239 (EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) ( 240 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath 241 ); 242 243 typedef 244 BOOLEAN 245 (EFIAPI *EFI_SHELL_GET_PAGE_BREAK) ( 246 VOID 247 ); 248 249 typedef 250 BOOLEAN 251 (EFIAPI *EFI_SHELL_IS_ROOT_SHELL) ( 252 VOID 253 ); 254 255 typedef 256 EFI_STATUS 257 (EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) ( 258 IN CONST CHAR16 *FileName, 259 OUT SHELL_FILE_HANDLE *FileHandle, 260 IN UINT64 OpenMode 261 ); 262 263 typedef 264 EFI_STATUS 265 (EFIAPI *EFI_SHELL_OPEN_FILE_LIST) ( 266 IN CHAR16 *Path, 267 IN UINT64 OpenMode, 268 IN OUT EFI_SHELL_FILE_INFO **FileList 269 ); 270 271 typedef 272 EFI_STATUS 273 (EFIAPI *EFI_SHELL_OPEN_ROOT) ( 274 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, 275 OUT SHELL_FILE_HANDLE *FileHandle 276 ); 277 278 typedef 279 EFI_STATUS 280 (EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE) ( 281 IN EFI_HANDLE DeviceHandle, 282 OUT SHELL_FILE_HANDLE *FileHandle 283 ); 284 285 typedef 286 EFI_STATUS 287 (EFIAPI *EFI_SHELL_READ_FILE) ( 288 IN SHELL_FILE_HANDLE FileHandle, 289 IN OUT UINTN *ReadSize, 290 IN OUT VOID *Buffer 291 ); 292 293 typedef 294 EFI_STATUS 295 (EFIAPI *EFI_SHELL_REGISTER_GUID_NAME) ( 296 IN CONST EFI_GUID *Guid, 297 IN CONST CHAR16 *GuidName 298 ); 299 300 typedef 301 EFI_STATUS 302 (EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) ( 303 IN EFI_SHELL_FILE_INFO **FileList 304 ); 305 306 typedef 307 EFI_STATUS 308 (EFIAPI *EFI_SHELL_SET_ALIAS) ( 309 IN CONST CHAR16 *Command, 310 IN CONST CHAR16 *Alias, 311 IN BOOLEAN Replace, 312 IN BOOLEAN Volatile 313 ); 314 315 typedef 316 EFI_STATUS 317 (EFIAPI *EFI_SHELL_SET_CUR_DIR) ( 318 IN CONST CHAR16 *FileSystem OPTIONAL, 319 IN CONST CHAR16 *Dir 320 ); 321 322 typedef 323 EFI_STATUS 324 (EFIAPI *EFI_SHELL_SET_ENV) ( 325 IN CONST CHAR16 *Name, 326 IN CONST CHAR16 *Value, 327 IN BOOLEAN Volatile 328 ); 329 330 typedef 331 EFI_STATUS 332 (EFIAPI *EFI_SHELL_SET_FILE_INFO) ( 333 IN SHELL_FILE_HANDLE FileHandle, 334 IN CONST EFI_FILE_INFO *FileInfo 335 ); 336 337 typedef 338 EFI_STATUS 339 (EFIAPI *EFI_SHELL_SET_FILE_POSITION) ( 340 IN SHELL_FILE_HANDLE FileHandle, 341 IN UINT64 Position 342 ); 343 344 typedef 345 EFI_STATUS 346 (EFIAPI *EFI_SHELL_SET_MAP) ( 347 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, 348 IN CONST CHAR16 *Mapping 349 ); 350 351 typedef 352 EFI_STATUS 353 (EFIAPI *EFI_SHELL_WRITE_FILE) ( 354 IN SHELL_FILE_HANDLE FileHandle, 355 IN OUT UINTN *BufferSize, 356 IN VOID *Buffer 357 ); 358 359 typedef struct _EFI_SHELL_PROTOCOL { 360 EFI_SHELL_EXECUTE Execute; 361 EFI_SHELL_GET_ENV GetEnv; 362 EFI_SHELL_SET_ENV SetEnv; 363 EFI_SHELL_GET_ALIAS GetAlias; 364 EFI_SHELL_SET_ALIAS SetAlias; 365 EFI_SHELL_GET_HELP_TEXT GetHelpText; 366 EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap; 367 EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath; 368 EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath; 369 EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath; 370 EFI_SHELL_SET_MAP SetMap; 371 EFI_SHELL_GET_CUR_DIR GetCurDir; 372 EFI_SHELL_SET_CUR_DIR SetCurDir; 373 EFI_SHELL_OPEN_FILE_LIST OpenFileList; 374 EFI_SHELL_FREE_FILE_LIST FreeFileList; 375 EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList; 376 EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive; 377 EFI_SHELL_IS_ROOT_SHELL IsRootShell; 378 EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak; 379 EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak; 380 EFI_SHELL_GET_PAGE_BREAK GetPageBreak; 381 EFI_SHELL_GET_DEVICE_NAME GetDeviceName; 382 EFI_SHELL_GET_FILE_INFO GetFileInfo; 383 EFI_SHELL_SET_FILE_INFO SetFileInfo; 384 EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName; 385 EFI_SHELL_CLOSE_FILE CloseFile; 386 EFI_SHELL_CREATE_FILE CreateFile; 387 EFI_SHELL_READ_FILE ReadFile; 388 EFI_SHELL_WRITE_FILE WriteFile; 389 EFI_SHELL_DELETE_FILE DeleteFile; 390 EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName; 391 EFI_SHELL_GET_FILE_POSITION GetFilePosition; 392 EFI_SHELL_SET_FILE_POSITION SetFilePosition; 393 EFI_SHELL_FLUSH_FILE FlushFile; 394 EFI_SHELL_FIND_FILES FindFiles; 395 EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir; 396 EFI_SHELL_GET_FILE_SIZE GetFileSize; 397 EFI_SHELL_OPEN_ROOT OpenRoot; 398 EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle; 399 EFI_EVENT ExecutionBreak; 400 UINT32 MajorVersion; 401 UINT32 MinorVersion; 402 // Added for Shell 2.1 403 EFI_SHELL_REGISTER_GUID_NAME RegisterGuidName; 404 EFI_SHELL_GET_GUID_NAME GetGuidName; 405 EFI_SHELL_GET_GUID_FROM_NAME GetGuidFromName; 406 EFI_SHELL_GET_ENV_EX GetEnvEx; 407 } EFI_SHELL_PROTOCOL; 408 409 #define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \ 410 { 0x752f3136, 0x4e16, 0x4fdc, { 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca } } 411 412 INTERFACE_DECL(_EFI_SHELL_PARAMETERS_PROTOCOL); 413 414 typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL { 415 CHAR16 **Argv; 416 UINTN Argc; 417 SHELL_FILE_HANDLE StdIn; 418 SHELL_FILE_HANDLE StdOut; 419 SHELL_FILE_HANDLE StdErr; 420 } EFI_SHELL_PARAMETERS_PROTOCOL; 421 422 #endif 423