33 ASSERT (ConsoleInfo !=
NULL);
36 if ((*ConsoleInfo) ==
NULL) {
37 return (EFI_OUT_OF_RESOURCES);
40 (*ConsoleInfo)->Signature = CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE;
43 (*ConsoleInfo)->Buffer =
NULL;
44 (*ConsoleInfo)->BufferSize = 0;
45 (*ConsoleInfo)->OriginalStartRow = 0;
46 (*ConsoleInfo)->CurrentStartRow = 0;
47 (*ConsoleInfo)->RowsPerScreen = 0;
48 (*ConsoleInfo)->ColsPerScreen = 0;
49 (*ConsoleInfo)->Attributes =
NULL;
50 (*ConsoleInfo)->AttribSize = 0;
51 (*ConsoleInfo)->ScreenCount = ScreensToSave;
52 (*ConsoleInfo)->HistoryMode.MaxMode = 1;
53 (*ConsoleInfo)->HistoryMode.Mode = 0;
54 (*ConsoleInfo)->HistoryMode.Attribute = 0;
55 (*ConsoleInfo)->HistoryMode.CursorColumn = 0;
56 (*ConsoleInfo)->HistoryMode.CursorRow = 0;
57 (*ConsoleInfo)->HistoryMode.CursorVisible =
FALSE;
68 (*ConsoleInfo)->Enabled =
TRUE;
71 if (EFI_ERROR (Status)) {
72 SHELL_FREE_NON_NULL ((*ConsoleInfo));
78 if (EFI_ERROR (Status)) {
79 SHELL_FREE_NON_NULL ((*ConsoleInfo)->Buffer);
80 SHELL_FREE_NON_NULL ((*ConsoleInfo)->Attributes);
81 SHELL_FREE_NON_NULL ((*ConsoleInfo));
115 ASSERT (ConsoleInfo !=
NULL);
116 ASSERT (ConsoleInfo->OldConOut !=
NULL);
118 if (ConsoleInfo->Buffer !=
NULL) {
121 ConsoleInfo->Buffer =
NULL;
124 ConsoleInfo->BufferSize = 0;
128 if (ConsoleInfo->Attributes !=
NULL) {
131 ConsoleInfo->Attributes =
NULL;
134 ConsoleInfo->AttribSize = 0;
145 gBS->CalculateCrc32 (
151 return (
gBS->UninstallProtocolInterface (
gImageHandle, &gEfiSimpleTextOutProtocolGuid, (VOID *)&ConsoleInfo->OurConOut));
175 ASSERT (ConsoleInfo !=
NULL);
182 RowChange = ConsoleInfo->RowsPerScreen;
185 RowChange = ConsoleInfo->RowsPerScreen / 2;
196 if ((ConsoleInfo->OriginalStartRow - ConsoleInfo->CurrentStartRow) < RowChange) {
197 RowChange = ConsoleInfo->OriginalStartRow - ConsoleInfo->CurrentStartRow;
200 if (ConsoleInfo->CurrentStartRow < RowChange) {
201 RowChange = ConsoleInfo->CurrentStartRow;
208 if (RowChange == 0) {
215 ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
221 ConsoleInfo->CurrentStartRow += RowChange;
223 ConsoleInfo->CurrentStartRow -= RowChange;
246 ASSERT (ConsoleInfo !=
NULL);
247 if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) {
254 ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
256 ConsoleInfo->CurrentStartRow = ConsoleInfo->OriginalStartRow;
277 CHAR16 TempCharHolder;
281 CHAR16 *StringSegment;
282 CHAR16 *StringSegmentEnd;
283 CHAR16 StringSegmentEndChar;
286 ASSERT (ConsoleInfo !=
NULL);
287 TempCharHolder = CHAR_NULL;
289 OrigAttribute = ConsoleInfo->OldConOut->Mode->Attribute;
294 ConsoleInfo->OldConOut->EnableCursor (ConsoleInfo->OldConOut,
FALSE);
295 ConsoleInfo->OldConOut->SetCursorPosition (ConsoleInfo->OldConOut, 0, 0);
297 Screen = &ConsoleInfo->Buffer[(ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->CurrentStartRow];
298 Attributes = &ConsoleInfo->Attributes[ConsoleInfo->ColsPerScreen * ConsoleInfo->CurrentStartRow];
300 ; CurrentRow < ConsoleInfo->RowsPerScreen
302 Screen += (ConsoleInfo->ColsPerScreen + 2),
303 Attributes += ConsoleInfo->ColsPerScreen
309 if (CurrentRow == (ConsoleInfo->RowsPerScreen-1)) {
310 TempCharHolder = Screen[ConsoleInfo->ColsPerScreen - 1];
311 Screen[ConsoleInfo->ColsPerScreen - 1] = CHAR_NULL;
315 ; Column < ConsoleInfo->ColsPerScreen
319 if (Screen[Column] != CHAR_NULL) {
320 CurrentAttrib = Attributes[Column];
321 CurrentColumn = Column;
322 StringSegment = &Screen[Column];
329 StringSegmentEndChar = CHAR_NULL;
330 for ( StringSegmentEnd = StringSegment
331 ; *StringSegmentEnd != CHAR_NULL
332 ; StringSegmentEnd++,
336 if (Attributes[Column] != CurrentAttrib) {
337 StringSegmentEndChar = *StringSegmentEnd;
338 *StringSegmentEnd = CHAR_NULL;
347 ConsoleInfo->OldConOut->SetAttribute (ConsoleInfo->OldConOut, CurrentAttrib);
348 ConsoleInfo->OldConOut->SetCursorPosition (ConsoleInfo->OldConOut, CurrentColumn, CurrentRow);
349 Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, StringSegment);
351 if (EFI_ERROR (Status)) {
361 if (StringSegmentEndChar != CHAR_NULL) {
362 *StringSegmentEnd = StringSegmentEndChar;
363 StringSegmentEndChar = CHAR_NULL;
372 if (TempCharHolder != CHAR_NULL) {
373 Screen[ConsoleInfo->ColsPerScreen - 1] = TempCharHolder;
374 TempCharHolder = CHAR_NULL;
382 if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) {
383 ConsoleInfo->OldConOut->SetAttribute (
384 ConsoleInfo->OldConOut,
385 ConsoleInfo->HistoryMode.Attribute
387 ConsoleInfo->OldConOut->SetCursorPosition (
388 ConsoleInfo->OldConOut,
389 ConsoleInfo->HistoryMode.CursorColumn,
390 ConsoleInfo->HistoryMode.CursorRow - ConsoleInfo->OriginalStartRow
393 Status = ConsoleInfo->OldConOut->EnableCursor (
394 ConsoleInfo->OldConOut,
395 ConsoleInfo->HistoryMode.CursorVisible
397 if (EFI_ERROR (Status)) {
401 ConsoleInfo->OldConOut->SetAttribute (
402 ConsoleInfo->OldConOut,
424 IN BOOLEAN ExtendedVerification
430 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
435 Status = ConsoleInfo->
OldConOut->Reset (ConsoleInfo->
OldConOut, ExtendedVerification);
440 if (!EFI_ERROR (Status)) {
442 if (ExtendedVerification) {
465 CONST CHAR16 *Walker;
470 ASSERT (ConsoleInfo !=
NULL);
472 for ( Walker = String
473 ; Walker !=
NULL && *Walker != CHAR_NULL
478 case (CHAR_BACKSPACE):
479 if (ConsoleInfo->HistoryMode.CursorColumn > 0) {
480 ConsoleInfo->HistoryMode.CursorColumn--;
484 case (CHAR_LINEFEED):
485 if (ConsoleInfo->HistoryMode.CursorRow >= (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)) {
489 ASSERT (ConsoleInfo->HistoryMode.CursorRow == (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1));
494 CopySize = ConsoleInfo->ColsPerScreen
495 * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
496 *
sizeof (ConsoleInfo->Attributes[0]);
497 ASSERT (CopySize < ConsoleInfo->AttribSize);
499 ConsoleInfo->Attributes,
500 ConsoleInfo->Attributes + ConsoleInfo->ColsPerScreen,
505 ; Index < ConsoleInfo->ColsPerScreen
509 *(ConsoleInfo->Attributes + (CopySize/
sizeof (ConsoleInfo->Attributes[0])) + Index) = ConsoleInfo->HistoryMode.Attribute;
515 CopySize = (ConsoleInfo->ColsPerScreen + 2)
516 * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
517 *
sizeof (ConsoleInfo->Buffer[0]);
518 ASSERT (CopySize < ConsoleInfo->BufferSize);
521 ConsoleInfo->Buffer + (ConsoleInfo->ColsPerScreen + 2),
528 SetMem16 (((UINT8 *)ConsoleInfo->Buffer)+CopySize, ConsoleInfo->ColsPerScreen*sizeof (CHAR16), L
' ');
537 ASSERT (ConsoleInfo->OriginalStartRow == ConsoleInfo->CurrentStartRow);
541 if (ConsoleInfo->HistoryMode.CursorRow == (INT32)(ConsoleInfo->OriginalStartRow + ConsoleInfo->RowsPerScreen - 1)) {
542 ConsoleInfo->OriginalStartRow++;
543 ConsoleInfo->CurrentStartRow++;
546 ConsoleInfo->HistoryMode.CursorRow++;
550 case (CHAR_CARRIAGE_RETURN):
554 ConsoleInfo->HistoryMode.CursorColumn = 0;
561 PrintIndex = ConsoleInfo->HistoryMode.CursorRow * ConsoleInfo->ColsPerScreen + ConsoleInfo->HistoryMode.CursorColumn;
564 ; ConsoleInfo->HistoryMode.CursorColumn < (INT32)ConsoleInfo->ColsPerScreen
565 ; ConsoleInfo->HistoryMode.CursorColumn++,
570 if ( (*Walker == CHAR_NULL)
571 || (*Walker == CHAR_BACKSPACE)
572 || (*Walker == CHAR_LINEFEED)
573 || (*Walker == CHAR_CARRIAGE_RETURN)
584 ASSERT (PrintIndex + ConsoleInfo->HistoryMode.CursorRow < ConsoleInfo->BufferSize);
585 ConsoleInfo->Buffer[PrintIndex + (2*ConsoleInfo->HistoryMode.CursorRow)] = *Walker;
586 ASSERT (PrintIndex < ConsoleInfo->AttribSize);
587 ConsoleInfo->Attributes[PrintIndex] = ConsoleInfo->HistoryMode.Attribute;
593 if (ConsoleInfo->HistoryMode.CursorColumn >= (INT32)ConsoleInfo->ColsPerScreen) {
632 Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, (CHAR16 *)String);
634 if (EFI_ERROR (Status)) {
658 ASSERT (ShellInfoObject.PageBreakEnabled);
659 ShellInfoObject.PageBreakEnabled =
FALSE;
661 ShellInfoObject.PageBreakEnabled =
TRUE;
662 ASSERT (Resp !=
NULL);
664 return (EFI_NOT_FOUND);
667 if (EFI_ERROR (Status)) {
675 if (*Resp == ShellPromptResponseContinue) {
682 }
else if (*Resp == ShellPromptResponseQuit) {
688 gBS->SignalEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak);
689 return (EFI_DEVICE_ERROR);
718 CONST CHAR16 *Walker;
719 CONST CHAR16 *LineStart;
725 if (StringCopy ==
NULL) {
726 return (EFI_OUT_OF_RESOURCES);
729 for ( Walker = StringCopy,
730 LineStart = StringCopy
731 ; Walker !=
NULL && *Walker != CHAR_NULL
736 case (CHAR_BACKSPACE):
737 if (ConsoleInfo->OurConOut.Mode->CursorColumn > 0) {
738 ConsoleInfo->OurConOut.Mode->CursorColumn--;
742 case (CHAR_LINEFEED):
746 TempChar = *(Walker + 1);
747 *((CHAR16 *)(Walker+1)) = CHAR_NULL;
757 *((CHAR16 *)(Walker+1)) = TempChar;
762 LineStart = Walker + 1;
768 ConsoleInfo->OurConOut.Mode->CursorRow++;
771 case (CHAR_CARRIAGE_RETURN):
775 ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
781 ConsoleInfo->OurConOut.Mode->CursorColumn++;
785 if ((
INTN)ConsoleInfo->ColsPerScreen == ConsoleInfo->OurConOut.Mode->CursorColumn + 1) {
793 TempChar = *(Walker + 1);
794 *((CHAR16 *)(Walker+1)) = CHAR_NULL;
804 *((CHAR16 *)(Walker+1)) = TempChar;
809 LineStart = Walker + 1;
815 ConsoleInfo->OurConOut.Mode->CursorRow++;
816 ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
830 SHELL_FREE_NON_NULL (StringCopy);
831 return (EFI_DEVICE_ERROR);
836 if ((LineStart !=
NULL) && (*LineStart != CHAR_NULL)) {
840 SHELL_FREE_NON_NULL (StringCopy);
873 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
874 if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.
NoConsoleOut) {
875 return (EFI_UNSUPPORTED);
878 ASSERT (ShellInfoObject.
ConsoleInfo == ConsoleInfo);
880 Status =
gBS->HandleProtocol (
gST->
ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **)&TxtInEx);
881 if (!EFI_ERROR (Status)) {
889 Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
890 if (EFI_ERROR (Status)) {
894 if ((KeyData.
Key.UnicodeChar == L
's') && (KeyData.
Key.ScanCode == SCAN_NULL) &&
906 return (EFI_DEVICE_ERROR);
907 }
else if (ShellInfoObject.PageBreakEnabled) {
937 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
969 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
973 return (ConsoleInfo->
OldConOut->QueryMode (
1004 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
1014 if (!EFI_ERROR (Status)) {
1051 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
1061 if (!EFI_ERROR (Status)) {
1092 if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.
NoConsoleOut) {
1093 return (EFI_UNSUPPORTED);
1096 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
1106 if (!EFI_ERROR (Status)) {
1162 if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.
NoConsoleOut) {
1163 return (EFI_UNSUPPORTED);
1166 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
1170 Status = ConsoleInfo->
OldConOut->SetCursorPosition (
1179 if (!EFI_ERROR (Status)) {
1211 ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
1220 if (!EFI_ERROR (Status)) {
1242 if (ConsoleInfo->Buffer !=
NULL) {
1244 ConsoleInfo->Buffer =
NULL;
1245 ConsoleInfo->BufferSize = 0;
1248 if (ConsoleInfo->Attributes !=
NULL) {
1249 FreePool (ConsoleInfo->Attributes);
1250 ConsoleInfo->Attributes =
NULL;
1251 ConsoleInfo->AttribSize = 0;
1255 if (EFI_ERROR (Status)) {
1259 ConsoleInfo->BufferSize = (ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof (ConsoleInfo->Buffer[0]);
1260 ConsoleInfo->AttribSize = ConsoleInfo->ColsPerScreen * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount *
sizeof (ConsoleInfo->Attributes[0]);
1262 ConsoleInfo->Buffer = (CHAR16 *)
AllocateZeroPool (ConsoleInfo->BufferSize);
1264 if (ConsoleInfo->Buffer ==
NULL) {
1265 return (EFI_OUT_OF_RESOURCES);
1268 ConsoleInfo->Attributes = (INT32 *)
AllocateZeroPool (ConsoleInfo->AttribSize);
1269 if (ConsoleInfo->Attributes ==
NULL) {
1271 ConsoleInfo->Buffer =
NULL;
1272 return (EFI_OUT_OF_RESOURCES);
VOID *EFIAPI SetMem16(OUT VOID *Buffer, IN UINTN Length, IN UINT16 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS ConsoleLoggerResetBuffers(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS ConsoleLoggerPrintWithPageBreak(IN CONST CHAR16 *String, IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS ConsoleLoggerDoPageBreak(VOID)
EFI_STATUS EFIAPI ConsoleLoggerTestString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *WString)
EFI_STATUS EFIAPI ConsoleLoggerEnableCursor(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN Visible)
EFI_STATUS ConsoleLoggerDisplayHistory(IN CONST BOOLEAN Forward, IN CONST UINTN Rows, IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS AppendStringToHistory(IN CONST CHAR16 *String, IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS EFIAPI ConsoleLoggerSetAttribute(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Attribute)
EFI_STATUS EFIAPI ConsoleLoggerClearScreen(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This)
EFI_STATUS UpdateDisplayFromHistory(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS EFIAPI ConsoleLoggerReset(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI ConsoleLoggerSetCursorPosition(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Column, IN UINTN Row)
EFI_STATUS ConsoleLoggerStopHistory(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS EFIAPI ConsoleLoggerSetMode(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber)
EFI_STATUS EFIAPI ConsoleLoggerQueryMode(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber, OUT UINTN *Columns, OUT UINTN *Rows)
EFI_STATUS ConsoleLoggerInstall(IN CONST UINTN ScreensToSave, OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo)
EFI_STATUS EFIAPI ConsoleLoggerOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *WString)
EFI_STATUS ConsoleLoggerUninstall(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
EFI_STATUS ConsoleLoggerOutputStringSplit(IN CONST CHAR16 *String, IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE(Expression)
EFI_STATUS EFIAPI ShellPromptForResponseHii(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle, IN OUT VOID **Response)
CHAR16 *EFIAPI StrnCatGrow(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
EFI_SIMPLE_TEXT_OUTPUT_MODE HistoryMode
mode of the history log
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * OldConOut
old protocol to reinstall upon exiting
UINTN CurrentStartRow
what the currently visible start row is
BOOLEAN Enabled
Set to FALSE when a break is requested.
UINTN OriginalStartRow
What the originally visible start row was.
UINTN ColsPerScreen
how many columns the screen can display
UINTN RowCounter
Initial row of each print job.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL OurConOut
the protocol we installed onto the system table
UINTN RowsPerScreen
how many rows the screen can display
INT32 * Attributes
Buffer for Attribute to be saved for each character.
UINTN ScreenCount
How many screens worth of data to save.
CHAR16 * Buffer
Buffer to save data.
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_HANDLE ConsoleInHandle
EFI_HANDLE ConsoleOutHandle
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
UINT32 NoConsoleOut
Was "-noconsoleout" found on command line.
BOOLEAN HaltOutput
TRUE to start a CTRL-S halt.
EFI_HII_HANDLE HiiHandle
Handle from HiiLib.
CONSOLE_LOGGER_PRIVATE_DATA * ConsoleInfo
Pointer for ConsoleInformation.