summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Console/TerminalDxe
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:02 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commit1436aea4d5707e672672a11bda72be2c63c936c3 (patch)
tree370c9d5bd8823aa8ea7bce71a0f29bff71feff67 /MdeModulePkg/Universal/Console/TerminalDxe
parent7c7184e201a90a1d2376e615e55e3f4074731468 (diff)
downloadedk2-1436aea4d5707e672672a11bda72be2c63c936c3.zip
edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.gz
edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.bz2
MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg/Universal/Console/TerminalDxe')
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c23
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c23
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c381
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h302
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c1543
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c604
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c262
7 files changed, 1580 insertions, 1558 deletions
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
index f117d90..0acd8cf 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
@@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Terminal.h"
/**
@@ -18,10 +17,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
AnsiRawDataToUnicode (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
)
{
- UINT8 RawData;
+ UINT8 RawData;
//
// pop the raw data out from the raw fifo,
@@ -29,10 +28,9 @@ AnsiRawDataToUnicode (
// the unicode into unicode fifo, until the raw fifo is empty.
//
while (!IsRawFiFoEmpty (TerminalDevice) && !IsUnicodeFiFoFull (TerminalDevice)) {
-
RawFiFoRemoveOneKey (TerminalDevice, &RawData);
- UnicodeFiFoInsertOneKey (TerminalDevice, (UINT16) RawData);
+ UnicodeFiFoInsertOneKey (TerminalDevice, (UINT16)RawData);
}
}
@@ -49,22 +47,21 @@ AnsiRawDataToUnicode (
**/
EFI_STATUS
AnsiTestString (
- IN TERMINAL_DEV *TerminalDevice,
- IN CHAR16 *WString
+ IN TERMINAL_DEV *TerminalDevice,
+ IN CHAR16 *WString
)
{
- CHAR8 GraphicChar;
+ CHAR8 GraphicChar;
//
// support three kind of character:
// valid ascii, valid efi control char, valid text graphics.
//
- for (; *WString != CHAR_NULL; WString++) {
-
+ for ( ; *WString != CHAR_NULL; WString++) {
if ( !(TerminalIsValidAscii (*WString) ||
- TerminalIsValidEfiCntlChar (*WString) ||
- TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {
-
+ TerminalIsValidEfiCntlChar (*WString) ||
+ TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL)))
+ {
return EFI_UNSUPPORTED;
}
}
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c b/MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
index c06d21b..5c983ef 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
@@ -20,17 +20,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentNam
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) TerminalComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) TerminalComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)TerminalComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)TerminalComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {
{
"eng;en",
- (CHAR16 *) L"Serial Terminal Driver"
+ (CHAR16 *)L"Serial Terminal Driver"
},
{
NULL,
@@ -165,11 +164,11 @@ TerminalComponentNameGetDriverName (
EFI_STATUS
EFIAPI
TerminalComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
@@ -210,7 +209,7 @@ TerminalComponentNameGetControllerName (
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiSimpleTextOutProtocolGuid,
- (VOID **) &SimpleTextOutput,
+ (VOID **)&SimpleTextOutput,
gTerminalDriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index 89d6e72..e2d779c 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -7,13 +7,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Terminal.h"
//
// Globals
//
-EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding = {
TerminalDriverBindingSupported,
TerminalDriverBindingStart,
TerminalDriverBindingStop,
@@ -22,7 +21,6 @@ EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding = {
NULL
};
-
EFI_GUID *mTerminalType[] = {
&gEfiPcAnsiGuid,
&gEfiVT100Guid,
@@ -35,8 +33,7 @@ EFI_GUID *mTerminalType[] = {
&gEdkiiSCOTermGuid
};
-
-CHAR16 *mSerialConsoleNames[] = {
+CHAR16 *mSerialConsoleNames[] = {
L"PC-ANSI Serial Console",
L"VT-100 Serial Console",
L"VT-100+ Serial Console",
@@ -71,16 +68,16 @@ TERMINAL_DEV mTerminalDevTemplate = {
TerminalConOutEnableCursor,
NULL
},
- { // SimpleTextOutputMode
- 1, // MaxMode
- 0, // Mode
- EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK), // Attribute
- 0, // CursorColumn
- 0, // CursorRow
- TRUE // CursorVisible
+ { // SimpleTextOutputMode
+ 1, // MaxMode
+ 0, // Mode
+ EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK), // Attribute
+ 0, // CursorColumn
+ 0, // CursorRow
+ TRUE // CursorVisible
},
NULL, // TerminalConsoleModeData
- 0, // SerialInTimeOut
+ 0, // SerialInTimeOut
NULL, // RawFifo
NULL, // UnicodeFiFo
@@ -93,9 +90,9 @@ TERMINAL_DEV mTerminalDevTemplate = {
INPUT_STATE_DEFAULT,
RESET_STATE_DEFAULT,
{
- 0,
- 0,
- 0
+ 0,
+ 0,
+ 0
},
0,
FALSE,
@@ -114,10 +111,10 @@ TERMINAL_DEV mTerminalDevTemplate = {
NULL // KeyNotifyProcessEvent
};
-TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
- {80, 25},
- {80, 50},
- {100, 31},
+TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
+ { 80, 25 },
+ { 80, 50 },
+ { 100, 31 },
//
// New modes can be added here.
//
@@ -132,16 +129,17 @@ TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
**/
TERMINAL_TYPE
TerminalTypeFromGuid (
- IN EFI_GUID *Guid
-)
+ IN EFI_GUID *Guid
+ )
{
- TERMINAL_TYPE Type;
+ TERMINAL_TYPE Type;
for (Type = 0; Type < ARRAY_SIZE (mTerminalType); Type++) {
if (CompareGuid (Guid, mTerminalType[Type])) {
break;
}
}
+
return Type;
}
@@ -161,9 +159,9 @@ TerminalTypeFromGuid (
EFI_STATUS
EFIAPI
TerminalDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
@@ -185,15 +183,15 @@ TerminalDriverBindingSupported (
// If RemainingDevicePath isn't the End of Device Path Node,
// check its validation
//
- Node = (VENDOR_DEVICE_PATH *) RemainingDevicePath;
-
- if (Node->Header.Type != MESSAGING_DEVICE_PATH ||
- Node->Header.SubType != MSG_VENDOR_DP ||
- DevicePathNodeLength(&Node->Header) != sizeof(VENDOR_DEVICE_PATH)) {
+ Node = (VENDOR_DEVICE_PATH *)RemainingDevicePath;
+ if ((Node->Header.Type != MESSAGING_DEVICE_PATH) ||
+ (Node->Header.SubType != MSG_VENDOR_DP) ||
+ (DevicePathNodeLength (&Node->Header) != sizeof (VENDOR_DEVICE_PATH)))
+ {
return EFI_UNSUPPORTED;
-
}
+
//
// only supports PC ANSI, VT100, VT100+, VT-UTF8, TtyTerm
// Linux, XtermR6, VT400 and SCO terminal types
@@ -203,6 +201,7 @@ TerminalDriverBindingSupported (
}
}
}
+
//
// Open the IO Abstraction(s) needed to perform the supported test
// The Controller must support the Serial I/O Protocol.
@@ -212,7 +211,7 @@ TerminalDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
+ (VOID **)&SerialIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -229,11 +228,11 @@ TerminalDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEfiSerialIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiSerialIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
//
// Open the EFI Device Path protocol needed to perform the supported test
@@ -241,7 +240,7 @@ TerminalDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -258,16 +257,15 @@ TerminalDriverBindingSupported (
// Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return Status;
}
-
/**
Free notify functions list.
@@ -279,14 +277,15 @@ TerminalDriverBindingSupported (
**/
EFI_STATUS
TerminalFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
+ IN OUT LIST_ENTRY *ListHead
)
{
- TERMINAL_CONSOLE_IN_EX_NOTIFY *NotifyNode;
+ TERMINAL_CONSOLE_IN_EX_NOTIFY *NotifyNode;
if (ListHead == NULL) {
return EFI_INVALID_PARAMETER;
}
+
while (!IsListEmpty (ListHead)) {
NotifyNode = CR (
ListHead->ForwardLink,
@@ -314,8 +313,8 @@ TerminalFreeNotifyList (
**/
TERMINAL_CONSOLE_MODE_DATA *
InitializeTerminalConsoleTextMode (
- OUT INT32 *TextModeCount
-)
+ OUT INT32 *TextModeCount
+ )
{
TERMINAL_CONSOLE_MODE_DATA *TextModeData;
@@ -325,14 +324,22 @@ InitializeTerminalConsoleTextMode (
if (TextModeData == NULL) {
return NULL;
}
+
*TextModeCount = ARRAY_SIZE (mTerminalConsoleModeData);
DEBUG_CODE_BEGIN ();
- INT32 Index;
- for (Index = 0; Index < *TextModeCount; Index++) {
- DEBUG ((DEBUG_INFO, "Terminal - Mode %d, Column = %d, Row = %d\n",
- Index, TextModeData[Index].Columns, TextModeData[Index].Rows));
- }
+ INT32 Index;
+
+ for (Index = 0; Index < *TextModeCount; Index++) {
+ DEBUG ((
+ DEBUG_INFO,
+ "Terminal - Mode %d, Column = %d, Row = %d\n",
+ Index,
+ TextModeData[Index].Columns,
+ TextModeData[Index].Rows
+ ));
+ }
+
DEBUG_CODE_END ();
return TextModeData;
}
@@ -344,10 +351,10 @@ InitializeTerminalConsoleTextMode (
**/
VOID
StopTerminalStateMachine (
- TERMINAL_DEV *TerminalDevice
+ TERMINAL_DEV *TerminalDevice
)
{
- EFI_TPL OriginalTpl;
+ EFI_TPL OriginalTpl;
OriginalTpl = gBS->RaiseTPL (TPL_NOTIFY);
@@ -364,10 +371,11 @@ StopTerminalStateMachine (
**/
VOID
StartTerminalStateMachine (
- TERMINAL_DEV *TerminalDevice
+ TERMINAL_DEV *TerminalDevice
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
@@ -407,13 +415,13 @@ EFI_STATUS
InitializeControllerNameTable (
TERMINAL_TYPE TerminalType,
EFI_UNICODE_STRING_TABLE **ControllerNameTable
-)
+ )
{
EFI_STATUS Status;
EFI_UNICODE_STRING_TABLE *Table;
ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
- Table = NULL;
+ Table = NULL;
Status = AddUnicodeString2 (
"eng",
gTerminalComponentName.SupportedLanguages,
@@ -433,9 +441,11 @@ InitializeControllerNameTable (
FreeUnicodeStringTable (Table);
}
}
+
if (!EFI_ERROR (Status)) {
*ControllerNameTable = Table;
}
+
return Status;
}
@@ -458,26 +468,26 @@ InitializeControllerNameTable (
EFI_STATUS
EFIAPI
TerminalDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *Vendor;
- EFI_HANDLE SerialIoHandle;
- EFI_SERIAL_IO_MODE *Mode;
- UINTN SerialInTimeOut;
- TERMINAL_DEV *TerminalDevice;
- UINT8 TerminalType;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- UINTN EntryCount;
- UINTN Index;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextInput;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_STATUS Status;
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Vendor;
+ EFI_HANDLE SerialIoHandle;
+ EFI_SERIAL_IO_MODE *Mode;
+ UINTN SerialInTimeOut;
+ TERMINAL_DEV *TerminalDevice;
+ UINT8 TerminalType;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ UINTN EntryCount;
+ UINTN Index;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextInput;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
//
// Get the Device Path Protocol to build the device path of the child device
@@ -485,7 +495,7 @@ TerminalDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -501,7 +511,7 @@ TerminalDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
+ (VOID **)&SerialIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -529,7 +539,6 @@ TerminalDriverBindingStart (
}
if (Status == EFI_ALREADY_STARTED) {
-
if (RemainingDevicePath == NULL) {
//
// If RemainingDevicePath is NULL or is the End of Device Path Node
@@ -554,14 +563,14 @@ TerminalDriverBindingStart (
Status = gBS->OpenProtocol (
OpenInfoBuffer[Index].ControllerHandle,
&gEfiSimpleTextInProtocolGuid,
- (VOID **) &SimpleTextInput,
+ (VOID **)&SimpleTextInput,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (SimpleTextInput);
- TerminalType = TerminalTypeFromGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid);
+ TerminalType = TerminalTypeFromGuid (&((VENDOR_DEVICE_PATH *)RemainingDevicePath)->Guid);
ASSERT (TerminalType < ARRAY_SIZE (mTerminalType));
if (TerminalDevice->TerminalType != TerminalType) {
Status = InitializeControllerNameTable (TerminalType, &ControllerNameTable);
@@ -573,7 +582,7 @@ TerminalDriverBindingStart (
Vendor = TerminalDevice->DevicePath;
Status = gBS->LocateDevicePath (&gEfiSerialIoProtocolGuid, &Vendor, &SerialIoHandle);
ASSERT_EFI_ERROR (Status);
- CopyGuid (&((VENDOR_DEVICE_PATH *) Vendor)->Guid, mTerminalType[TerminalType]);
+ CopyGuid (&((VENDOR_DEVICE_PATH *)Vendor)->Guid, mTerminalType[TerminalType]);
Status = gBS->ReinstallProtocolInterface (
TerminalDevice->Handle,
&gEfiDevicePathProtocolGuid,
@@ -589,17 +598,20 @@ TerminalDriverBindingStart (
//
// Restore the device path on failure
//
- CopyGuid (&((VENDOR_DEVICE_PATH *) Vendor)->Guid, mTerminalType[TerminalDevice->TerminalType]);
+ CopyGuid (&((VENDOR_DEVICE_PATH *)Vendor)->Guid, mTerminalType[TerminalDevice->TerminalType]);
FreeUnicodeStringTable (ControllerNameTable);
}
}
}
}
+
break;
}
}
+
FreePool (OpenInfoBuffer);
}
+
return Status;
}
@@ -626,8 +638,9 @@ TerminalDriverBindingStart (
// If RemainingDevicePath isn't the End of Device Path Node,
// Use the RemainingDevicePath to determine the terminal type
//
- TerminalDevice->TerminalType = TerminalTypeFromGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid);
+ TerminalDevice->TerminalType = TerminalTypeFromGuid (&((VENDOR_DEVICE_PATH *)RemainingDevicePath)->Guid);
}
+
ASSERT (TerminalDevice->TerminalType < ARRAY_SIZE (mTerminalType));
TerminalDevice->SerialIo = SerialIo;
@@ -682,14 +695,17 @@ TerminalDriverBindingStart (
if (TerminalDevice->RawFiFo == NULL) {
goto FreeResources;
}
+
TerminalDevice->UnicodeFiFo = AllocateZeroPool (sizeof (UNICODE_FIFO));
if (TerminalDevice->UnicodeFiFo == NULL) {
goto FreeResources;
}
+
TerminalDevice->EfiKeyFiFo = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
if (TerminalDevice->EfiKeyFiFo == NULL) {
goto FreeResources;
}
+
TerminalDevice->EfiKeyFiFoForNotify = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
if (TerminalDevice->EfiKeyFiFoForNotify == NULL) {
goto FreeResources;
@@ -702,17 +718,17 @@ TerminalDriverBindingStart (
SerialInTimeOut = 0;
if (Mode->BaudRate != 0) {
- SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;
+ SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN)Mode->BaudRate;
}
Status = TerminalDevice->SerialIo->SetAttributes (
TerminalDevice->SerialIo,
Mode->BaudRate,
Mode->ReceiveFifoDepth,
- (UINT32) SerialInTimeOut,
- (EFI_PARITY_TYPE) (Mode->Parity),
- (UINT8) Mode->DataBits,
- (EFI_STOP_BITS_TYPE) (Mode->StopBits)
+ (UINT32)SerialInTimeOut,
+ (EFI_PARITY_TYPE)(Mode->Parity),
+ (UINT8)Mode->DataBits,
+ (EFI_STOP_BITS_TYPE)(Mode->StopBits)
);
if (EFI_ERROR (Status)) {
//
@@ -728,26 +744,28 @@ TerminalDriverBindingStart (
}
SimpleTextOutput = &TerminalDevice->SimpleTextOutput;
- SimpleTextInput = &TerminalDevice->SimpleInput;
+ SimpleTextInput = &TerminalDevice->SimpleInput;
//
// Initialize SimpleTextOut instance
//
- SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
+ SimpleTextOutput->Mode = &TerminalDevice->SimpleTextOutputMode;
TerminalDevice->TerminalConsoleModeData = InitializeTerminalConsoleTextMode (
- &SimpleTextOutput->Mode->MaxMode
- );
+ &SimpleTextOutput->Mode->MaxMode
+ );
if (TerminalDevice->TerminalConsoleModeData == NULL) {
goto FreeResources;
}
+
//
// For terminal devices, cursor is always visible
//
SimpleTextOutput->Mode->CursorVisible = TRUE;
- Status = SimpleTextOutput->SetAttribute (SimpleTextOutput, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
+ Status = SimpleTextOutput->SetAttribute (SimpleTextOutput, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
if (!EFI_ERROR (Status)) {
Status = SimpleTextOutput->Reset (SimpleTextOutput, FALSE);
}
+
if (EFI_ERROR (Status)) {
goto ReportError;
}
@@ -762,17 +780,21 @@ TerminalDriverBindingStart (
Status = gBS->InstallMultipleProtocolInterfaces (
&TerminalDevice->Handle,
- &gEfiSimpleTextInProtocolGuid, &TerminalDevice->SimpleInput,
- &gEfiSimpleTextInputExProtocolGuid, &TerminalDevice->SimpleInputEx,
- &gEfiSimpleTextOutProtocolGuid, &TerminalDevice->SimpleTextOutput,
- &gEfiDevicePathProtocolGuid, TerminalDevice->DevicePath,
+ &gEfiSimpleTextInProtocolGuid,
+ &TerminalDevice->SimpleInput,
+ &gEfiSimpleTextInputExProtocolGuid,
+ &TerminalDevice->SimpleInputEx,
+ &gEfiSimpleTextOutProtocolGuid,
+ &TerminalDevice->SimpleTextOutput,
+ &gEfiDevicePathProtocolGuid,
+ TerminalDevice->DevicePath,
NULL
);
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
Controller,
&gEfiSerialIoProtocolGuid,
- (VOID **) &TerminalDevice->SerialIo,
+ (VOID **)&TerminalDevice->SerialIo,
This->DriverBindingHandle,
TerminalDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -795,9 +817,11 @@ FreeResources:
if (TerminalDevice->SimpleInput.WaitForKey != NULL) {
gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
}
+
if (TerminalDevice->SimpleInputEx.WaitForKeyEx != NULL) {
gBS->CloseEvent (TerminalDevice->SimpleInputEx.WaitForKeyEx);
}
+
if (TerminalDevice->KeyNotifyProcessEvent != NULL) {
gBS->CloseEvent (TerminalDevice->KeyNotifyProcessEvent);
}
@@ -805,12 +829,15 @@ FreeResources:
if (TerminalDevice->RawFiFo != NULL) {
FreePool (TerminalDevice->RawFiFo);
}
+
if (TerminalDevice->UnicodeFiFo != NULL) {
FreePool (TerminalDevice->UnicodeFiFo);
}
+
if (TerminalDevice->EfiKeyFiFo != NULL) {
FreePool (TerminalDevice->EfiKeyFiFo);
}
+
if (TerminalDevice->EfiKeyFiFoForNotify != NULL) {
FreePool (TerminalDevice->EfiKeyFiFoForNotify);
}
@@ -875,10 +902,10 @@ CloseProtocols:
EFI_STATUS
EFIAPI
TerminalDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
EFI_STATUS Status;
@@ -900,7 +927,7 @@ TerminalDriverBindingStop (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -916,18 +943,18 @@ TerminalDriverBindingStop (
TerminalRemoveConsoleDevVariable (EFI_ERR_OUT_DEV_VARIABLE_NAME, ParentDevicePath);
gBS->CloseProtocol (
- Controller,
- &gEfiSerialIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiSerialIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
}
@@ -935,25 +962,23 @@ TerminalDriverBindingStop (
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
-
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiSimpleTextOutProtocolGuid,
- (VOID **) &SimpleTextOutput,
+ (VOID **)&SimpleTextOutput,
This->DriverBindingHandle,
ChildHandleBuffer[Index],
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
-
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
gBS->CloseProtocol (
- Controller,
- &gEfiSerialIoProtocolGuid,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index]
- );
+ Controller,
+ &gEfiSerialIoProtocolGuid,
+ This->DriverBindingHandle,
+ ChildHandleBuffer[Index]
+ );
Status = gBS->UninstallMultipleProtocolInterfaces (
ChildHandleBuffer[Index],
@@ -969,15 +994,14 @@ TerminalDriverBindingStop (
);
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
- Controller,
- &gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index],
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
+ Controller,
+ &gEfiSerialIoProtocolGuid,
+ (VOID **)&SerialIo,
+ This->DriverBindingHandle,
+ ChildHandleBuffer[Index],
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
} else {
-
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
StopTerminalStateMachine (TerminalDevice);
gBS->CloseEvent (TerminalDevice->SimpleInput.WaitForKey);
@@ -1023,8 +1047,8 @@ MatchDevicePaths (
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
UINTN Size;
- DevicePath = Multi;
- DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
+ DevicePath = Multi;
+ DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
//
// Search for the match of 'Single' in 'Multi'
//
@@ -1058,23 +1082,24 @@ TerminalUpdateConsoleDevVariable (
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath
)
{
- EFI_STATUS Status;
- UINTN NameSize;
- UINTN VariableSize;
- TERMINAL_TYPE TerminalType;
- EFI_DEVICE_PATH_PROTOCOL *Variable;
- EFI_DEVICE_PATH_PROTOCOL *NewVariable;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EDKII_SET_VARIABLE_STATUS *SetVariableStatus;
+ EFI_STATUS Status;
+ UINTN NameSize;
+ UINTN VariableSize;
+ TERMINAL_TYPE TerminalType;
+ EFI_DEVICE_PATH_PROTOCOL *Variable;
+ EFI_DEVICE_PATH_PROTOCOL *NewVariable;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EDKII_SET_VARIABLE_STATUS *SetVariableStatus;
//
// Get global variable and its size according to the name given.
//
- Status = GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);
+ Status = GetEfiGlobalVariable2 (VariableName, (VOID **)&Variable, NULL);
if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
Variable = NULL;
}
+
if (EFI_ERROR (Status)) {
return;
}
@@ -1092,13 +1117,13 @@ TerminalUpdateConsoleDevVariable (
if (Variable != NULL) {
FreePool (Variable);
}
+
Variable = NewVariable;
}
}
FreePool (TempDevicePath);
}
-
}
VariableSize = GetDevicePathSize (Variable);
@@ -1112,7 +1137,7 @@ TerminalUpdateConsoleDevVariable (
);
if (EFI_ERROR (Status)) {
- NameSize = StrSize (VariableName);
+ NameSize = StrSize (VariableName);
SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + VariableSize);
if (SetVariableStatus != NULL) {
CopyGuid (&SetVariableStatus->Guid, &gEfiGlobalVariableGuid);
@@ -1120,8 +1145,8 @@ TerminalUpdateConsoleDevVariable (
SetVariableStatus->DataSize = VariableSize;
SetVariableStatus->SetStatus = Status;
SetVariableStatus->Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
- CopyMem (SetVariableStatus + 1, VariableName, NameSize);
- CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Variable, VariableSize);
+ CopyMem (SetVariableStatus + 1, VariableName, NameSize);
+ CopyMem (((UINT8 *)(SetVariableStatus + 1)) + NameSize, Variable, VariableSize);
REPORT_STATUS_CODE_EX (
EFI_ERROR_CODE,
@@ -1139,10 +1164,9 @@ TerminalUpdateConsoleDevVariable (
FreePool (Variable);
- return ;
+ return;
}
-
/**
Remove terminal device path from Console Device Environment Variables.
@@ -1169,19 +1193,19 @@ TerminalRemoveConsoleDevVariable (
EFI_DEVICE_PATH_PROTOCOL *SavedNewVariable;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- Instance = NULL;
+ Instance = NULL;
//
// Get global variable and its size according to the name given.
//
- GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);
+ GetEfiGlobalVariable2 (VariableName, (VOID **)&Variable, NULL);
if (Variable == NULL) {
- return ;
+ return;
}
- FoundOne = FALSE;
- OriginalVariable = Variable;
- NewVariable = NULL;
+ FoundOne = FALSE;
+ OriginalVariable = Variable;
+ NewVariable = NULL;
//
// Get first device path instance from Variable
@@ -1189,8 +1213,9 @@ TerminalRemoveConsoleDevVariable (
Instance = GetNextDevicePathInstance (&Variable, &InstanceSize);
if (Instance == NULL) {
FreePool (OriginalVariable);
- return ;
+ return;
}
+
//
// Loop through all the device path instances of Variable
//
@@ -1200,7 +1225,6 @@ TerminalRemoveConsoleDevVariable (
//
Match = FALSE;
for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {
-
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
//
@@ -1208,23 +1232,25 @@ TerminalRemoveConsoleDevVariable (
//
if (TempDevicePath != NULL) {
if (CompareMem (Instance, TempDevicePath, InstanceSize) == 0) {
- Match = TRUE;
- FoundOne = TRUE;
+ Match = TRUE;
+ FoundOne = TRUE;
}
FreePool (TempDevicePath);
}
}
+
//
// If a match was not found, then keep the current device path instance
//
if (!Match) {
- SavedNewVariable = NewVariable;
- NewVariable = AppendDevicePathInstance (NewVariable, Instance);
+ SavedNewVariable = NewVariable;
+ NewVariable = AppendDevicePathInstance (NewVariable, Instance);
if (SavedNewVariable != NULL) {
FreePool (SavedNewVariable);
}
}
+
//
// Get next device path instance from Variable
//
@@ -1254,7 +1280,7 @@ TerminalRemoveConsoleDevVariable (
FreePool (NewVariable);
}
- return ;
+ return;
}
/**
@@ -1271,9 +1297,9 @@ TerminalRemoveConsoleDevVariable (
**/
EFI_STATUS
SetTerminalDevicePath (
- IN TERMINAL_TYPE TerminalType,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
+ IN TERMINAL_TYPE TerminalType,
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
)
{
VENDOR_DEVICE_PATH Node;
@@ -1290,7 +1316,7 @@ SetTerminalDevicePath (
//
*TerminalDevicePath = AppendDevicePathNode (
ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &Node
+ (EFI_DEVICE_PATH_PROTOCOL *)&Node
);
if (*TerminalDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -1311,12 +1337,12 @@ SetTerminalDevicePath (
**/
EFI_STATUS
EFIAPI
-InitializeTerminal(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeTerminal (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
@@ -1348,10 +1374,10 @@ InitializeTerminal(
**/
BOOLEAN
IsHotPlugDevice (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath;
CheckDevicePath = DevicePath;
while (!IsDevicePathEnd (CheckDevicePath)) {
@@ -1359,16 +1385,19 @@ IsHotPlugDevice (
// Check device whether is hot plug device or not throught Device Path
//
if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (CheckDevicePath) == MSG_USB_DP ||
- DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP ||
- DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) {
+ ((DevicePathSubType (CheckDevicePath) == MSG_USB_DP) ||
+ (DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP) ||
+ (DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)))
+ {
//
// If Device is USB device
//
return TRUE;
}
+
if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) &&
- (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) {
+ (DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP))
+ {
//
// If Device is PCCard
//
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index dfe9882..4238f84 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _TERMINAL_H_
#define _TERMINAL_H_
-
#include <Uefi.h>
#include <Guid/GlobalVariable.h>
@@ -36,44 +35,43 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/PcdLib.h>
#include <Library/BaseLib.h>
-
-#define RAW_FIFO_MAX_NUMBER 255
-#define FIFO_MAX_NUMBER 128
+#define RAW_FIFO_MAX_NUMBER 255
+#define FIFO_MAX_NUMBER 128
typedef struct {
- UINT8 Head;
- UINT8 Tail;
- UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];
+ UINT8 Head;
+ UINT8 Tail;
+ UINT8 Data[RAW_FIFO_MAX_NUMBER + 1];
} RAW_DATA_FIFO;
typedef struct {
- UINT8 Head;
- UINT8 Tail;
- UINT16 Data[FIFO_MAX_NUMBER + 1];
+ UINT8 Head;
+ UINT8 Tail;
+ UINT16 Data[FIFO_MAX_NUMBER + 1];
} UNICODE_FIFO;
typedef struct {
- UINT8 Head;
- UINT8 Tail;
- EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];
+ UINT8 Head;
+ UINT8 Tail;
+ EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1];
} EFI_KEY_FIFO;
typedef struct {
- UINTN Columns;
- UINTN Rows;
+ UINTN Columns;
+ UINTN Rows;
} TERMINAL_CONSOLE_MODE_DATA;
-#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
+#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
#define TERMINAL_DEV_SIGNATURE SIGNATURE_32 ('t', 'm', 'n', 'l')
-#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('t', 'm', 'e', 'n')
+#define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('t', 'm', 'e', 'n')
typedef struct _TERMINAL_CONSOLE_IN_EX_NOTIFY {
- UINTN Signature;
- EFI_KEY_DATA KeyData;
- EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
- LIST_ENTRY NotifyEntry;
+ UINTN Signature;
+ EFI_KEY_DATA KeyData;
+ EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
+ LIST_ENTRY NotifyEntry;
} TERMINAL_CONSOLE_IN_EX_NOTIFY;
typedef enum {
@@ -89,27 +87,27 @@ typedef enum {
} TERMINAL_TYPE;
typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- TERMINAL_TYPE TerminalType;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- 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;
- EFI_KEY_FIFO *EfiKeyFiFo;
- EFI_KEY_FIFO *EfiKeyFiFoForNotify;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- EFI_EVENT TimerEvent;
- EFI_EVENT TwoSecondTimeOut;
- UINT32 InputState;
- UINT32 ResetState;
- UINT16 TtyEscapeStr[3];
- INTN TtyEscapeIndex;
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ TERMINAL_TYPE TerminalType;
+ EFI_SERIAL_IO_PROTOCOL *SerialIo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ 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;
+ EFI_KEY_FIFO *EfiKeyFiFo;
+ EFI_KEY_FIFO *EfiKeyFiFoForNotify;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_EVENT TimerEvent;
+ EFI_EVENT TwoSecondTimeOut;
+ UINT32 InputState;
+ UINT32 ResetState;
+ UINT16 TtyEscapeStr[3];
+ INTN TtyEscapeIndex;
//
// Esc could not be output to the screen by user,
@@ -118,57 +116,57 @@ typedef struct {
// This boolean is used by the terminal driver only
// to indicate whether the Esc could be sent or not.
//
- BOOLEAN OutputEscChar;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
- LIST_ENTRY NotifyList;
- EFI_EVENT KeyNotifyProcessEvent;
+ BOOLEAN OutputEscChar;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
+ LIST_ENTRY NotifyList;
+ EFI_EVENT KeyNotifyProcessEvent;
} TERMINAL_DEV;
-#define INPUT_STATE_DEFAULT 0x00
-#define INPUT_STATE_ESC 0x01
-#define INPUT_STATE_CSI 0x02
-#define INPUT_STATE_LEFTOPENBRACKET 0x04
-#define INPUT_STATE_O 0x08
-#define INPUT_STATE_2 0x10
-#define INPUT_STATE_LEFTOPENBRACKET_TTY 0x20
-#define INPUT_STATE_1 0x40
-#define INPUT_STATE_LEFTOPENBRACKET_2ND 0x80
-
-#define RESET_STATE_DEFAULT 0x00
-#define RESET_STATE_ESC_R 0x01
-#define RESET_STATE_ESC_R_ESC_R 0x02
-
-#define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)
-#define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)
+#define INPUT_STATE_DEFAULT 0x00
+#define INPUT_STATE_ESC 0x01
+#define INPUT_STATE_CSI 0x02
+#define INPUT_STATE_LEFTOPENBRACKET 0x04
+#define INPUT_STATE_O 0x08
+#define INPUT_STATE_2 0x10
+#define INPUT_STATE_LEFTOPENBRACKET_TTY 0x20
+#define INPUT_STATE_1 0x40
+#define INPUT_STATE_LEFTOPENBRACKET_2ND 0x80
+
+#define RESET_STATE_DEFAULT 0x00
+#define RESET_STATE_ESC_R 0x01
+#define RESET_STATE_ESC_R_ESC_R 0x02
+
+#define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)
+#define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)
#define TERMINAL_CON_IN_EX_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInputEx, TERMINAL_DEV_SIGNATURE)
typedef union {
- UINT8 Utf8_1;
- UINT8 Utf8_2[2];
- UINT8 Utf8_3[3];
+ UINT8 Utf8_1;
+ UINT8 Utf8_2[2];
+ UINT8 Utf8_3[3];
} UTF8_CHAR;
-#define LEFTOPENBRACKET 0x5b // '['
-#define ACAP 0x41
-#define BCAP 0x42
-#define CCAP 0x43
-#define DCAP 0x44
-
-#define BACKSPACE 8
-#define ESC 27
-#define CSI 0x9B
-#define DEL 127
-#define BRIGHT_CONTROL_OFFSET 2
-#define FOREGROUND_CONTROL_OFFSET 6
-#define BACKGROUND_CONTROL_OFFSET 11
-#define ROW_OFFSET 2
-#define COLUMN_OFFSET 5
-#define FW_BACK_OFFSET 2
+#define LEFTOPENBRACKET 0x5b // '['
+#define ACAP 0x41
+#define BCAP 0x42
+#define CCAP 0x43
+#define DCAP 0x44
+
+#define BACKSPACE 8
+#define ESC 27
+#define CSI 0x9B
+#define DEL 127
+#define BRIGHT_CONTROL_OFFSET 2
+#define FOREGROUND_CONTROL_OFFSET 6
+#define BACKGROUND_CONTROL_OFFSET 11
+#define ROW_OFFSET 2
+#define COLUMN_OFFSET 5
+#define FW_BACK_OFFSET 2
typedef struct {
- UINT16 Unicode;
- CHAR8 PcAnsi;
- CHAR8 Ascii;
+ UINT16 Unicode;
+ CHAR8 PcAnsi;
+ CHAR8 Ascii;
} UNICODE_TO_CHAR;
//
@@ -191,8 +189,8 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2;
EFI_STATUS
EFIAPI
InitializeTerminal (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@@ -210,11 +208,10 @@ InitializeTerminal (
EFI_STATUS
EFIAPI
TerminalConInReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
-
/**
Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().
@@ -266,8 +263,8 @@ IsKeyRegistered (
VOID
EFIAPI
TerminalConInWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
//
@@ -311,8 +308,8 @@ TerminalConInResetEx (
EFI_STATUS
EFIAPI
TerminalConInReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
);
/**
@@ -399,8 +396,8 @@ TerminalConInUnregisterKeyNotify (
VOID
EFIAPI
TerminalConInWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -421,8 +418,8 @@ TerminalConInWaitForKey (
EFI_STATUS
EFIAPI
TerminalConOutReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -609,9 +606,9 @@ TerminalConOutEnableCursor (
EFI_STATUS
EFIAPI
TerminalDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -633,12 +630,11 @@ TerminalDriverBindingSupported (
EFI_STATUS
EFIAPI
TerminalDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
-
/**
Stop this driver on Controller by closing Simple Text In, Simple Text
In Ex, Simple Text Out protocol, and removing parent device path from
@@ -657,10 +653,10 @@ TerminalDriverBindingStart (
EFI_STATUS
EFIAPI
TerminalDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
/**
@@ -674,7 +670,7 @@ TerminalDriverBindingStop (
**/
EFI_STATUS
TerminalFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
+ IN OUT LIST_ENTRY *ListHead
);
/**
@@ -724,7 +720,6 @@ TerminalComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -796,14 +791,13 @@ TerminalComponentNameGetDriverName (
EFI_STATUS
EFIAPI
TerminalComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
//
// internal functions
//
@@ -866,9 +860,9 @@ TerminalRemoveConsoleDevVariable (
**/
EFI_STATUS
SetTerminalDevicePath (
- IN TERMINAL_TYPE TerminalType,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
+ IN TERMINAL_TYPE TerminalType,
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
);
/**
@@ -963,8 +957,8 @@ IsRawFiFoFull (
**/
BOOLEAN
EfiKeyFiFoForNotifyInsertOneKey (
- EFI_KEY_FIFO *EfiKeyFiFo,
- EFI_INPUT_KEY *Input
+ EFI_KEY_FIFO *EfiKeyFiFo,
+ EFI_INPUT_KEY *Input
);
/**
@@ -979,8 +973,8 @@ EfiKeyFiFoForNotifyInsertOneKey (
**/
BOOLEAN
EfiKeyFiFoForNotifyRemoveOneKey (
- EFI_KEY_FIFO *EfiKeyFiFo,
- EFI_INPUT_KEY *Output
+ EFI_KEY_FIFO *EfiKeyFiFo,
+ EFI_INPUT_KEY *Output
);
/**
@@ -994,7 +988,7 @@ EfiKeyFiFoForNotifyRemoveOneKey (
**/
BOOLEAN
IsEfiKeyFiFoForNotifyEmpty (
- IN EFI_KEY_FIFO *EfiKeyFiFo
+ IN EFI_KEY_FIFO *EfiKeyFiFo
);
/**
@@ -1008,7 +1002,7 @@ IsEfiKeyFiFoForNotifyEmpty (
**/
BOOLEAN
IsEfiKeyFiFoForNotifyFull (
- EFI_KEY_FIFO *EfiKeyFiFo
+ EFI_KEY_FIFO *EfiKeyFiFo
);
/**
@@ -1024,8 +1018,8 @@ IsEfiKeyFiFoForNotifyFull (
**/
BOOLEAN
EfiKeyFiFoInsertOneKey (
- TERMINAL_DEV *TerminalDevice,
- EFI_INPUT_KEY *Key
+ TERMINAL_DEV *TerminalDevice,
+ EFI_INPUT_KEY *Key
);
/**
@@ -1040,8 +1034,8 @@ EfiKeyFiFoInsertOneKey (
**/
BOOLEAN
EfiKeyFiFoRemoveOneKey (
- TERMINAL_DEV *TerminalDevice,
- EFI_INPUT_KEY *Output
+ TERMINAL_DEV *TerminalDevice,
+ EFI_INPUT_KEY *Output
);
/**
@@ -1085,8 +1079,8 @@ IsEfiKeyFiFoFull (
**/
BOOLEAN
UnicodeFiFoInsertOneKey (
- TERMINAL_DEV *TerminalDevice,
- UINT16 Input
+ TERMINAL_DEV *TerminalDevice,
+ UINT16 Input
);
/**
@@ -1132,7 +1126,6 @@ IsUnicodeFiFoFull (
TERMINAL_DEV *TerminalDevice
);
-
/**
Translate raw data into Unicode (according to different encode), and
translate Unicode into key information. (according to different standard).
@@ -1142,7 +1135,7 @@ IsUnicodeFiFoFull (
**/
VOID
TranslateRawDataToEfiKey (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
);
//
@@ -1158,7 +1151,7 @@ TranslateRawDataToEfiKey (
**/
VOID
AnsiRawDataToUnicode (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
);
/**
@@ -1248,7 +1241,7 @@ Putty function key map:
**/
VOID
UnicodeToEfiKey (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
);
/**
@@ -1264,8 +1257,8 @@ UnicodeToEfiKey (
**/
EFI_STATUS
AnsiTestString (
- IN TERMINAL_DEV *TerminalDevice,
- IN CHAR16 *WString
+ IN TERMINAL_DEV *TerminalDevice,
+ IN CHAR16 *WString
);
//
@@ -1281,7 +1274,7 @@ AnsiTestString (
**/
VOID
VTUTF8RawDataToUnicode (
- IN TERMINAL_DEV *VtUtf8Device
+ IN TERMINAL_DEV *VtUtf8Device
);
/**
@@ -1295,8 +1288,8 @@ VTUTF8RawDataToUnicode (
**/
EFI_STATUS
VTUTF8TestString (
- IN TERMINAL_DEV *TerminalDevice,
- IN CHAR16 *WString
+ IN TERMINAL_DEV *TerminalDevice,
+ IN CHAR16 *WString
);
/**
@@ -1317,9 +1310,9 @@ VTUTF8TestString (
**/
VOID
UnicodeToUtf8 (
- IN CHAR16 Unicode,
- OUT UTF8_CHAR *Utf8Char,
- OUT UINT8 *ValidBytes
+ IN CHAR16 Unicode,
+ OUT UTF8_CHAR *Utf8Char,
+ OUT UINT8 *ValidBytes
);
/**
@@ -1333,9 +1326,9 @@ UnicodeToUtf8 (
**/
VOID
GetOneValidUtf8Char (
- IN TERMINAL_DEV *Utf8Device,
- OUT UTF8_CHAR *Utf8Char,
- OUT UINT8 *ValidBytes
+ IN TERMINAL_DEV *Utf8Device,
+ OUT UTF8_CHAR *Utf8Char,
+ OUT UINT8 *ValidBytes
);
/**
@@ -1355,9 +1348,9 @@ GetOneValidUtf8Char (
**/
VOID
Utf8ToUnicode (
- IN UTF8_CHAR Utf8Char,
- IN UINT8 ValidBytes,
- OUT CHAR16 *UnicodeChar
+ IN UTF8_CHAR Utf8Char,
+ IN UINT8 ValidBytes,
+ OUT CHAR16 *UnicodeChar
);
//
@@ -1425,7 +1418,7 @@ TerminalIsValidEfiCntlChar (
**/
BOOLEAN
IsHotPlugDevice (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -1437,11 +1430,10 @@ IsHotPlugDevice (
VOID
EFIAPI
TerminalConInTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
-
/**
Process key notify.
@@ -1451,8 +1443,8 @@ TerminalConInTimerHandler (
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
#endif
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 4d6ede4..2286264 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Terminal.h"
-
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existence of a keystroke via WaitForEvent () call.
@@ -27,8 +26,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
ReadKeyStrokeWorker (
- IN TERMINAL_DEV *TerminalDevice,
- OUT EFI_KEY_DATA *KeyData
+ IN TERMINAL_DEV *TerminalDevice,
+ OUT EFI_KEY_DATA *KeyData
)
{
if (KeyData == NULL) {
@@ -43,7 +42,6 @@ ReadKeyStrokeWorker (
}
return EFI_SUCCESS;
-
}
/**
@@ -84,9 +82,9 @@ TerminalConInReset (
//
// Make all the internal buffer empty for keys
//
- TerminalDevice->RawFiFo->Head = TerminalDevice->RawFiFo->Tail;
- TerminalDevice->UnicodeFiFo->Head = TerminalDevice->UnicodeFiFo->Tail;
- TerminalDevice->EfiKeyFiFo->Head = TerminalDevice->EfiKeyFiFo->Tail;
+ TerminalDevice->RawFiFo->Head = TerminalDevice->RawFiFo->Tail;
+ TerminalDevice->UnicodeFiFo->Head = TerminalDevice->UnicodeFiFo->Tail;
+ TerminalDevice->EfiKeyFiFo->Head = TerminalDevice->EfiKeyFiFo->Tail;
TerminalDevice->EfiKeyFiFoForNotify->Head = TerminalDevice->EfiKeyFiFoForNotify->Tail;
if (EFI_ERROR (Status)) {
@@ -127,7 +125,7 @@ TerminalConInReadKeyStroke (
//
// get TERMINAL_DEV from "This" parameter.
//
- TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);
+ TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);
Status = ReadKeyStrokeWorker (TerminalDevice, &KeyData);
if (EFI_ERROR (Status)) {
@@ -137,7 +135,6 @@ TerminalConInReadKeyStroke (
CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
return EFI_SUCCESS;
-
}
/**
@@ -165,15 +162,14 @@ IsKeyRegistered (
ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+ (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
+ {
return FALSE;
}
return TRUE;
}
-
-
/**
Event notification function for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
Signal the event if there is key available
@@ -185,8 +181,8 @@ IsKeyRegistered (
VOID
EFIAPI
TerminalConInWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
TerminalConInWaitForKey (Event, Context);
@@ -214,8 +210,8 @@ TerminalConInResetEx (
IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- TERMINAL_DEV *TerminalDevice;
+ EFI_STATUS Status;
+ TERMINAL_DEV *TerminalDevice;
TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
@@ -225,10 +221,8 @@ TerminalConInResetEx (
}
return EFI_SUCCESS;
-
}
-
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existence of a keystroke via WaitForEvent () call.
@@ -248,11 +242,11 @@ TerminalConInResetEx (
EFI_STATUS
EFIAPI
TerminalConInReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
)
{
- TERMINAL_DEV *TerminalDevice;
+ TERMINAL_DEV *TerminalDevice;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
@@ -261,10 +255,8 @@ TerminalConInReadKeyStrokeEx (
TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
return ReadKeyStrokeWorker (TerminalDevice, KeyData);
-
}
-
/**
Set certain state for the input device.
@@ -298,7 +290,6 @@ TerminalConInSetState (
return EFI_SUCCESS;
}
-
/**
Register a notification function for a particular keystroke for the input device.
@@ -330,13 +321,13 @@ TerminalConInRegisterKeyNotify (
OUT VOID **NotifyHandle
)
{
- TERMINAL_DEV *TerminalDevice;
- TERMINAL_CONSOLE_IN_EX_NOTIFY *NewNotify;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ TERMINAL_DEV *TerminalDevice;
+ TERMINAL_CONSOLE_IN_EX_NOTIFY *NewNotify;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
+ if ((KeyData == NULL) || (NotifyHandle == NULL) || (KeyNotificationFunction == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -346,7 +337,7 @@ TerminalConInRegisterKeyNotify (
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
//
NotifyList = &TerminalDevice->NotifyList;
- for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList,Link); Link = GetNextNode (NotifyList,Link)) {
+ for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
@@ -364,7 +355,7 @@ TerminalConInRegisterKeyNotify (
//
// Allocate resource to save the notification function
//
- NewNotify = (TERMINAL_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (TERMINAL_CONSOLE_IN_EX_NOTIFY));
+ NewNotify = (TERMINAL_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool (sizeof (TERMINAL_CONSOLE_IN_EX_NOTIFY));
if (NewNotify == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -374,12 +365,11 @@ TerminalConInRegisterKeyNotify (
CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
InsertTailList (&TerminalDevice->NotifyList, &NewNotify->NotifyEntry);
- *NotifyHandle = NewNotify;
+ *NotifyHandle = NewNotify;
return EFI_SUCCESS;
}
-
/**
Remove a registered notification function from a particular keystroke.
@@ -399,10 +389,10 @@ TerminalConInUnregisterKeyNotify (
IN VOID *NotificationHandle
)
{
- TERMINAL_DEV *TerminalDevice;
- LIST_ENTRY *Link;
- TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- LIST_ENTRY *NotifyList;
+ TERMINAL_DEV *TerminalDevice;
+ LIST_ENTRY *Link;
+ TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ LIST_ENTRY *NotifyList;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -411,7 +401,7 @@ TerminalConInUnregisterKeyNotify (
TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
NotifyList = &TerminalDevice->NotifyList;
- for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList,Link); Link = GetNextNode (NotifyList,Link)) {
+ for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
@@ -444,37 +434,36 @@ TerminalConInUnregisterKeyNotify (
**/
VOID
TranslateRawDataToEfiKey (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
)
{
switch (TerminalDevice->TerminalType) {
+ case TerminalTypePcAnsi:
+ case TerminalTypeVt100:
+ case TerminalTypeVt100Plus:
+ case TerminalTypeTtyTerm:
+ case TerminalTypeLinux:
+ case TerminalTypeXtermR6:
+ case TerminalTypeVt400:
+ case TerminalTypeSCO:
+ AnsiRawDataToUnicode (TerminalDevice);
+ UnicodeToEfiKey (TerminalDevice);
+ break;
- case TerminalTypePcAnsi:
- case TerminalTypeVt100:
- case TerminalTypeVt100Plus:
- case TerminalTypeTtyTerm:
- case TerminalTypeLinux:
- case TerminalTypeXtermR6:
- case TerminalTypeVt400:
- case TerminalTypeSCO:
- AnsiRawDataToUnicode (TerminalDevice);
- UnicodeToEfiKey (TerminalDevice);
- break;
-
- case TerminalTypeVtUtf8:
- //
- // Process all the raw data in the RawFIFO,
- // put the processed key into UnicodeFIFO.
- //
- VTUTF8RawDataToUnicode (TerminalDevice);
+ case TerminalTypeVtUtf8:
+ //
+ // Process all the raw data in the RawFIFO,
+ // put the processed key into UnicodeFIFO.
+ //
+ VTUTF8RawDataToUnicode (TerminalDevice);
- //
- // Translate all the Unicode data in the UnicodeFIFO to Efi key,
- // then put into EfiKeyFIFO.
- //
- UnicodeToEfiKey (TerminalDevice);
+ //
+ // Translate all the Unicode data in the UnicodeFIFO to Efi key,
+ // then put into EfiKeyFIFO.
+ //
+ UnicodeToEfiKey (TerminalDevice);
- break;
+ break;
}
}
@@ -489,16 +478,15 @@ TranslateRawDataToEfiKey (
VOID
EFIAPI
TerminalConInWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
// Someone is waiting on the keystroke event, if there's
// a key pending, signal the event
//
- if (!IsEfiKeyFiFoEmpty ((TERMINAL_DEV *) Context)) {
-
+ if (!IsEfiKeyFiFoEmpty ((TERMINAL_DEV *)Context)) {
gBS->SignalEvent (Event);
}
}
@@ -512,8 +500,8 @@ TerminalConInWaitForKey (
VOID
EFIAPI
TerminalConInTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_STATUS Status;
@@ -524,12 +512,13 @@ TerminalConInTimerHandler (
EFI_SERIAL_IO_PROTOCOL *SerialIo;
UINTN SerialInTimeOut;
- TerminalDevice = (TERMINAL_DEV *) Context;
+ TerminalDevice = (TERMINAL_DEV *)Context;
- SerialIo = TerminalDevice->SerialIo;
+ SerialIo = TerminalDevice->SerialIo;
if (SerialIo == NULL) {
- return ;
+ return;
}
+
//
// if current timeout value for serial device is not identical with
// the value saved in TERMINAL_DEV structure, then recalculate the
@@ -537,24 +526,23 @@ TerminalConInTimerHandler (
//
Mode = SerialIo->Mode;
if (Mode->Timeout != TerminalDevice->SerialInTimeOut) {
-
SerialInTimeOut = 0;
if (Mode->BaudRate != 0) {
//
// According to BAUD rate to calculate the timeout value.
//
- SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;
+ SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN)Mode->BaudRate;
}
Status = SerialIo->SetAttributes (
- SerialIo,
- Mode->BaudRate,
- Mode->ReceiveFifoDepth,
- (UINT32) SerialInTimeOut,
- (EFI_PARITY_TYPE) (Mode->Parity),
- (UINT8) Mode->DataBits,
- (EFI_STOP_BITS_TYPE) (Mode->StopBits)
- );
+ SerialIo,
+ Mode->BaudRate,
+ Mode->ReceiveFifoDepth,
+ (UINT32)SerialInTimeOut,
+ (EFI_PARITY_TYPE)(Mode->Parity),
+ (UINT8)Mode->DataBits,
+ (EFI_STOP_BITS_TYPE)(Mode->StopBits)
+ );
if (EFI_ERROR (Status)) {
TerminalDevice->SerialInTimeOut = 0;
@@ -562,6 +550,7 @@ TerminalConInTimerHandler (
TerminalDevice->SerialInTimeOut = SerialInTimeOut;
}
}
+
//
// Check whether serial buffer is empty.
// Skip the key transfer loop only if the SerialIo protocol instance
@@ -574,7 +563,6 @@ TerminalConInTimerHandler (
// and insert the byte stream into RawFIFO.
//
while (!IsRawFiFoFull (TerminalDevice)) {
-
Status = GetOneKeyFromSerial (TerminalDevice->SerialIo, &Input);
if (EFI_ERROR (Status)) {
@@ -585,6 +573,7 @@ TerminalConInTimerHandler (
TerminalDevice->DevicePath
);
}
+
break;
}
@@ -608,20 +597,20 @@ TerminalConInTimerHandler (
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- BOOLEAN HasKey;
- TERMINAL_DEV *TerminalDevice;
- EFI_INPUT_KEY Key;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_TPL OldTpl;
+ BOOLEAN HasKey;
+ TERMINAL_DEV *TerminalDevice;
+ EFI_INPUT_KEY Key;
+ EFI_KEY_DATA KeyData;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_TPL OldTpl;
- TerminalDevice = (TERMINAL_DEV *) Context;
+ TerminalDevice = (TERMINAL_DEV *)Context;
//
// Invoke notification functions.
@@ -643,6 +632,7 @@ KeyNotifyProcessHandler (
if (!HasKey) {
break;
}
+
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (Link, TERMINAL_CONSOLE_IN_EX_NOTIFY, NotifyEntry, TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
@@ -679,16 +669,14 @@ GetOneKeyFromSerial (
//
// Read one key from serial I/O device.
//
- Status = SerialIo->Read (SerialIo, &Size, Output);
+ Status = SerialIo->Read (SerialIo, &Size, Output);
if (EFI_ERROR (Status)) {
-
if (Status == EFI_TIMEOUT) {
return EFI_NOT_READY;
}
return EFI_DEVICE_ERROR;
-
}
if (*Output == 0) {
@@ -711,11 +699,11 @@ GetOneKeyFromSerial (
**/
BOOLEAN
RawFiFoInsertOneKey (
- TERMINAL_DEV *TerminalDevice,
- UINT8 Input
+ TERMINAL_DEV *TerminalDevice,
+ UINT8 Input
)
{
- UINT8 Tail;
+ UINT8 Tail;
Tail = TerminalDevice->RawFiFo->Tail;
@@ -726,9 +714,9 @@ RawFiFoInsertOneKey (
return FALSE;
}
- TerminalDevice->RawFiFo->Data[Tail] = Input;
+ TerminalDevice->RawFiFo->Data[Tail] = Input;
- TerminalDevice->RawFiFo->Tail = (UINT8) ((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));
+ TerminalDevice->RawFiFo->Tail = (UINT8)((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -749,7 +737,7 @@ RawFiFoRemoveOneKey (
UINT8 *Output
)
{
- UINT8 Head;
+ UINT8 Head;
Head = TerminalDevice->RawFiFo->Head;
@@ -761,9 +749,9 @@ RawFiFoRemoveOneKey (
return FALSE;
}
- *Output = TerminalDevice->RawFiFo->Data[Head];
+ *Output = TerminalDevice->RawFiFo->Data[Head];
- TerminalDevice->RawFiFo->Head = (UINT8) ((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));
+ TerminalDevice->RawFiFo->Head = (UINT8)((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -803,14 +791,13 @@ IsRawFiFoFull (
TERMINAL_DEV *TerminalDevice
)
{
- UINT8 Tail;
- UINT8 Head;
+ UINT8 Tail;
+ UINT8 Head;
- Tail = TerminalDevice->RawFiFo->Tail;
- Head = TerminalDevice->RawFiFo->Head;
+ Tail = TerminalDevice->RawFiFo->Tail;
+ Head = TerminalDevice->RawFiFo->Head;
if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {
-
return TRUE;
}
@@ -830,11 +817,11 @@ IsRawFiFoFull (
**/
BOOLEAN
EfiKeyFiFoForNotifyInsertOneKey (
- EFI_KEY_FIFO *EfiKeyFiFo,
- EFI_INPUT_KEY *Input
+ EFI_KEY_FIFO *EfiKeyFiFo,
+ EFI_INPUT_KEY *Input
)
{
- UINT8 Tail;
+ UINT8 Tail;
Tail = EfiKeyFiFo->Tail;
@@ -847,7 +834,7 @@ EfiKeyFiFoForNotifyInsertOneKey (
CopyMem (&EfiKeyFiFo->Data[Tail], Input, sizeof (EFI_INPUT_KEY));
- EfiKeyFiFo->Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
+ EfiKeyFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -864,11 +851,11 @@ EfiKeyFiFoForNotifyInsertOneKey (
**/
BOOLEAN
EfiKeyFiFoForNotifyRemoveOneKey (
- EFI_KEY_FIFO *EfiKeyFiFo,
- EFI_INPUT_KEY *Output
+ EFI_KEY_FIFO *EfiKeyFiFo,
+ EFI_INPUT_KEY *Output
)
{
- UINT8 Head;
+ UINT8 Head;
Head = EfiKeyFiFo->Head;
ASSERT (Head < FIFO_MAX_NUMBER + 1);
@@ -884,7 +871,7 @@ EfiKeyFiFoForNotifyRemoveOneKey (
CopyMem (Output, &EfiKeyFiFo->Data[Head], sizeof (EFI_INPUT_KEY));
- EfiKeyFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));
+ EfiKeyFiFo->Head = (UINT8)((Head + 1) % (FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -900,7 +887,7 @@ EfiKeyFiFoForNotifyRemoveOneKey (
**/
BOOLEAN
IsEfiKeyFiFoForNotifyEmpty (
- EFI_KEY_FIFO *EfiKeyFiFo
+ EFI_KEY_FIFO *EfiKeyFiFo
)
{
if (EfiKeyFiFo->Head == EfiKeyFiFo->Tail) {
@@ -921,11 +908,11 @@ IsEfiKeyFiFoForNotifyEmpty (
**/
BOOLEAN
IsEfiKeyFiFoForNotifyFull (
- EFI_KEY_FIFO *EfiKeyFiFo
+ EFI_KEY_FIFO *EfiKeyFiFo
)
{
- UINT8 Tail;
- UINT8 Head;
+ UINT8 Tail;
+ UINT8 Head;
Tail = EfiKeyFiFo->Tail;
Head = EfiKeyFiFo->Head;
@@ -950,15 +937,15 @@ IsEfiKeyFiFoForNotifyFull (
**/
BOOLEAN
EfiKeyFiFoInsertOneKey (
- TERMINAL_DEV *TerminalDevice,
- EFI_INPUT_KEY *Key
+ TERMINAL_DEV *TerminalDevice,
+ EFI_INPUT_KEY *Key
)
{
- UINT8 Tail;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_KEY_DATA KeyData;
+ UINT8 Tail;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_KEY_DATA KeyData;
Tail = TerminalDevice->EfiKeyFiFo->Tail;
@@ -970,7 +957,7 @@ EfiKeyFiFoInsertOneKey (
// Signal KeyNotify process event if this key pressed matches any key registered.
//
NotifyList = &TerminalDevice->NotifyList;
- for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList,Link); Link = GetNextNode (NotifyList,Link)) {
+ for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
@@ -988,6 +975,7 @@ EfiKeyFiFoInsertOneKey (
break;
}
}
+
if (IsEfiKeyFiFoFull (TerminalDevice)) {
//
// Efi Key FIFO is full
@@ -997,7 +985,7 @@ EfiKeyFiFoInsertOneKey (
CopyMem (&TerminalDevice->EfiKeyFiFo->Data[Tail], Key, sizeof (EFI_INPUT_KEY));
- TerminalDevice->EfiKeyFiFo->Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
+ TerminalDevice->EfiKeyFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -1014,11 +1002,11 @@ EfiKeyFiFoInsertOneKey (
**/
BOOLEAN
EfiKeyFiFoRemoveOneKey (
- TERMINAL_DEV *TerminalDevice,
- EFI_INPUT_KEY *Output
+ TERMINAL_DEV *TerminalDevice,
+ EFI_INPUT_KEY *Output
)
{
- UINT8 Head;
+ UINT8 Head;
Head = TerminalDevice->EfiKeyFiFo->Head;
ASSERT (Head < FIFO_MAX_NUMBER + 1);
@@ -1034,7 +1022,7 @@ EfiKeyFiFoRemoveOneKey (
CopyMem (Output, &TerminalDevice->EfiKeyFiFo->Data[Head], sizeof (EFI_INPUT_KEY));
- TerminalDevice->EfiKeyFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));
+ TerminalDevice->EfiKeyFiFo->Head = (UINT8)((Head + 1) % (FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -1074,14 +1062,13 @@ IsEfiKeyFiFoFull (
TERMINAL_DEV *TerminalDevice
)
{
- UINT8 Tail;
- UINT8 Head;
+ UINT8 Tail;
+ UINT8 Head;
- Tail = TerminalDevice->EfiKeyFiFo->Tail;
- Head = TerminalDevice->EfiKeyFiFo->Head;
+ Tail = TerminalDevice->EfiKeyFiFo->Tail;
+ Head = TerminalDevice->EfiKeyFiFo->Head;
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
-
return TRUE;
}
@@ -1101,16 +1088,15 @@ IsEfiKeyFiFoFull (
**/
BOOLEAN
UnicodeFiFoInsertOneKey (
- TERMINAL_DEV *TerminalDevice,
- UINT16 Input
+ TERMINAL_DEV *TerminalDevice,
+ UINT16 Input
)
{
- UINT8 Tail;
+ UINT8 Tail;
Tail = TerminalDevice->UnicodeFiFo->Tail;
ASSERT (Tail < FIFO_MAX_NUMBER + 1);
-
if (IsUnicodeFiFoFull (TerminalDevice)) {
//
// Unicode FIFO is full
@@ -1118,9 +1104,9 @@ UnicodeFiFoInsertOneKey (
return FALSE;
}
- TerminalDevice->UnicodeFiFo->Data[Tail] = Input;
+ TerminalDevice->UnicodeFiFo->Data[Tail] = Input;
- TerminalDevice->UnicodeFiFo->Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
+ TerminalDevice->UnicodeFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1));
return TRUE;
}
@@ -1140,14 +1126,14 @@ UnicodeFiFoRemoveOneKey (
UINT16 *Output
)
{
- UINT8 Head;
+ UINT8 Head;
Head = TerminalDevice->UnicodeFiFo->Head;
ASSERT (Head < FIFO_MAX_NUMBER + 1);
*Output = TerminalDevice->UnicodeFiFo->Data[Head];
- TerminalDevice->UnicodeFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));
+ TerminalDevice->UnicodeFiFo->Head = (UINT8)((Head + 1) % (FIFO_MAX_NUMBER + 1));
}
/**
@@ -1185,21 +1171,19 @@ IsUnicodeFiFoFull (
TERMINAL_DEV *TerminalDevice
)
{
- UINT8 Tail;
- UINT8 Head;
+ UINT8 Tail;
+ UINT8 Head;
- Tail = TerminalDevice->UnicodeFiFo->Tail;
- Head = TerminalDevice->UnicodeFiFo->Head;
+ Tail = TerminalDevice->UnicodeFiFo->Tail;
+ Head = TerminalDevice->UnicodeFiFo->Head;
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
-
return TRUE;
}
return FALSE;
}
-
/**
Update the Unicode characters from a terminal input device into EFI Keys FIFO.
@@ -1208,11 +1192,11 @@ IsUnicodeFiFoFull (
**/
VOID
UnicodeToEfiKeyFlushState (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
)
{
- EFI_INPUT_KEY Key;
- UINT32 InputState;
+ EFI_INPUT_KEY Key;
+ UINT32 InputState;
InputState = TerminalDevice->InputState;
@@ -1254,15 +1238,14 @@ UnicodeToEfiKeyFlushState (
// Cancel the timer.
//
gBS->SetTimer (
- TerminalDevice->TwoSecondTimeOut,
- TimerCancel,
- 0
- );
+ TerminalDevice->TwoSecondTimeOut,
+ TimerCancel,
+ 0
+ );
TerminalDevice->InputState = INPUT_STATE_DEFAULT;
}
-
/**
Converts a stream of Unicode characters from a terminal input device into EFI Keys that
can be read through the Simple Input Protocol.
@@ -1353,14 +1336,14 @@ Putty function key map:
**/
VOID
UnicodeToEfiKey (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
)
{
- EFI_STATUS Status;
- EFI_STATUS TimerStatus;
- UINT16 UnicodeChar;
- EFI_INPUT_KEY Key;
- BOOLEAN SetDefaultResetState;
+ EFI_STATUS Status;
+ EFI_STATUS TimerStatus;
+ UINT16 UnicodeChar;
+ EFI_INPUT_KEY Key;
+ BOOLEAN SetDefaultResetState;
TimerStatus = gBS->CheckEvent (TerminalDevice->TwoSecondTimeOut);
@@ -1370,7 +1353,6 @@ UnicodeToEfiKey (
}
while (!IsUnicodeFiFoEmpty (TerminalDevice) && !IsEfiKeyFiFoFull (TerminalDevice)) {
-
if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {
//
// Check to see if the 2 seconds timer has expired
@@ -1390,666 +1372,714 @@ UnicodeToEfiKey (
SetDefaultResetState = TRUE;
switch (TerminalDevice->InputState) {
- case INPUT_STATE_DEFAULT:
+ case INPUT_STATE_DEFAULT:
- break;
+ break;
- case INPUT_STATE_ESC:
+ case INPUT_STATE_ESC:
- if (UnicodeChar == LEFTOPENBRACKET) {
- TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET;
- TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- continue;
- }
+ if (UnicodeChar == LEFTOPENBRACKET) {
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET;
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+ continue;
+ }
- if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
- TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt100Plus)) {
- TerminalDevice->InputState |= INPUT_STATE_O;
- TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- continue;
- }
+ if ((UnicodeChar == 'O') && ((TerminalDevice->TerminalType == TerminalTypeVt100) ||
+ (TerminalDevice->TerminalType == TerminalTypeTtyTerm) ||
+ (TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt100Plus)))
+ {
+ TerminalDevice->InputState |= INPUT_STATE_O;
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+ continue;
+ }
- Key.ScanCode = SCAN_NULL;
+ Key.ScanCode = SCAN_NULL;
+
+ if ((TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
+ (TerminalDevice->TerminalType == TerminalTypeVtUtf8))
+ {
+ switch (UnicodeChar) {
+ case '1':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case '2':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case '3':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case '4':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case '5':
+ Key.ScanCode = SCAN_F5;
+ break;
+ case '6':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case '7':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case '8':
+ Key.ScanCode = SCAN_F8;
+ break;
+ case '9':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case '0':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case '!':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '@':
+ Key.ScanCode = SCAN_F12;
+ break;
+ case 'h':
+ Key.ScanCode = SCAN_HOME;
+ break;
+ case 'k':
+ Key.ScanCode = SCAN_END;
+ break;
+ case '+':
+ Key.ScanCode = SCAN_INSERT;
+ break;
+ case '-':
+ Key.ScanCode = SCAN_DELETE;
+ break;
+ case '/':
+ Key.ScanCode = SCAN_PAGE_DOWN;
+ break;
+ case '?':
+ Key.ScanCode = SCAN_PAGE_UP;
+ break;
+ default:
+ break;
+ }
+ }
- if (TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
- TerminalDevice->TerminalType == TerminalTypeVtUtf8) {
switch (UnicodeChar) {
- case '1':
- Key.ScanCode = SCAN_F1;
- break;
- case '2':
- Key.ScanCode = SCAN_F2;
- break;
- case '3':
- Key.ScanCode = SCAN_F3;
- break;
- case '4':
- Key.ScanCode = SCAN_F4;
- break;
- case '5':
- Key.ScanCode = SCAN_F5;
- break;
- case '6':
- Key.ScanCode = SCAN_F6;
- break;
- case '7':
- Key.ScanCode = SCAN_F7;
- break;
- case '8':
- Key.ScanCode = SCAN_F8;
- break;
- case '9':
- Key.ScanCode = SCAN_F9;
- break;
- case '0':
- Key.ScanCode = SCAN_F10;
- break;
- case '!':
- Key.ScanCode = SCAN_F11;
- break;
- case '@':
- Key.ScanCode = SCAN_F12;
- break;
- case 'h':
- Key.ScanCode = SCAN_HOME;
- break;
- case 'k':
- Key.ScanCode = SCAN_END;
- break;
- case '+':
- Key.ScanCode = SCAN_INSERT;
- break;
- case '-':
- Key.ScanCode = SCAN_DELETE;
- break;
- case '/':
- Key.ScanCode = SCAN_PAGE_DOWN;
- break;
- case '?':
- Key.ScanCode = SCAN_PAGE_UP;
- break;
- default :
- break;
+ case 'R':
+ if (TerminalDevice->ResetState == RESET_STATE_DEFAULT) {
+ TerminalDevice->ResetState = RESET_STATE_ESC_R;
+ SetDefaultResetState = FALSE;
+ } else if (TerminalDevice->ResetState == RESET_STATE_ESC_R_ESC_R) {
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ }
+
+ Key.ScanCode = SCAN_NULL;
+ break;
+ case 'r':
+ if (TerminalDevice->ResetState == RESET_STATE_ESC_R) {
+ TerminalDevice->ResetState = RESET_STATE_ESC_R_ESC_R;
+ SetDefaultResetState = FALSE;
+ }
+
+ Key.ScanCode = SCAN_NULL;
+ break;
+ default:
+ break;
}
- }
- switch (UnicodeChar) {
- case 'R':
- if (TerminalDevice->ResetState == RESET_STATE_DEFAULT) {
- TerminalDevice->ResetState = RESET_STATE_ESC_R;
- SetDefaultResetState = FALSE;
- } else if (TerminalDevice->ResetState == RESET_STATE_ESC_R_ESC_R) {
- gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ if (SetDefaultResetState) {
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
}
- Key.ScanCode = SCAN_NULL;
- break;
- case 'r':
- if (TerminalDevice->ResetState == RESET_STATE_ESC_R) {
- TerminalDevice->ResetState = RESET_STATE_ESC_R_ESC_R;
- SetDefaultResetState = FALSE;
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
}
- Key.ScanCode = SCAN_NULL;
- break;
- default :
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
break;
- }
- if (SetDefaultResetState) {
+ case INPUT_STATE_ESC | INPUT_STATE_O:
+
TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- }
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
- UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
+ Key.ScanCode = SCAN_NULL;
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ if (TerminalDevice->TerminalType == TerminalTypeVt100) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'w':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'x':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 't':
+ Key.ScanCode = SCAN_F5;
+ break;
+ case 'u':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case 'q':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case 'r':
+ Key.ScanCode = SCAN_F8;
+ break;
+ case 'p':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case 'M':
+ Key.ScanCode = SCAN_F10;
+ break;
+ default:
+ break;
+ }
+ } else if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
+ /* Also accept VT100 escape codes for F1-F4, HOME and END for TTY term */
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'H':
+ Key.ScanCode = SCAN_HOME;
+ break;
+ case 'F':
+ Key.ScanCode = SCAN_END;
+ break;
+ }
+ } else if (TerminalDevice->TerminalType == TerminalTypeVt100Plus) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'T':
+ Key.ScanCode = SCAN_F5;
+ break;
+ case 'U':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case 'V':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case 'W':
+ Key.ScanCode = SCAN_F8;
+ break;
+ case 'X':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case 'Y':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case 'Z':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '[':
+ Key.ScanCode = SCAN_F12;
+ break;
+ }
+ } else if (TerminalDevice->TerminalType == TerminalTypeXtermR6) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ }
+ }
- break;
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
- case INPUT_STATE_ESC | INPUT_STATE_O:
+ UnicodeToEfiKeyFlushState (TerminalDevice);
- TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+ break;
- Key.ScanCode = SCAN_NULL;
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:
- if (TerminalDevice->TerminalType == TerminalTypeVt100) {
- switch (UnicodeChar) {
- case 'P':
- Key.ScanCode = SCAN_F1;
- break;
- case 'Q':
- Key.ScanCode = SCAN_F2;
- break;
- case 'w':
- Key.ScanCode = SCAN_F3;
- break;
- case 'x':
- Key.ScanCode = SCAN_F4;
- break;
- case 't':
- Key.ScanCode = SCAN_F5;
- break;
- case 'u':
- Key.ScanCode = SCAN_F6;
- break;
- case 'q':
- Key.ScanCode = SCAN_F7;
- break;
- case 'r':
- Key.ScanCode = SCAN_F8;
- break;
- case 'p':
- Key.ScanCode = SCAN_F9;
- break;
- case 'M':
- Key.ScanCode = SCAN_F10;
- break;
- default :
- break;
- }
- } else if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
- /* Also accept VT100 escape codes for F1-F4, HOME and END for TTY term */
- switch (UnicodeChar) {
- case 'P':
- Key.ScanCode = SCAN_F1;
- break;
- case 'Q':
- Key.ScanCode = SCAN_F2;
- break;
- case 'R':
- Key.ScanCode = SCAN_F3;
- break;
- case 'S':
- Key.ScanCode = SCAN_F4;
- break;
- case 'H':
- Key.ScanCode = SCAN_HOME;
- break;
- case 'F':
- Key.ScanCode = SCAN_END;
- break;
+ if ((UnicodeChar == '1') && ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt400) ||
+ (TerminalDevice->TerminalType == TerminalTypeLinux)))
+ {
+ TerminalDevice->InputState |= INPUT_STATE_1;
+ continue;
}
- } else if (TerminalDevice->TerminalType == TerminalTypeVt100Plus) {
- switch (UnicodeChar) {
- case 'P':
- Key.ScanCode = SCAN_F1;
- break;
- case 'Q':
- Key.ScanCode = SCAN_F2;
- break;
- case 'R':
- Key.ScanCode = SCAN_F3;
- break;
- case 'S':
- Key.ScanCode = SCAN_F4;
- break;
- case 'T':
- Key.ScanCode = SCAN_F5;
- break;
- case 'U':
- Key.ScanCode = SCAN_F6;
- break;
- case 'V':
- Key.ScanCode = SCAN_F7;
- break;
- case 'W':
- Key.ScanCode = SCAN_F8;
- break;
- case 'X':
- Key.ScanCode = SCAN_F9;
- break;
- case 'Y':
- Key.ScanCode = SCAN_F10;
- break;
- case 'Z':
- Key.ScanCode = SCAN_F11;
- break;
- case '[':
- Key.ScanCode = SCAN_F12;
- break;
+
+ if ((UnicodeChar == '2') && ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt400) ||
+ (TerminalDevice->TerminalType == TerminalTypeLinux)))
+ {
+ TerminalDevice->InputState |= INPUT_STATE_2;
+ continue;
}
- } else if (TerminalDevice->TerminalType == TerminalTypeXtermR6) {
- switch (UnicodeChar) {
- case 'P':
- Key.ScanCode = SCAN_F1;
- break;
- case 'Q':
- Key.ScanCode = SCAN_F2;
- break;
- case 'R':
- Key.ScanCode = SCAN_F3;
- break;
- case 'S':
- Key.ScanCode = SCAN_F4;
- break;
+
+ if ((UnicodeChar == LEFTOPENBRACKET) && (TerminalDevice->TerminalType == TerminalTypeLinux)) {
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2ND;
+ continue;
}
- }
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
- UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ Key.ScanCode = SCAN_NULL;
- break;
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt100) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
+ (TerminalDevice->TerminalType == TerminalTypeVtUtf8) ||
+ (TerminalDevice->TerminalType == TerminalTypeTtyTerm) ||
+ (TerminalDevice->TerminalType == TerminalTypeLinux) ||
+ (TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt400) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ switch (UnicodeChar) {
+ case 'A':
+ Key.ScanCode = SCAN_UP;
+ break;
+ case 'B':
+ Key.ScanCode = SCAN_DOWN;
+ break;
+ case 'C':
+ Key.ScanCode = SCAN_RIGHT;
+ break;
+ case 'D':
+ Key.ScanCode = SCAN_LEFT;
+ break;
+ case 'H':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt100) ||
+ (TerminalDevice->TerminalType == TerminalTypeTtyTerm))
+ {
+ Key.ScanCode = SCAN_HOME;
+ }
- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:
+ break;
+ case 'F':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeTtyTerm))
+ {
+ Key.ScanCode = SCAN_END;
+ }
- if (UnicodeChar == '1' && (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt400 ||
- TerminalDevice->TerminalType == TerminalTypeLinux)) {
- TerminalDevice->InputState |= INPUT_STATE_1;
- continue;
- }
+ break;
+ case 'K':
+ if (TerminalDevice->TerminalType == TerminalTypeVt100) {
+ Key.ScanCode = SCAN_END;
+ }
- if (UnicodeChar == '2' && (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt400 ||
- TerminalDevice->TerminalType == TerminalTypeLinux)) {
- TerminalDevice->InputState |= INPUT_STATE_2;
- continue;
- }
+ break;
+ case 'L':
+ case '@':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt100))
+ {
+ Key.ScanCode = SCAN_INSERT;
+ }
- if (UnicodeChar == LEFTOPENBRACKET && TerminalDevice->TerminalType == TerminalTypeLinux) {
- TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2ND;
- continue;
- }
+ break;
+ case 'X':
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ Key.ScanCode = SCAN_DELETE;
+ } else if (TerminalDevice->TerminalType == TerminalTypeSCO) {
+ Key.ScanCode = SCAN_F12;
+ }
- TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+ break;
+ case 'P':
+ if (TerminalDevice->TerminalType == TerminalTypeVt100) {
+ Key.ScanCode = SCAN_DELETE;
+ } else if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F4;
+ }
- Key.ScanCode = SCAN_NULL;
-
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
- TerminalDevice->TerminalType == TerminalTypeVtUtf8 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
- TerminalDevice->TerminalType == TerminalTypeLinux ||
- TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt400 ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- switch (UnicodeChar) {
- case 'A':
- Key.ScanCode = SCAN_UP;
- break;
- case 'B':
- Key.ScanCode = SCAN_DOWN;
- break;
- case 'C':
- Key.ScanCode = SCAN_RIGHT;
- break;
- case 'D':
- Key.ScanCode = SCAN_LEFT;
- break;
- case 'H':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
- Key.ScanCode = SCAN_HOME;
- }
- break;
- case 'F':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
- Key.ScanCode = SCAN_END;
- }
- break;
- case 'K':
- if (TerminalDevice->TerminalType == TerminalTypeVt100) {
- Key.ScanCode = SCAN_END;
- }
- break;
- case 'L':
- case '@':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeVt100) {
- Key.ScanCode = SCAN_INSERT;
- }
- break;
- case 'X':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
- Key.ScanCode = SCAN_DELETE;
- } else if (TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F12;
- }
- break;
- case 'P':
- if (TerminalDevice->TerminalType == TerminalTypeVt100) {
- Key.ScanCode = SCAN_DELETE;
- } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F4;
- }
- break;
- case 'I':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
- Key.ScanCode = SCAN_PAGE_UP;
- }
- break;
- case 'V':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F10;
- }
- break;
- case '?':
- if (TerminalDevice->TerminalType == TerminalTypeVt100) {
- Key.ScanCode = SCAN_PAGE_UP;
- }
- break;
- case 'G':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
- Key.ScanCode = SCAN_PAGE_DOWN;
- }
- break;
- case 'U':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F9;
- }
- break;
- case '/':
- if (TerminalDevice->TerminalType == TerminalTypeVt100) {
- Key.ScanCode = SCAN_PAGE_DOWN;
- }
- break;
- case 'M':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F1;
- }
- break;
- case 'N':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F2;
- }
- break;
- case 'O':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F3;
- }
- break;
- case 'Q':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F5;
- }
- break;
- case 'R':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F6;
- }
- break;
- case 'S':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F7;
- }
- break;
- case 'T':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
- TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F8;
- }
- break;
- case 'W':
- if (TerminalDevice->TerminalType == TerminalTypeSCO) {
- Key.ScanCode = SCAN_F11;
- }
- break;
- default :
- break;
- }
- }
+ break;
+ case 'I':
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ Key.ScanCode = SCAN_PAGE_UP;
+ }
- /*
- * The VT220 escape codes that the TTY terminal accepts all have
- * numeric codes, and there are no ambiguous prefixes shared with
- * other terminal types.
- */
- if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
- Key.ScanCode == SCAN_NULL &&
- UnicodeChar >= '0' &&
- UnicodeChar <= '9') {
- TerminalDevice->TtyEscapeStr[0] = UnicodeChar;
- TerminalDevice->TtyEscapeIndex = 1;
- TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_TTY;
- continue;
- }
+ break;
+ case 'V':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F10;
+ }
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
- UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
+ break;
+ case '?':
+ if (TerminalDevice->TerminalType == TerminalTypeVt100) {
+ Key.ScanCode = SCAN_PAGE_UP;
+ }
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ break;
+ case 'G':
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ Key.ScanCode = SCAN_PAGE_DOWN;
+ }
- break;
+ break;
+ case 'U':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F9;
+ }
- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_1:
+ break;
+ case '/':
+ if (TerminalDevice->TerminalType == TerminalTypeVt100) {
+ Key.ScanCode = SCAN_PAGE_DOWN;
+ }
- TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+ break;
+ case 'M':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F1;
+ }
- Key.ScanCode = SCAN_NULL;
+ break;
+ case 'N':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F2;
+ }
- if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt400 ||
- TerminalDevice->TerminalType == TerminalTypeLinux) {
- switch (UnicodeChar) {
- case '1':
- if (TerminalDevice->TerminalType == TerminalTypeVt400) {
- Key.ScanCode = SCAN_F1;
- }
- break;
- case '2':
- if (TerminalDevice->TerminalType == TerminalTypeVt400) {
- Key.ScanCode = SCAN_F2;
- }
- break;
- case '3':
- if (TerminalDevice->TerminalType == TerminalTypeVt400) {
- Key.ScanCode = SCAN_F3;
- }
- break;
- case '4':
- if (TerminalDevice->TerminalType == TerminalTypeVt400) {
- Key.ScanCode = SCAN_F4;
- }
- break;
- case '5':
- if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt400) {
- Key.ScanCode = SCAN_F5;
+ break;
+ case 'O':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F3;
+ }
+
+ break;
+ case 'Q':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F5;
+ }
+
+ break;
+ case 'R':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F6;
+ }
+
+ break;
+ case 'S':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F7;
+ }
+
+ break;
+ case 'T':
+ if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
+ (TerminalDevice->TerminalType == TerminalTypeSCO))
+ {
+ Key.ScanCode = SCAN_F8;
+ }
+
+ break;
+ case 'W':
+ if (TerminalDevice->TerminalType == TerminalTypeSCO) {
+ Key.ScanCode = SCAN_F11;
+ }
+
+ break;
+ default:
+ break;
}
- break;
- case '7':
- Key.ScanCode = SCAN_F6;
- break;
- case '8':
- Key.ScanCode = SCAN_F7;
- break;
- case '9':
- Key.ScanCode = SCAN_F8;
- break;
}
- }
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ /*
+ * The VT220 escape codes that the TTY terminal accepts all have
+ * numeric codes, and there are no ambiguous prefixes shared with
+ * other terminal types.
+ */
+ if ((TerminalDevice->TerminalType == TerminalTypeTtyTerm) &&
+ (Key.ScanCode == SCAN_NULL) &&
+ (UnicodeChar >= '0') &&
+ (UnicodeChar <= '9'))
+ {
+ TerminalDevice->TtyEscapeStr[0] = UnicodeChar;
+ TerminalDevice->TtyEscapeIndex = 1;
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_TTY;
+ continue;
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ break;
- break;
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_1:
- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_2:
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
- Key.ScanCode = SCAN_NULL;
- if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
- TerminalDevice->TerminalType == TerminalTypeVt400 ||
- TerminalDevice->TerminalType == TerminalTypeLinux) {
- switch (UnicodeChar) {
- case '0':
- Key.ScanCode = SCAN_F9;
- break;
- case '1':
- Key.ScanCode = SCAN_F10;
- break;
- case '3':
- Key.ScanCode = SCAN_F11;
- break;
- case '4':
- Key.ScanCode = SCAN_F12;
- break;
- }
- }
+ Key.ScanCode = SCAN_NULL;
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
- UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
+ if ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt400) ||
+ (TerminalDevice->TerminalType == TerminalTypeLinux))
+ {
+ switch (UnicodeChar) {
+ case '1':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F1;
+ }
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ break;
+ case '2':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F2;
+ }
- break;
+ break;
+ case '3':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F3;
+ }
- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2ND:
+ break;
+ case '4':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F4;
+ }
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
- Key.ScanCode = SCAN_NULL;
+ break;
+ case '5':
+ if ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt400))
+ {
+ Key.ScanCode = SCAN_F5;
+ }
- if (TerminalDevice->TerminalType == TerminalTypeLinux) {
- switch (UnicodeChar) {
- case 'A':
- Key.ScanCode = SCAN_F1;
- break;
- case 'B':
- Key.ScanCode = SCAN_F2;
- break;
- case 'C':
- Key.ScanCode = SCAN_F3;
- break;
- case 'D':
- Key.ScanCode = SCAN_F4;
- break;
- case 'E':
- Key.ScanCode = SCAN_F5;
- break;
+ break;
+ case '7':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case '8':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case '9':
+ Key.ScanCode = SCAN_F8;
+ break;
+ }
}
- }
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;
+
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_2:
+
TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ Key.ScanCode = SCAN_NULL;
+ if ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
+ (TerminalDevice->TerminalType == TerminalTypeVt400) ||
+ (TerminalDevice->TerminalType == TerminalTypeLinux))
+ {
+ switch (UnicodeChar) {
+ case '0':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case '1':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case '3':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '4':
+ Key.ScanCode = SCAN_F12;
+ break;
+ }
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ break;
- break;
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2ND:
- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_TTY:
- /*
- * Here we handle the VT220 escape codes that we accept. This
- * state is only used by the TTY terminal type.
- */
- Key.ScanCode = SCAN_NULL;
- if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ Key.ScanCode = SCAN_NULL;
- if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) {
- UINT16 EscCode;
- TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] = 0; /* Terminate string */
- EscCode = (UINT16) StrDecimalToUintn(TerminalDevice->TtyEscapeStr);
- switch (EscCode) {
- case 2:
- Key.ScanCode = SCAN_INSERT;
+ if (TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case 'A':
+ Key.ScanCode = SCAN_F1;
break;
- case 3:
- Key.ScanCode = SCAN_DELETE;
+ case 'B':
+ Key.ScanCode = SCAN_F2;
break;
- case 5:
- Key.ScanCode = SCAN_PAGE_UP;
+ case 'C':
+ Key.ScanCode = SCAN_F3;
break;
- case 6:
- Key.ScanCode = SCAN_PAGE_DOWN;
+ case 'D':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'E':
+ Key.ScanCode = SCAN_F5;
break;
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- Key.ScanCode = SCAN_F1 + EscCode - 11;
- break;
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- Key.ScanCode = SCAN_F6 + EscCode - 17;
- break;
- case 23:
- case 24:
- Key.ScanCode = SCAN_F11 + EscCode - 23;
- break;
- default:
- break;
}
- } else if (TerminalDevice->TtyEscapeIndex == 1){
- /* 2 character escape code */
- TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex++] = UnicodeChar;
- continue;
}
- else {
- DEBUG ((DEBUG_ERROR, "Unexpected state in escape2\n"));
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
}
- }
- TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- if (Key.ScanCode != SCAN_NULL) {
- Key.UnicodeChar = 0;
- EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
- TerminalDevice->InputState = INPUT_STATE_DEFAULT;
UnicodeToEfiKeyFlushState (TerminalDevice);
- continue;
- }
- UnicodeToEfiKeyFlushState (TerminalDevice);
- break;
+ break;
- default:
- //
- // Invalid state. This should never happen.
- //
- ASSERT (FALSE);
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_TTY:
+ /*
+ * Here we handle the VT220 escape codes that we accept. This
+ * state is only used by the TTY terminal type.
+ */
+ Key.ScanCode = SCAN_NULL;
+ if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
+ if ((UnicodeChar == '~') && (TerminalDevice->TtyEscapeIndex <= 2)) {
+ UINT16 EscCode;
+ TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] = 0; /* Terminate string */
+ EscCode = (UINT16)StrDecimalToUintn (TerminalDevice->TtyEscapeStr);
+ switch (EscCode) {
+ case 2:
+ Key.ScanCode = SCAN_INSERT;
+ break;
+ case 3:
+ Key.ScanCode = SCAN_DELETE;
+ break;
+ case 5:
+ Key.ScanCode = SCAN_PAGE_UP;
+ break;
+ case 6:
+ Key.ScanCode = SCAN_PAGE_DOWN;
+ break;
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ Key.ScanCode = SCAN_F1 + EscCode - 11;
+ break;
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ Key.ScanCode = SCAN_F6 + EscCode - 17;
+ break;
+ case 23:
+ case 24:
+ Key.ScanCode = SCAN_F11 + EscCode - 23;
+ break;
+ default:
+ break;
+ }
+ } else if (TerminalDevice->TtyEscapeIndex == 1) {
+ /* 2 character escape code */
+ TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex++] = UnicodeChar;
+ continue;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Unexpected state in escape2\n"));
+ }
+ }
- UnicodeToEfiKeyFlushState (TerminalDevice);
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
- break;
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ break;
+
+ default:
+ //
+ // Invalid state. This should never happen.
+ //
+ ASSERT (FALSE);
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;
}
if (UnicodeChar == ESC) {
@@ -2061,7 +2091,7 @@ UnicodeToEfiKey (
}
if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {
- Status = gBS->SetTimer(
+ Status = gBS->SetTimer (
TerminalDevice->TwoSecondTimeOut,
TimerRelative,
(UINT64)20000000
@@ -2078,8 +2108,7 @@ UnicodeToEfiKey (
if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = CHAR_BACKSPACE;
- }
- else {
+ } else {
Key.ScanCode = SCAN_DELETE;
Key.UnicodeChar = 0;
}
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index 4959677..7809869 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -16,69 +16,69 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
//
UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {
- { BOXDRAW_HORIZONTAL, 0xc4, L'-' },
- { BOXDRAW_VERTICAL, 0xb3, L'|' },
- { BOXDRAW_DOWN_RIGHT, 0xda, L'/' },
+ { BOXDRAW_HORIZONTAL, 0xc4, L'-' },
+ { BOXDRAW_VERTICAL, 0xb3, L'|' },
+ { BOXDRAW_DOWN_RIGHT, 0xda, L'/' },
{ BOXDRAW_DOWN_LEFT, 0xbf, L'\\' },
{ BOXDRAW_UP_RIGHT, 0xc0, L'\\' },
- { BOXDRAW_UP_LEFT, 0xd9, L'/' },
- { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|' },
- { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|' },
- { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+' },
- { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+' },
- { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+' },
- { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-' },
- { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|' },
- { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/' },
- { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/' },
- { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/' },
+ { BOXDRAW_UP_LEFT, 0xd9, L'/' },
+ { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|' },
+ { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|' },
+ { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+' },
+ { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+' },
+ { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+' },
+ { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-' },
+ { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|' },
+ { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/' },
+ { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/' },
+ { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/' },
{ BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\' },
{ BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\' },
{ BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\' },
{ BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\' },
{ BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\' },
{ BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\' },
- { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/' },
- { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/' },
- { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/' },
- { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|' },
- { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|' },
- { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|' },
- { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|' },
- { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|' },
- { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|' },
- { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+' },
- { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+' },
- { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+' },
- { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+' },
- { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+' },
- { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+' },
- { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },
- { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },
- { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },
-
- { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*' },
- { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+' },
-
- { GEOMETRICSHAPE_UP_TRIANGLE, '^', L'^' },
- { GEOMETRICSHAPE_RIGHT_TRIANGLE, '>', L'>' },
- { GEOMETRICSHAPE_DOWN_TRIANGLE, 'v', L'v' },
- { GEOMETRICSHAPE_LEFT_TRIANGLE, '<', L'<' },
-
- { ARROW_LEFT, '<', L'<' },
- { ARROW_UP, '^', L'^' },
- { ARROW_RIGHT, '>', L'>' },
- { ARROW_DOWN, 'v', L'v' },
+ { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/' },
+ { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/' },
+ { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/' },
+ { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|' },
+ { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|' },
+ { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|' },
+ { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|' },
+ { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|' },
+ { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|' },
+ { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+' },
+ { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+' },
+ { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+' },
+ { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+' },
+ { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+' },
+ { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+' },
+ { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },
+ { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },
+ { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },
+
+ { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*' },
+ { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+' },
+
+ { GEOMETRICSHAPE_UP_TRIANGLE, '^', L'^' },
+ { GEOMETRICSHAPE_RIGHT_TRIANGLE, '>', L'>' },
+ { GEOMETRICSHAPE_DOWN_TRIANGLE, 'v', L'v' },
+ { GEOMETRICSHAPE_LEFT_TRIANGLE, '<', L'<' },
+
+ { ARROW_LEFT, '<', L'<' },
+ { ARROW_UP, '^', L'^' },
+ { ARROW_RIGHT, '>', L'>' },
+ { ARROW_DOWN, 'v', L'v' },
{ 0x0000, 0x00, L'\0' }
};
-CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };
-CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
-CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };
-CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };
-CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 };
-CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 };
+CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };
+CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
+CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };
+CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };
+CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 };
+CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 };
//
// Body of the ConOut functions
@@ -147,7 +147,6 @@ TerminalConOutReset (
return Status;
}
-
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
@@ -172,26 +171,26 @@ TerminalConOutOutputString (
IN CHAR16 *WString
)
{
- TERMINAL_DEV *TerminalDevice;
- EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
- UINTN MaxColumn;
- UINTN MaxRow;
- UINTN Length;
- UTF8_CHAR Utf8Char;
- CHAR8 GraphicChar;
- CHAR8 AsciiChar;
- EFI_STATUS Status;
- UINT8 ValidBytes;
- CHAR8 CrLfStr[2];
+ TERMINAL_DEV *TerminalDevice;
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
+ UINTN MaxColumn;
+ UINTN MaxRow;
+ UINTN Length;
+ UTF8_CHAR Utf8Char;
+ CHAR8 GraphicChar;
+ CHAR8 AsciiChar;
+ EFI_STATUS Status;
+ UINT8 ValidBytes;
+ CHAR8 CrLfStr[2];
//
// flag used to indicate whether condition happens which will cause
// return EFI_WARN_UNKNOWN_GLYPH
//
- BOOLEAN Warning;
+ BOOLEAN Warning;
- ValidBytes = 0;
- Warning = FALSE;
- AsciiChar = 0;
+ ValidBytes = 0;
+ Warning = FALSE;
+ AsciiChar = 0;
//
// get Terminal device data structure pointer.
@@ -214,137 +213,134 @@ TerminalConOutOutputString (
&MaxRow
);
- for (; *WString != CHAR_NULL; WString++) {
-
+ for ( ; *WString != CHAR_NULL; WString++) {
switch (TerminalDevice->TerminalType) {
-
- case TerminalTypePcAnsi:
- case TerminalTypeVt100:
- case TerminalTypeVt100Plus:
- case TerminalTypeTtyTerm:
- case TerminalTypeLinux:
- case TerminalTypeXtermR6:
- case TerminalTypeVt400:
- case TerminalTypeSCO:
-
- if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
- //
- // If it's not a graphic character convert Unicode to ASCII.
- //
- GraphicChar = (CHAR8) *WString;
-
- if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar (GraphicChar))) {
+ case TerminalTypePcAnsi:
+ case TerminalTypeVt100:
+ case TerminalTypeVt100Plus:
+ case TerminalTypeTtyTerm:
+ case TerminalTypeLinux:
+ case TerminalTypeXtermR6:
+ case TerminalTypeVt400:
+ case TerminalTypeSCO:
+
+ if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
//
- // when this driver use the OutputString to output control string,
- // TerminalDevice->OutputEscChar is set to let the Esc char
- // to be output to the terminal emulation software.
+ // If it's not a graphic character convert Unicode to ASCII.
//
- if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
- GraphicChar = 27;
- } else {
- GraphicChar = '?';
- Warning = TRUE;
+ GraphicChar = (CHAR8)*WString;
+
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntlChar (GraphicChar))) {
+ //
+ // when this driver use the OutputString to output control string,
+ // TerminalDevice->OutputEscChar is set to let the Esc char
+ // to be output to the terminal emulation software.
+ //
+ if ((GraphicChar == 27) && TerminalDevice->OutputEscChar) {
+ GraphicChar = 27;
+ } else {
+ GraphicChar = '?';
+ Warning = TRUE;
+ }
}
- }
-
- AsciiChar = GraphicChar;
- }
+ AsciiChar = GraphicChar;
+ }
- if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
- GraphicChar = AsciiChar;
- }
+ if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
+ GraphicChar = AsciiChar;
+ }
- Length = 1;
+ Length = 1;
- Status = TerminalDevice->SerialIo->Write (
- TerminalDevice->SerialIo,
- &Length,
- &GraphicChar
- );
+ Status = TerminalDevice->SerialIo->Write (
+ TerminalDevice->SerialIo,
+ &Length,
+ &GraphicChar
+ );
- if (EFI_ERROR (Status)) {
- goto OutputError;
- }
+ if (EFI_ERROR (Status)) {
+ goto OutputError;
+ }
- break;
+ break;
+
+ case TerminalTypeVtUtf8:
+ UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
+ Length = ValidBytes;
+ Status = TerminalDevice->SerialIo->Write (
+ TerminalDevice->SerialIo,
+ &Length,
+ (UINT8 *)&Utf8Char
+ );
+ if (EFI_ERROR (Status)) {
+ goto OutputError;
+ }
- case TerminalTypeVtUtf8:
- UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);
- Length = ValidBytes;
- Status = TerminalDevice->SerialIo->Write (
- TerminalDevice->SerialIo,
- &Length,
- (UINT8 *) &Utf8Char
- );
- if (EFI_ERROR (Status)) {
- goto OutputError;
- }
- break;
+ break;
}
+
//
// Update cursor position.
//
switch (*WString) {
+ case CHAR_BACKSPACE:
+ if (Mode->CursorColumn > 0) {
+ Mode->CursorColumn--;
+ }
- case CHAR_BACKSPACE:
- if (Mode->CursorColumn > 0) {
- Mode->CursorColumn--;
- }
- break;
-
- case CHAR_LINEFEED:
- if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
- Mode->CursorRow++;
- }
- break;
-
- case CHAR_CARRIAGE_RETURN:
- Mode->CursorColumn = 0;
- break;
-
- default:
- if (Mode->CursorColumn < (INT32) (MaxColumn - 1)) {
-
- Mode->CursorColumn++;
-
- } else {
+ break;
- Mode->CursorColumn = 0;
- if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
+ case CHAR_LINEFEED:
+ if (Mode->CursorRow < (INT32)(MaxRow - 1)) {
Mode->CursorRow++;
}
- if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
- !TerminalDevice->OutputEscChar) {
- //
- // We've written the last character on the line. The
- // terminal doesn't actually wrap its cursor until we print
- // the next character, but the driver thinks it has wrapped
- // already. Print CR LF to synchronize the terminal with
- // the driver, but only if we're not in the middle of
- // printing an escape sequence.
- //
- CrLfStr[0] = '\r';
- CrLfStr[1] = '\n';
+ break;
- Length = sizeof(CrLfStr);
-
- Status = TerminalDevice->SerialIo->Write (
- TerminalDevice->SerialIo,
- &Length,
- CrLfStr
- );
+ case CHAR_CARRIAGE_RETURN:
+ Mode->CursorColumn = 0;
+ break;
+
+ default:
+ if (Mode->CursorColumn < (INT32)(MaxColumn - 1)) {
+ Mode->CursorColumn++;
+ } else {
+ Mode->CursorColumn = 0;
+ if (Mode->CursorRow < (INT32)(MaxRow - 1)) {
+ Mode->CursorRow++;
+ }
- if (EFI_ERROR (Status)) {
- goto OutputError;
+ if ((TerminalDevice->TerminalType == TerminalTypeTtyTerm) &&
+ !TerminalDevice->OutputEscChar)
+ {
+ //
+ // We've written the last character on the line. The
+ // terminal doesn't actually wrap its cursor until we print
+ // the next character, but the driver thinks it has wrapped
+ // already. Print CR LF to synchronize the terminal with
+ // the driver, but only if we're not in the middle of
+ // printing an escape sequence.
+ //
+ CrLfStr[0] = '\r';
+ CrLfStr[1] = '\n';
+
+ Length = sizeof (CrLfStr);
+
+ Status = TerminalDevice->SerialIo->Write (
+ TerminalDevice->SerialIo,
+ &Length,
+ CrLfStr
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto OutputError;
+ }
}
}
- }
- break;
-
- };
+ break;
+ }
}
if (Warning) {
@@ -363,7 +359,6 @@ OutputError:
return EFI_DEVICE_ERROR;
}
-
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
@@ -395,27 +390,25 @@ TerminalConOutTestString (
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
switch (TerminalDevice->TerminalType) {
+ case TerminalTypePcAnsi:
+ case TerminalTypeVt100:
+ case TerminalTypeVt100Plus:
+ case TerminalTypeTtyTerm:
+ Status = AnsiTestString (TerminalDevice, WString);
+ break;
- case TerminalTypePcAnsi:
- case TerminalTypeVt100:
- case TerminalTypeVt100Plus:
- case TerminalTypeTtyTerm:
- Status = AnsiTestString (TerminalDevice, WString);
- break;
-
- case TerminalTypeVtUtf8:
- Status = VTUTF8TestString (TerminalDevice, WString);
- break;
+ case TerminalTypeVtUtf8:
+ Status = VTUTF8TestString (TerminalDevice, WString);
+ break;
- default:
- Status = EFI_UNSUPPORTED;
- break;
+ default:
+ Status = EFI_UNSUPPORTED;
+ break;
}
return Status;
}
-
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
@@ -442,7 +435,7 @@ TerminalConOutQueryMode (
{
TERMINAL_DEV *TerminalDevice;
- if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
+ if (ModeNumber >= (UINTN)This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
@@ -450,13 +443,12 @@ TerminalConOutQueryMode (
// Get Terminal device data structure pointer.
//
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
- *Columns = TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns;
- *Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;
+ *Columns = TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns;
+ *Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;
return EFI_SUCCESS;
}
-
/**
Implements EFI_SIMPLE_TEXT_OUT.SetMode().
@@ -487,14 +479,14 @@ TerminalConOutSetMode (
//
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
- if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
+ if (ModeNumber >= (UINTN)This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
//
// Set the current mode
//
- This->Mode->Mode = (INT32) ModeNumber;
+ This->Mode->Mode = (INT32)ModeNumber;
This->ClearScreen (This);
@@ -506,18 +498,16 @@ TerminalConOutSetMode (
return EFI_DEVICE_ERROR;
}
- This->Mode->Mode = (INT32) ModeNumber;
+ This->Mode->Mode = (INT32)ModeNumber;
- Status = This->ClearScreen (This);
+ Status = This->ClearScreen (This);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
-
}
-
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
@@ -564,7 +554,7 @@ TerminalConOutSetAttribute (
// Skip outputting the command string for the same attribute
// It improves the terminal performance significantly
//
- if (This->Mode->Attribute == (INT32) Attribute) {
+ if (This->Mode->Attribute == (INT32)Attribute) {
return EFI_SUCCESS;
}
@@ -573,103 +563,102 @@ TerminalConOutSetAttribute (
// understandable foreground color
//
switch (Attribute & 0x07) {
+ case EFI_BLACK:
+ ForegroundControl = 30;
+ break;
- case EFI_BLACK:
- ForegroundControl = 30;
- break;
-
- case EFI_BLUE:
- ForegroundControl = 34;
- break;
-
- case EFI_GREEN:
- ForegroundControl = 32;
- break;
+ case EFI_BLUE:
+ ForegroundControl = 34;
+ break;
- case EFI_CYAN:
- ForegroundControl = 36;
- break;
+ case EFI_GREEN:
+ ForegroundControl = 32;
+ break;
- case EFI_RED:
- ForegroundControl = 31;
- break;
+ case EFI_CYAN:
+ ForegroundControl = 36;
+ break;
- case EFI_MAGENTA:
- ForegroundControl = 35;
- break;
+ case EFI_RED:
+ ForegroundControl = 31;
+ break;
- case EFI_BROWN:
- ForegroundControl = 33;
- break;
+ case EFI_MAGENTA:
+ ForegroundControl = 35;
+ break;
- default:
+ case EFI_BROWN:
+ ForegroundControl = 33;
+ break;
- case EFI_LIGHTGRAY:
- ForegroundControl = 37;
- break;
+ default:
+ case EFI_LIGHTGRAY:
+ ForegroundControl = 37;
+ break;
}
+
//
// bit4 of the Attribute indicates bright control
// of terminal emulator.
//
- BrightControl = (UINT8) ((Attribute >> 3) & 1);
+ BrightControl = (UINT8)((Attribute >> 3) & 1);
//
// convert Attribute value to terminal emulator
// understandable background color.
//
switch ((Attribute >> 4) & 0x07) {
+ case EFI_BLACK:
+ BackgroundControl = 40;
+ break;
- case EFI_BLACK:
- BackgroundControl = 40;
- break;
-
- case EFI_BLUE:
- BackgroundControl = 44;
- break;
+ case EFI_BLUE:
+ BackgroundControl = 44;
+ break;
- case EFI_GREEN:
- BackgroundControl = 42;
- break;
+ case EFI_GREEN:
+ BackgroundControl = 42;
+ break;
- case EFI_CYAN:
- BackgroundControl = 46;
- break;
+ case EFI_CYAN:
+ BackgroundControl = 46;
+ break;
- case EFI_RED:
- BackgroundControl = 41;
- break;
+ case EFI_RED:
+ BackgroundControl = 41;
+ break;
- case EFI_MAGENTA:
- BackgroundControl = 45;
- break;
+ case EFI_MAGENTA:
+ BackgroundControl = 45;
+ break;
- case EFI_BROWN:
- BackgroundControl = 43;
- break;
+ case EFI_BROWN:
+ BackgroundControl = 43;
+ break;
- default:
+ default:
- case EFI_LIGHTGRAY:
- BackgroundControl = 47;
- break;
+ case EFI_LIGHTGRAY:
+ BackgroundControl = 47;
+ break;
}
+
//
// terminal emulator's control sequence to set attributes
//
- mSetAttributeString[BRIGHT_CONTROL_OFFSET] = (CHAR16) ('0' + BrightControl);
- mSetAttributeString[FOREGROUND_CONTROL_OFFSET + 0] = (CHAR16) ('0' + (ForegroundControl / 10));
- mSetAttributeString[FOREGROUND_CONTROL_OFFSET + 1] = (CHAR16) ('0' + (ForegroundControl % 10));
- mSetAttributeString[BACKGROUND_CONTROL_OFFSET + 0] = (CHAR16) ('0' + (BackgroundControl / 10));
- mSetAttributeString[BACKGROUND_CONTROL_OFFSET + 1] = (CHAR16) ('0' + (BackgroundControl % 10));
+ mSetAttributeString[BRIGHT_CONTROL_OFFSET] = (CHAR16)('0' + BrightControl);
+ mSetAttributeString[FOREGROUND_CONTROL_OFFSET + 0] = (CHAR16)('0' + (ForegroundControl / 10));
+ mSetAttributeString[FOREGROUND_CONTROL_OFFSET + 1] = (CHAR16)('0' + (ForegroundControl % 10));
+ mSetAttributeString[BACKGROUND_CONTROL_OFFSET + 0] = (CHAR16)('0' + (BackgroundControl / 10));
+ mSetAttributeString[BACKGROUND_CONTROL_OFFSET + 1] = (CHAR16)('0' + (BackgroundControl % 10));
//
// save current column and row
// for future scrolling back use.
//
- SavedColumn = This->Mode->CursorColumn;
- SavedRow = This->Mode->CursorRow;
+ SavedColumn = This->Mode->CursorColumn;
+ SavedRow = This->Mode->CursorRow;
TerminalDevice->OutputEscChar = TRUE;
Status = This->OutputString (This, mSetAttributeString);
@@ -678,19 +667,18 @@ TerminalConOutSetAttribute (
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
+
//
// scroll back to saved cursor position.
//
- This->Mode->CursorColumn = SavedColumn;
- This->Mode->CursorRow = SavedRow;
+ This->Mode->CursorColumn = SavedColumn;
+ This->Mode->CursorRow = SavedRow;
- This->Mode->Attribute = (INT32) Attribute;
+ This->Mode->Attribute = (INT32)Attribute;
return EFI_SUCCESS;
-
}
-
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
It clears the ANSI terminal's display to the
@@ -730,7 +718,6 @@ TerminalConOutClearScreen (
return Status;
}
-
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
@@ -752,12 +739,12 @@ TerminalConOutSetCursorPosition (
IN UINTN Row
)
{
- EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
- UINTN MaxColumn;
- UINTN MaxRow;
- EFI_STATUS Status;
- TERMINAL_DEV *TerminalDevice;
- CHAR16 *String;
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
+ UINTN MaxColumn;
+ UINTN MaxRow;
+ EFI_STATUS Status;
+ TERMINAL_DEV *TerminalDevice;
+ CHAR16 *String;
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
@@ -770,18 +757,19 @@ TerminalConOutSetCursorPosition (
// get geometry of current mode
//
Status = This->QueryMode (
- This,
- Mode->Mode,
- &MaxColumn,
- &MaxRow
- );
+ This,
+ Mode->Mode,
+ &MaxColumn,
+ &MaxRow
+ );
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
- if (Column >= MaxColumn || Row >= MaxRow) {
+ if ((Column >= MaxColumn) || (Row >= MaxRow)) {
return EFI_UNSUPPORTED;
}
+
//
// control sequence to move the cursor
//
@@ -789,48 +777,46 @@ TerminalConOutSetCursorPosition (
// within the current line if possible, and don't output anyting if
// it isn't necessary.
//
- if (TerminalDevice->TerminalType == TerminalTypeTtyTerm &&
- (UINTN)Mode->CursorRow == Row) {
+ if ((TerminalDevice->TerminalType == TerminalTypeTtyTerm) &&
+ ((UINTN)Mode->CursorRow == Row))
+ {
if ((UINTN)Mode->CursorColumn > Column) {
- mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) / 10));
- mCursorBackwardString[FW_BACK_OFFSET + 1] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) % 10));
- String = mCursorBackwardString;
- }
- else if (Column > (UINTN)Mode->CursorColumn) {
- mCursorForwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Column - Mode->CursorColumn) / 10));
- mCursorForwardString[FW_BACK_OFFSET + 1] = (CHAR16) ('0' + ((Column - Mode->CursorColumn) % 10));
- String = mCursorForwardString;
- }
- else {
+ mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16)('0' + ((Mode->CursorColumn - Column) / 10));
+ mCursorBackwardString[FW_BACK_OFFSET + 1] = (CHAR16)('0' + ((Mode->CursorColumn - Column) % 10));
+ String = mCursorBackwardString;
+ } else if (Column > (UINTN)Mode->CursorColumn) {
+ mCursorForwardString[FW_BACK_OFFSET + 0] = (CHAR16)('0' + ((Column - Mode->CursorColumn) / 10));
+ mCursorForwardString[FW_BACK_OFFSET + 1] = (CHAR16)('0' + ((Column - Mode->CursorColumn) % 10));
+ String = mCursorForwardString;
+ } else {
String = L""; // No cursor motion necessary
}
- }
- else {
- mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16) ('0' + ((Row + 1) / 10));
- mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16) ('0' + ((Row + 1) % 10));
- mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16) ('0' + ((Column + 1) / 10));
- mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16) ('0' + ((Column + 1) % 10));
- String = mSetCursorPositionString;
+ } else {
+ mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16)('0' + ((Row + 1) / 10));
+ mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16)('0' + ((Row + 1) % 10));
+ mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16)('0' + ((Column + 1) / 10));
+ mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16)('0' + ((Column + 1) % 10));
+ String = mSetCursorPositionString;
}
- TerminalDevice->OutputEscChar = TRUE;
- Status = This->OutputString (This, String);
+ TerminalDevice->OutputEscChar = TRUE;
+ Status = This->OutputString (This, String);
TerminalDevice->OutputEscChar = FALSE;
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
+
//
// update current cursor position
// in the Mode data structure.
//
- Mode->CursorColumn = (INT32) Column;
- Mode->CursorRow = (INT32) Row;
+ Mode->CursorColumn = (INT32)Column;
+ Mode->CursorRow = (INT32)Row;
return EFI_SUCCESS;
}
-
/**
Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
@@ -858,7 +844,6 @@ TerminalConOutEnableCursor (
return EFI_SUCCESS;
}
-
/**
Detects if a Unicode char is for Box Drawing text graphics.
@@ -878,7 +863,7 @@ TerminalIsValidTextGraphics (
OUT CHAR8 *Ascii OPTIONAL
)
{
- UNICODE_TO_CHAR *Table;
+ UNICODE_TO_CHAR *Table;
if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
//
@@ -946,12 +931,13 @@ TerminalIsValidEfiCntlChar (
//
// only support four control characters.
//
- if (CharC == CHAR_NULL ||
- CharC == CHAR_BACKSPACE ||
- CharC == CHAR_LINEFEED ||
- CharC == CHAR_CARRIAGE_RETURN ||
- CharC == CHAR_TAB
- ) {
+ if ((CharC == CHAR_NULL) ||
+ (CharC == CHAR_BACKSPACE) ||
+ (CharC == CHAR_LINEFEED) ||
+ (CharC == CHAR_CARRIAGE_RETURN) ||
+ (CharC == CHAR_TAB)
+ )
+ {
return TRUE;
}
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c b/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c
index 9cf52d9..bd3d906 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c
@@ -17,12 +17,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
VTUTF8RawDataToUnicode (
- IN TERMINAL_DEV *TerminalDevice
+ IN TERMINAL_DEV *TerminalDevice
)
{
- UTF8_CHAR Utf8Char;
- UINT8 ValidBytes;
- UINT16 UnicodeChar;
+ UTF8_CHAR Utf8Char;
+ UINT8 ValidBytes;
+ UINT16 UnicodeChar;
ValidBytes = 0;
//
@@ -31,14 +31,13 @@ VTUTF8RawDataToUnicode (
// the unicode into unicode fifo, until the raw fifo is empty.
//
while (!IsRawFiFoEmpty (TerminalDevice) && !IsUnicodeFiFoFull (TerminalDevice)) {
-
GetOneValidUtf8Char (TerminalDevice, &Utf8Char, &ValidBytes);
- if (ValidBytes < 1 || ValidBytes > 3) {
+ if ((ValidBytes < 1) || (ValidBytes > 3)) {
continue;
}
- Utf8ToUnicode (Utf8Char, ValidBytes, (CHAR16 *) &UnicodeChar);
+ Utf8ToUnicode (Utf8Char, ValidBytes, (CHAR16 *)&UnicodeChar);
UnicodeFiFoInsertOneKey (TerminalDevice, UnicodeChar);
}
@@ -55,14 +54,14 @@ VTUTF8RawDataToUnicode (
**/
VOID
GetOneValidUtf8Char (
- IN TERMINAL_DEV *Utf8Device,
- OUT UTF8_CHAR *Utf8Char,
- OUT UINT8 *ValidBytes
+ IN TERMINAL_DEV *Utf8Device,
+ OUT UTF8_CHAR *Utf8Char,
+ OUT UINT8 *ValidBytes
)
{
- UINT8 Temp;
- UINT8 Index;
- BOOLEAN FetchFlag;
+ UINT8 Temp;
+ UINT8 Index;
+ BOOLEAN FetchFlag;
Temp = 0;
Index = 0;
@@ -75,88 +74,82 @@ GetOneValidUtf8Char (
*ValidBytes = 0;
while (!IsRawFiFoEmpty (Utf8Device)) {
-
RawFiFoRemoveOneKey (Utf8Device, &Temp);
switch (*ValidBytes) {
+ case 0:
+ if ((Temp & 0x80) == 0) {
+ //
+ // one-byte utf8 char
+ //
+ *ValidBytes = 1;
- case 0:
- if ((Temp & 0x80) == 0) {
- //
- // one-byte utf8 char
- //
- *ValidBytes = 1;
+ Utf8Char->Utf8_1 = Temp;
- Utf8Char->Utf8_1 = Temp;
+ FetchFlag = FALSE;
+ } else if ((Temp & 0xe0) == 0xc0) {
+ //
+ // two-byte utf8 char
+ //
+ *ValidBytes = 2;
- FetchFlag = FALSE;
+ Utf8Char->Utf8_2[1] = Temp;
+ } else if ((Temp & 0xf0) == 0xe0) {
+ //
+ // three-byte utf8 char
+ //
+ *ValidBytes = 3;
- } else if ((Temp & 0xe0) == 0xc0) {
- //
- // two-byte utf8 char
- //
- *ValidBytes = 2;
+ Utf8Char->Utf8_3[2] = Temp;
- Utf8Char->Utf8_2[1] = Temp;
+ Index++;
+ } else {
+ //
+ // reset *ValidBytes to zero, let valid utf8 char search restart
+ //
+ *ValidBytes = 0;
+ }
- } else if ((Temp & 0xf0) == 0xe0) {
+ break;
+
+ case 2:
//
- // three-byte utf8 char
+ // two-byte utf8 char go on
//
- *ValidBytes = 3;
+ if ((Temp & 0xc0) == 0x80) {
+ Utf8Char->Utf8_2[0] = Temp;
- Utf8Char->Utf8_3[2] = Temp;
+ FetchFlag = FALSE;
+ } else {
+ *ValidBytes = 0;
+ }
- Index++;
+ break;
- } else {
+ case 3:
//
- // reset *ValidBytes to zero, let valid utf8 char search restart
+ // three-byte utf8 char go on
//
- *ValidBytes = 0;
- }
-
- break;
-
- case 2:
- //
- // two-byte utf8 char go on
- //
- if ((Temp & 0xc0) == 0x80) {
-
- Utf8Char->Utf8_2[0] = Temp;
-
- FetchFlag = FALSE;
-
- } else {
-
- *ValidBytes = 0;
- }
- break;
-
- case 3:
- //
- // three-byte utf8 char go on
- //
- if ((Temp & 0xc0) == 0x80) {
- if (Index == 1) {
- Utf8Char->Utf8_3[1] = Temp;
- Index++;
+ if ((Temp & 0xc0) == 0x80) {
+ if (Index == 1) {
+ Utf8Char->Utf8_3[1] = Temp;
+ Index++;
+ } else {
+ Utf8Char->Utf8_3[0] = Temp;
+ FetchFlag = FALSE;
+ }
} else {
- Utf8Char->Utf8_3[0] = Temp;
- FetchFlag = FALSE;
+ //
+ // reset *ValidBytes and Index to zero, let valid utf8 char search restart
+ //
+ *ValidBytes = 0;
+ Index = 0;
}
- } else {
- //
- // reset *ValidBytes and Index to zero, let valid utf8 char search restart
- //
- *ValidBytes = 0;
- Index = 0;
- }
- break;
- default:
- break;
+ break;
+
+ default:
+ break;
}
if (!FetchFlag) {
@@ -164,7 +157,7 @@ GetOneValidUtf8Char (
}
}
- return ;
+ return;
}
/**
@@ -184,16 +177,16 @@ GetOneValidUtf8Char (
**/
VOID
Utf8ToUnicode (
- IN UTF8_CHAR Utf8Char,
- IN UINT8 ValidBytes,
- OUT CHAR16 *UnicodeChar
+ IN UTF8_CHAR Utf8Char,
+ IN UINT8 ValidBytes,
+ OUT CHAR16 *UnicodeChar
)
{
- UINT8 UnicodeByte0;
- UINT8 UnicodeByte1;
- UINT8 Byte0;
- UINT8 Byte1;
- UINT8 Byte2;
+ UINT8 UnicodeByte0;
+ UINT8 UnicodeByte1;
+ UINT8 Byte0;
+ UINT8 Byte1;
+ UINT8 Byte2;
*UnicodeChar = 0;
@@ -202,42 +195,42 @@ Utf8ToUnicode (
// up to 3 bytes utf8 code is supported.
//
switch (ValidBytes) {
- case 1:
- //
- // one-byte utf8 code
- //
- *UnicodeChar = (UINT16) Utf8Char.Utf8_1;
- break;
+ case 1:
+ //
+ // one-byte utf8 code
+ //
+ *UnicodeChar = (UINT16)Utf8Char.Utf8_1;
+ break;
- case 2:
- //
- // two-byte utf8 code
- //
- Byte0 = Utf8Char.Utf8_2[0];
- Byte1 = Utf8Char.Utf8_2[1];
+ case 2:
+ //
+ // two-byte utf8 code
+ //
+ Byte0 = Utf8Char.Utf8_2[0];
+ Byte1 = Utf8Char.Utf8_2[1];
- UnicodeByte0 = (UINT8) ((Byte1 << 6) | (Byte0 & 0x3f));
- UnicodeByte1 = (UINT8) ((Byte1 >> 2) & 0x07);
- *UnicodeChar = (UINT16) (UnicodeByte0 | (UnicodeByte1 << 8));
- break;
+ UnicodeByte0 = (UINT8)((Byte1 << 6) | (Byte0 & 0x3f));
+ UnicodeByte1 = (UINT8)((Byte1 >> 2) & 0x07);
+ *UnicodeChar = (UINT16)(UnicodeByte0 | (UnicodeByte1 << 8));
+ break;
- case 3:
- //
- // three-byte utf8 code
- //
- Byte0 = Utf8Char.Utf8_3[0];
- Byte1 = Utf8Char.Utf8_3[1];
- Byte2 = Utf8Char.Utf8_3[2];
+ case 3:
+ //
+ // three-byte utf8 code
+ //
+ Byte0 = Utf8Char.Utf8_3[0];
+ Byte1 = Utf8Char.Utf8_3[1];
+ Byte2 = Utf8Char.Utf8_3[2];
- UnicodeByte0 = (UINT8) ((Byte1 << 6) | (Byte0 & 0x3f));
- UnicodeByte1 = (UINT8) ((Byte2 << 4) | ((Byte1 >> 2) & 0x0f));
- *UnicodeChar = (UINT16) (UnicodeByte0 | (UnicodeByte1 << 8));
+ UnicodeByte0 = (UINT8)((Byte1 << 6) | (Byte0 & 0x3f));
+ UnicodeByte1 = (UINT8)((Byte2 << 4) | ((Byte1 >> 2) & 0x0f));
+ *UnicodeChar = (UINT16)(UnicodeByte0 | (UnicodeByte1 << 8));
- default:
- break;
+ default:
+ break;
}
- return ;
+ return;
}
/**
@@ -258,48 +251,45 @@ Utf8ToUnicode (
**/
VOID
UnicodeToUtf8 (
- IN CHAR16 Unicode,
- OUT UTF8_CHAR *Utf8Char,
- OUT UINT8 *ValidBytes
+ IN CHAR16 Unicode,
+ OUT UTF8_CHAR *Utf8Char,
+ OUT UINT8 *ValidBytes
)
{
- UINT8 UnicodeByte0;
- UINT8 UnicodeByte1;
+ UINT8 UnicodeByte0;
+ UINT8 UnicodeByte1;
+
//
// translate unicode to utf8 code
//
- UnicodeByte0 = (UINT8) Unicode;
- UnicodeByte1 = (UINT8) (Unicode >> 8);
+ UnicodeByte0 = (UINT8)Unicode;
+ UnicodeByte1 = (UINT8)(Unicode >> 8);
if (Unicode < 0x0080) {
-
- Utf8Char->Utf8_1 = (UINT8) (UnicodeByte0 & 0x7f);
- *ValidBytes = 1;
-
+ Utf8Char->Utf8_1 = (UINT8)(UnicodeByte0 & 0x7f);
+ *ValidBytes = 1;
} else if (Unicode < 0x0800) {
//
// byte sequence: high -> low
// Utf8_2[0], Utf8_2[1]
//
- Utf8Char->Utf8_2[1] = (UINT8) ((UnicodeByte0 & 0x3f) + 0x80);
- Utf8Char->Utf8_2[0] = (UINT8) ((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x1f) + 0xc0);
-
- *ValidBytes = 2;
+ Utf8Char->Utf8_2[1] = (UINT8)((UnicodeByte0 & 0x3f) + 0x80);
+ Utf8Char->Utf8_2[0] = (UINT8)((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x1f) + 0xc0);
+ *ValidBytes = 2;
} else {
//
// byte sequence: high -> low
// Utf8_3[0], Utf8_3[1], Utf8_3[2]
//
- Utf8Char->Utf8_3[2] = (UINT8) ((UnicodeByte0 & 0x3f) + 0x80);
- Utf8Char->Utf8_3[1] = (UINT8) ((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x3f) + 0x80);
- Utf8Char->Utf8_3[0] = (UINT8) (((UnicodeByte1 >> 4) & 0x0f) + 0xe0);
+ Utf8Char->Utf8_3[2] = (UINT8)((UnicodeByte0 & 0x3f) + 0x80);
+ Utf8Char->Utf8_3[1] = (UINT8)((((UnicodeByte1 << 2) + (UnicodeByte0 >> 6)) & 0x3f) + 0x80);
+ Utf8Char->Utf8_3[0] = (UINT8)(((UnicodeByte1 >> 4) & 0x0f) + 0xe0);
- *ValidBytes = 3;
+ *ValidBytes = 3;
}
}
-
/**
Check if input string is valid VT-UTF8 string.
@@ -311,8 +301,8 @@ UnicodeToUtf8 (
**/
EFI_STATUS
VTUTF8TestString (
- IN TERMINAL_DEV *TerminalDevice,
- IN CHAR16 *WString
+ IN TERMINAL_DEV *TerminalDevice,
+ IN CHAR16 *WString
)
{
//