33 if (KeyData ==
NULL) {
34 return EFI_INVALID_PARAMETER;
37 KeyData->KeyState.KeyShiftState = 0;
38 KeyData->KeyState.KeyToggleState = 0;
63 IN BOOLEAN ExtendedVerification
69 TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);
76 (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET),
77 TerminalDevice->DevicePath
80 Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);
85 TerminalDevice->RawFiFo->Head = TerminalDevice->RawFiFo->Tail;
86 TerminalDevice->UnicodeFiFo->Head = TerminalDevice->UnicodeFiFo->Tail;
87 TerminalDevice->EfiKeyFiFo->Head = TerminalDevice->EfiKeyFiFo->Tail;
88 TerminalDevice->EfiKeyFiFoForNotify->Head = TerminalDevice->EfiKeyFiFoForNotify->Tail;
90 if (EFI_ERROR (Status)) {
93 (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_CONTROLLER_ERROR),
94 TerminalDevice->DevicePath
98 if (!EFI_ERROR (Status)) {
99 Status = TerminalDevice->SerialIo->SetControl (TerminalDevice->SerialIo, EFI_SERIAL_DATA_TERMINAL_READY|EFI_SERIAL_REQUEST_TO_SEND);
100 if (Status == EFI_UNSUPPORTED) {
137 TerminalDevice = TERMINAL_CON_IN_DEV_FROM_THIS (This);
140 if (EFI_ERROR (Status)) {
171 ASSERT (RegsiteredData !=
NULL && InputData !=
NULL);
173 if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
174 (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
219 IN BOOLEAN ExtendedVerification
225 TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
227 Status = TerminalDevice->SimpleInput.Reset (&TerminalDevice->SimpleInput, ExtendedVerification);
228 if (EFI_ERROR (Status)) {
229 return EFI_DEVICE_ERROR;
262 if (KeyData ==
NULL) {
263 return EFI_INVALID_PARAMETER;
266 TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
293 if (KeyToggleState ==
NULL) {
294 return EFI_INVALID_PARAMETER;
297 if ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) {
298 return EFI_UNSUPPORTED;
332 OUT VOID **NotifyHandle
341 if ((KeyData ==
NULL) || (NotifyHandle ==
NULL) || (KeyNotificationFunction ==
NULL)) {
342 return EFI_INVALID_PARAMETER;
345 TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
350 NotifyList = &TerminalDevice->NotifyList;
356 TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE
359 if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
360 *NotifyHandle = CurrentNotify;
370 if (NewNotify ==
NULL) {
371 return EFI_OUT_OF_RESOURCES;
374 NewNotify->Signature = TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE;
375 NewNotify->KeyNotificationFn = KeyNotificationFunction;
377 InsertTailList (&TerminalDevice->NotifyList, &NewNotify->NotifyEntry);
379 *NotifyHandle = NewNotify;
400 IN VOID *NotificationHandle
408 if (NotificationHandle ==
NULL) {
409 return EFI_INVALID_PARAMETER;
412 TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
414 NotifyList = &TerminalDevice->NotifyList;
420 TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE
422 if (CurrentNotify == NotificationHandle) {
428 gBS->FreePool (CurrentNotify);
436 return EFI_INVALID_PARAMETER;
451 switch (TerminalDevice->TerminalType) {
452 case TerminalTypePcAnsi:
453 case TerminalTypeVt100:
454 case TerminalTypeVt100Plus:
455 case TerminalTypeTtyTerm:
456 case TerminalTypeLinux:
457 case TerminalTypeXtermR6:
458 case TerminalTypeVt400:
459 case TerminalTypeSCO:
464 case TerminalTypeVtUtf8:
501 gBS->SignalEvent (Event);
524 UINTN SerialInTimeOut;
528 SerialIo = TerminalDevice->SerialIo;
529 if (SerialIo ==
NULL) {
538 Mode = SerialIo->
Mode;
539 if (Mode->Timeout != TerminalDevice->SerialInTimeOut) {
541 if (Mode->BaudRate != 0) {
545 SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (
UINTN)Mode->BaudRate;
548 Status = SerialIo->SetAttributes (
551 Mode->ReceiveFifoDepth,
552 (UINT32)SerialInTimeOut,
554 (UINT8)Mode->DataBits,
558 if (EFI_ERROR (Status)) {
559 TerminalDevice->SerialInTimeOut = 0;
561 TerminalDevice->SerialInTimeOut = SerialInTimeOut;
570 Status = SerialIo->GetControl (SerialIo, &Control);
571 if (EFI_ERROR (Status) || ((Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) == 0)) {
579 if (EFI_ERROR (Status)) {
580 if (Status == EFI_DEVICE_ERROR) {
583 (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_INPUT_ERROR),
584 TerminalDevice->DevicePath
629 NotifyList = &TerminalDevice->NotifyList;
634 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
642 gBS->RestoreTPL (OldTpl);
650 CurrentNotify->KeyNotificationFn (&KeyData);
683 Status = SerialIo->Read (SerialIo, &Size, Output);
685 if (EFI_ERROR (Status)) {
686 if (Status == EFI_TIMEOUT) {
687 return EFI_NOT_READY;
690 return EFI_DEVICE_ERROR;
694 return EFI_NOT_READY;
719 Tail = TerminalDevice->RawFiFo->Tail;
728 TerminalDevice->RawFiFo->Data[Tail] =
Input;
730 TerminalDevice->RawFiFo->Tail = (UINT8)((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1));
753 Head = TerminalDevice->RawFiFo->Head;
763 *Output = TerminalDevice->RawFiFo->Data[Head];
765 TerminalDevice->RawFiFo->Head = (UINT8)((Head + 1) % (RAW_FIFO_MAX_NUMBER + 1));
784 if (TerminalDevice->RawFiFo->Head == TerminalDevice->RawFiFo->Tail) {
808 Tail = TerminalDevice->RawFiFo->Tail;
809 Head = TerminalDevice->RawFiFo->Head;
811 if (((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)) == Head) {
837 Tail = EfiKeyFiFo->Tail;
848 EfiKeyFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1));
871 Head = EfiKeyFiFo->Head;
872 ASSERT (Head < FIFO_MAX_NUMBER + 1);
878 Output->ScanCode = SCAN_NULL;
879 Output->UnicodeChar = 0;
885 EfiKeyFiFo->Head = (UINT8)((Head + 1) % (FIFO_MAX_NUMBER + 1));
904 if (EfiKeyFiFo->Head == EfiKeyFiFo->Tail) {
928 Tail = EfiKeyFiFo->Tail;
929 Head = EfiKeyFiFo->Head;
931 if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
961 Tail = TerminalDevice->EfiKeyFiFo->Tail;
970 NotifyList = &TerminalDevice->NotifyList;
976 TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE
985 gBS->SignalEvent (TerminalDevice->KeyNotifyProcessEvent);
999 TerminalDevice->EfiKeyFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1));
1022 Head = TerminalDevice->EfiKeyFiFo->Head;
1023 ASSERT (Head < FIFO_MAX_NUMBER + 1);
1029 Output->ScanCode = SCAN_NULL;
1030 Output->UnicodeChar = 0;
1036 TerminalDevice->EfiKeyFiFo->Head = (UINT8)((Head + 1) % (FIFO_MAX_NUMBER + 1));
1055 if (TerminalDevice->EfiKeyFiFo->Head == TerminalDevice->EfiKeyFiFo->Tail) {
1079 Tail = TerminalDevice->EfiKeyFiFo->Tail;
1080 Head = TerminalDevice->EfiKeyFiFo->Head;
1082 if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
1108 Tail = TerminalDevice->UnicodeFiFo->Tail;
1109 ASSERT (Tail < FIFO_MAX_NUMBER + 1);
1118 TerminalDevice->UnicodeFiFo->Data[Tail] =
Input;
1120 TerminalDevice->UnicodeFiFo->Tail = (UINT8)((Tail + 1) % (FIFO_MAX_NUMBER + 1));
1142 Head = TerminalDevice->UnicodeFiFo->Head;
1143 ASSERT (Head < FIFO_MAX_NUMBER + 1);
1145 *Output = TerminalDevice->UnicodeFiFo->Data[Head];
1147 TerminalDevice->UnicodeFiFo->Head = (UINT8)((Head + 1) % (FIFO_MAX_NUMBER + 1));
1164 if (TerminalDevice->UnicodeFiFo->Head == TerminalDevice->UnicodeFiFo->Tail) {
1188 Tail = TerminalDevice->UnicodeFiFo->Tail;
1189 Head = TerminalDevice->UnicodeFiFo->Head;
1191 if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {
1212 InputState = TerminalDevice->InputState;
1218 if ((InputState & INPUT_STATE_ESC) != 0) {
1219 Key.ScanCode = SCAN_ESC;
1220 Key.UnicodeChar = 0;
1224 if ((InputState & INPUT_STATE_CSI) != 0) {
1225 Key.ScanCode = SCAN_NULL;
1226 Key.UnicodeChar = CSI;
1230 if ((InputState & INPUT_STATE_LEFTOPENBRACKET) != 0) {
1231 Key.ScanCode = SCAN_NULL;
1232 Key.UnicodeChar = LEFTOPENBRACKET;
1236 if ((InputState & INPUT_STATE_O) != 0) {
1237 Key.ScanCode = SCAN_NULL;
1238 Key.UnicodeChar =
'O';
1242 if ((InputState & INPUT_STATE_2) != 0) {
1243 Key.ScanCode = SCAN_NULL;
1244 Key.UnicodeChar =
'2';
1252 TerminalDevice->TwoSecondTimeOut,
1257 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1357 BOOLEAN SetDefaultResetState;
1359 TimerStatus =
gBS->CheckEvent (TerminalDevice->TwoSecondTimeOut);
1361 if (!EFI_ERROR (TimerStatus)) {
1363 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1367 if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {
1371 TimerStatus =
gBS->CheckEvent (TerminalDevice->TwoSecondTimeOut);
1372 if (!EFI_ERROR (TimerStatus)) {
1374 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1383 SetDefaultResetState =
TRUE;
1385 switch (TerminalDevice->InputState) {
1386 case INPUT_STATE_DEFAULT:
1390 case INPUT_STATE_ESC:
1392 if (UnicodeChar == LEFTOPENBRACKET) {
1393 TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET;
1394 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1398 if ((UnicodeChar ==
'O') && ((TerminalDevice->TerminalType == TerminalTypeVt100) ||
1399 (TerminalDevice->TerminalType == TerminalTypeTtyTerm) ||
1400 (TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1401 (TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
1402 (TerminalDevice->TerminalType == TerminalTypeVtUtf8)))
1404 TerminalDevice->InputState |= INPUT_STATE_O;
1405 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1409 Key.ScanCode = SCAN_NULL;
1411 if ((TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
1412 (TerminalDevice->TerminalType == TerminalTypeVtUtf8))
1414 switch (UnicodeChar) {
1416 Key.ScanCode = SCAN_F1;
1419 Key.ScanCode = SCAN_F2;
1422 Key.ScanCode = SCAN_F3;
1425 Key.ScanCode = SCAN_F4;
1428 Key.ScanCode = SCAN_F5;
1431 Key.ScanCode = SCAN_F6;
1434 Key.ScanCode = SCAN_F7;
1437 Key.ScanCode = SCAN_F8;
1440 Key.ScanCode = SCAN_F9;
1443 Key.ScanCode = SCAN_F10;
1446 Key.ScanCode = SCAN_F11;
1449 Key.ScanCode = SCAN_F12;
1452 Key.ScanCode = SCAN_HOME;
1455 Key.ScanCode = SCAN_END;
1458 Key.ScanCode = SCAN_INSERT;
1461 Key.ScanCode = SCAN_DELETE;
1464 Key.ScanCode = SCAN_PAGE_DOWN;
1467 Key.ScanCode = SCAN_PAGE_UP;
1474 switch (UnicodeChar) {
1476 if (TerminalDevice->ResetState == RESET_STATE_DEFAULT) {
1477 TerminalDevice->ResetState = RESET_STATE_ESC_R;
1478 SetDefaultResetState =
FALSE;
1479 }
else if (TerminalDevice->ResetState == RESET_STATE_ESC_R_ESC_R) {
1483 Key.ScanCode = SCAN_NULL;
1486 if (TerminalDevice->ResetState == RESET_STATE_ESC_R) {
1487 TerminalDevice->ResetState = RESET_STATE_ESC_R_ESC_R;
1488 SetDefaultResetState =
FALSE;
1491 Key.ScanCode = SCAN_NULL;
1497 if (SetDefaultResetState) {
1498 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1501 if (Key.ScanCode != SCAN_NULL) {
1502 Key.UnicodeChar = 0;
1504 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1513 case INPUT_STATE_ESC | INPUT_STATE_O:
1515 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1517 Key.ScanCode = SCAN_NULL;
1519 if (TerminalDevice->TerminalType == TerminalTypeVt100) {
1520 switch (UnicodeChar) {
1522 Key.ScanCode = SCAN_F1;
1525 Key.ScanCode = SCAN_F2;
1528 Key.ScanCode = SCAN_F3;
1531 Key.ScanCode = SCAN_F4;
1534 Key.ScanCode = SCAN_F5;
1537 Key.ScanCode = SCAN_F6;
1540 Key.ScanCode = SCAN_F7;
1543 Key.ScanCode = SCAN_F8;
1546 Key.ScanCode = SCAN_F9;
1549 Key.ScanCode = SCAN_F10;
1554 }
else if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
1556 switch (UnicodeChar) {
1558 Key.ScanCode = SCAN_F1;
1561 Key.ScanCode = SCAN_F2;
1564 Key.ScanCode = SCAN_F3;
1567 Key.ScanCode = SCAN_F4;
1570 Key.ScanCode = SCAN_HOME;
1573 Key.ScanCode = SCAN_END;
1576 }
else if ((TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
1577 (TerminalDevice->TerminalType == TerminalTypeVtUtf8))
1579 switch (UnicodeChar) {
1581 Key.ScanCode = SCAN_F1;
1584 Key.ScanCode = SCAN_F2;
1587 Key.ScanCode = SCAN_F3;
1590 Key.ScanCode = SCAN_F4;
1593 Key.ScanCode = SCAN_F5;
1596 Key.ScanCode = SCAN_F6;
1599 Key.ScanCode = SCAN_F7;
1602 Key.ScanCode = SCAN_F8;
1605 Key.ScanCode = SCAN_F9;
1608 Key.ScanCode = SCAN_F10;
1611 Key.ScanCode = SCAN_F11;
1614 Key.ScanCode = SCAN_F12;
1617 }
else if (TerminalDevice->TerminalType == TerminalTypeXtermR6) {
1618 switch (UnicodeChar) {
1620 Key.ScanCode = SCAN_F1;
1623 Key.ScanCode = SCAN_F2;
1626 Key.ScanCode = SCAN_F3;
1629 Key.ScanCode = SCAN_F4;
1634 if (Key.ScanCode != SCAN_NULL) {
1635 Key.UnicodeChar = 0;
1637 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1646 case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:
1648 if ((UnicodeChar ==
'1') && ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1649 (TerminalDevice->TerminalType == TerminalTypeVt400) ||
1650 (TerminalDevice->TerminalType == TerminalTypeLinux)))
1652 TerminalDevice->InputState |= INPUT_STATE_1;
1656 if ((UnicodeChar ==
'2') && ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1657 (TerminalDevice->TerminalType == TerminalTypeVt400) ||
1658 (TerminalDevice->TerminalType == TerminalTypeLinux)))
1660 TerminalDevice->InputState |= INPUT_STATE_2;
1664 if ((UnicodeChar == LEFTOPENBRACKET) && (TerminalDevice->TerminalType == TerminalTypeLinux)) {
1665 TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2ND;
1669 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1671 Key.ScanCode = SCAN_NULL;
1673 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1674 (TerminalDevice->TerminalType == TerminalTypeVt100) ||
1675 (TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
1676 (TerminalDevice->TerminalType == TerminalTypeVtUtf8) ||
1677 (TerminalDevice->TerminalType == TerminalTypeTtyTerm) ||
1678 (TerminalDevice->TerminalType == TerminalTypeLinux) ||
1679 (TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1680 (TerminalDevice->TerminalType == TerminalTypeVt400) ||
1681 (TerminalDevice->TerminalType == TerminalTypeSCO))
1683 switch (UnicodeChar) {
1685 Key.ScanCode = SCAN_UP;
1688 Key.ScanCode = SCAN_DOWN;
1691 Key.ScanCode = SCAN_RIGHT;
1694 Key.ScanCode = SCAN_LEFT;
1697 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1698 (TerminalDevice->TerminalType == TerminalTypeVt100) ||
1699 (TerminalDevice->TerminalType == TerminalTypeTtyTerm))
1701 Key.ScanCode = SCAN_HOME;
1706 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1707 (TerminalDevice->TerminalType == TerminalTypeTtyTerm))
1709 Key.ScanCode = SCAN_END;
1714 if (TerminalDevice->TerminalType == TerminalTypeVt100) {
1715 Key.ScanCode = SCAN_END;
1721 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1722 (TerminalDevice->TerminalType == TerminalTypeVt100))
1724 Key.ScanCode = SCAN_INSERT;
1729 if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
1730 Key.ScanCode = SCAN_DELETE;
1731 }
else if (TerminalDevice->TerminalType == TerminalTypeSCO) {
1732 Key.ScanCode = SCAN_F12;
1737 if (TerminalDevice->TerminalType == TerminalTypeVt100) {
1738 Key.ScanCode = SCAN_DELETE;
1739 }
else if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1740 (TerminalDevice->TerminalType == TerminalTypeSCO))
1742 Key.ScanCode = SCAN_F4;
1747 if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
1748 Key.ScanCode = SCAN_PAGE_UP;
1753 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1754 (TerminalDevice->TerminalType == TerminalTypeSCO))
1756 Key.ScanCode = SCAN_F10;
1761 if (TerminalDevice->TerminalType == TerminalTypeVt100) {
1762 Key.ScanCode = SCAN_PAGE_UP;
1767 if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
1768 Key.ScanCode = SCAN_PAGE_DOWN;
1773 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1774 (TerminalDevice->TerminalType == TerminalTypeSCO))
1776 Key.ScanCode = SCAN_F9;
1781 if (TerminalDevice->TerminalType == TerminalTypeVt100) {
1782 Key.ScanCode = SCAN_PAGE_DOWN;
1787 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1788 (TerminalDevice->TerminalType == TerminalTypeSCO))
1790 Key.ScanCode = SCAN_F1;
1795 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1796 (TerminalDevice->TerminalType == TerminalTypeSCO))
1798 Key.ScanCode = SCAN_F2;
1803 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1804 (TerminalDevice->TerminalType == TerminalTypeSCO))
1806 Key.ScanCode = SCAN_F3;
1811 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1812 (TerminalDevice->TerminalType == TerminalTypeSCO))
1814 Key.ScanCode = SCAN_F5;
1819 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1820 (TerminalDevice->TerminalType == TerminalTypeSCO))
1822 Key.ScanCode = SCAN_F6;
1827 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1828 (TerminalDevice->TerminalType == TerminalTypeSCO))
1830 Key.ScanCode = SCAN_F7;
1835 if ((TerminalDevice->TerminalType == TerminalTypePcAnsi) ||
1836 (TerminalDevice->TerminalType == TerminalTypeSCO))
1838 Key.ScanCode = SCAN_F8;
1843 if (TerminalDevice->TerminalType == TerminalTypeSCO) {
1844 Key.ScanCode = SCAN_F11;
1858 if ((TerminalDevice->TerminalType == TerminalTypeTtyTerm) &&
1859 (Key.ScanCode == SCAN_NULL) &&
1860 (UnicodeChar >=
'0') &&
1861 (UnicodeChar <=
'9'))
1863 TerminalDevice->TtyEscapeStr[0] = UnicodeChar;
1864 TerminalDevice->TtyEscapeIndex = 1;
1865 TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_TTY;
1869 if (Key.ScanCode != SCAN_NULL) {
1870 Key.UnicodeChar = 0;
1872 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1881 case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_1:
1883 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
1885 Key.ScanCode = SCAN_NULL;
1887 if ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1888 (TerminalDevice->TerminalType == TerminalTypeVt400) ||
1889 (TerminalDevice->TerminalType == TerminalTypeLinux))
1891 switch (UnicodeChar) {
1893 if (TerminalDevice->TerminalType == TerminalTypeVt400) {
1894 Key.ScanCode = SCAN_F1;
1899 if (TerminalDevice->TerminalType == TerminalTypeVt400) {
1900 Key.ScanCode = SCAN_F2;
1905 if (TerminalDevice->TerminalType == TerminalTypeVt400) {
1906 Key.ScanCode = SCAN_F3;
1911 if (TerminalDevice->TerminalType == TerminalTypeVt400) {
1912 Key.ScanCode = SCAN_F4;
1917 if ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1918 (TerminalDevice->TerminalType == TerminalTypeVt400))
1920 Key.ScanCode = SCAN_F5;
1925 Key.ScanCode = SCAN_F6;
1928 Key.ScanCode = SCAN_F7;
1931 Key.ScanCode = SCAN_F8;
1936 if (Key.ScanCode != SCAN_NULL) {
1937 Key.UnicodeChar = 0;
1939 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1948 case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_2:
1950 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1951 Key.ScanCode = SCAN_NULL;
1952 if ((TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
1953 (TerminalDevice->TerminalType == TerminalTypeVt400) ||
1954 (TerminalDevice->TerminalType == TerminalTypeLinux))
1956 switch (UnicodeChar) {
1958 Key.ScanCode = SCAN_F9;
1961 Key.ScanCode = SCAN_F10;
1964 Key.ScanCode = SCAN_F11;
1967 Key.ScanCode = SCAN_F12;
1972 if (Key.ScanCode != SCAN_NULL) {
1973 Key.UnicodeChar = 0;
1975 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1984 case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2ND:
1986 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
1987 Key.ScanCode = SCAN_NULL;
1989 if (TerminalDevice->TerminalType == TerminalTypeLinux) {
1990 switch (UnicodeChar) {
1992 Key.ScanCode = SCAN_F1;
1995 Key.ScanCode = SCAN_F2;
1998 Key.ScanCode = SCAN_F3;
2001 Key.ScanCode = SCAN_F4;
2004 Key.ScanCode = SCAN_F5;
2009 if (Key.ScanCode != SCAN_NULL) {
2010 Key.UnicodeChar = 0;
2012 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
2021 case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_TTY:
2026 Key.ScanCode = SCAN_NULL;
2027 if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
2028 if ((UnicodeChar ==
'~') && (TerminalDevice->TtyEscapeIndex <= 2)) {
2030 TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] = 0;
2034 Key.ScanCode = SCAN_INSERT;
2037 Key.ScanCode = SCAN_DELETE;
2040 Key.ScanCode = SCAN_PAGE_UP;
2043 Key.ScanCode = SCAN_PAGE_DOWN;
2050 Key.ScanCode = SCAN_F1 + EscCode - 11;
2057 Key.ScanCode = SCAN_F6 + EscCode - 17;
2061 Key.ScanCode = SCAN_F11 + EscCode - 23;
2066 }
else if (TerminalDevice->TtyEscapeIndex == 1) {
2068 TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex++] = UnicodeChar;
2071 DEBUG ((DEBUG_ERROR,
"Unexpected state in escape2\n"));
2075 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
2077 if (Key.ScanCode != SCAN_NULL) {
2078 Key.UnicodeChar = 0;
2080 TerminalDevice->InputState = INPUT_STATE_DEFAULT;
2099 if (UnicodeChar == ESC) {
2100 TerminalDevice->InputState = INPUT_STATE_ESC;
2103 if (UnicodeChar == CSI) {
2104 TerminalDevice->InputState = INPUT_STATE_CSI;
2107 if (TerminalDevice->InputState != INPUT_STATE_DEFAULT) {
2108 Status =
gBS->SetTimer (
2109 TerminalDevice->TwoSecondTimeOut,
2117 if (SetDefaultResetState) {
2118 TerminalDevice->ResetState = RESET_STATE_DEFAULT;
2121 if (UnicodeChar == DEL) {
2122 if (TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
2123 Key.ScanCode = SCAN_NULL;
2124 Key.UnicodeChar = CHAR_BACKSPACE;
2126 Key.ScanCode = SCAN_DELETE;
2127 Key.UnicodeChar = 0;
2130 Key.ScanCode = SCAN_NULL;
2131 Key.UnicodeChar = UnicodeChar;
VOID AnsiRawDataToUnicode(IN TERMINAL_DEV *TerminalDevice)
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINTN EFIAPI StrDecimalToUintn(IN CONST CHAR16 *String)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI Input(IN CHAR16 *Prompt OPTIONAL, OUT CHAR16 *InStr, IN UINTN StrLen)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter)
#define EFI_PROGRESS_CODE
UINT8 EFI_KEY_TOGGLE_STATE
EFI_STATUS(EFIAPI * EFI_KEY_NOTIFY_FUNCTION)(IN EFI_KEY_DATA *KeyData)
VOID VTUTF8RawDataToUnicode(IN TERMINAL_DEV *VtUtf8Device)
EFI_STATUS EFIAPI TerminalConInReadKeyStrokeEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData)
EFI_STATUS GetOneKeyFromSerial(EFI_SERIAL_IO_PROTOCOL *SerialIo, UINT8 *Output)
VOID EFIAPI TerminalConInTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI KeyNotifyProcessHandler(IN EFI_EVENT Event, IN VOID *Context)
VOID UnicodeToEfiKeyFlushState(IN TERMINAL_DEV *TerminalDevice)
BOOLEAN IsRawFiFoFull(TERMINAL_DEV *TerminalDevice)
EFI_STATUS EFIAPI TerminalConInReset(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI TerminalConInResetEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
BOOLEAN IsEfiKeyFiFoFull(TERMINAL_DEV *TerminalDevice)
VOID EFIAPI TerminalConInWaitForKey(IN EFI_EVENT Event, IN VOID *Context)
BOOLEAN RawFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, UINT8 Input)
BOOLEAN EfiKeyFiFoForNotifyRemoveOneKey(EFI_KEY_FIFO *EfiKeyFiFo, EFI_INPUT_KEY *Output)
BOOLEAN EfiKeyFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, EFI_INPUT_KEY *Key)
EFI_STATUS EFIAPI TerminalConInUnregisterKeyNotify(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle)
BOOLEAN IsEfiKeyFiFoForNotifyFull(EFI_KEY_FIFO *EfiKeyFiFo)
BOOLEAN EfiKeyFiFoForNotifyInsertOneKey(EFI_KEY_FIFO *EfiKeyFiFo, EFI_INPUT_KEY *Input)
BOOLEAN IsUnicodeFiFoEmpty(TERMINAL_DEV *TerminalDevice)
VOID UnicodeToEfiKey(IN TERMINAL_DEV *TerminalDevice)
EFI_STATUS ReadKeyStrokeWorker(IN TERMINAL_DEV *TerminalDevice, OUT EFI_KEY_DATA *KeyData)
BOOLEAN IsEfiKeyFiFoForNotifyEmpty(EFI_KEY_FIFO *EfiKeyFiFo)
BOOLEAN RawFiFoRemoveOneKey(TERMINAL_DEV *TerminalDevice, UINT8 *Output)
EFI_STATUS EFIAPI TerminalConInRegisterKeyNotify(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData, IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, OUT VOID **NotifyHandle)
VOID UnicodeFiFoRemoveOneKey(TERMINAL_DEV *TerminalDevice, UINT16 *Output)
BOOLEAN IsUnicodeFiFoFull(TERMINAL_DEV *TerminalDevice)
EFI_STATUS EFIAPI TerminalConInReadKeyStroke(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key)
BOOLEAN IsEfiKeyFiFoEmpty(TERMINAL_DEV *TerminalDevice)
BOOLEAN UnicodeFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, UINT16 Input)
EFI_STATUS EFIAPI TerminalConInSetState(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_TOGGLE_STATE *KeyToggleState)
BOOLEAN IsRawFiFoEmpty(TERMINAL_DEV *TerminalDevice)
VOID EFIAPI TerminalConInWaitForKeyEx(IN EFI_EVENT Event, IN VOID *Context)
BOOLEAN IsKeyRegistered(IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData)
BOOLEAN EfiKeyFiFoRemoveOneKey(TERMINAL_DEV *TerminalDevice, EFI_INPUT_KEY *Output)
VOID TranslateRawDataToEfiKey(IN TERMINAL_DEV *TerminalDevice)
EFI_KEY_TOGGLE_STATE KeyToggleState
EFI_SERIAL_IO_MODE * Mode