mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/TerminalDxe: Refine InitializeTerminalConsoleTextMode
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
parent
fa3f99e5ef
commit
390b95a49c
|
@ -113,6 +113,8 @@ TERMINAL_DEV mTerminalDevTemplate = {
|
||||||
};
|
};
|
||||||
|
|
||||||
TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
|
TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
|
||||||
|
{80, 25},
|
||||||
|
{80, 50},
|
||||||
{100, 31},
|
{100, 31},
|
||||||
//
|
//
|
||||||
// New modes can be added here.
|
// New modes can be added here.
|
||||||
|
@ -450,97 +452,39 @@ TerminalFreeNotifyList (
|
||||||
It returns information for available text modes that the terminal can support.
|
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] 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.
|
@return The buffer to the text modes column and row information.
|
||||||
@retval EFI_INVALID_PARAMETER The parameters are invalid.
|
Caller is responsible to free it when it's non-NULL.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
TERMINAL_CONSOLE_MODE_DATA *
|
||||||
InitializeTerminalConsoleTextMode (
|
InitializeTerminalConsoleTextMode (
|
||||||
OUT UINTN *TextModeCount,
|
OUT INT32 *TextModeCount
|
||||||
OUT TERMINAL_CONSOLE_MODE_DATA **TextModeData
|
)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UINTN Index;
|
TERMINAL_CONSOLE_MODE_DATA *TextModeData;
|
||||||
UINTN Count;
|
|
||||||
TERMINAL_CONSOLE_MODE_DATA *ModeBuffer;
|
ASSERT (TextModeCount != NULL);
|
||||||
TERMINAL_CONSOLE_MODE_DATA *NewModeBuffer;
|
|
||||||
UINTN ValidCount;
|
|
||||||
UINTN ValidIndex;
|
|
||||||
|
|
||||||
if ((TextModeCount == NULL) || (TextModeData == NULL)) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
Count = sizeof (mTerminalConsoleModeData) / sizeof (TERMINAL_CONSOLE_MODE_DATA);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get defined mode buffer pointer.
|
|
||||||
//
|
|
||||||
ModeBuffer = mTerminalConsoleModeData;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here we make sure that the final mode exposed does not include the duplicated modes,
|
// 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.
|
// and does not include the invalid modes which exceed the max column and row.
|
||||||
// Reserve 2 modes for 80x25, 80x50 of terminal console.
|
// Reserve 2 modes for 80x25, 80x50 of terminal console.
|
||||||
//
|
//
|
||||||
NewModeBuffer = AllocateZeroPool (sizeof (TERMINAL_CONSOLE_MODE_DATA) * (Count + 2));
|
TextModeData = AllocateCopyPool (sizeof (mTerminalConsoleModeData), mTerminalConsoleModeData);
|
||||||
ASSERT (NewModeBuffer != NULL);
|
if (TextModeData == NULL) {
|
||||||
|
return 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++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
*TextModeCount = ARRAY_SIZE (mTerminalConsoleModeData);
|
||||||
|
|
||||||
DEBUG_CODE (
|
DEBUG_CODE (
|
||||||
for (Index = 0; Index < ValidCount; Index++) {
|
INT32 Index;
|
||||||
DEBUG ((EFI_D_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
|
for (Index = 0; Index < *TextModeCount; Index++) {
|
||||||
Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));
|
DEBUG ((DEBUG_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
|
||||||
|
Index, TextModeData[Index].Columns, TextModeData[Index].Rows));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
return TextModeData;
|
||||||
//
|
|
||||||
// Return valid mode count and mode information buffer.
|
|
||||||
//
|
|
||||||
*TextModeCount = ValidCount;
|
|
||||||
*TextModeData = NewModeBuffer;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -632,7 +576,6 @@ TerminalDriverBindingStart (
|
||||||
BOOLEAN SimTxtInInstalled;
|
BOOLEAN SimTxtInInstalled;
|
||||||
BOOLEAN SimTxtOutInstalled;
|
BOOLEAN SimTxtOutInstalled;
|
||||||
BOOLEAN FirstEnter;
|
BOOLEAN FirstEnter;
|
||||||
UINTN ModeCount;
|
|
||||||
|
|
||||||
TerminalDevice = NULL;
|
TerminalDevice = NULL;
|
||||||
ConInSelected = FALSE;
|
ConInSelected = FALSE;
|
||||||
|
@ -896,12 +839,13 @@ TerminalDriverBindingStart (
|
||||||
);
|
);
|
||||||
SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
|
SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
|
||||||
|
|
||||||
Status = InitializeTerminalConsoleTextMode (&ModeCount, &TerminalDevice->TerminalConsoleModeData);
|
TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
|
||||||
if (EFI_ERROR (Status)) {
|
&SimpleTextOutput->Mode->MaxMode
|
||||||
|
);
|
||||||
|
if (TerminalDevice->TerminalConsoleModeData == NULL) {
|
||||||
goto ReportError;
|
goto ReportError;
|
||||||
}
|
}
|
||||||
TerminalDevice->SimpleTextOutputMode.MaxMode = (INT32) ModeCount;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// For terminal devices, cursor is always visible
|
// For terminal devices, cursor is always visible
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue