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