#include "Terminal.h"\r
\r
\r
-\r
/**\r
Reads the next keystroke from the input device. The WaitForKey Event can\r
be used to test for existance of a keystroke via WaitForEvent () call.\r
\r
SerialInTimeOut = 0;\r
if (Mode->BaudRate != 0) {\r
+ //\r
+ // According to BAUD rate to calculate the timeout value.\r
+ //\r
SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate;\r
}\r
\r
}\r
}\r
//\r
- // check whether serial buffer is empty\r
+ // Check whether serial buffer is empty.\r
//\r
Status = SerialIo->GetControl (SerialIo, &Control);\r
\r
- if (0 != (Control & EFI_SERIAL_INPUT_BUFFER_EMPTY)) {\r
+ if ((Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) != 0) {\r
//\r
// Translate all the raw data in RawFIFO into EFI Key,\r
// according to different terminal type supported.\r
Size = 1;\r
*Output = 0;\r
\r
+ //\r
+ // Read one key from serial I/O device.\r
+ //\r
Status = SerialIo->Read (SerialIo, &Size, Output);\r
\r
if (EFI_ERROR (Status)) {\r
{\r
EFI_INPUT_KEY Key;\r
\r
- if (0 != (TerminalDevice->InputState & INPUT_STATE_ESC)) {\r
+ if ((TerminalDevice->InputState & INPUT_STATE_ESC) != 0) {\r
Key.ScanCode = SCAN_ESC;\r
Key.UnicodeChar = 0;\r
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
}\r
\r
- if (0 != (TerminalDevice->InputState & INPUT_STATE_CSI)) {\r
+ if ((TerminalDevice->InputState & INPUT_STATE_CSI) != 0) {\r
Key.ScanCode = SCAN_NULL;\r
Key.UnicodeChar = CSI;\r
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
}\r
\r
- if (0 != (TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET)) {\r
+ if ((TerminalDevice->InputState & INPUT_STATE_LEFTOPENBRACKET) != 0) {\r
Key.ScanCode = SCAN_NULL;\r
Key.UnicodeChar = LEFTOPENBRACKET;\r
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
}\r
\r
- if (0 != (TerminalDevice->InputState & INPUT_STATE_O)) {\r
+ if ((TerminalDevice->InputState & INPUT_STATE_O) != 0) {\r
Key.ScanCode = SCAN_NULL;\r
Key.UnicodeChar = 'O';\r
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
}\r
\r
- if (0 != (TerminalDevice->InputState & INPUT_STATE_2)) {\r
+ if ((TerminalDevice->InputState & INPUT_STATE_2) != 0) {\r
Key.ScanCode = SCAN_NULL;\r
Key.UnicodeChar = '2';\r
EfiKeyFiFoInsertOneKey (TerminalDevice, Key);\r
}\r
\r
+ //\r
+ // Cancel the timer.\r
+ //\r
gBS->SetTimer (\r
TerminalDevice->TwoSecondTimeOut,\r
TimerCancel,\r