/** @file\r
Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.\r
\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
pressed.\r
\r
@retval TRUE Key be pressed matches a registered key.\r
- @retval FLASE Match failed.\r
+ @retval FALSE Match failed.\r
\r
**/\r
BOOLEAN\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ if ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
return EFI_SUCCESS;\r
}\r
\r
case PCANSITYPE:\r
case VT100TYPE:\r
case VT100PLUSTYPE:\r
+ case TTYTERMTYPE:\r
AnsiRawDataToUnicode (TerminalDevice);\r
UnicodeToEfiKey (TerminalDevice);\r
break;\r
@param Input The key will be input.\r
\r
@retval TRUE If insert successfully.\r
- @retval FLASE If Raw Data buffer is full before key insertion,\r
+ @retval FALSE If Raw Data buffer is full before key insertion,\r
and the key is lost.\r
\r
**/\r
@param Output The key will be removed.\r
\r
@retval TRUE If insert successfully.\r
- @retval FLASE If Raw Data FIFO buffer is empty before remove operation.\r
+ @retval FALSE If Raw Data FIFO buffer is empty before remove operation.\r
\r
**/\r
BOOLEAN\r
@param TerminalDevice Terminal driver private structure\r
\r
@retval TRUE If Raw Data FIFO buffer is empty.\r
- @retval FLASE If Raw Data FIFO buffer is not empty.\r
+ @retval FALSE If Raw Data FIFO buffer is not empty.\r
\r
**/\r
BOOLEAN\r
@param TerminalDevice Terminal driver private structure\r
\r
@retval TRUE If Raw Data FIFO buffer is full.\r
- @retval FLASE If Raw Data FIFO buffer is not full.\r
+ @retval FALSE If Raw Data FIFO buffer is not full.\r
\r
**/\r
BOOLEAN\r
@param Key The key will be input.\r
\r
@retval TRUE If insert successfully.\r
- @retval FLASE If FIFO buffer is full before key insertion,\r
+ @retval FALSE If FIFO buffer is full before key insertion,\r
and the key is lost.\r
\r
**/\r
@param Output The key will be removed.\r
\r
@retval TRUE If insert successfully.\r
- @retval FLASE If FIFO buffer is empty before remove operation.\r
+ @retval FALSE If FIFO buffer is empty before remove operation.\r
\r
**/\r
BOOLEAN\r
return FALSE;\r
}\r
\r
- *Output = TerminalDevice->EfiKeyFiFo->Data[Head];\r
+ CopyMem (Output, &TerminalDevice->EfiKeyFiFo->Data[Head], sizeof (EFI_INPUT_KEY));\r
\r
TerminalDevice->EfiKeyFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
\r
@param TerminalDevice Terminal driver private structure\r
\r
@retval TRUE If FIFO buffer is empty.\r
- @retval FLASE If FIFO buffer is not empty.\r
+ @retval FALSE If FIFO buffer is not empty.\r
\r
**/\r
BOOLEAN\r
@param TerminalDevice Terminal driver private structure\r
\r
@retval TRUE If FIFO buffer is full.\r
- @retval FLASE If FIFO buffer is not full.\r
+ @retval FALSE If FIFO buffer is not full.\r
\r
**/\r
BOOLEAN\r
@param Input The key will be input.\r
\r
@retval TRUE If insert successfully.\r
- @retval FLASE If Unicode FIFO buffer is full before key insertion,\r
+ @retval FALSE If Unicode FIFO buffer is full before key insertion,\r
and the key is lost.\r
\r
**/\r
\r
/**\r
Remove one pre-fetched key out of the Unicode FIFO buffer.\r
+ The caller should guarantee that Unicode FIFO buffer is not empty \r
+ by IsUnicodeFiFoEmpty ().\r
\r
@param TerminalDevice Terminal driver private structure.\r
@param Output The key will be removed.\r
\r
- @retval TRUE If insert successfully.\r
- @retval FLASE If Unicode FIFO buffer is empty before remove operation.\r
-\r
**/\r
-BOOLEAN\r
+VOID\r
UnicodeFiFoRemoveOneKey (\r
TERMINAL_DEV *TerminalDevice,\r
UINT16 *Output\r
Head = TerminalDevice->UnicodeFiFo->Head;\r
ASSERT (Head < FIFO_MAX_NUMBER + 1);\r
\r
- if (IsUnicodeFiFoEmpty (TerminalDevice)) {\r
- //\r
- // FIFO is empty\r
- //\r
- Output = NULL;\r
- return FALSE;\r
- }\r
-\r
*Output = TerminalDevice->UnicodeFiFo->Data[Head];\r
\r
TerminalDevice->UnicodeFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
-\r
- return TRUE;\r
}\r
\r
/**\r
@param TerminalDevice Terminal driver private structure\r
\r
@retval TRUE If Unicode FIFO buffer is empty.\r
- @retval FLASE If Unicode FIFO buffer is not empty.\r
+ @retval FALSE If Unicode FIFO buffer is not empty.\r
\r
**/\r
BOOLEAN\r
@param TerminalDevice Terminal driver private structure\r
\r
@retval TRUE If Unicode FIFO buffer is full.\r
- @retval FLASE If Unicode FIFO buffer is not full.\r
+ @retval FALSE If Unicode FIFO buffer is not full.\r
\r
**/\r
BOOLEAN\r
continue;\r
}\r
\r
- if (UnicodeChar == 'O' && TerminalDevice->TerminalType == VT100TYPE) {\r
+ if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == VT100TYPE ||\r
+ TerminalDevice->TerminalType == TTYTERMTYPE)) {\r
TerminalDevice->InputState |= INPUT_STATE_O;\r
TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
continue;\r
default :\r
break;\r
}\r
+ } else if (TerminalDevice->TerminalType == TTYTERMTYPE) {\r
+ /* Also accept VT100 escape codes for F1-F4 for TTY term */\r
+ switch (UnicodeChar) {\r
+ case 'P':\r
+ Key.ScanCode = SCAN_F1;\r
+ break;\r
+ case 'Q':\r
+ Key.ScanCode = SCAN_F2;\r
+ break;\r
+ case 'R':\r
+ Key.ScanCode = SCAN_F3;\r
+ break;\r
+ case 'S':\r
+ Key.ScanCode = SCAN_F4;\r
+ break;\r
+ }\r
}\r
\r
if (Key.ScanCode != SCAN_NULL) {\r
if (TerminalDevice->TerminalType == PCANSITYPE ||\r
TerminalDevice->TerminalType == VT100TYPE ||\r
TerminalDevice->TerminalType == VT100PLUSTYPE ||\r
- TerminalDevice->TerminalType == VTUTF8TYPE) {\r
+ TerminalDevice->TerminalType == VTUTF8TYPE ||\r
+ TerminalDevice->TerminalType == TTYTERMTYPE) {\r
switch (UnicodeChar) {\r
case 'A':\r
Key.ScanCode = SCAN_UP;\r
if (TerminalDevice->TerminalType == PCANSITYPE) {\r
Key.ScanCode = SCAN_F10;\r
}\r
+ break;\r
case '?':\r
if (TerminalDevice->TerminalType == VT100TYPE) {\r
Key.ScanCode = SCAN_PAGE_UP;\r
if (TerminalDevice->TerminalType == PCANSITYPE) {\r
Key.ScanCode = SCAN_F9;\r
}\r
+ break;\r
case '/':\r
if (TerminalDevice->TerminalType == VT100TYPE) {\r
Key.ScanCode = SCAN_PAGE_DOWN;\r
}\r
}\r
\r
+ /*\r
+ * The VT220 escape codes that the TTY terminal accepts all have\r
+ * numeric codes, and there are no ambiguous prefixes shared with\r
+ * other terminal types.\r
+ */\r
+ if (TerminalDevice->TerminalType == TTYTERMTYPE &&\r
+ Key.ScanCode == SCAN_NULL &&\r
+ UnicodeChar >= '0' &&\r
+ UnicodeChar <= '9') {\r
+ TerminalDevice->TtyEscapeStr[0] = UnicodeChar;\r
+ TerminalDevice->TtyEscapeIndex = 1;\r
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2;\r
+ continue;\r
+ }\r
+\r
if (Key.ScanCode != SCAN_NULL) {\r
Key.UnicodeChar = 0;\r
EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);\r
break;\r
\r
\r
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2:\r
+ /*\r
+ * Here we handle the VT220 escape codes that we accept. This\r
+ * state is only used by the TTY terminal type.\r
+ */\r
+ Key.ScanCode = SCAN_NULL;\r
+ if (TerminalDevice->TerminalType == TTYTERMTYPE) {\r
+\r
+ if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) {\r
+ UINT16 EscCode;\r
+ TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] = 0; /* Terminate string */\r
+ EscCode = (UINT16) StrDecimalToUintn(TerminalDevice->TtyEscapeStr);\r
+ switch (EscCode) {\r
+ case 3:\r
+ Key.ScanCode = SCAN_DELETE;\r
+ break;\r
+ case 11:\r
+ case 12:\r
+ case 13:\r
+ case 14:\r
+ case 15:\r
+ Key.ScanCode = SCAN_F1 + EscCode - 11;\r
+ break;\r
+ case 17:\r
+ case 18:\r
+ case 19:\r
+ case 20:\r
+ case 21:\r
+ Key.ScanCode = SCAN_F6 + EscCode - 17;\r
+ break;\r
+ case 23:\r
+ case 24:\r
+ Key.ScanCode = SCAN_F11 + EscCode - 23;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ } else if (TerminalDevice->TtyEscapeIndex == 1){\r
+ /* 2 character escape code */\r
+ TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex++] = UnicodeChar;\r
+ continue;\r
+ }\r
+ else {\r
+ DEBUG ((EFI_D_ERROR, "Unexpected state in escape2\n"));\r
+ }\r
+ }\r
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;\r
+\r
+ if (Key.ScanCode != SCAN_NULL) {\r
+ Key.UnicodeChar = 0;\r
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);\r
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ continue;\r
+ }\r
+\r
+ UnicodeToEfiKeyFlushState (TerminalDevice);\r
+ break;\r
+\r
default:\r
//\r
// Invalid state. This should never happen.\r
}\r
\r
if (UnicodeChar == DEL) {\r
- Key.ScanCode = SCAN_DELETE;\r
- Key.UnicodeChar = 0;\r
+ if (TerminalDevice->TerminalType == TTYTERMTYPE) {\r
+ Key.ScanCode = SCAN_NULL;\r
+ Key.UnicodeChar = CHAR_BACKSPACE;\r
+ }\r
+ else {\r
+ Key.ScanCode = SCAN_DELETE;\r
+ Key.UnicodeChar = 0;\r
+ }\r
} else {\r
Key.ScanCode = SCAN_NULL;\r
Key.UnicodeChar = UnicodeChar;\r