ConsoleLogger.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /** @file
  2. Provides interface to shell console logger.
  3. Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _CONSOLE_LOGGER_HEADER_
  7. #define _CONSOLE_LOGGER_HEADER_
  8. #include "Shell.h"
  9. #define CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('c', 'o', 'P', 'D')
  10. typedef struct _CONSOLE_LOGGER_PRIVATE_DATA {
  11. UINTN Signature;
  12. EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL OurConOut; ///< the protocol we installed onto the system table
  13. EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OldConOut; ///< old protocol to reinstall upon exiting
  14. EFI_HANDLE OldConHandle; ///< old protocol handle
  15. UINTN ScreenCount; ///< How many screens worth of data to save
  16. CHAR16 *Buffer; ///< Buffer to save data
  17. UINTN BufferSize; ///< size of buffer in bytes
  18. // start row is the top of the screen
  19. UINTN OriginalStartRow; ///< What the originally visible start row was
  20. UINTN CurrentStartRow; ///< what the currently visible start row is
  21. UINTN RowsPerScreen; ///< how many rows the screen can display
  22. UINTN ColsPerScreen; ///< how many columns the screen can display
  23. INT32 *Attributes; ///< Buffer for Attribute to be saved for each character
  24. UINTN AttribSize; ///< Size of Attributes in bytes
  25. EFI_SIMPLE_TEXT_OUTPUT_MODE HistoryMode; ///< mode of the history log
  26. BOOLEAN Enabled; ///< Set to FALSE when a break is requested.
  27. UINTN RowCounter; ///< Initial row of each print job.
  28. } CONSOLE_LOGGER_PRIVATE_DATA;
  29. #define CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(a) CR (a, CONSOLE_LOGGER_PRIVATE_DATA, OurConOut, CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE)
  30. /**
  31. Install our intermediate ConOut into the system table to
  32. keep a log of all the info that is displayed to the user.
  33. @param[in] ScreensToSave Sets how many screen-worths of data to save.
  34. @param[out] ConsoleInfo The object to pass into later functions.
  35. @retval EFI_SUCCESS The operation was successful.
  36. @return other The operation failed.
  37. @sa ConsoleLoggerResetBuffers
  38. @sa InstallProtocolInterface
  39. **/
  40. EFI_STATUS
  41. ConsoleLoggerInstall (
  42. IN CONST UINTN ScreensToSave,
  43. OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
  44. );
  45. /**
  46. Return the system to the state it was before InstallConsoleLogger
  47. was installed.
  48. @param[in, out] ConsoleInfo The object from the install function.
  49. @retval EFI_SUCCESS The operation was successful
  50. @return other The operation failed. This was from UninstallProtocolInterface.
  51. **/
  52. EFI_STATUS
  53. ConsoleLoggerUninstall (
  54. IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
  55. );
  56. /**
  57. Displays previously logged output back to the screen.
  58. This will scroll the screen forwards and backwards through the log of previous
  59. output. If Rows is 0 then the size of 1/2 the screen will be scrolled. If Rows
  60. is (UINTN)(-1) then the size of the screen will be scrolled.
  61. @param[in] Forward If TRUE then the log will be displayed forwards (scroll to newer).
  62. If FALSE then the log will be displayed backwards (scroll to older).
  63. @param[in] Rows Determines how many rows the log should scroll.
  64. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
  65. **/
  66. EFI_STATUS
  67. ConsoleLoggerDisplayHistory (
  68. IN CONST BOOLEAN Forward,
  69. IN CONST UINTN Rows,
  70. IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
  71. );
  72. /**
  73. Function to return to normal output whent he scrolling is complete.
  74. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
  75. @retval EFI_SUCCESS The operation was successful.
  76. @return other The operation failed. See UpdateDisplayFromHistory.
  77. @sa UpdateDisplayFromHistory
  78. **/
  79. EFI_STATUS
  80. ConsoleLoggerStopHistory (
  81. IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
  82. );
  83. /**
  84. Updates the hidden ConOut to be displaying the correct stuff.
  85. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
  86. @retval EFI_SUCCESS The operation was successful.
  87. @return other The operation failed.
  88. **/
  89. EFI_STATUS
  90. UpdateDisplayFromHistory (
  91. IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
  92. );
  93. /**
  94. Reset the text output device hardware and optionally run diagnostics
  95. @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
  96. @param ExtendedVerification Indicates that a more extensive test may be performed
  97. @retval EFI_SUCCESS The text output device was reset.
  98. @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
  99. could not be reset.
  100. **/
  101. EFI_STATUS
  102. EFIAPI
  103. ConsoleLoggerReset (
  104. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  105. IN BOOLEAN ExtendedVerification
  106. );
  107. /**
  108. Write a Unicode string to the output device.
  109. @param[in] This Protocol instance pointer.
  110. @param[in] WString The NULL-terminated Unicode string to be displayed on the output
  111. device(s). All output devices must also support the Unicode
  112. drawing defined in this file.
  113. @retval EFI_SUCCESS The string was output to the device.
  114. @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
  115. the text.
  116. @retval EFI_UNSUPPORTED The output device's mode is not currently in a
  117. defined text mode.
  118. @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
  119. characters in the Unicode string could not be
  120. rendered and were skipped.
  121. **/
  122. EFI_STATUS
  123. EFIAPI
  124. ConsoleLoggerOutputString (
  125. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  126. IN CHAR16 *WString
  127. );
  128. /**
  129. Verifies that all characters in a Unicode string can be output to the
  130. target device.
  131. @param[in] This Protocol instance pointer.
  132. @param[in] WString The NULL-terminated Unicode string to be examined for the output
  133. device(s).
  134. @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
  135. @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
  136. rendered by one or more of the output devices mapped
  137. by the EFI handle.
  138. **/
  139. EFI_STATUS
  140. EFIAPI
  141. ConsoleLoggerTestString (
  142. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  143. IN CHAR16 *WString
  144. );
  145. /**
  146. Returns information for an available text mode that the output device(s)
  147. supports.
  148. @param[in] This Protocol instance pointer.
  149. @param[in] ModeNumber The mode number to return information on.
  150. @param[out] Columns Upon return, the number of columns in the selected geometry
  151. @param[out] Rows Upon return, the number of rows in the selected geometry
  152. @retval EFI_SUCCESS The requested mode information was returned.
  153. @retval EFI_DEVICE_ERROR The device had an error and could not
  154. complete the request.
  155. @retval EFI_UNSUPPORTED The mode number was not valid.
  156. **/
  157. EFI_STATUS
  158. EFIAPI
  159. ConsoleLoggerQueryMode (
  160. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  161. IN UINTN ModeNumber,
  162. OUT UINTN *Columns,
  163. OUT UINTN *Rows
  164. );
  165. /**
  166. Sets the output device(s) to a specified mode.
  167. @param[in] This Protocol instance pointer.
  168. @param[in] ModeNumber The mode number to set.
  169. @retval EFI_SUCCESS The requested text mode was set.
  170. @retval EFI_DEVICE_ERROR The device had an error and
  171. could not complete the request.
  172. @retval EFI_UNSUPPORTED The mode number was not valid.
  173. **/
  174. EFI_STATUS
  175. EFIAPI
  176. ConsoleLoggerSetMode (
  177. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  178. IN UINTN ModeNumber
  179. );
  180. /**
  181. Sets the background and foreground colors for the OutputString () and
  182. ClearScreen () functions.
  183. @param[in] This Protocol instance pointer.
  184. @param[in] Attribute The attribute to set. Bits 0..3 are the foreground color, and
  185. bits 4..6 are the background color. All other bits are undefined
  186. and must be zero. The valid Attributes are defined in this file.
  187. @retval EFI_SUCCESS The attribute was set.
  188. @retval EFI_DEVICE_ERROR The device had an error and
  189. could not complete the request.
  190. @retval EFI_UNSUPPORTED The attribute requested is not defined.
  191. **/
  192. EFI_STATUS
  193. EFIAPI
  194. ConsoleLoggerSetAttribute (
  195. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  196. IN UINTN Attribute
  197. );
  198. /**
  199. Clears the output device(s) display to the currently selected background
  200. color.
  201. @param[in] This Protocol instance pointer.
  202. @retval EFI_SUCCESS The operation completed successfully.
  203. @retval EFI_DEVICE_ERROR The device had an error and
  204. could not complete the request.
  205. @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
  206. **/
  207. EFI_STATUS
  208. EFIAPI
  209. ConsoleLoggerClearScreen (
  210. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
  211. );
  212. /**
  213. Sets the current coordinates of the cursor position.
  214. @param[in] This Protocol instance pointer.
  215. @param[in] Column Column to put the cursor in. Must be between zero and Column returned from QueryMode
  216. @param[in] Row Row to put the cursor in. Must be between zero and Row returned from QueryMode
  217. @retval EFI_SUCCESS The operation completed successfully.
  218. @retval EFI_DEVICE_ERROR The device had an error and
  219. could not complete the request.
  220. @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
  221. cursor position is invalid for the current mode.
  222. **/
  223. EFI_STATUS
  224. EFIAPI
  225. ConsoleLoggerSetCursorPosition (
  226. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  227. IN UINTN Column,
  228. IN UINTN Row
  229. );
  230. /**
  231. Makes the cursor visible or invisible
  232. @param[in] This Protocol instance pointer.
  233. @param[in] Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is
  234. set to be invisible.
  235. @retval EFI_SUCCESS The operation completed successfully.
  236. @retval EFI_DEVICE_ERROR The device had an error and could not complete the
  237. request, or the device does not support changing
  238. the cursor mode.
  239. @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
  240. **/
  241. EFI_STATUS
  242. EFIAPI
  243. ConsoleLoggerEnableCursor (
  244. IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
  245. IN BOOLEAN Visible
  246. );
  247. /**
  248. Function to update and verify that the current buffers are correct.
  249. @param[in] ConsoleInfo The pointer to the instance of the console logger information.
  250. This will be used when a mode has changed or a reset occurred to verify all
  251. history buffers.
  252. **/
  253. EFI_STATUS
  254. ConsoleLoggerResetBuffers (
  255. IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
  256. );
  257. #endif //_CONSOLE_LOGGER_HEADER_