code scrub.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5518 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2008-07-18 08:20:08 +00:00
parent ca4eb92e3b
commit ab76200c05
4 changed files with 77 additions and 75 deletions

View File

@ -119,16 +119,16 @@ TERMINAL_DEV gTerminalDevTemplate = {
/**
Test to see if this driver supports ControllerHandle.
Test to see if this driver supports Controller.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to test
@param Controller Handle of device to test
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver supports this device
@retval EFI_ALREADY_STARTED This driver is already running on this device
@retval other This driver does not support this device
@retval EFI_SUCCESS This driver supports this device.
@retval EFI_ALREADY_STARTED This driver is already running on this device.
@retval other This driver does not support this device.
**/
EFI_STATUS
@ -230,19 +230,19 @@ TerminalDriverBindingSupported (
}
/**
Start this driver on ControllerHandle by opening a Serial IO protocol,
Start this driver on Controller by opening a Serial IO protocol,
reading Device Path, and creating a child handle with a Simple Text In,
Simple Text In Ex and Simple Text Out protocol, and device path protocol.
And store Console Device Environment Variables.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to bind driver to
@param Controller Handle of device to bind driver to
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver is added to ControllerHandle
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
@retval other This driver does not support this device
@retval EFI_SUCCESS This driver is added to Controller.
@retval EFI_ALREADY_STARTED This driver is already running on Controller.
@retval other This driver does not support this device.
**/
EFI_STATUS
@ -383,7 +383,7 @@ TerminalDriverBindingStart (
ASSERT (TerminalType <= VTUTF8TYPE);
CopyMem (&DefaultNode->Guid, gTerminalType[TerminalType], sizeof (EFI_GUID));
RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL*)DefaultNode;
RemainingDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DefaultNode;
} else {
//
// Use the RemainingDevicePath to determine the terminal type
@ -753,17 +753,17 @@ Error:
}
/**
Stop this driver on ControllerHandle 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
Console Device Environment Variables.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to stop driver on
@param Controller Handle of device to stop driver on
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param ChildHandleBuffer List of Child Handles to Stop.
@retval EFI_SUCCESS This driver is removed ControllerHandle.
@retval EFI_SUCCESS This driver is removed Controller.
@retval other This driver could not be removed from this device.
**/
@ -972,7 +972,7 @@ TerminalFreeNotifyList (
TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE
);
RemoveEntryList (ListHead->ForwardLink);
gBS->FreePool (NotifyNode);
FreePool (NotifyNode);
}
return EFI_SUCCESS;
@ -1172,8 +1172,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.
@return Caller is repsoncible freeing the buffer.
@retval NULL Variable was not read
Caller is repsoncible freeing the buffer. If variable was not read,
NULL regturned.
**/
VOID *
@ -1263,53 +1263,40 @@ SetTerminalDevicePath (
Node.Header.SubType = MSG_VENDOR_DP;
//
// generate terminal device path node according to terminal type.
// Generate terminal device path node according to terminal type.
//
switch (TerminalType) {
case PCANSITYPE:
CopyMem (
&Node.Guid,
&gEfiPcAnsiGuid,
sizeof (EFI_GUID)
);
CopyGuid (&Node.Guid, &gEfiPcAnsiGuid);
break;
case VT100TYPE:
CopyMem (
&Node.Guid,
&gEfiVT100Guid,
sizeof (EFI_GUID)
);
CopyGuid (&Node.Guid, &gEfiVT100Guid);
break;
case VT100PLUSTYPE:
CopyMem (
&Node.Guid,
&gEfiVT100PlusGuid,
sizeof (EFI_GUID)
);
CopyGuid (&Node.Guid, &gEfiVT100PlusGuid);
break;
case VTUTF8TYPE:
CopyMem (
&Node.Guid,
&gEfiVTUTF8Guid,
sizeof (EFI_GUID)
);
CopyGuid (&Node.Guid, &gEfiVTUTF8Guid);
break;
default:
return EFI_UNSUPPORTED;
break;
}
//
// Get VENDOR_DEVCIE_PATH size and put into Node.Header
//
SetDevicePathNodeLength (
&Node.Header,
sizeof (VENDOR_DEVICE_PATH)
);
//
// append the terminal node onto parent device path
// Append the terminal node onto parent device path
// to generate a complete terminal device path.
//
*TerminalDevicePath = AppendDevicePathNode (
@ -1384,8 +1371,8 @@ InitializeEfiKeyFiFo (
/**
The user Entry Point for module Terminal. The user code starts with this function.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval other Some error occurs when executing this entry point.

View File

@ -603,40 +603,40 @@ TerminalConOutEnableCursor (
;
/**
Test to see if this driver supports ControllerHandle.
Test to see if this driver supports Controller.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to test
@param Controller Handle of device to test
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver supports this device
@retval EFI_ALREADY_STARTED This driver is already running on this device
@retval other This driver does not support this device
@retval EFI_SUCCESS This driver supports this device.
@retval EFI_ALREADY_STARTED This driver is already running on this device.
@retval other This driver does not support this device.
**/
EFI_STATUS
EFIAPI
TerminalDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Start this driver on ControllerHandle by opening a Serial IO protocol,
Start this driver on Controller by opening a Serial IO protocol,
reading Device Path, and creating a child handle with a Simple Text In,
Simple Text In Ex and Simple Text Out protocol, and device path protocol.
And store Console Device Environment Variables.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to bind driver to
@param Controller Handle of device to bind driver to
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver is added to ControllerHandle
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
@retval other This driver does not support this device
@retval EFI_SUCCESS This driver is added to Controller.
@retval EFI_ALREADY_STARTED This driver is already running on Controller.
@retval other This driver does not support this device.
**/
EFI_STATUS
@ -647,18 +647,19 @@ TerminalDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Stop this driver on ControllerHandle 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
Console Device Environment Variables.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to stop driver on
@param Controller Handle of device to stop driver on
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param ChildHandleBuffer List of Child Handles to Stop.
@retval EFI_SUCCESS This driver is removed ControllerHandle.
@retval EFI_SUCCESS This driver is removed Controller.
@retval other This driver could not be removed from this device.
**/
@ -859,8 +860,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.
@return Caller is repsoncible freeing the buffer.
@retval NULL Variable was not read
Caller is repsoncible freeing the buffer. If variable was not read,
NULL regturned.
**/
VOID *
@ -1262,7 +1263,7 @@ AnsiRawDataToUnicode (
**/
VOID
UnicodeToEfiKey (
IN TERMINAL_DEV *PcAnsiDevice
IN TERMINAL_DEV *TerminalDevice
)
;

View File

@ -15,7 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Terminal.h"
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existance of a keystroke via WaitForEvent () call.
@ -601,6 +600,9 @@ TerminalConInCheckForKey (
SerialInTimeOut = 0;
if (Mode->BaudRate != 0) {
//
// According to BAUD rate to calculate the timeout value.
//
SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;
}
@ -621,11 +623,11 @@ TerminalConInCheckForKey (
}
}
//
// check whether serial buffer is empty
// Check whether serial buffer is empty.
//
Status = SerialIo->GetControl (SerialIo, &Control);
if (0 != (Control & EFI_SERIAL_INPUT_BUFFER_EMPTY)) {
if ((Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) != 0) {
//
// Translate all the raw data in RawFIFO into EFI Key,
// according to different terminal type supported.
@ -701,6 +703,9 @@ GetOneKeyFromSerial (
Size = 1;
*Output = 0;
//
// Read one key from serial I/O device.
//
Status = SerialIo->Read (SerialIo, &Size, Output);
if (EFI_ERROR (Status)) {
@ -1119,36 +1124,39 @@ UnicodeToEfiKeyFlushState (
{
EFI_INPUT_KEY Key;
if (0 != (TerminalDevice->InputState & INPUT_STATE_ESC)) {
if ((TerminalDevice->InputState & INPUT_STATE_ESC) != 0) {
Key.ScanCode = SCAN_ESC;
Key.UnicodeChar = 0;
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if (0 != (TerminalDevice->InputState & INPUT_STATE_CSI)) {
if ((TerminalDevice->InputState & INPUT_STATE_CSI) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = CSI;
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if (0 != (TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET)) {
if ((TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = LEFTOPENBRACKET;
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if (0 != (TerminalDevice->InputState & INPUT_STATE_O)) {
if ((TerminalDevice->InputState & INPUT_STATE_O) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = 'O';
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
if (0 != (TerminalDevice->InputState & INPUT_STATE_2)) {
if ((TerminalDevice->InputState & INPUT_STATE_2) != 0) {
Key.ScanCode = SCAN_NULL;
Key.UnicodeChar = '2';
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);
}
//
// Cancel the timer.
//
gBS->SetTimer (
TerminalDevice->TwoSecondTimeOut,
TimerCancel,

View File

@ -70,18 +70,18 @@ STATIC UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {
{ GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v' },
{ GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<' },
{ ARROW_LEFT, 0x3c, L'<' },
{ ARROW_UP, 0x18, L'^' },
{ ARROW_RIGHT, 0x3e, L'>' },
{ ARROW_DOWN, 0x19, L'v' },
{ ARROW_LEFT, 0x3c, L'<' },
{ ARROW_UP, 0x18, L'^' },
{ ARROW_RIGHT, 0x3e, L'>' },
{ ARROW_DOWN, 0x19, 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 };
STATIC CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };
STATIC CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
STATIC CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };
STATIC CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };
//
// Body of the ConOut functions
@ -89,6 +89,7 @@ CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
If ExtendeVerification is TRUE, then perform dependent serial device reset,
and set display mode to mode 0.
If ExtendedVerification is FALSE, only set display mode to mode 0.
@ -152,6 +153,7 @@ TerminalConOutReset (
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
The Unicode string will be converted to terminal expressible data stream
and send to terminal via serial port.
@ -335,6 +337,7 @@ OutputError:
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
If one of the characters in the *Wstring is
neither valid Unicode drawing characters,
not ASCII code, then this function will return
@ -385,6 +388,7 @@ TerminalConOutTestString (
/**
Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
It returns information for an available text mode
that the terminal supports.
In this driver, we support text mode 80x25 (mode 0),
@ -433,6 +437,7 @@ TerminalConOutQueryMode (
/**
Implements EFI_SIMPLE_TEXT_OUT.SetMode().
Set the terminal to a specified display mode.
In this driver, we only support mode 0.
@ -782,6 +787,7 @@ TerminalConOutSetCursorPosition (
/**
Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
In this driver, the cursor cannot be hidden.
@param This Indicates the calling context.