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