From 189eac2199940cdc1265503ba4854ea947042424 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Thu, 6 Mar 2008 10:53:58 +0000 Subject: Sync in patch for EDK 945 Add console mode setting in UI. User can select console mode (e.g. 80x25, 100x31) in UI; and boot with user-defined mode. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4797 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/Console/ConSplitterDxe/ConSplitter.c | 132 +++++++++++++++++++++ .../Universal/Console/ConSplitterDxe/ConSplitter.h | 10 ++ .../Console/ConSplitterDxe/ConSplitterDxe.inf | 2 + .../Console/ConSplitterDxe/ConSplitterGraphics.c | 2 +- 4 files changed, 145 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index abf3595..5053251 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -683,6 +683,12 @@ ConSplitterTextOutConstructor ( // ConOutPrivate->TextOut.Mode = &ConOutPrivate->TextOutMode; + // + // When new console device is added, the new mode will be set later, + // so put current mode back to init state. + // + ConOutPrivate->TextOutMode.Mode = 0xFF; + Status = ConSplitterGrowBuffer ( sizeof (TEXT_OUT_AND_GOP_DATA), &ConOutPrivate->TextOutListCount, @@ -1258,6 +1264,13 @@ Returns: if (EFI_ERROR (Status)) { UgaDraw = NULL; } + + // + // When new console device is added, the new mode will be set later, + // so put current mode back to init state. + // + mConOut.TextOutMode.Mode = 0xFF; + // // If both ConOut and StdErr incorporate the same Text Out device, // their MaxMode and QueryData should be the intersection of both. @@ -1319,6 +1332,13 @@ Returns: if (EFI_ERROR (Status)) { return Status; } + + // + // When new console device is added, the new mode will be set later, + // so put current mode back to init state. + // + mStdErr.TextOutMode.Mode = 0xFF; + // // If both ConOut and StdErr incorporate the same Text Out device, // their MaxMode and QueryData should be the intersection of both. @@ -2761,6 +2781,112 @@ Done: return Status; } +VOID +ConsplitterSetConsoleOutMode ( + IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private + ) +/*++ + +Routine Description: + + This routine will get the current console mode information (column, row) + from ConsoleOutMode variable and set it; if the variable does not exist, + set to user defined console mode. + +Arguments: + + None + +Returns: + + None + +--*/ +{ + UINTN Col; + UINTN Row; + UINTN Mode; + UINTN PreferMode; + UINTN BaseMode; + UINTN ModeInfoSize; + UINTN MaxMode; + EFI_STATUS Status; + CONSOLE_OUT_MODE *ModeInfo; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut; + + PreferMode = 0xFF; + BaseMode = 0xFF; + TextOut = &Private->TextOut; + MaxMode = (UINTN) (TextOut->Mode->MaxMode); + ModeInfoSize = sizeof (CONSOLE_OUT_MODE); + + ModeInfo = AllocateZeroPool (sizeof(CONSOLE_OUT_MODE)); + ASSERT(ModeInfo != NULL); + + Status = gRT->GetVariable ( + VarConOutMode, + &gEfiGenericPlatformVariableGuid, + NULL, + &ModeInfoSize, + ModeInfo + ); + + // + // Set to the default mode 80 x 25 required by EFI/UEFI spec; + // user can also define other valid default console mode here. + // + if (EFI_ERROR(Status)) { + ModeInfo->Column = 80; + ModeInfo->Row = 25; + Status = gRT->SetVariable ( + VarConOutMode, + &gEfiGenericPlatformVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, + sizeof (CONSOLE_OUT_MODE), + ModeInfo + ); + } + + for (Mode = 0; Mode < MaxMode; Mode++) { + Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row); + if (!EFI_ERROR(Status)) { + if (Col == ModeInfo->Column && Row == ModeInfo->Row) { + PreferMode = Mode; + } + if (Col == 80 && Row == 25) { + BaseMode = Mode; + } + } + } + + Status = TextOut->SetMode (TextOut, PreferMode); + + // + // if current mode setting is failed, default 80x25 mode will be set. + // + if (EFI_ERROR(Status)) { + Status = TextOut->SetMode (TextOut, BaseMode); + ASSERT(!EFI_ERROR(Status)); + + ModeInfo->Column = 80; + ModeInfo->Row = 25; + + // + // Update ConOutMode variable + // + Status = gRT->SetVariable ( + VarConOutMode, + &gEfiGenericPlatformVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, + sizeof (CONSOLE_OUT_MODE), + ModeInfo + ); + } + + gBS->FreePool (ModeInfo); +} + + EFI_STATUS ConSplitterTextOutAddDevice ( IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, @@ -2916,6 +3042,12 @@ Returns: Private->TextOut.SetMode (&Private->TextOut, 0); } + // + // After adding new console device, all existing console devices should be + // synced to the current shared mode. + // + ConsplitterSetConsoleOutMode (Private); + return Status; } diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h index 9fcbab3..757aed8 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h @@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include @@ -38,6 +39,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include + // // Driver Binding Externs @@ -73,6 +76,13 @@ extern EFI_GUID gSimpleTextInExNotifyGuid; #define CONSOLE_SPLITTER_MODES_ALLOC_UNIT 32 #define MAX_STD_IN_PASSWORD 80 +#define VarConOutMode L"ConOutMode" + +typedef struct { + UINTN Column; + UINTN Row; +} CONSOLE_OUT_MODE; + typedef struct { UINTN Columns; UINTN Rows; diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf index 8201f2c..3f627b8 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf @@ -52,6 +52,7 @@ [LibraryClasses] UefiBootServicesTableLib + UefiRuntimeServicesTableLib MemoryAllocationLib BaseMemoryLib BaseLib @@ -68,6 +69,7 @@ gEfiPrimaryConsoleInDeviceGuid # ALWAYS_PRODUCED gEfiPrimaryStandardErrorDeviceGuid # ALWAYS_PRODUCED gSimpleTextInExNotifyGuid # ALWAYS_PRODUCED + gEfiGenericPlatformVariableGuid # ALWAYS_CONSUMED [Protocols] gEfiConsoleControlProtocolGuid # PROTOCOL ALWAYS_PRODUCED diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c index 2c66a44..77c076f 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c @@ -1373,7 +1373,7 @@ DevNullTextOutSetMode ( return EFI_UNSUPPORTED; } - if (Private->DevNullColumns != Column || Private->DevNullRows != Row) { + if (Private->TextOutMode.Mode != (INT32) ModeNumber) { Private->TextOutMode.Mode = (INT32) ModeNumber; Private->DevNullColumns = Column; -- cgit v1.1