Code scrub for Universal\Console\TerminalDxe.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7066 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
gikidy 2008-12-17 09:34:06 +00:00
parent 6c94a00d0e
commit 11baadb671
6 changed files with 110 additions and 97 deletions

View File

@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Terminal.h"
/**
Translate all raw data in the Raw FIFI into unicode, and insert
Translate all raw data in the Raw FIFO into unicode, and insert
them into Unicode FIFO.
@param TerminalDevice The terminal device.

View File

@ -1,5 +1,5 @@
/** @file
Produces Simple Text Input Protocl, Simple Text Input Extended Protocol and
Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
Simple Text Output Protocol upon Serial IO Protocol.
Copyright (c) 2006 - 2008, Intel Corporation. <BR>
@ -62,30 +62,30 @@ TERMINAL_DEV mTerminalDevTemplate = {
},
{ // SimpleTextOutputMode
1, // MaxMode
0, // Mode?
0, // Mode
EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK), // Attribute
0, // CursorColumn
0, // CursorRow
TRUE // CursorVisible
},
0,
{
0, // SerialInTimeOut
{ // RawFiFo
0,
0,
{ 0 }
},
{
{ // UnicodeFiFo
0,
0,
{ 0 }
},
{
{ // EfiKeyFiFo
0,
0,
{ {0} }
},
NULL, // ControllerNameTable
NULL,
NULL, // TwoSecondTimeOut
INPUT_STATE_DEFAULT,
RESET_STATE_DEFAULT,
FALSE,
@ -97,27 +97,12 @@ TERMINAL_DEV mTerminalDevTemplate = {
TerminalConInRegisterKeyNotify,
TerminalConInUnregisterKeyNotify,
},
{
{ // NotifyList
NULL,
NULL,
}
};
/**
Free notify functions list.
@param ListHead The list head
@retval EFI_SUCCESS Free the notify list successfully.
@retval EFI_INVALID_PARAMETER ListHead is NULL.
**/
EFI_STATUS
TerminalFreeNotifyList (
IN OUT LIST_ENTRY *ListHead
);
/**
Test to see if this driver supports Controller.
@ -266,6 +251,7 @@ TerminalDriverBindingStart (
UINTN EntryCount;
UINTN Index;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
TerminalDevice = NULL;
DefaultNode = NULL;
@ -504,50 +490,52 @@ TerminalDriverBindingStart (
//
// Simple Text Output Protocol
//
TerminalDevice->SimpleTextOutput.Reset = TerminalConOutReset;
TerminalDevice->SimpleTextOutput.OutputString = TerminalConOutOutputString;
TerminalDevice->SimpleTextOutput.TestString = TerminalConOutTestString;
TerminalDevice->SimpleTextOutput.QueryMode = TerminalConOutQueryMode;
TerminalDevice->SimpleTextOutput.SetMode = TerminalConOutSetMode;
TerminalDevice->SimpleTextOutput.SetAttribute = TerminalConOutSetAttribute;
TerminalDevice->SimpleTextOutput.ClearScreen = TerminalConOutClearScreen;
TerminalDevice->SimpleTextOutput.SetCursorPosition = TerminalConOutSetCursorPosition;
TerminalDevice->SimpleTextOutput.EnableCursor = TerminalConOutEnableCursor;
TerminalDevice->SimpleTextOutput.Mode = &TerminalDevice->SimpleTextOutputMode;
SimpleTextOutput = TerminalDevice->SimpleTextOutput;
SimpleTextOutput.Reset = TerminalConOutReset;
SimpleTextOutput.OutputString = TerminalConOutOutputString;
SimpleTextOutput.TestString = TerminalConOutTestString;
SimpleTextOutput.QueryMode = TerminalConOutQueryMode;
SimpleTextOutput.SetMode = TerminalConOutSetMode;
SimpleTextOutput.SetAttribute = TerminalConOutSetAttribute;
SimpleTextOutput.ClearScreen = TerminalConOutClearScreen;
SimpleTextOutput.SetCursorPosition = TerminalConOutSetCursorPosition;
SimpleTextOutput.EnableCursor = TerminalConOutEnableCursor;
SimpleTextOutput.Mode = &TerminalDevice->SimpleTextOutputMode;
TerminalDevice->SimpleTextOutputMode.MaxMode = 3;
//
// For terminal devices, cursor is always visible
//
TerminalDevice->SimpleTextOutputMode.CursorVisible = TRUE;
Status = TerminalDevice->SimpleTextOutput.SetAttribute (
&TerminalDevice->SimpleTextOutput,
EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)
);
Status = SimpleTextOutput.SetAttribute (
&TerminalDevice->SimpleTextOutput,
EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)
);
if (EFI_ERROR (Status)) {
goto ReportError;
}
Status = TerminalDevice->SimpleTextOutput.Reset (
&TerminalDevice->SimpleTextOutput,
FALSE
);
Status = SimpleTextOutput.Reset (
&TerminalDevice->SimpleTextOutput,
FALSE
);
if (EFI_ERROR (Status)) {
goto ReportError;
}
Status = TerminalDevice->SimpleTextOutput.SetMode (
&TerminalDevice->SimpleTextOutput,
0
);
Status = SimpleTextOutput.SetMode (
&TerminalDevice->SimpleTextOutput,
0
);
if (EFI_ERROR (Status)) {
goto ReportError;
}
Status = TerminalDevice->SimpleTextOutput.EnableCursor (
&TerminalDevice->SimpleTextOutput,
TRUE
);
Status = SimpleTextOutput.EnableCursor (
&TerminalDevice->SimpleTextOutput,
TRUE
);
if (EFI_ERROR (Status)) {
goto ReportError;
}
@ -983,7 +971,7 @@ TerminalFreeNotifyList (
Update terminal device path in Console Device Environment Variables.
@param VariableName The Console Device Environment Variable.
@param ParentDevicePath The terminal devcie path to be updated.
@param ParentDevicePath The terminal device path to be updated.
@return None.
@ -1048,7 +1036,7 @@ TerminalUpdateConsoleDevVariable (
Remove terminal device path from Console Device Environment Variables.
@param VariableName Console Device Environment Variables.
@param ParentDevicePath The terminal devcie path to be updated.
@param ParentDevicePath The terminal device path to be updated.
@return None.
@ -1112,7 +1100,7 @@ TerminalRemoveConsoleDevVariable (
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
//
// Compare the genterated device path to the current device path instance
// Compare the generated device path to the current device path instance
//
if (TempDevicePath != NULL) {
if (CompareMem (Instance, TempDevicePath, InstanceSize) == 0) {
@ -1172,8 +1160,8 @@ TerminalRemoveConsoleDevVariable (
@param VariableSize Returns the size of the EFI variable that was read
@return Dynamically allocated memory that contains a copy of the EFI variable.
Caller is repsoncible freeing the buffer. If variable was not read,
NULL regturned.
Caller is responsible freeing the buffer. If variable was not read,
NULL returned.
**/
VOID *
@ -1238,10 +1226,10 @@ TerminalGetVariableAndSize (
}
/**
Build termial device path according to terminal type.
Build terminal device path according to terminal type.
@param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.
@param ParentDevicePath Parent devcie path.
@param ParentDevicePath Parent device path.
@param TerminalDevicePath Returned terminal device path, if building successfully.
@retval EFI_UNSUPPORTED Terminal does not belong to the supported type.
@ -1324,7 +1312,7 @@ InitializeRawFiFo (
)
{
//
// Make the raw fifo empty.
// Make the raw FIFO empty.
//
TerminalDevice->RawFiFo.Head = TerminalDevice->RawFiFo.Tail;
}
@ -1343,7 +1331,7 @@ InitializeUnicodeFiFo (
)
{
//
// Make the unicode fifo empty
// Make the unicode FIFO empty
//
TerminalDevice->UnicodeFiFo.Head = TerminalDevice->UnicodeFiFo.Tail;
}
@ -1362,7 +1350,7 @@ InitializeEfiKeyFiFo (
)
{
//
// Make the efi key fifo empty
// Make the efi key FIFO empty
//
TerminalDevice->EfiKeyFiFo.Head = TerminalDevice->EfiKeyFiFo.Tail;
}
@ -1400,6 +1388,5 @@ InitializeTerminal(
);
ASSERT_EFI_ERROR (Status);
return Status;
}

View File

@ -265,7 +265,7 @@ TerminalConInWaitForKeyEx (
//
/**
Reset the input device and optionaly run diagnostics
Reset the input device and optionally run diagnostics
@param This Protocol instance pointer.
@param ExtendedVerification Driver may perform diagnostics on reset.
@ -284,7 +284,7 @@ TerminalConInResetEx (
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existance of a keystroke via WaitForEvent () call.
be used to test for existence of a keystroke via WaitForEvent () call.
@param This Protocol instance pointer.
@param KeyData A pointer to a buffer that is filled in with the
@ -292,7 +292,7 @@ TerminalConInResetEx (
pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due
to hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
@ -652,6 +652,20 @@ TerminalDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
);
/**
Free notify functions list.
@param ListHead The list head
@retval EFI_SUCCESS Free the notify list successfully.
@retval EFI_INVALID_PARAMETER ListHead is NULL.
**/
EFI_STATUS
TerminalFreeNotifyList (
IN OUT LIST_ENTRY *ListHead
);
/**
Retrieves a Unicode string that is the user readable name of the driver.
@ -790,7 +804,7 @@ TerminalComponentNameGetControllerName (
@retval EFI_SUCCESS There is key pending.
@retval EFI_NOT_READY There is no key pending.
@retval EFI_DEVICE_ERROR If Serial IO is not attched to serial device.
@retval EFI_DEVICE_ERROR If Serial IO is not attached to serial device.
**/
EFI_STATUS
@ -802,7 +816,7 @@ TerminalConInCheckForKey (
Update terminal device path in Console Device Environment Variables.
@param VariableName The Console Device Environment Variable.
@param ParentDevicePath The terminal devcie path to be updated.
@param ParentDevicePath The terminal device path to be updated.
@return None.
@ -852,7 +866,7 @@ TerminalGetVariableAndSize (
Build termial device path according to terminal type.
@param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.
@param ParentDevicePath Parent devcie path.
@param ParentDevicePath Parent device path.
@param TerminalDevicePath Returned terminal device path, if building successfully.
@retval EFI_UNSUPPORTED Terminal does not belong to the supported type.
@ -1277,9 +1291,9 @@ VTUTF8TestString (
UTF8 Encoding Table
Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
@param Unicode Unicode character need translating.
@ -1318,9 +1332,9 @@ GetOneValidUtf8Char (
UTF8 Encoding Table
Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding
0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx
8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx
12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx
@param Utf8Char VT-UTF8 character set needs translating.

View File

@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existance of a keystroke via WaitForEvent () call.
be used to test for existence of a keystroke via WaitForEvent () call.
@param TerminalDevice Terminal driver private structure
@param KeyData A pointer to a buffer that is filled in with the
@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due
to hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
@ -39,6 +39,7 @@ ReadKeyStrokeWorker (
{
EFI_STATUS Status;
LIST_ENTRY *Link;
LIST_ENTRY *NotifyList;
TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
if (KeyData == NULL) {
@ -66,7 +67,8 @@ ReadKeyStrokeWorker (
//
// Invoke notification functions if exist
//
for (Link = TerminalDevice->NotifyList.ForwardLink; Link != &TerminalDevice->NotifyList; Link = Link->ForwardLink) {
NotifyList = &TerminalDevice->NotifyList;
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList,Link); Link = GetNextNode (NotifyList,Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
@ -177,6 +179,8 @@ TerminalConInReadKeyStroke (
/**
Check if the key already has been registered.
If both RegsiteredData and InputData is NULL, then ASSERT().
@param RegsiteredData A pointer to a buffer that is filled in with the
keystroke state data for the key that was
@ -237,7 +241,7 @@ TerminalConInWaitForKeyEx (
//
/**
Reset the input device and optionaly run diagnostics
Reset the input device and optionally run diagnostics
@param This Protocol instance pointer.
@param ExtendedVerification Driver may perform diagnostics on reset.
@ -271,7 +275,7 @@ TerminalConInResetEx (
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existance of a keystroke via WaitForEvent () call.
be used to test for existence of a keystroke via WaitForEvent () call.
@param This Protocol instance pointer.
@param KeyData A pointer to a buffer that is filled in with the
@ -279,7 +283,7 @@ TerminalConInResetEx (
pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due
to hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
@ -349,7 +353,7 @@ TerminalConInSetState (
@retval EFI_SUCCESS The notification function was registered
successfully.
@retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
@retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necessary data
structures.
@retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.
@ -367,6 +371,7 @@ TerminalConInRegisterKeyNotify (
TERMINAL_DEV *TerminalDevice;
TERMINAL_CONSOLE_IN_EX_NOTIFY *NewNotify;
LIST_ENTRY *Link;
LIST_ENTRY *NotifyList;
TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
@ -378,7 +383,8 @@ TerminalConInRegisterKeyNotify (
//
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
//
for (Link = TerminalDevice->NotifyList.ForwardLink; Link != &TerminalDevice->NotifyList; Link = Link->ForwardLink) {
NotifyList = &TerminalDevice->NotifyList;
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList,Link); Link = GetNextNode (NotifyList,Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
@ -445,7 +451,8 @@ TerminalConInUnregisterKeyNotify (
TERMINAL_DEV *TerminalDevice;
LIST_ENTRY *Link;
TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
LIST_ENTRY *NotifyList;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -464,7 +471,8 @@ TerminalConInUnregisterKeyNotify (
TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
for (Link = TerminalDevice->NotifyList.ForwardLink; Link != &TerminalDevice->NotifyList; Link = Link->ForwardLink) {
NotifyList = &TerminalDevice->NotifyList;
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList,Link); Link = GetNextNode (NotifyList,Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
@ -568,7 +576,7 @@ TerminalConInWaitForKey (
@retval EFI_SUCCESS There is key pending.
@retval EFI_NOT_READY There is no key pending.
@retval EFI_DEVICE_ERROR If Serial IO is not attched to serial device.
@retval EFI_DEVICE_ERROR If Serial IO is not attached to serial device.
**/
EFI_STATUS
@ -682,7 +690,7 @@ TerminalConInCheckForKey (
/**
Get one key out of serial buffer.
@param SerialIo Serial I/O protocl attached to the serial device.
@param SerialIo Serial I/O protocol attached to the serial device.
@param Output The fetched key.
@return EFI_NOT_READY If serial buffer is empty.
@ -1123,32 +1131,35 @@ UnicodeToEfiKeyFlushState (
)
{
EFI_INPUT_KEY Key;
if ((TerminalDevice->InputState & INPUT_STATE_ESC) != 0) {
UINT32 InputState;
InputState = TerminalDevice->InputState;
if ((InputState & INPUT_STATE_ESC) != 0) {
Key.ScanCode = SCAN_ESC;
Key.UnicodeChar = 0;
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if ((TerminalDevice->InputState & INPUT_STATE_CSI) != 0) {
if ((InputState & INPUT_STATE_CSI) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = CSI;
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if ((TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET) != 0) {
if ((InputState & INPUT_STATE_LEFTOPENBRACKET) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = LEFTOPENBRACKET;
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if ((TerminalDevice->InputState & INPUT_STATE_O) != 0) {
if ((InputState & INPUT_STATE_O) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = 'O';
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if ((TerminalDevice->InputState & INPUT_STATE_2) != 0) {
if ((InputState & INPUT_STATE_2) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = '2';
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
@ -1173,7 +1184,7 @@ UnicodeToEfiKeyFlushState (
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
into the coorespoding 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
key strokes are converted into EFI Keys.
2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not

View File

@ -540,7 +540,7 @@ TerminalConOutSetAttribute (
//
// Skip outputting the command string for the same attribute
// It improves the terminal performance siginificantly
// It improves the terminal performance significantly
//
if (This->Mode->Attribute == (INT32) Attribute) {
return EFI_SUCCESS;

View File

@ -1,9 +1,10 @@
#/** @file
# Component description file for Terminal module.
#
# This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).
# Copyright (c) 2006 - 2008, Intel Corporation
#
# Component description file for Terminal module.
#
# This driver installs Simple Text In/Out protocol for terminal devices (serial devices or hotplug devices).
#
# Copyright (c) 2006 - 2008, Intel Corporation
# 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