efishell.h 11 KB

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