diff options
author | li-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-11-25 08:35:00 +0000 |
---|---|---|
committer | li-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-11-25 08:35:00 +0000 |
commit | 79d07c66d98c033883494aff19023a87d09c4045 (patch) | |
tree | 32550251f4fa3df7314094bd061569f4e5d969fd /MdeModulePkg/Universal | |
parent | 13535a3bdace81b201b8f96d2c5830824c70fb3c (diff) | |
download | edk2-platforms-79d07c66d98c033883494aff19023a87d09c4045.tar.xz |
Updated GraphicsConsole and Terminal driver text mode initialization routine for easy mode extension in future.
Signed-off-by: li-elvin
Reviewed-by: hhtian
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12787 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
5 files changed, 330 insertions, 135 deletions
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 553a814634..44282b1f9f 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -41,16 +41,20 @@ GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = { 0,
TRUE
},
- {
- { 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
- },
+ (GRAPHICS_CONSOLE_MODE_DATA *) NULL,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL
};
+GRAPHICS_CONSOLE_MODE_DATA mGraphicsConsoleModeData[] = {
+ {100, 31},
+ //
+ // New modes can be added here.
+ // The last 2 entries are specific for PcdConOutRow x PcdConOutColumn and full screen mode.
+ //
+ {0, 0},
+ {0, 0}
+};
+
EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
EFI_HII_FONT_PROTOCOL *mHiiFont;
EFI_HII_HANDLE mHiiHandle;
@@ -210,6 +214,159 @@ Error: return Status;
}
+/**
+ Initialize all the text modes which the graphics console supports.
+
+ It returns information for available text modes that the graphics can support.
+
+ @param[in] HorizontalResolution The size of video screen in pixels in the X dimension.
+ @param[in] VerticalResolution The size of video screen in pixels in the Y dimension.
+ @param[in] GopModeNumber The graphics mode number which graphis console is based on.
+ @param[out] TextModeCount The total number of text modes that graphics console supports.
+ @param[out] TextModeData The buffer to the text modes column and row information.
+ Caller is responsible to free it when it's non-NULL.
+
+ @retval EFI_SUCCESS The supporting mode information is returned.
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.
+
+**/
+EFI_STATUS
+InitializeGraphicsConsoleTextMode (
+ IN UINT32 HorizontalResolution,
+ IN UINT32 VerticalResolution,
+ IN UINT32 GopModeNumber,
+ OUT UINTN *TextModeCount,
+ OUT GRAPHICS_CONSOLE_MODE_DATA **TextModeData
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ GRAPHICS_CONSOLE_MODE_DATA *ModeBuffer;
+ GRAPHICS_CONSOLE_MODE_DATA *NewModeBuffer;
+ UINTN ValidCount;
+ UINTN ValidIndex;
+ UINTN MaxColumns;
+ UINTN MaxRows;
+
+ if ((TextModeCount == NULL) || (TextModeData == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Add PcdConOutColumn and PcdConOutRow to the last second entry.
+ //
+ Count = sizeof (mGraphicsConsoleModeData) / sizeof (GRAPHICS_CONSOLE_MODE_DATA);
+ mGraphicsConsoleModeData[Count - 2].Columns = (UINTN) PcdGet32 (PcdConOutColumn);
+ mGraphicsConsoleModeData[Count - 2].Rows = (UINTN) PcdGet32 (PcdConOutRow);
+
+ //
+ // Compute the maximum number of text Rows and Columns that this current graphics mode can support.
+ // To make graphics console work well, MaxColumns and MaxRows should not be zero.
+ //
+ MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;
+ MaxRows = VerticalResolution / EFI_GLYPH_HEIGHT;
+
+ //
+ // Add full screen mode to the last entry.
+ //
+ mGraphicsConsoleModeData[Count - 1].Columns = MaxColumns;
+ mGraphicsConsoleModeData[Count - 1].Rows = MaxRows;
+
+ //
+ // Get defined mode buffer pointer.
+ //
+ ModeBuffer = mGraphicsConsoleModeData;
+
+ //
+ // Here we make sure that the final mode exposed does not include the duplicated modes,
+ // and does not include the invalid modes which exceed the max column and row.
+ // Reserve 2 modes for 80x25, 80x50 of graphics console.
+ //
+ NewModeBuffer = AllocateZeroPool (sizeof (GRAPHICS_CONSOLE_MODE_DATA) * (Count + 2));
+ ASSERT (NewModeBuffer != NULL);
+
+ //
+ // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
+ //
+ ValidCount = 0;
+
+ if ((MaxColumns >= 80) && (MaxRows >= 25)) {
+ //
+ // 80x25 can be supported.
+ //
+ NewModeBuffer[ValidCount].Columns = 80;
+ NewModeBuffer[ValidCount].Rows = 25;
+ } else {
+ //
+ // 80x25 cannot be supported, set PCD defined mode.
+ //
+ NewModeBuffer[ValidCount].Columns = (UINTN) PcdGet32 (PcdConOutColumn);
+ NewModeBuffer[ValidCount].Rows = (UINTN) PcdGet32 (PcdConOutRow);
+ }
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
+ NewModeBuffer[ValidCount].GopHeight = VerticalResolution;
+ NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;
+ NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1;
+ NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1;
+ ValidCount++;
+
+ if ((MaxColumns >= 80) && (MaxRows >= 50)) {
+ NewModeBuffer[ValidCount].Columns = 80;
+ NewModeBuffer[ValidCount].Rows = 50;
+ NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;
+ NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1;
+ }
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
+ NewModeBuffer[ValidCount].GopHeight = VerticalResolution;
+ NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;
+ ValidCount++;
+
+ //
+ // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.
+ //
+ for (Index = 0; Index < Count; Index++) {
+ if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0) ||
+ (ModeBuffer[Index].Columns > MaxColumns) || (ModeBuffer[Index].Rows > MaxRows)) {
+ //
+ // Skip the pre-defined mode which is invalid or exceeds the max column and row.
+ //
+ continue;
+ }
+ for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
+ if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
+ (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
+ //
+ // Skip the duplicated mode.
+ //
+ break;
+ }
+ }
+ if (ValidIndex == ValidCount) {
+ NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
+ NewModeBuffer[ValidCount].Rows = ModeBuffer[Index].Rows;
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
+ NewModeBuffer[ValidCount].GopHeight = VerticalResolution;
+ NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;
+ NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1;
+ NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1;
+ ValidCount++;
+ }
+ }
+
+ DEBUG_CODE (
+ for (Index = 0; Index < ValidCount; Index++) {
+ DEBUG ((EFI_D_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n",
+ Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));
+ }
+ );
+
+ //
+ // Return valid mode count and mode information buffer.
+ //
+ *TextModeCount = ValidCount;
+ *TextModeData = NewModeBuffer;
+ return EFI_SUCCESS;
+}
/**
Start this driver on Controller by opening Graphics Output protocol or
@@ -241,14 +398,10 @@ GraphicsConsoleControllerDriverStart ( UINT32 RefreshRate;
UINT32 ModeIndex;
UINTN MaxMode;
- UINTN MaxColumns;
- UINTN MaxRows;
UINT32 ModeNumber;
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
- GRAPHICS_CONSOLE_MODE_DATA *ModeData;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- BOOLEAN TextModeFound;
ModeNumber = 0;
@@ -399,80 +552,17 @@ GraphicsConsoleControllerDriverStart ( }
//
- // Include the existing pre-defined 80x25, 80x50 and 100x31
- // in mGraphicsConsoleDevTemplate.
- //
- MaxMode = 3;
-
- //
- // Compute the maximum number of text Rows and Columns that this current graphics mode can support
- //
- MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;
- MaxRows = VerticalResolution / EFI_GLYPH_HEIGHT;
-
- //
- // Add Mode #3 that uses the entire display for user-defined mode
- //
- Private->ModeData[MaxMode].Columns = MaxColumns;
- Private->ModeData[MaxMode].Rows = MaxRows;
- MaxMode++;
-
- //
- // Add Mode #4 that uses the PCD values
- //
- Private->ModeData[MaxMode].Columns = (UINTN) PcdGet32 (PcdConOutColumn);
- Private->ModeData[MaxMode].Rows = (UINTN) PcdGet32 (PcdConOutRow);
- if ((Private->ModeData[MaxMode].Columns != 0) && (Private->ModeData[MaxMode].Rows != 0)) {
- MaxMode++;
- }
-
- //
- // Here we make sure that mode 0 is valid
+ // Initialize the mode which GraphicsConsole supports.
//
- if (MaxColumns < Private->ModeData[0].Columns ||
- MaxRows < Private->ModeData[0].Rows) {
- //
- // 80x25 cannot be supported.
- //
- if ((Private->ModeData[4].Columns != 0) && (Private->ModeData[4].Rows != 0)) {
- //
- // Fallback to using the Mode 4 for mode 0 if PcdConOutColumn and PcdConOutRow
- // are not 0. If the PCDs are also too large, then mode 0
- // will be shrunk to fit as needed. If the PCDs are all 0,
- // then mode 0 will be the entire display.
- //
- Private->ModeData[0].Columns = MIN (Private->ModeData[4].Columns, MaxColumns);
- Private->ModeData[0].Rows = MIN (Private->ModeData[4].Rows, MaxRows);
- } else {
- Private->ModeData[0].Columns = MaxColumns;
- Private->ModeData[0].Rows = MaxRows;
- }
- }
-
- TextModeFound = FALSE;
- for (ModeIndex = 0; ModeIndex < GRAPHICS_MAX_MODE; ModeIndex++) {
- ModeData = &Private->ModeData[ModeIndex];
- ModeData->GopWidth = HorizontalResolution;
- ModeData->GopHeight = VerticalResolution;
- ModeData->GopModeNumber = ModeNumber;
- if ((ModeData->Columns != 0) && (ModeData->Rows != 0) &&
- (MaxColumns >= ModeData->Columns) && (MaxRows >= ModeData->Rows)) {
- ModeData->DeltaX = (HorizontalResolution - (ModeData->Columns * EFI_GLYPH_WIDTH)) >> 1;
- ModeData->DeltaY = (VerticalResolution - (ModeData->Rows * EFI_GLYPH_HEIGHT)) >> 1;
- TextModeFound = TRUE;
- } else {
- ModeData->Columns = 0;
- ModeData->Rows = 0;
- ModeData->DeltaX = 0;
- ModeData->DeltaY = 0;
- }
- }
+ Status = InitializeGraphicsConsoleTextMode (
+ HorizontalResolution,
+ VerticalResolution,
+ ModeNumber,
+ &MaxMode,
+ &Private->ModeData
+ );
- //
- // See if the resolution was too small to support any text modes
- //
- if (!TextModeFound) {
- Status = EFI_UNSUPPORTED;
+ if (EFI_ERROR (Status)) {
goto Error;
}
@@ -528,6 +618,10 @@ Error: FreePool (Private->LineBuffer);
}
+ if (Private->ModeData != NULL) {
+ FreePool (Private->ModeData);
+ }
+
//
// Free private data
//
@@ -612,6 +706,10 @@ GraphicsConsoleControllerDriverStop ( FreePool (Private->LineBuffer);
}
+ if (Private->ModeData != NULL) {
+ FreePool (Private->ModeData);
+ }
+
//
// Free our instance data
//
@@ -1162,7 +1260,7 @@ GraphicsConsoleConOutQueryMode ( *Columns = Private->ModeData[ModeNumber].Columns;
*Rows = Private->ModeData[ModeNumber].Rows;
- if (*Columns <= 0 && *Rows <= 0) {
+ if (*Columns <= 0 || *Rows <= 0) {
Status = EFI_UNSUPPORTED;
goto Done;
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h index 338b7aad29..0db6f04c11 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h @@ -63,15 +63,13 @@ typedef struct { UINT32 GopModeNumber;
} GRAPHICS_CONSOLE_MODE_DATA;
-#define GRAPHICS_MAX_MODE 5
-
typedef struct {
UINTN Signature;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
- GRAPHICS_CONSOLE_MODE_DATA ModeData[GRAPHICS_MAX_MODE];
+ GRAPHICS_CONSOLE_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;
} GRAPHICS_CONSOLE_DEV;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index 9574390eb0..0934f16301 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -68,6 +68,7 @@ TERMINAL_DEV mTerminalDevTemplate = { 0, // CursorRow
TRUE // CursorVisible
},
+ NULL, // TerminalConsoleModeData
0, // SerialInTimeOut
NULL, // RawFifo
@@ -94,6 +95,15 @@ TERMINAL_DEV mTerminalDevTemplate = { }
};
+TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
+ {100, 31},
+ //
+ // New modes can be added here.
+ // The last entry is specific for PcdConOutRow x PcdConOutColumn.
+ //
+ {0, 0}
+};
+
/**
Test to see if this driver supports Controller.
@@ -398,6 +408,109 @@ TerminalFreeNotifyList ( return EFI_SUCCESS;
}
+/**
+ Initialize all the text modes which the terminal console supports.
+
+ It returns information for available text modes that the terminal can support.
+
+ @param[out] TextModeCount The total number of text modes that terminal console supports.
+ @param[out] TextModeData The buffer to the text modes column and row information.
+ Caller is responsible to free it when it's non-NULL.
+
+ @retval EFI_SUCCESS The supporting mode information is returned.
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.
+
+**/
+EFI_STATUS
+InitializeTerminalConsoleTextMode (
+ OUT UINTN *TextModeCount,
+ OUT TERMINAL_CONSOLE_MODE_DATA **TextModeData
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ TERMINAL_CONSOLE_MODE_DATA *ModeBuffer;
+ TERMINAL_CONSOLE_MODE_DATA *NewModeBuffer;
+ UINTN ValidCount;
+ UINTN ValidIndex;
+
+ if ((TextModeCount == NULL) || (TextModeData == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Assign the last entry as PcdConOutColumn and PcdConOutRow defined.
+ //
+ Count = sizeof (mTerminalConsoleModeData) / sizeof (TERMINAL_CONSOLE_MODE_DATA);
+ mTerminalConsoleModeData[Count - 1].Columns = (UINTN) PcdGet32 (PcdConOutColumn);
+ mTerminalConsoleModeData[Count - 1].Rows = (UINTN) PcdGet32 (PcdConOutRow);;
+
+ //
+ // Get defined mode buffer pointer.
+ //
+ ModeBuffer = mTerminalConsoleModeData;
+
+ //
+ // Here we make sure that the final mode exposed does not include the duplicated modes,
+ // and does not include the invalid modes which exceed the max column and row.
+ // Reserve 2 modes for 80x25, 80x50 of terminal console.
+ //
+ NewModeBuffer = AllocateZeroPool (sizeof (TERMINAL_CONSOLE_MODE_DATA) * (Count + 2));
+ ASSERT (NewModeBuffer != NULL);
+
+ //
+ // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
+ //
+ ValidCount = 0;
+
+ NewModeBuffer[ValidCount].Columns = 80;
+ NewModeBuffer[ValidCount].Rows = 25;
+ ValidCount++;
+
+ NewModeBuffer[ValidCount].Columns = 80;
+ NewModeBuffer[ValidCount].Rows = 50;
+ ValidCount++;
+
+ //
+ // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.
+ //
+ for (Index = 0; Index < Count; Index++) {
+ if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0)) {
+ //
+ // Skip the pre-defined mode which is invalid.
+ //
+ continue;
+ }
+ for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
+ if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
+ (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
+ //
+ // Skip the duplicated mode.
+ //
+ break;
+ }
+ }
+ if (ValidIndex == ValidCount) {
+ NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
+ NewModeBuffer[ValidCount].Rows = ModeBuffer[Index].Rows;
+ ValidCount++;
+ }
+ }
+
+ DEBUG_CODE (
+ for (Index = 0; Index < ValidCount; Index++) {
+ DEBUG ((EFI_D_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
+ Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));
+ }
+ );
+
+ //
+ // Return valid mode count and mode information buffer.
+ //
+ *TextModeCount = ValidCount;
+ *TextModeData = NewModeBuffer;
+ return EFI_SUCCESS;
+}
/**
Start this driver on Controller by opening a Serial IO protocol,
@@ -444,6 +557,7 @@ TerminalDriverBindingStart ( BOOLEAN SimTxtInInstalled;
BOOLEAN SimTxtOutInstalled;
BOOLEAN FirstEnter;
+ UINTN ModeCount;
TerminalDevice = NULL;
DefaultNode = NULL;
@@ -724,8 +838,13 @@ TerminalDriverBindingStart ( sizeof (mTerminalDevTemplate.SimpleTextOutput)
);
SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
-
- TerminalDevice->SimpleTextOutputMode.MaxMode = TERMINAL_MAX_MODE;
+
+ Status = InitializeTerminalConsoleTextMode (&ModeCount, &TerminalDevice->TerminalConsoleModeData);
+ if (EFI_ERROR (Status)) {
+ goto ReportError;
+ }
+ TerminalDevice->SimpleTextOutputMode.MaxMode = (INT32) ModeCount;
+
//
// For terminal devices, cursor is always visible
//
@@ -1102,6 +1221,10 @@ Error: FreePool (TerminalDevice->DevicePath);
}
+ if (TerminalDevice->TerminalConsoleModeData != NULL) {
+ FreePool (TerminalDevice->TerminalConsoleModeData);
+ }
+
FreePool (TerminalDevice);
}
}
@@ -1273,6 +1396,9 @@ TerminalDriverBindingStop ( gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
TerminalFreeNotifyList (&TerminalDevice->NotifyList);
FreePool (TerminalDevice->DevicePath);
+ if (TerminalDevice->TerminalConsoleModeData != NULL) {
+ FreePool (TerminalDevice->TerminalConsoleModeData);
+ }
FreePool (TerminalDevice);
}
}
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index fe4ce90bbb..9387998e01 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -61,6 +61,11 @@ typedef struct { EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];
} EFI_KEY_FIFO;
+typedef struct {
+ UINTN Columns;
+ UINTN Rows;
+} TERMINAL_CONSOLE_MODE_DATA;
+
#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
#define TERMINAL_DEV_SIGNATURE SIGNATURE_32 ('t', 'm', 'n', 'l')
@@ -83,6 +88,7 @@ typedef struct { EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
+ TERMINAL_CONSOLE_MODE_DATA *TerminalConsoleModeData;
UINTN SerialInTimeOut;
RAW_DATA_FIFO *RawFiFo;
UNICODE_FIFO *UnicodeFiFo;
@@ -137,21 +143,6 @@ typedef union { #define CCAP 0x43
#define DCAP 0x44
-#define MODE0_COLUMN_COUNT 80
-#define MODE0_ROW_COUNT 25
-
-#define MODE1_COLUMN_COUNT 80
-#define MODE1_ROW_COUNT 50
-
-#define MODE2_COLUMN_COUNT 100
-#define MODE2_ROW_COUNT 31
-
-//
-// MODE3 is defined by PcdConOutColumn & PcdConOutRow
-//
-
-#define TERMINAL_MAX_MODE 4
-
#define BACKSPACE 8
#define ESC 27
#define CSI 0x9B
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index 8f2675228f..affb3ae8e1 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -205,7 +205,7 @@ TerminalConOutOutputString ( //
Mode = This->Mode;
- if (Mode->Mode >= TERMINAL_MAX_MODE) {
+ if (Mode->Mode >= Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
@@ -392,8 +392,6 @@ TerminalConOutTestString ( It returns information for an available text mode
that the terminal supports.
- In this driver, we support text mode 80x25 (mode 0),
- 80x50 (mode 1), 100x31 (mode 2).
@param This Indicates the calling context.
@param ModeNumber The mode number to return information on.
@@ -402,7 +400,6 @@ TerminalConOutTestString ( @retval EFI_SUCCESS The requested mode information is returned.
@retval EFI_UNSUPPORTED The mode number is not valid.
- @retval EFI_DEVICE_ERROR
**/
EFI_STATUS
@@ -414,35 +411,20 @@ TerminalConOutQueryMode ( OUT UINTN *Rows
)
{
- if (This->Mode->MaxMode > TERMINAL_MAX_MODE) {
- return EFI_DEVICE_ERROR;
- }
+ TERMINAL_DEV *TerminalDevice;
- if (ModeNumber == 0) {
- *Columns = MODE0_COLUMN_COUNT;
- *Rows = MODE0_ROW_COUNT;
- return EFI_SUCCESS;
- } else if (ModeNumber == 1) {
- *Columns = MODE1_COLUMN_COUNT;
- *Rows = MODE1_ROW_COUNT;
- return EFI_SUCCESS;
- } else if (ModeNumber == 2) {
- *Columns = MODE2_COLUMN_COUNT;
- *Rows = MODE2_ROW_COUNT;
- return EFI_SUCCESS;
- } else if (ModeNumber == 3) {
- *Columns = (UINTN) PcdGet32 (PcdConOutColumn);
- if (*Columns == 0) {
- *Columns = MODE0_COLUMN_COUNT;
- }
- *Rows = (UINTN) PcdGet32 (PcdConOutRow);
- if (*Rows == 0) {
- *Rows = MODE0_ROW_COUNT;
- }
- return EFI_SUCCESS;
+ if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
+ return EFI_UNSUPPORTED;
}
- return EFI_UNSUPPORTED;
+ //
+ // Get Terminal device data structure pointer.
+ //
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
+ *Columns = TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns;
+ *Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;
+
+ return EFI_SUCCESS;
}
@@ -476,7 +458,7 @@ TerminalConOutSetMode ( //
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
- if (ModeNumber >= TERMINAL_MAX_MODE) {
+ if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
|