UefiShellLevel2CommandsLib.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /** @file
  2. Main file for NULL named library for level 2 shell command functions.
  3. these functions are:
  4. attrib, cd, cp, date*, time*, rm, reset,
  5. load, ls, map, mkdir, mv, parse, set, timezone*
  6. * functions are non-interactive only
  7. Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
  8. SPDX-License-Identifier: BSD-2-Clause-Patent
  9. **/
  10. #ifndef _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
  11. #define _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
  12. #include <Uefi.h>
  13. #include <Guid/GlobalVariable.h>
  14. #include <Guid/ShellLibHiiGuid.h>
  15. #include <Protocol/Shell.h>
  16. #include <Protocol/ShellParameters.h>
  17. #include <Protocol/DevicePath.h>
  18. #include <Protocol/LoadedImage.h>
  19. #include <Protocol/UnicodeCollation.h>
  20. #include <Library/BaseLib.h>
  21. #include <Library/BaseMemoryLib.h>
  22. #include <Library/DebugLib.h>
  23. #include <Library/MemoryAllocationLib.h>
  24. #include <Library/PcdLib.h>
  25. #include <Library/ShellCommandLib.h>
  26. #include <Library/ShellLib.h>
  27. #include <Library/UefiLib.h>
  28. #include <Library/UefiRuntimeServicesTableLib.h>
  29. #include <Library/UefiBootServicesTableLib.h>
  30. #include <Library/HiiLib.h>
  31. #include <Library/SortLib.h>
  32. #include <Library/FileHandleLib.h>
  33. extern CONST CHAR16 mFileName[];
  34. extern EFI_HII_HANDLE gShellLevel2HiiHandle;
  35. /**
  36. Function for 'attrib' command.
  37. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  38. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  39. **/
  40. SHELL_STATUS
  41. EFIAPI
  42. ShellCommandRunAttrib (
  43. IN EFI_HANDLE ImageHandle,
  44. IN EFI_SYSTEM_TABLE *SystemTable
  45. );
  46. /**
  47. Function for 'date' command.
  48. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  49. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  50. **/
  51. SHELL_STATUS
  52. EFIAPI
  53. ShellCommandRunDate (
  54. IN EFI_HANDLE ImageHandle,
  55. IN EFI_SYSTEM_TABLE *SystemTable
  56. );
  57. /**
  58. Function for 'time' command.
  59. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  60. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  61. **/
  62. SHELL_STATUS
  63. EFIAPI
  64. ShellCommandRunTime (
  65. IN EFI_HANDLE ImageHandle,
  66. IN EFI_SYSTEM_TABLE *SystemTable
  67. );
  68. /**
  69. Function for 'load' command.
  70. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  71. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  72. **/
  73. SHELL_STATUS
  74. EFIAPI
  75. ShellCommandRunLoad (
  76. IN EFI_HANDLE ImageHandle,
  77. IN EFI_SYSTEM_TABLE *SystemTable
  78. );
  79. /**
  80. Function for 'ls' command.
  81. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  82. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  83. **/
  84. SHELL_STATUS
  85. EFIAPI
  86. ShellCommandRunLs (
  87. IN EFI_HANDLE ImageHandle,
  88. IN EFI_SYSTEM_TABLE *SystemTable
  89. );
  90. /**
  91. Function for 'map' command.
  92. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  93. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  94. **/
  95. SHELL_STATUS
  96. EFIAPI
  97. ShellCommandRunMap (
  98. IN EFI_HANDLE ImageHandle,
  99. IN EFI_SYSTEM_TABLE *SystemTable
  100. );
  101. /**
  102. Function for 'reset' command.
  103. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  104. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  105. **/
  106. SHELL_STATUS
  107. EFIAPI
  108. ShellCommandRunReset (
  109. IN EFI_HANDLE ImageHandle,
  110. IN EFI_SYSTEM_TABLE *SystemTable
  111. );
  112. /**
  113. Function for 'timezone' command.
  114. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  115. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  116. **/
  117. SHELL_STATUS
  118. EFIAPI
  119. ShellCommandRunTimeZone (
  120. IN EFI_HANDLE ImageHandle,
  121. IN EFI_SYSTEM_TABLE *SystemTable
  122. );
  123. /**
  124. Function for 'set' command.
  125. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  126. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  127. **/
  128. SHELL_STATUS
  129. EFIAPI
  130. ShellCommandRunSet (
  131. IN EFI_HANDLE ImageHandle,
  132. IN EFI_SYSTEM_TABLE *SystemTable
  133. );
  134. /**
  135. Function for 'mkdir' command.
  136. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  137. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  138. **/
  139. SHELL_STATUS
  140. EFIAPI
  141. ShellCommandRunMkDir (
  142. IN EFI_HANDLE ImageHandle,
  143. IN EFI_SYSTEM_TABLE *SystemTable
  144. );
  145. /**
  146. Function for 'cd' command.
  147. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  148. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  149. **/
  150. SHELL_STATUS
  151. EFIAPI
  152. ShellCommandRunCd (
  153. IN EFI_HANDLE ImageHandle,
  154. IN EFI_SYSTEM_TABLE *SystemTable
  155. );
  156. /**
  157. Function for 'cp' command.
  158. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  159. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  160. **/
  161. SHELL_STATUS
  162. EFIAPI
  163. ShellCommandRunCp (
  164. IN EFI_HANDLE ImageHandle,
  165. IN EFI_SYSTEM_TABLE *SystemTable
  166. );
  167. /**
  168. Function for 'parse' command.
  169. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  170. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  171. **/
  172. SHELL_STATUS
  173. EFIAPI
  174. ShellCommandRunParse (
  175. IN EFI_HANDLE ImageHandle,
  176. IN EFI_SYSTEM_TABLE *SystemTable
  177. );
  178. /**
  179. Function for 'rm' command.
  180. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  181. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  182. **/
  183. SHELL_STATUS
  184. EFIAPI
  185. ShellCommandRunRm (
  186. IN EFI_HANDLE ImageHandle,
  187. IN EFI_SYSTEM_TABLE *SystemTable
  188. );
  189. /**
  190. Function for 'mv' command.
  191. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  192. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  193. **/
  194. SHELL_STATUS
  195. EFIAPI
  196. ShellCommandRunMv (
  197. IN EFI_HANDLE ImageHandle,
  198. IN EFI_SYSTEM_TABLE *SystemTable
  199. );
  200. /**
  201. returns a fully qualified directory (contains a map drive at the begining)
  202. path from a unknown directory path.
  203. If Path is already fully qualified this will return a duplicat otherwise this
  204. will use get the current directory and use that to build the fully qualified
  205. version.
  206. if the return value is not NULL it must be caller freed.
  207. @param[in] Path The unknown Path Value
  208. @retval NULL A memory allocation failed
  209. @retval NULL a fully qualified path could not be discovered.
  210. @retval other pointer to a fuly qualified path.
  211. **/
  212. CHAR16*
  213. GetFullyQualifiedPath(
  214. IN CONST CHAR16* Path
  215. );
  216. /**
  217. Function to verify all intermediate directories in the path.
  218. @param[in] Path The pointer to the path to fix.
  219. @retval EFI_SUCCESS The operation was successful.
  220. **/
  221. EFI_STATUS
  222. VerifyIntermediateDirectories (
  223. IN CONST CHAR16 *Path
  224. );
  225. /**
  226. String comparison without regard to case for a limited number of characters.
  227. @param[in] Source The first item to compare.
  228. @param[in] Target The second item to compare.
  229. @param[in] Count How many characters to compare.
  230. @retval 0 Source and Target are identical strings without regard to case.
  231. @retval !=0 Source is not identical to Target.
  232. **/
  233. INTN
  234. StrniCmp(
  235. IN CONST CHAR16 *Source,
  236. IN CONST CHAR16 *Target,
  237. IN CONST UINTN Count
  238. );
  239. /**
  240. Cleans off all the quotes in the string.
  241. @param[in] OriginalString pointer to the string to be cleaned.
  242. @param[out] CleanString The new string with all quotes removed.
  243. Memory allocated in the function and free
  244. by caller.
  245. @retval EFI_SUCCESS The operation was successful.
  246. **/
  247. EFI_STATUS
  248. ShellLevel2StripQuotes (
  249. IN CONST CHAR16 *OriginalString,
  250. OUT CHAR16 **CleanString
  251. );
  252. /**
  253. Function for 'Vol' command.
  254. @param[in] ImageHandle Handle to the Image (NULL if Internal).
  255. @param[in] SystemTable Pointer to the System Table (NULL if Internal).
  256. **/
  257. SHELL_STATUS
  258. EFIAPI
  259. ShellCommandRunVol (
  260. IN EFI_HANDLE ImageHandle,
  261. IN EFI_SYSTEM_TABLE *SystemTable
  262. );
  263. /**
  264. Function to Copy one file to another location
  265. If the destination exists the user will be prompted and the result put into *resp
  266. @param[in] Source pointer to source file name
  267. @param[in] Dest pointer to destination file name
  268. @param[out] Resp pointer to response from question. Pass back on looped calling
  269. @param[in] SilentMode whether to run in quiet mode or not
  270. @param[in] CmdName Source command name requesting single file copy
  271. @retval SHELL_SUCCESS The source file was copied to the destination
  272. **/
  273. SHELL_STATUS
  274. CopySingleFile(
  275. IN CONST CHAR16 *Source,
  276. IN CONST CHAR16 *Dest,
  277. OUT VOID **Resp,
  278. IN BOOLEAN SilentMode,
  279. IN CONST CHAR16 *CmdName
  280. );
  281. /**
  282. Delete a node and all nodes under it (including sub directories).
  283. @param[in] Node The node to start deleting with.
  284. @param[in] Quiet TRUE to print no messages.
  285. @retval SHELL_SUCCESS The operation was successful.
  286. @retval SHELL_ACCESS_DENIED A file was read only.
  287. @retval SHELL_ABORTED The abort message was received.
  288. @retval SHELL_DEVICE_ERROR A device error occurred reading this Node.
  289. **/
  290. SHELL_STATUS
  291. CascadeDelete(
  292. IN EFI_SHELL_FILE_INFO *Node,
  293. IN CONST BOOLEAN Quiet
  294. );
  295. #endif