From b1aab293ea13a4be62da9d6c1e3d69c084240341 Mon Sep 17 00:00:00 2001 From: jljusten Date: Wed, 23 Mar 2011 02:11:14 +0000 Subject: [PATCH] MdeModulePkg GraphicsConsole: Add text mode for PcdConOutColumn/Row Add a new text mode with a resolution of PcdConOutColumn x PcdConOutRow. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11415 6f19259b-4bc3-4df7-8a09-765794883524 --- .../GraphicsConsoleDxe/GraphicsConsole.c | 114 ++++++++---------- .../GraphicsConsoleDxe/GraphicsConsole.h | 2 +- .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf | 8 +- 3 files changed, 59 insertions(+), 65 deletions(-) diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index e6f732db8b..bed16ac4fa 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -42,10 +42,11 @@ GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = { TRUE }, { - { 80, 25, 0, 0, 0, 0 }, // Mode 0 - { 80, 50, 0, 0, 0, 0 }, // Mode 1 - { 100,31, 0, 0, 0, 0 }, // Mode 2 - { 0, 0, 0, 0, 0, 0 } // Mode 3 + { 80, 25, 0, 0, 0, 0, 0 }, // Mode 0 + { 80, 50, 0, 0, 0, 0, 0 }, // Mode 1 + { 100,31, 0, 0, 0, 0, 0 }, // Mode 2 + { 0, 0, 0, 0, 0, 0, 0 }, // Mode 3 + { 0, 0, 0, 0, 0, 0, 0 } // Mode 4 }, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL }; @@ -238,11 +239,13 @@ GraphicsConsoleControllerDriverStart ( UINT32 VerticalResolution; UINT32 ColorDepth; UINT32 RefreshRate; + UINTN ModeIndex; UINTN MaxMode; UINTN Columns; UINTN Rows; UINT32 ModeNumber; EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; + GRAPHICS_CONSOLE_MODE_DATA *ModeData; ModeNumber = 0; // @@ -374,6 +377,18 @@ GraphicsConsoleControllerDriverStart ( } } + // + // Add Mode #3 that uses the entire display for user-defined mode + // + Private->ModeData[3].Columns = HorizontalResolution / EFI_GLYPH_WIDTH; + Private->ModeData[3].Rows = VerticalResolution / EFI_GLYPH_HEIGHT; + + // + // Add Mode #4 that uses the PCD values + // + Private->ModeData[4].Columns = (UINTN) PcdGet32 (PcdConOutColumn); + Private->ModeData[4].Rows = (UINTN) PcdGet32 (PcdConOutRow); + // // Compute the maximum number of text Rows and Columns that this current graphics mode can support // @@ -381,72 +396,45 @@ GraphicsConsoleControllerDriverStart ( Rows = VerticalResolution / EFI_GLYPH_HEIGHT; // - // See if the mode is too small to support the required 80x25 text mode + // Here we make sure that mode 0 is valid // - if (Columns < 80 || Rows < 25) { - goto Error; + if (Columns < Private->ModeData[0].Columns || + Rows < Private->ModeData[0].Rows) { + // + // 80x25 cannot be supported. + // + // Fallback to using the PcdConOutColumn and PcdConOutRow + // for mode 0. If the PCDs are also to large, then mode 0 + // will be shrunk to fit as needed. + // + Private->ModeData[0].Columns = MIN (Private->ModeData[4].Columns, Columns); + Private->ModeData[0].Rows = MIN (Private->ModeData[4].Rows, Rows); } - // - // Add Mode #0 that must be 80x25 - // + MaxMode = 0; - Private->ModeData[MaxMode].GopWidth = HorizontalResolution; - Private->ModeData[MaxMode].GopHeight = VerticalResolution; - Private->ModeData[MaxMode].GopModeNumber = ModeNumber; - Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1; - Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (25 * EFI_GLYPH_HEIGHT)) >> 1; - MaxMode++; - - // - // If it is possible to support Mode #1 - 80x50, than add it as an active mode - // - if (Rows >= 50) { - Private->ModeData[MaxMode].GopWidth = HorizontalResolution; - Private->ModeData[MaxMode].GopHeight = VerticalResolution; - Private->ModeData[MaxMode].GopModeNumber = ModeNumber; - Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1; - Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1; - MaxMode++; + for (ModeIndex = 0; ModeIndex < GRAPHICS_MAX_MODE; ModeIndex++) { + ModeData = &Private->ModeData[ModeIndex]; + ModeData->GopWidth = HorizontalResolution; + ModeData->GopHeight = VerticalResolution; + ModeData->GopModeNumber = ModeNumber; + if (Columns >= ModeData->Columns && + Rows >= ModeData->Rows) { + ModeData->DeltaX = (HorizontalResolution - (ModeData->Columns * EFI_GLYPH_WIDTH)) >> 1; + ModeData->DeltaY = (VerticalResolution - (ModeData->Rows * EFI_GLYPH_HEIGHT)) >> 1; + MaxMode = ModeIndex + 1; + } else { + ModeData->Columns = 0; + ModeData->Rows = 0; + ModeData->DeltaX = 0; + ModeData->DeltaY = 0; + } } // - // If it is not to support Mode #1 - 80x50, then skip it + // See if the resolution was too small to support any text modes // - if (MaxMode < 2) { - Private->ModeData[MaxMode].Columns = 0; - Private->ModeData[MaxMode].Rows = 0; - Private->ModeData[MaxMode].GopWidth = HorizontalResolution; - Private->ModeData[MaxMode].GopHeight = VerticalResolution; - Private->ModeData[MaxMode].GopModeNumber = ModeNumber; - Private->ModeData[MaxMode].DeltaX = 0; - Private->ModeData[MaxMode].DeltaY = 0; - MaxMode++; - } - - // - // Add Mode #2 that must be 100x31 (graphic mode >= 800x600) - // - if (Columns >= 100 && Rows >= 31) { - Private->ModeData[MaxMode].GopWidth = HorizontalResolution; - Private->ModeData[MaxMode].GopHeight = VerticalResolution; - Private->ModeData[MaxMode].GopModeNumber = ModeNumber; - Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (100 * EFI_GLYPH_WIDTH)) >> 1; - Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (31 * EFI_GLYPH_HEIGHT)) >> 1; - MaxMode++; - } - - // - // Add Mode #3 that uses the entire display for user-defined mode - // - if (HorizontalResolution > 800 && VerticalResolution > 600) { - Private->ModeData[MaxMode].Columns = HorizontalResolution/EFI_GLYPH_WIDTH; - Private->ModeData[MaxMode].Rows = VerticalResolution/EFI_GLYPH_HEIGHT; - Private->ModeData[MaxMode].GopWidth = HorizontalResolution; - Private->ModeData[MaxMode].GopHeight = VerticalResolution; - Private->ModeData[MaxMode].GopModeNumber = ModeNumber; - Private->ModeData[MaxMode].DeltaX = (HorizontalResolution % EFI_GLYPH_WIDTH) >> 1; - Private->ModeData[MaxMode].DeltaY = (VerticalResolution % EFI_GLYPH_HEIGHT) >> 1; - MaxMode++; + if (MaxMode == 0) { + goto Error; } // diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h index 4d909a443f..24285a9adb 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h @@ -69,7 +69,7 @@ typedef struct { UINT32 GopModeNumber; } GRAPHICS_CONSOLE_MODE_DATA; -#define GRAPHICS_MAX_MODE 4 +#define GRAPHICS_MAX_MODE 5 typedef struct { UINTN Signature; diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf index 59c8f2d634..169e15a46f 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf @@ -51,6 +51,7 @@ UefiDriverEntryPoint DebugLib HiiLib + PcdLib [Protocols] gEfiDevicePathProtocolGuid ## CONSUMES @@ -61,4 +62,9 @@ gEfiHiiDatabaseProtocolGuid ## TO_START [FeaturePcd] - gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport \ No newline at end of file + gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow +