mirror of https://github.com/acidanthera/audk.git
remove some internal functions and allocate some FIFO data structure instead of declaring in global variable. To save size.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7416 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
1068a65374
commit
5c998646f3
|
@ -69,21 +69,11 @@ TERMINAL_DEV mTerminalDevTemplate = {
|
||||||
TRUE // CursorVisible
|
TRUE // CursorVisible
|
||||||
},
|
},
|
||||||
0, // SerialInTimeOut
|
0, // SerialInTimeOut
|
||||||
{ // RawFiFo
|
|
||||||
0,
|
NULL, // RawFifo
|
||||||
0,
|
NULL, // UnicodeFiFo
|
||||||
{ 0 }
|
NULL, // EfiKeyFiFo
|
||||||
},
|
|
||||||
{ // UnicodeFiFo
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{ 0 }
|
|
||||||
},
|
|
||||||
{ // EfiKeyFiFo
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{ {0} }
|
|
||||||
},
|
|
||||||
NULL, // ControllerNameTable
|
NULL, // ControllerNameTable
|
||||||
NULL, // TwoSecondTimeOut
|
NULL, // TwoSecondTimeOut
|
||||||
INPUT_STATE_DEFAULT,
|
INPUT_STATE_DEFAULT,
|
||||||
|
@ -424,12 +414,21 @@ TerminalDriverBindingStart (
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// initialize the FIFO buffer used for accommodating
|
// Allocates and initializes the FIFO buffer to be zero, used for accommodating
|
||||||
// the pre-read pending characters
|
// the pre-read pending characters.
|
||||||
//
|
//
|
||||||
InitializeRawFiFo (TerminalDevice);
|
TerminalDevice->RawFiFo = AllocateZeroPool (sizeof (RAW_DATA_FIFO));
|
||||||
InitializeUnicodeFiFo (TerminalDevice);
|
if (TerminalDevice->RawFiFo == NULL) {
|
||||||
InitializeEfiKeyFiFo (TerminalDevice);
|
goto Error;
|
||||||
|
}
|
||||||
|
TerminalDevice->UnicodeFiFo = AllocateZeroPool (sizeof (UNICODE_FIFO));
|
||||||
|
if (TerminalDevice->UnicodeFiFo == NULL) {
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
TerminalDevice->EfiKeyFiFo = AllocateZeroPool (sizeof (EFI_KEY_FIFO));
|
||||||
|
if (TerminalDevice->EfiKeyFiFo == NULL) {
|
||||||
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the timeout value of serial buffer for
|
// Set the timeout value of serial buffer for
|
||||||
|
@ -704,6 +703,16 @@ Error:
|
||||||
|
|
||||||
TerminalFreeNotifyList (&TerminalDevice->NotifyList);
|
TerminalFreeNotifyList (&TerminalDevice->NotifyList);
|
||||||
|
|
||||||
|
if (TerminalDevice->RawFiFo != NULL) {
|
||||||
|
FreePool (TerminalDevice->RawFiFo);
|
||||||
|
}
|
||||||
|
if (TerminalDevice->UnicodeFiFo != NULL) {
|
||||||
|
FreePool (TerminalDevice->UnicodeFiFo);
|
||||||
|
}
|
||||||
|
if (TerminalDevice->EfiKeyFiFo != NULL) {
|
||||||
|
FreePool (TerminalDevice->EfiKeyFiFo);
|
||||||
|
}
|
||||||
|
|
||||||
if (TerminalDevice->ControllerNameTable != NULL) {
|
if (TerminalDevice->ControllerNameTable != NULL) {
|
||||||
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
|
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
|
||||||
}
|
}
|
||||||
|
@ -1279,58 +1288,6 @@ SetTerminalDevicePath (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the Raw Data FIFO.
|
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeRawFiFo (
|
|
||||||
IN TERMINAL_DEV *TerminalDevice
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Make the raw FIFO empty.
|
|
||||||
//
|
|
||||||
TerminalDevice->RawFiFo.Head = TerminalDevice->RawFiFo.Tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the Unicode FIFO.
|
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeUnicodeFiFo (
|
|
||||||
IN TERMINAL_DEV *TerminalDevice
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Make the unicode FIFO empty
|
|
||||||
//
|
|
||||||
TerminalDevice->UnicodeFiFo.Head = TerminalDevice->UnicodeFiFo.Tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the EFI Key FIFO.
|
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeEfiKeyFiFo (
|
|
||||||
IN TERMINAL_DEV *TerminalDevice
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Make the efi key FIFO empty
|
|
||||||
//
|
|
||||||
TerminalDevice->EfiKeyFiFo.Head = TerminalDevice->EfiKeyFiFo.Tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The user Entry Point for module Terminal. The user code starts with this function.
|
The user Entry Point for module Terminal. The user code starts with this function.
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ typedef struct {
|
||||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
|
||||||
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
|
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
|
||||||
UINTN SerialInTimeOut;
|
UINTN SerialInTimeOut;
|
||||||
RAW_DATA_FIFO RawFiFo;
|
RAW_DATA_FIFO *RawFiFo;
|
||||||
UNICODE_FIFO UnicodeFiFo;
|
UNICODE_FIFO *UnicodeFiFo;
|
||||||
EFI_KEY_FIFO EfiKeyFiFo;
|
EFI_KEY_FIFO *EfiKeyFiFo;
|
||||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||||
EFI_EVENT TwoSecondTimeOut;
|
EFI_EVENT TwoSecondTimeOut;
|
||||||
UINT32 InputState;
|
UINT32 InputState;
|
||||||
|
@ -491,7 +491,7 @@ TerminalConOutQueryMode (
|
||||||
@param ModeNumber The text mode to set.
|
@param ModeNumber The text mode to set.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The requested text mode is set.
|
@retval EFI_SUCCESS The requested text mode is set.
|
||||||
@retval EFI_DEVICE_ERROR The requested text mode cannot be set
|
@retval EFI_DEVICE_ERROR The requested text mode cannot be set
|
||||||
because of serial device error.
|
because of serial device error.
|
||||||
@retval EFI_UNSUPPORTED The text mode number is not valid.
|
@retval EFI_UNSUPPORTED The text mode number is not valid.
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ TerminalConOutEnableCursor (
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Test to see if this driver supports Controller.
|
Test to see if this driver supports Controller.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@param This Protocol instance pointer.
|
||||||
@param ControllerHandle Handle of device to test
|
@param ControllerHandle Handle of device to test
|
||||||
|
@ -629,7 +629,7 @@ TerminalDriverBindingStart (
|
||||||
/**
|
/**
|
||||||
Stop this driver on Controller by closing Simple Text In, Simple Text
|
Stop this driver on Controller by closing Simple Text In, Simple Text
|
||||||
In Ex, Simple Text Out protocol, and removing parent device path from
|
In Ex, Simple Text Out protocol, and removing parent device path from
|
||||||
Console Device Environment Variables.
|
Console Device Environment Variables.
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
@param This Protocol instance pointer.
|
||||||
@param Controller Handle of device to stop driver on
|
@param Controller Handle of device to stop driver on
|
||||||
|
@ -847,7 +847,7 @@ TerminalRemoveConsoleDevVariable (
|
||||||
@param VariableSize Returns the size of the EFI variable that was read
|
@param VariableSize Returns the size of the EFI variable that was read
|
||||||
|
|
||||||
@return Dynamically allocated memory that contains a copy of the EFI variable.
|
@return Dynamically allocated memory that contains a copy of the EFI variable.
|
||||||
Caller is repsoncible freeing the buffer. If variable was not read,
|
Caller is repsoncible freeing the buffer. If variable was not read,
|
||||||
NULL regturned.
|
NULL regturned.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -877,39 +877,6 @@ SetTerminalDevicePath (
|
||||||
OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
|
OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the Raw Data FIFO.
|
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeRawFiFo (
|
|
||||||
IN TERMINAL_DEV *TerminalDevice
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the Unicode FIFO.
|
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeUnicodeFiFo (
|
|
||||||
IN TERMINAL_DEV *TerminalDevice
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the EFI Key FIFO.
|
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeEfiKeyFiFo (
|
|
||||||
IN TERMINAL_DEV *TerminalDevice
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get one key out of serial buffer.
|
Get one key out of serial buffer.
|
||||||
|
|
||||||
|
@ -1125,8 +1092,8 @@ UnicodeFiFoGetKeyCount (
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate raw data into Unicode (according to different encode), and
|
Translate raw data into Unicode (according to different encode), and
|
||||||
translate Unicode into key information. (according to different standard).
|
translate Unicode into key information. (according to different standard).
|
||||||
|
|
||||||
@param TerminalDevice Terminal driver private structure.
|
@param TerminalDevice Terminal driver private structure.
|
||||||
|
|
||||||
|
@ -1154,8 +1121,8 @@ AnsiRawDataToUnicode (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts a stream of Unicode characters from a terminal input device into EFI Keys that
|
Converts a stream of Unicode characters from a terminal input device into EFI Keys that
|
||||||
can be read through the Simple Input Protocol.
|
can be read through the Simple Input Protocol.
|
||||||
|
|
||||||
The table below shows the keyboard input mappings that this function supports.
|
The table below shows the keyboard input mappings that this function supports.
|
||||||
If the ESC sequence listed in one of the columns is presented, then it is translated
|
If the ESC sequence listed in one of the columns is presented, then it is translated
|
||||||
into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw
|
into the coorespoding EFI Scan Code. If a matching sequence is not found, then the raw
|
||||||
|
@ -1206,7 +1173,7 @@ AnsiRawDataToUnicode (
|
||||||
| F11 | 0x15 | | ESC ! | |
|
| F11 | 0x15 | | ESC ! | |
|
||||||
| F12 | 0x16 | | ESC @ | |
|
| F12 | 0x16 | | ESC @ | |
|
||||||
+=========+======+===========+==========+==========+
|
+=========+======+===========+==========+==========+
|
||||||
|
|
||||||
Special Mappings
|
Special Mappings
|
||||||
================
|
================
|
||||||
ESC R ESC r ESC R = Reset System
|
ESC R ESC r ESC R = Reset System
|
||||||
|
@ -1225,8 +1192,8 @@ UnicodeToEfiKey (
|
||||||
or valid text graphics.
|
or valid text graphics.
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
@param TerminalDevice The terminal device.
|
||||||
@param WString The input string.
|
@param WString The input string.
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED If not all input characters are valid.
|
@retval EFI_UNSUPPORTED If not all input characters are valid.
|
||||||
@retval EFI_SUCCESS If all input characters are valid.
|
@retval EFI_SUCCESS If all input characters are valid.
|
||||||
|
|
||||||
|
@ -1242,7 +1209,7 @@ AnsiTestString (
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
|
Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
|
||||||
and insert them into Unicode FIFO.
|
and insert them into Unicode FIFO.
|
||||||
|
|
||||||
@param VtUtf8Device The terminal device.
|
@param VtUtf8Device The terminal device.
|
||||||
|
@ -1257,8 +1224,8 @@ VTUTF8RawDataToUnicode (
|
||||||
Check if input string is valid VT-UTF8 string.
|
Check if input string is valid VT-UTF8 string.
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
@param TerminalDevice The terminal device.
|
||||||
@param WString The input string.
|
@param WString The input string.
|
||||||
|
|
||||||
@retval EFI_SUCCESS If all input characters are valid.
|
@retval EFI_SUCCESS If all input characters are valid.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -1268,7 +1235,7 @@ VTUTF8TestString (
|
||||||
IN CHAR16 *WString
|
IN CHAR16 *WString
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate one Unicode character into VT-UTF8 characters.
|
Translate one Unicode character into VT-UTF8 characters.
|
||||||
|
|
||||||
UTF8 Encoding Table
|
UTF8 Encoding Table
|
||||||
|
@ -1296,7 +1263,7 @@ UnicodeToUtf8 (
|
||||||
|
|
||||||
@param Utf8Device The terminal device.
|
@param Utf8Device The terminal device.
|
||||||
@param Utf8Char Returned valid VT-UTF8 characters set.
|
@param Utf8Char Returned valid VT-UTF8 characters set.
|
||||||
@param ValidBytes The count of returned VT-VTF8 characters.
|
@param ValidBytes The count of returned VT-VTF8 characters.
|
||||||
If ValidBytes is zero, no valid VT-UTF8 returned.
|
If ValidBytes is zero, no valid VT-UTF8 returned.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -1307,7 +1274,7 @@ GetOneValidUtf8Char (
|
||||||
OUT UINT8 *ValidBytes
|
OUT UINT8 *ValidBytes
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate VT-UTF8 characters into one Unicode character.
|
Translate VT-UTF8 characters into one Unicode character.
|
||||||
|
|
||||||
UTF8 Encoding Table
|
UTF8 Encoding Table
|
||||||
|
@ -1319,7 +1286,7 @@ GetOneValidUtf8Char (
|
||||||
|
|
||||||
@param Utf8Char VT-UTF8 character set needs translating.
|
@param Utf8Char VT-UTF8 character set needs translating.
|
||||||
@param ValidBytes The count of valid VT-UTF8 characters.
|
@param ValidBytes The count of valid VT-UTF8 characters.
|
||||||
@param UnicodeChar Returned unicode character.
|
@param UnicodeChar Returned unicode character.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
|
@ -1356,7 +1323,7 @@ TerminalIsValidTextGraphics (
|
||||||
Detects if a valid ASCII char.
|
Detects if a valid ASCII char.
|
||||||
|
|
||||||
@param Ascii An ASCII character.
|
@param Ascii An ASCII character.
|
||||||
|
|
||||||
@retval TRUE If it is a valid ASCII character.
|
@retval TRUE If it is a valid ASCII character.
|
||||||
@retval FALSE If it is not a valid ASCII character.
|
@retval FALSE If it is not a valid ASCII character.
|
||||||
|
|
||||||
|
@ -1370,7 +1337,7 @@ TerminalIsValidAscii (
|
||||||
Detects if a valid EFI control character.
|
Detects if a valid EFI control character.
|
||||||
|
|
||||||
@param CharC An input EFI Control character.
|
@param CharC An input EFI Control character.
|
||||||
|
|
||||||
@retval TRUE If it is a valid EFI control character.
|
@retval TRUE If it is a valid EFI control character.
|
||||||
@retval FALSE If it is not a valid EFI control character.
|
@retval FALSE If it is not a valid EFI control character.
|
||||||
|
|
||||||
|
|
|
@ -120,11 +120,11 @@ TerminalConInReset (
|
||||||
Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);
|
Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);
|
||||||
|
|
||||||
//
|
//
|
||||||
// clear all the internal buffer for keys
|
// Make all the internal buffer empty for keys
|
||||||
//
|
//
|
||||||
InitializeRawFiFo (TerminalDevice);
|
TerminalDevice->RawFiFo->Head = TerminalDevice->RawFiFo->Tail;
|
||||||
InitializeUnicodeFiFo (TerminalDevice);
|
TerminalDevice->UnicodeFiFo->Head = TerminalDevice->UnicodeFiFo->Tail;
|
||||||
InitializeEfiKeyFiFo (TerminalDevice);
|
TerminalDevice->EfiKeyFiFo->Head = TerminalDevice->EfiKeyFiFo->Tail;
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||||
|
@ -179,7 +179,7 @@ TerminalConInReadKeyStroke (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if the key already has been registered.
|
Check if the key already has been registered.
|
||||||
|
|
||||||
If both RegsiteredData and InputData is NULL, then ASSERT().
|
If both RegsiteredData and InputData is NULL, then ASSERT().
|
||||||
|
|
||||||
@param RegsiteredData A pointer to a buffer that is filled in with the
|
@param RegsiteredData A pointer to a buffer that is filled in with the
|
||||||
|
@ -450,7 +450,7 @@ TerminalConInUnregisterKeyNotify (
|
||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||||
LIST_ENTRY *NotifyList;
|
LIST_ENTRY *NotifyList;
|
||||||
|
|
||||||
if (NotificationHandle == NULL) {
|
if (NotificationHandle == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -498,8 +498,8 @@ TerminalConInUnregisterKeyNotify (
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate raw data into Unicode (according to different encode), and
|
Translate raw data into Unicode (according to different encode), and
|
||||||
translate Unicode into key information. (according to different standard).
|
translate Unicode into key information. (according to different standard).
|
||||||
|
|
||||||
@param TerminalDevice Terminal driver private structure.
|
@param TerminalDevice Terminal driver private structure.
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ RawFiFoInsertOneKey (
|
||||||
{
|
{
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
|
|
||||||
Tail = TerminalDevice->RawFiFo.Tail;
|
Tail = TerminalDevice->RawFiFo->Tail;
|
||||||
|
|
||||||
if (IsRawFiFoFull (TerminalDevice)) {
|
if (IsRawFiFoFull (TerminalDevice)) {
|
||||||
//
|
//
|
||||||
|
@ -755,9 +755,9 @@ RawFiFoInsertOneKey (
|
||||||
return FALSE;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ RawFiFoRemoveOneKey (
|
||||||
{
|
{
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Head = TerminalDevice->RawFiFo.Head;
|
Head = TerminalDevice->RawFiFo->Head;
|
||||||
|
|
||||||
if (IsRawFiFoEmpty (TerminalDevice)) {
|
if (IsRawFiFoEmpty (TerminalDevice)) {
|
||||||
//
|
//
|
||||||
|
@ -790,9 +790,9 @@ RawFiFoRemoveOneKey (
|
||||||
return FALSE;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ IsRawFiFoEmpty (
|
||||||
TERMINAL_DEV *TerminalDevice
|
TERMINAL_DEV *TerminalDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (TerminalDevice->RawFiFo.Head == TerminalDevice->RawFiFo.Tail) {
|
if (TerminalDevice->RawFiFo->Head == TerminalDevice->RawFiFo->Tail) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -835,8 +835,8 @@ IsRawFiFoFull (
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Tail = TerminalDevice->RawFiFo.Tail;
|
Tail = TerminalDevice->RawFiFo->Tail;
|
||||||
Head = TerminalDevice->RawFiFo.Head;
|
Head = TerminalDevice->RawFiFo->Head;
|
||||||
|
|
||||||
if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {
|
if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {
|
||||||
|
|
||||||
|
@ -865,7 +865,7 @@ EfiKeyFiFoInsertOneKey (
|
||||||
{
|
{
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
|
|
||||||
Tail = TerminalDevice->EfiKeyFiFo.Tail;
|
Tail = TerminalDevice->EfiKeyFiFo->Tail;
|
||||||
|
|
||||||
if (IsEfiKeyFiFoFull (TerminalDevice)) {
|
if (IsEfiKeyFiFoFull (TerminalDevice)) {
|
||||||
//
|
//
|
||||||
|
@ -874,9 +874,9 @@ EfiKeyFiFoInsertOneKey (
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalDevice->EfiKeyFiFo.Data[Tail] = Key;
|
TerminalDevice->EfiKeyFiFo->Data[Tail] = Key;
|
||||||
|
|
||||||
TerminalDevice->EfiKeyFiFo.Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
|
TerminalDevice->EfiKeyFiFo->Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -899,7 +899,7 @@ EfiKeyFiFoRemoveOneKey (
|
||||||
{
|
{
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Head = TerminalDevice->EfiKeyFiFo.Head;
|
Head = TerminalDevice->EfiKeyFiFo->Head;
|
||||||
|
|
||||||
if (IsEfiKeyFiFoEmpty (TerminalDevice)) {
|
if (IsEfiKeyFiFoEmpty (TerminalDevice)) {
|
||||||
//
|
//
|
||||||
|
@ -910,9 +910,9 @@ EfiKeyFiFoRemoveOneKey (
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Output = TerminalDevice->EfiKeyFiFo.Data[Head];
|
*Output = TerminalDevice->EfiKeyFiFo->Data[Head];
|
||||||
|
|
||||||
TerminalDevice->EfiKeyFiFo.Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));
|
TerminalDevice->EfiKeyFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -931,7 +931,7 @@ IsEfiKeyFiFoEmpty (
|
||||||
TERMINAL_DEV *TerminalDevice
|
TERMINAL_DEV *TerminalDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (TerminalDevice->EfiKeyFiFo.Head == TerminalDevice->EfiKeyFiFo.Tail) {
|
if (TerminalDevice->EfiKeyFiFo->Head == TerminalDevice->EfiKeyFiFo->Tail) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -955,8 +955,8 @@ IsEfiKeyFiFoFull (
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Tail = TerminalDevice->EfiKeyFiFo.Tail;
|
Tail = TerminalDevice->EfiKeyFiFo->Tail;
|
||||||
Head = TerminalDevice->EfiKeyFiFo.Head;
|
Head = TerminalDevice->EfiKeyFiFo->Head;
|
||||||
|
|
||||||
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
|
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ UnicodeFiFoInsertOneKey (
|
||||||
{
|
{
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
|
|
||||||
Tail = TerminalDevice->UnicodeFiFo.Tail;
|
Tail = TerminalDevice->UnicodeFiFo->Tail;
|
||||||
|
|
||||||
if (IsUnicodeFiFoFull (TerminalDevice)) {
|
if (IsUnicodeFiFoFull (TerminalDevice)) {
|
||||||
//
|
//
|
||||||
|
@ -994,9 +994,9 @@ UnicodeFiFoInsertOneKey (
|
||||||
return FALSE;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1019,7 +1019,7 @@ UnicodeFiFoRemoveOneKey (
|
||||||
{
|
{
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Head = TerminalDevice->UnicodeFiFo.Head;
|
Head = TerminalDevice->UnicodeFiFo->Head;
|
||||||
|
|
||||||
if (IsUnicodeFiFoEmpty (TerminalDevice)) {
|
if (IsUnicodeFiFoEmpty (TerminalDevice)) {
|
||||||
//
|
//
|
||||||
|
@ -1029,9 +1029,9 @@ UnicodeFiFoRemoveOneKey (
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Output = TerminalDevice->UnicodeFiFo.Data[Head];
|
*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));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1050,7 @@ IsUnicodeFiFoEmpty (
|
||||||
TERMINAL_DEV *TerminalDevice
|
TERMINAL_DEV *TerminalDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (TerminalDevice->UnicodeFiFo.Head == TerminalDevice->UnicodeFiFo.Tail) {
|
if (TerminalDevice->UnicodeFiFo->Head == TerminalDevice->UnicodeFiFo->Tail) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1074,8 +1074,8 @@ IsUnicodeFiFoFull (
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Tail = TerminalDevice->UnicodeFiFo.Tail;
|
Tail = TerminalDevice->UnicodeFiFo->Tail;
|
||||||
Head = TerminalDevice->UnicodeFiFo.Head;
|
Head = TerminalDevice->UnicodeFiFo->Head;
|
||||||
|
|
||||||
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
|
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
|
||||||
|
|
||||||
|
@ -1101,8 +1101,8 @@ UnicodeFiFoGetKeyCount (
|
||||||
UINT8 Tail;
|
UINT8 Tail;
|
||||||
UINT8 Head;
|
UINT8 Head;
|
||||||
|
|
||||||
Tail = TerminalDevice->UnicodeFiFo.Tail;
|
Tail = TerminalDevice->UnicodeFiFo->Tail;
|
||||||
Head = TerminalDevice->UnicodeFiFo.Head;
|
Head = TerminalDevice->UnicodeFiFo->Head;
|
||||||
|
|
||||||
if (Tail >= Head) {
|
if (Tail >= Head) {
|
||||||
return (UINT8) (Tail - Head);
|
return (UINT8) (Tail - Head);
|
||||||
|
@ -1113,7 +1113,7 @@ UnicodeFiFoGetKeyCount (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update the Unicode characters from a terminal input device into EFI Keys FIFO.
|
Update the Unicode characters from a terminal input device into EFI Keys FIFO.
|
||||||
|
|
||||||
@param TerminalDevice The terminal device to use to translate raw input into EFI Keys
|
@param TerminalDevice The terminal device to use to translate raw input into EFI Keys
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -1124,9 +1124,9 @@ UnicodeToEfiKeyFlushState (
|
||||||
{
|
{
|
||||||
EFI_INPUT_KEY Key;
|
EFI_INPUT_KEY Key;
|
||||||
UINT32 InputState;
|
UINT32 InputState;
|
||||||
|
|
||||||
InputState = TerminalDevice->InputState;
|
InputState = TerminalDevice->InputState;
|
||||||
|
|
||||||
if ((InputState & INPUT_STATE_ESC) != 0) {
|
if ((InputState & INPUT_STATE_ESC) != 0) {
|
||||||
Key.ScanCode = SCAN_ESC;
|
Key.ScanCode = SCAN_ESC;
|
||||||
Key.UnicodeChar = 0;
|
Key.UnicodeChar = 0;
|
||||||
|
@ -1172,8 +1172,8 @@ UnicodeToEfiKeyFlushState (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts a stream of Unicode characters from a terminal input device into EFI Keys that
|
Converts a stream of Unicode characters from a terminal input device into EFI Keys that
|
||||||
can be read through the Simple Input Protocol.
|
can be read through the Simple Input Protocol.
|
||||||
|
|
||||||
The table below shows the keyboard input mappings that this function supports.
|
The table below shows the keyboard input mappings that this function supports.
|
||||||
If the ESC sequence listed in one of the columns is presented, then it is translated
|
If the ESC sequence listed in one of the columns is presented, then it is translated
|
||||||
into the corresponding EFI Scan Code. If a matching sequence is not found, then the raw
|
into the corresponding EFI Scan Code. If a matching sequence is not found, then the raw
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Implementation of translation upon VT-UTF8.
|
Implementation of translation upon VT-UTF8.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation. <BR>
|
Copyright (c) 2006 - 2009, Intel Corporation. <BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include "Terminal.h"
|
#include "Terminal.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
|
Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,
|
||||||
and insert them into Unicode FIFO.
|
and insert them into Unicode FIFO.
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
@param TerminalDevice The terminal device.
|
||||||
|
@ -55,7 +55,7 @@ VTUTF8RawDataToUnicode (
|
||||||
|
|
||||||
@param Utf8Device The terminal device.
|
@param Utf8Device The terminal device.
|
||||||
@param Utf8Char Returned valid VT-UTF8 characters set.
|
@param Utf8Char Returned valid VT-UTF8 characters set.
|
||||||
@param ValidBytes The count of returned VT-VTF8 characters.
|
@param ValidBytes The count of returned VT-VTF8 characters.
|
||||||
If ValidBytes is zero, no valid VT-UTF8 returned.
|
If ValidBytes is zero, no valid VT-UTF8 returned.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -125,6 +125,9 @@ GetOneValidUtf8Char (
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
//
|
||||||
|
// two-byte utf8 char go on
|
||||||
|
//
|
||||||
if ((Temp & 0xc0) == 0x80) {
|
if ((Temp & 0xc0) == 0x80) {
|
||||||
|
|
||||||
Utf8Char->Utf8_2[0] = Temp;
|
Utf8Char->Utf8_2[0] = Temp;
|
||||||
|
@ -138,15 +141,20 @@ GetOneValidUtf8Char (
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
//
|
||||||
|
// three-byte utf8 char go on
|
||||||
|
//
|
||||||
if ((Temp & 0xc0) == 0x80) {
|
if ((Temp & 0xc0) == 0x80) {
|
||||||
|
|
||||||
Utf8Char->Utf8_3[2 - Index] = Temp;
|
Utf8Char->Utf8_3[2 - Index] = Temp;
|
||||||
Index++;
|
Index++;
|
||||||
if (Index == 3) {
|
if (Index > 2) {
|
||||||
FetchFlag = FALSE;
|
FetchFlag = FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//
|
||||||
|
// reset *ValidBytes and Index to zero, let valid utf8 char search restart
|
||||||
|
//
|
||||||
*ValidBytes = 0;
|
*ValidBytes = 0;
|
||||||
Index = 0;
|
Index = 0;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +172,7 @@ GetOneValidUtf8Char (
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate VT-UTF8 characters into one Unicode character.
|
Translate VT-UTF8 characters into one Unicode character.
|
||||||
|
|
||||||
UTF8 Encoding Table
|
UTF8 Encoding Table
|
||||||
|
@ -176,7 +184,7 @@ GetOneValidUtf8Char (
|
||||||
|
|
||||||
@param Utf8Char VT-UTF8 character set needs translating.
|
@param Utf8Char VT-UTF8 character set needs translating.
|
||||||
@param ValidBytes The count of valid VT-UTF8 characters.
|
@param ValidBytes The count of valid VT-UTF8 characters.
|
||||||
@param UnicodeChar Returned unicode character.
|
@param UnicodeChar Returned unicode character.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
|
@ -237,7 +245,7 @@ Utf8ToUnicode (
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Translate one Unicode character into VT-UTF8 characters.
|
Translate one Unicode character into VT-UTF8 characters.
|
||||||
|
|
||||||
UTF8 Encoding Table
|
UTF8 Encoding Table
|
||||||
|
@ -301,8 +309,8 @@ UnicodeToUtf8 (
|
||||||
Check if input string is valid VT-UTF8 string.
|
Check if input string is valid VT-UTF8 string.
|
||||||
|
|
||||||
@param TerminalDevice The terminal device.
|
@param TerminalDevice The terminal device.
|
||||||
@param WString The input string.
|
@param WString The input string.
|
||||||
|
|
||||||
@retval EFI_SUCCESS If all input characters are valid.
|
@retval EFI_SUCCESS If all input characters are valid.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
Loading…
Reference in New Issue