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>
This commit is contained in:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
//
|
||||
|
@@ -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 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 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_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 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 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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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'+' },
|
||||
{ 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'+' },
|
||||
{ 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'<' },
|
||||
{ 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' },
|
||||
{ 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:
|
||||
|
||||
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))) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Length = 1;
|
||||
|
||||
if (TerminalDevice->TerminalType != TerminalTypePcAnsi) {
|
||||
GraphicChar = AsciiChar;
|
||||
}
|
||||
Status = TerminalDevice->SerialIo->Write (
|
||||
TerminalDevice->SerialIo,
|
||||
&Length,
|
||||
&GraphicChar
|
||||
);
|
||||
|
||||
Length = 1;
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto OutputError;
|
||||
}
|
||||
|
||||
Status = TerminalDevice->SerialIo->Write (
|
||||
TerminalDevice->SerialIo,
|
||||
&Length,
|
||||
&GraphicChar
|
||||
);
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
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 {
|
||||
|
||||
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);
|
||||
case CHAR_CARRIAGE_RETURN:
|
||||
Mode->CursorColumn = 0;
|
||||
break;
|
||||
|
||||
Status = TerminalDevice->SerialIo->Write (
|
||||
TerminalDevice->SerialIo,
|
||||
&Length,
|
||||
CrLfStr
|
||||
);
|
||||
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_BLUE:
|
||||
ForegroundControl = 34;
|
||||
break;
|
||||
case EFI_GREEN:
|
||||
ForegroundControl = 32;
|
||||
break;
|
||||
|
||||
case EFI_GREEN:
|
||||
ForegroundControl = 32;
|
||||
break;
|
||||
case EFI_CYAN:
|
||||
ForegroundControl = 36;
|
||||
break;
|
||||
|
||||
case EFI_CYAN:
|
||||
ForegroundControl = 36;
|
||||
break;
|
||||
case EFI_RED:
|
||||
ForegroundControl = 31;
|
||||
break;
|
||||
|
||||
case EFI_RED:
|
||||
ForegroundControl = 31;
|
||||
break;
|
||||
case EFI_MAGENTA:
|
||||
ForegroundControl = 35;
|
||||
break;
|
||||
|
||||
case EFI_MAGENTA:
|
||||
ForegroundControl = 35;
|
||||
break;
|
||||
case EFI_BROWN:
|
||||
ForegroundControl = 33;
|
||||
break;
|
||||
|
||||
case EFI_BROWN:
|
||||
ForegroundControl = 33;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
} else if ((Temp & 0xf0) == 0xe0) {
|
||||
//
|
||||
// three-byte utf8 char
|
||||
//
|
||||
*ValidBytes = 3;
|
||||
|
||||
Utf8Char->Utf8_3[2] = Temp;
|
||||
|
||||
Index++;
|
||||
|
||||
} else {
|
||||
//
|
||||
// reset *ValidBytes to zero, let valid utf8 char search restart
|
||||
//
|
||||
*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++;
|
||||
} else {
|
||||
Utf8Char->Utf8_3[0] = Temp;
|
||||
FetchFlag = FALSE;
|
||||
//
|
||||
// reset *ValidBytes to zero, let valid utf8 char search restart
|
||||
//
|
||||
*ValidBytes = 0;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// reset *ValidBytes and Index to zero, let valid utf8 char search restart
|
||||
//
|
||||
*ValidBytes = 0;
|
||||
Index = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
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++;
|
||||
} else {
|
||||
Utf8Char->Utf8_3[0] = Temp;
|
||||
FetchFlag = FALSE;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// reset *ValidBytes and Index to zero, let valid utf8 char search restart
|
||||
//
|
||||
*ValidBytes = 0;
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
//
|
||||
|
Reference in New Issue
Block a user