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
|
||||
},
|
||||
0, // SerialInTimeOut
|
||||
{ // RawFiFo
|
||||
0,
|
||||
0,
|
||||
{ 0 }
|
||||
},
|
||||
{ // UnicodeFiFo
|
||||
0,
|
||||
0,
|
||||
{ 0 }
|
||||
},
|
||||
{ // EfiKeyFiFo
|
||||
0,
|
||||
0,
|
||||
{ {0} }
|
||||
},
|
||||
|
||||
NULL, // RawFifo
|
||||
NULL, // UnicodeFiFo
|
||||
NULL, // EfiKeyFiFo
|
||||
|
||||
NULL, // ControllerNameTable
|
||||
NULL, // TwoSecondTimeOut
|
||||
INPUT_STATE_DEFAULT,
|
||||
|
@ -424,12 +414,21 @@ TerminalDriverBindingStart (
|
|||
goto Error;
|
||||
}
|
||||
//
|
||||
// initialize the FIFO buffer used for accommodating
|
||||
// the pre-read pending characters
|
||||
// Allocates and initializes the FIFO buffer to be zero, used for accommodating
|
||||
// the pre-read pending characters.
|
||||
//
|
||||
InitializeRawFiFo (TerminalDevice);
|
||||
InitializeUnicodeFiFo (TerminalDevice);
|
||||
InitializeEfiKeyFiFo (TerminalDevice);
|
||||
TerminalDevice->RawFiFo = AllocateZeroPool (sizeof (RAW_DATA_FIFO));
|
||||
if (TerminalDevice->RawFiFo == NULL) {
|
||||
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
|
||||
|
@ -704,6 +703,16 @@ Error:
|
|||
|
||||
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) {
|
||||
FreeUnicodeStringTable (TerminalDevice->ControllerNameTable);
|
||||
}
|
||||
|
@ -1279,58 +1288,6 @@ SetTerminalDevicePath (
|
|||
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.
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ typedef struct {
|
|||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
|
||||
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
|
||||
UINTN SerialInTimeOut;
|
||||
RAW_DATA_FIFO RawFiFo;
|
||||
UNICODE_FIFO UnicodeFiFo;
|
||||
EFI_KEY_FIFO EfiKeyFiFo;
|
||||
RAW_DATA_FIFO *RawFiFo;
|
||||
UNICODE_FIFO *UnicodeFiFo;
|
||||
EFI_KEY_FIFO *EfiKeyFiFo;
|
||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||
EFI_EVENT TwoSecondTimeOut;
|
||||
UINT32 InputState;
|
||||
|
@ -877,39 +877,6 @@ SetTerminalDevicePath (
|
|||
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.
|
||||
|
||||
|
|
|
@ -120,11 +120,11 @@ TerminalConInReset (
|
|||
Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);
|
||||
|
||||
//
|
||||
// clear all the internal buffer for keys
|
||||
// Make all the internal buffer empty for keys
|
||||
//
|
||||
InitializeRawFiFo (TerminalDevice);
|
||||
InitializeUnicodeFiFo (TerminalDevice);
|
||||
InitializeEfiKeyFiFo (TerminalDevice);
|
||||
TerminalDevice->RawFiFo->Head = TerminalDevice->RawFiFo->Tail;
|
||||
TerminalDevice->UnicodeFiFo->Head = TerminalDevice->UnicodeFiFo->Tail;
|
||||
TerminalDevice->EfiKeyFiFo->Head = TerminalDevice->EfiKeyFiFo->Tail;
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
|
@ -746,7 +746,7 @@ RawFiFoInsertOneKey (
|
|||
{
|
||||
UINT8 Tail;
|
||||
|
||||
Tail = TerminalDevice->RawFiFo.Tail;
|
||||
Tail = TerminalDevice->RawFiFo->Tail;
|
||||
|
||||
if (IsRawFiFoFull (TerminalDevice)) {
|
||||
//
|
||||
|
@ -755,9 +755,9 @@ RawFiFoInsertOneKey (
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
TerminalDevice->RawFiFo.Data[Tail] = Input;
|
||||
TerminalDevice->RawFiFo->Data[Tail] = Input;
|
||||
|
||||
TerminalDevice->RawFiFo.Tail = (UINT8) ((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));
|
||||
TerminalDevice->RawFiFo->Tail = (UINT8) ((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ RawFiFoRemoveOneKey (
|
|||
{
|
||||
UINT8 Head;
|
||||
|
||||
Head = TerminalDevice->RawFiFo.Head;
|
||||
Head = TerminalDevice->RawFiFo->Head;
|
||||
|
||||
if (IsRawFiFoEmpty (TerminalDevice)) {
|
||||
//
|
||||
|
@ -790,9 +790,9 @@ RawFiFoRemoveOneKey (
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
*Output = TerminalDevice->RawFiFo.Data[Head];
|
||||
*Output = TerminalDevice->RawFiFo->Data[Head];
|
||||
|
||||
TerminalDevice->RawFiFo.Head = (UINT8) ((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));
|
||||
TerminalDevice->RawFiFo->Head = (UINT8) ((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -811,7 +811,7 @@ IsRawFiFoEmpty (
|
|||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
{
|
||||
if (TerminalDevice->RawFiFo.Head == TerminalDevice->RawFiFo.Tail) {
|
||||
if (TerminalDevice->RawFiFo->Head == TerminalDevice->RawFiFo->Tail) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
|
@ -835,8 +835,8 @@ IsRawFiFoFull (
|
|||
UINT8 Tail;
|
||||
UINT8 Head;
|
||||
|
||||
Tail = TerminalDevice->RawFiFo.Tail;
|
||||
Head = TerminalDevice->RawFiFo.Head;
|
||||
Tail = TerminalDevice->RawFiFo->Tail;
|
||||
Head = TerminalDevice->RawFiFo->Head;
|
||||
|
||||
if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {
|
||||
|
||||
|
@ -865,7 +865,7 @@ EfiKeyFiFoInsertOneKey (
|
|||
{
|
||||
UINT8 Tail;
|
||||
|
||||
Tail = TerminalDevice->EfiKeyFiFo.Tail;
|
||||
Tail = TerminalDevice->EfiKeyFiFo->Tail;
|
||||
|
||||
if (IsEfiKeyFiFoFull (TerminalDevice)) {
|
||||
//
|
||||
|
@ -874,9 +874,9 @@ EfiKeyFiFoInsertOneKey (
|
|||
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;
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ EfiKeyFiFoRemoveOneKey (
|
|||
{
|
||||
UINT8 Head;
|
||||
|
||||
Head = TerminalDevice->EfiKeyFiFo.Head;
|
||||
Head = TerminalDevice->EfiKeyFiFo->Head;
|
||||
|
||||
if (IsEfiKeyFiFoEmpty (TerminalDevice)) {
|
||||
//
|
||||
|
@ -910,9 +910,9 @@ EfiKeyFiFoRemoveOneKey (
|
|||
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;
|
||||
}
|
||||
|
@ -931,7 +931,7 @@ IsEfiKeyFiFoEmpty (
|
|||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
{
|
||||
if (TerminalDevice->EfiKeyFiFo.Head == TerminalDevice->EfiKeyFiFo.Tail) {
|
||||
if (TerminalDevice->EfiKeyFiFo->Head == TerminalDevice->EfiKeyFiFo->Tail) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
|
@ -955,8 +955,8 @@ IsEfiKeyFiFoFull (
|
|||
UINT8 Tail;
|
||||
UINT8 Head;
|
||||
|
||||
Tail = TerminalDevice->EfiKeyFiFo.Tail;
|
||||
Head = TerminalDevice->EfiKeyFiFo.Head;
|
||||
Tail = TerminalDevice->EfiKeyFiFo->Tail;
|
||||
Head = TerminalDevice->EfiKeyFiFo->Head;
|
||||
|
||||
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
|
||||
|
||||
|
@ -985,7 +985,7 @@ UnicodeFiFoInsertOneKey (
|
|||
{
|
||||
UINT8 Tail;
|
||||
|
||||
Tail = TerminalDevice->UnicodeFiFo.Tail;
|
||||
Tail = TerminalDevice->UnicodeFiFo->Tail;
|
||||
|
||||
if (IsUnicodeFiFoFull (TerminalDevice)) {
|
||||
//
|
||||
|
@ -994,9 +994,9 @@ UnicodeFiFoInsertOneKey (
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
TerminalDevice->UnicodeFiFo.Data[Tail] = Input;
|
||||
TerminalDevice->UnicodeFiFo->Data[Tail] = Input;
|
||||
|
||||
TerminalDevice->UnicodeFiFo.Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
|
||||
TerminalDevice->UnicodeFiFo->Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1019,7 +1019,7 @@ UnicodeFiFoRemoveOneKey (
|
|||
{
|
||||
UINT8 Head;
|
||||
|
||||
Head = TerminalDevice->UnicodeFiFo.Head;
|
||||
Head = TerminalDevice->UnicodeFiFo->Head;
|
||||
|
||||
if (IsUnicodeFiFoEmpty (TerminalDevice)) {
|
||||
//
|
||||
|
@ -1029,9 +1029,9 @@ UnicodeFiFoRemoveOneKey (
|
|||
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;
|
||||
}
|
||||
|
@ -1050,7 +1050,7 @@ IsUnicodeFiFoEmpty (
|
|||
TERMINAL_DEV *TerminalDevice
|
||||
)
|
||||
{
|
||||
if (TerminalDevice->UnicodeFiFo.Head == TerminalDevice->UnicodeFiFo.Tail) {
|
||||
if (TerminalDevice->UnicodeFiFo->Head == TerminalDevice->UnicodeFiFo->Tail) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
|
@ -1074,8 +1074,8 @@ IsUnicodeFiFoFull (
|
|||
UINT8 Tail;
|
||||
UINT8 Head;
|
||||
|
||||
Tail = TerminalDevice->UnicodeFiFo.Tail;
|
||||
Head = TerminalDevice->UnicodeFiFo.Head;
|
||||
Tail = TerminalDevice->UnicodeFiFo->Tail;
|
||||
Head = TerminalDevice->UnicodeFiFo->Head;
|
||||
|
||||
if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
|
||||
|
||||
|
@ -1101,8 +1101,8 @@ UnicodeFiFoGetKeyCount (
|
|||
UINT8 Tail;
|
||||
UINT8 Head;
|
||||
|
||||
Tail = TerminalDevice->UnicodeFiFo.Tail;
|
||||
Head = TerminalDevice->UnicodeFiFo.Head;
|
||||
Tail = TerminalDevice->UnicodeFiFo->Tail;
|
||||
Head = TerminalDevice->UnicodeFiFo->Head;
|
||||
|
||||
if (Tail >= Head) {
|
||||
return (UINT8) (Tail - Head);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
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
|
||||
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
|
||||
|
@ -125,6 +125,9 @@ GetOneValidUtf8Char (
|
|||
break;
|
||||
|
||||
case 2:
|
||||
//
|
||||
// two-byte utf8 char go on
|
||||
//
|
||||
if ((Temp & 0xc0) == 0x80) {
|
||||
|
||||
Utf8Char->Utf8_2[0] = Temp;
|
||||
|
@ -138,15 +141,20 @@ GetOneValidUtf8Char (
|
|||
break;
|
||||
|
||||
case 3:
|
||||
//
|
||||
// three-byte utf8 char go on
|
||||
//
|
||||
if ((Temp & 0xc0) == 0x80) {
|
||||
|
||||
Utf8Char->Utf8_3[2 - Index] = Temp;
|
||||
Index++;
|
||||
if (Index == 3) {
|
||||
if (Index > 2) {
|
||||
FetchFlag = FALSE;
|
||||
}
|
||||
} else {
|
||||
|
||||
//
|
||||
// reset *ValidBytes and Index to zero, let valid utf8 char search restart
|
||||
//
|
||||
*ValidBytes = 0;
|
||||
Index = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue