2 Implementation for EFI_SIMPLE_TEXT_IN_PROTOCOL protocol.
4 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
21 IN BOOLEAN ExtendedVerification
26 Implements EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset().
27 This driver only perform dependent serial device reset regardless of
28 the value of ExtendeVerification
32 This - Indicates the calling context.
34 ExtendedVerification - Skip by this driver.
39 The reset operation succeeds.
42 The dependent serial port reset fails.
47 TERMINAL_DEV
*TerminalDevice
;
49 TerminalDevice
= TERMINAL_CON_IN_DEV_FROM_THIS (This
);
52 // Report progress code here
54 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
56 EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_PC_RESET
,
57 TerminalDevice
->DevicePath
60 Status
= TerminalDevice
->SerialIo
->Reset (TerminalDevice
->SerialIo
);
63 // clear all the internal buffer for keys
65 InitializeRawFiFo (TerminalDevice
);
66 InitializeUnicodeFiFo (TerminalDevice
);
67 InitializeEfiKeyFiFo (TerminalDevice
);
69 if (EFI_ERROR (Status
)) {
70 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
71 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
72 EFI_PERIPHERAL_LOCAL_CONSOLE
| EFI_P_EC_CONTROLLER_ERROR
,
73 TerminalDevice
->DevicePath
82 TerminalConInReadKeyStroke (
83 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
84 OUT EFI_INPUT_KEY
*Key
89 Implements EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke().
93 This - Indicates the calling context.
95 Key - A pointer to a buffer that is filled in with the keystroke
96 information for the key that was sent from terminal.
101 The keystroke information is returned successfully.
104 There is no keystroke data available.
107 The dependent serial device encounters error.
111 TERMINAL_DEV
*TerminalDevice
;
115 // Initialize *Key to nonsense value.
117 Key
->ScanCode
= SCAN_NULL
;
118 Key
->UnicodeChar
= 0;
120 // get TERMINAL_DEV from "This" parameter.
122 TerminalDevice
= TERMINAL_CON_IN_DEV_FROM_THIS (This
);
124 Status
= TerminalConInCheckForKey (This
);
125 if (EFI_ERROR (Status
)) {
126 return EFI_NOT_READY
;
129 EfiKeyFiFoRemoveOneKey (TerminalDevice
, Key
);
136 TranslateRawDataToEfiKey (
137 IN TERMINAL_DEV
*TerminalDevice
140 Step1: Turn raw data into Unicode (according to different encode).
141 Step2: Translate Unicode into key information.
142 (according to different terminal standard).
145 switch (TerminalDevice
->TerminalType
) {
150 AnsiRawDataToUnicode (TerminalDevice
);
151 UnicodeToEfiKey (TerminalDevice
);
156 // Process all the raw data in the RawFIFO,
157 // put the processed key into UnicodeFIFO.
159 VTUTF8RawDataToUnicode (TerminalDevice
);
162 // Translate all the Unicode data in the UnicodeFIFO to Efi key,
163 // then put into EfiKeyFIFO.
165 UnicodeToEfiKey (TerminalDevice
);
173 TerminalConInWaitForKey (
180 Event notification function for EFI_SIMPLE_TEXT_IN_PROTOCOL.WaitForKey event
181 Signal the event if there is key available
185 Event - Indicates the event that invoke this function.
187 Context - Indicates the calling context.
196 // Someone is waiting on the keystroke event, if there's
197 // a key pending, signal the event
199 // Context is the pointer to EFI_SIMPLE_TEXT_IN_PROTOCOL
201 if (!EFI_ERROR (TerminalConInCheckForKey (Context
))) {
203 gBS
->SignalEvent (Event
);
208 TerminalConInCheckForKey (
209 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
214 Check for a pending key in the Efi Key FIFO or Serial device buffer.
218 This - Indicates the calling context.
223 There is key pending.
226 There is no key pending.
233 TERMINAL_DEV
*TerminalDevice
;
236 EFI_SERIAL_IO_MODE
*Mode
;
237 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
238 UINTN SerialInTimeOut
;
240 TerminalDevice
= TERMINAL_CON_IN_DEV_FROM_THIS (This
);
242 SerialIo
= TerminalDevice
->SerialIo
;
243 if (SerialIo
== NULL
) {
244 return EFI_DEVICE_ERROR
;
247 // if current timeout value for serial device is not identical with
248 // the value saved in TERMINAL_DEV structure, then recalculate the
249 // timeout value again and set serial attribute according to this value.
251 Mode
= SerialIo
->Mode
;
252 if (Mode
->Timeout
!= TerminalDevice
->SerialInTimeOut
) {
255 if (Mode
->BaudRate
!= 0) {
256 SerialInTimeOut
= (1 + Mode
->DataBits
+ Mode
->StopBits
) * 2 * 1000000 / (UINTN
) Mode
->BaudRate
;
259 Status
= SerialIo
->SetAttributes (
262 Mode
->ReceiveFifoDepth
,
263 (UINT32
) SerialInTimeOut
,
264 (EFI_PARITY_TYPE
) (Mode
->Parity
),
265 (UINT8
) Mode
->DataBits
,
266 (EFI_STOP_BITS_TYPE
) (Mode
->StopBits
)
269 if (EFI_ERROR (Status
)) {
270 TerminalDevice
->SerialInTimeOut
= 0;
272 TerminalDevice
->SerialInTimeOut
= SerialInTimeOut
;
276 // check whether serial buffer is empty
278 Status
= SerialIo
->GetControl (SerialIo
, &Control
);
280 if (Control
& EFI_SERIAL_INPUT_BUFFER_EMPTY
) {
282 // Translate all the raw data in RawFIFO into EFI Key,
283 // according to different terminal type supported.
285 TranslateRawDataToEfiKey (TerminalDevice
);
288 // if there is pre-fetched Efi Key in EfiKeyFIFO buffer,
291 if (!IsEfiKeyFiFoEmpty (TerminalDevice
)) {
294 return EFI_NOT_READY
;
298 // Fetch all the keys in the serial buffer,
299 // and insert the byte stream into RawFIFO.
303 Status
= GetOneKeyFromSerial (TerminalDevice
->SerialIo
, &Input
);
305 if (EFI_ERROR (Status
)) {
306 if (Status
== EFI_DEVICE_ERROR
) {
307 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
308 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
309 EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_INPUT_ERROR
,
310 TerminalDevice
->DevicePath
316 RawFiFoInsertOneKey (TerminalDevice
, Input
);
320 // Translate all the raw data in RawFIFO into EFI Key,
321 // according to different terminal type supported.
323 TranslateRawDataToEfiKey (TerminalDevice
);
325 if (IsEfiKeyFiFoEmpty (TerminalDevice
)) {
326 return EFI_NOT_READY
;
333 GetOneKeyFromSerial (
334 EFI_SERIAL_IO_PROTOCOL
*SerialIo
,
338 Get one key out of serial buffer.
339 If serial buffer is empty, return EFI_NOT_READY;
340 if reading serial buffer encounter error, returns EFI_DEVICE_ERROR;
341 if reading serial buffer successfully, put the fetched key to
342 the parameter "Input", and return EFI_SUCCESS.
351 Status
= SerialIo
->Read (SerialIo
, &Size
, Input
);
353 if (EFI_ERROR (Status
)) {
355 if (Status
== EFI_TIMEOUT
) {
356 return EFI_NOT_READY
;
359 return EFI_DEVICE_ERROR
;
364 return EFI_NOT_READY
;
371 RawFiFoInsertOneKey (
372 TERMINAL_DEV
*TerminalDevice
,
376 Insert one byte raw data into the Raw Data FIFO.
377 If FIFO is FULL before data insertion,
378 return FALSE, and the key is lost.
383 Tail
= TerminalDevice
->RawFiFo
.Tail
;
385 if (IsRawFiFoFull (TerminalDevice
)) {
392 TerminalDevice
->RawFiFo
.Data
[Tail
] = Input
;
394 TerminalDevice
->RawFiFo
.Tail
= (UINT8
) ((Tail
+ 1) % (RAW_FIFO_MAX_NUMBER
+ 1));
400 RawFiFoRemoveOneKey (
401 TERMINAL_DEV
*TerminalDevice
,
405 Remove one byte raw data out of the Raw Data FIFO.
406 If FIFO buffer is empty before remove operation,
412 Head
= TerminalDevice
->RawFiFo
.Head
;
414 if (IsRawFiFoEmpty (TerminalDevice
)) {
422 *Output
= TerminalDevice
->RawFiFo
.Data
[Head
];
424 TerminalDevice
->RawFiFo
.Head
= (UINT8
) ((Head
+ 1) % (RAW_FIFO_MAX_NUMBER
+ 1));
431 TERMINAL_DEV
*TerminalDevice
434 Clarify whether FIFO buffer is empty.
437 if (TerminalDevice
->RawFiFo
.Head
== TerminalDevice
->RawFiFo
.Tail
) {
446 TERMINAL_DEV
*TerminalDevice
449 Clarify whether FIFO buffer is full.
455 Tail
= TerminalDevice
->RawFiFo
.Tail
;
456 Head
= TerminalDevice
->RawFiFo
.Head
;
458 if (((Tail
+ 1) % (RAW_FIFO_MAX_NUMBER
+ 1)) == Head
) {
467 EfiKeyFiFoInsertOneKey (
468 TERMINAL_DEV
*TerminalDevice
,
472 Insert one pre-fetched key into the FIFO buffer.
473 If FIFO buffer is FULL before key insertion,
474 return FALSE, and the key is lost.
479 Tail
= TerminalDevice
->EfiKeyFiFo
.Tail
;
481 if (IsEfiKeyFiFoFull (TerminalDevice
)) {
483 // Efi Key FIFO is full
488 TerminalDevice
->EfiKeyFiFo
.Data
[Tail
] = Key
;
490 TerminalDevice
->EfiKeyFiFo
.Tail
= (UINT8
) ((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1));
496 EfiKeyFiFoRemoveOneKey (
497 TERMINAL_DEV
*TerminalDevice
,
498 EFI_INPUT_KEY
*Output
501 Remove one pre-fetched key out of the FIFO buffer.
502 If FIFO buffer is empty before remove operation,
508 Head
= TerminalDevice
->EfiKeyFiFo
.Head
;
510 if (IsEfiKeyFiFoEmpty (TerminalDevice
)) {
514 Output
->ScanCode
= SCAN_NULL
;
515 Output
->UnicodeChar
= 0;
519 *Output
= TerminalDevice
->EfiKeyFiFo
.Data
[Head
];
521 TerminalDevice
->EfiKeyFiFo
.Head
= (UINT8
) ((Head
+ 1) % (FIFO_MAX_NUMBER
+ 1));
528 TERMINAL_DEV
*TerminalDevice
531 Clarify whether FIFO buffer is empty.
534 if (TerminalDevice
->EfiKeyFiFo
.Head
== TerminalDevice
->EfiKeyFiFo
.Tail
) {
543 TERMINAL_DEV
*TerminalDevice
546 Clarify whether FIFO buffer is full.
552 Tail
= TerminalDevice
->EfiKeyFiFo
.Tail
;
553 Head
= TerminalDevice
->EfiKeyFiFo
.Head
;
555 if (((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1)) == Head
) {
564 UnicodeFiFoInsertOneKey (
565 TERMINAL_DEV
*TerminalDevice
,
569 Insert one pre-fetched key into the FIFO buffer.
570 If FIFO buffer is FULL before key insertion,
571 return FALSE, and the key is lost.
576 Tail
= TerminalDevice
->UnicodeFiFo
.Tail
;
578 if (IsUnicodeFiFoFull (TerminalDevice
)) {
580 // Unicode FIFO is full
585 TerminalDevice
->UnicodeFiFo
.Data
[Tail
] = Input
;
587 TerminalDevice
->UnicodeFiFo
.Tail
= (UINT8
) ((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1));
593 UnicodeFiFoRemoveOneKey (
594 TERMINAL_DEV
*TerminalDevice
,
598 Remove one pre-fetched key out of the FIFO buffer.
599 If FIFO buffer is empty before remove operation,
605 Head
= TerminalDevice
->UnicodeFiFo
.Head
;
607 if (IsUnicodeFiFoEmpty (TerminalDevice
)) {
615 *Output
= TerminalDevice
->UnicodeFiFo
.Data
[Head
];
617 TerminalDevice
->UnicodeFiFo
.Head
= (UINT8
) ((Head
+ 1) % (FIFO_MAX_NUMBER
+ 1));
624 TERMINAL_DEV
*TerminalDevice
627 Clarify whether FIFO buffer is empty.
630 if (TerminalDevice
->UnicodeFiFo
.Head
== TerminalDevice
->UnicodeFiFo
.Tail
) {
639 TERMINAL_DEV
*TerminalDevice
642 Clarify whether FIFO buffer is full.
648 Tail
= TerminalDevice
->UnicodeFiFo
.Tail
;
649 Head
= TerminalDevice
->UnicodeFiFo
.Head
;
651 if (((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1)) == Head
) {
660 UnicodeFiFoGetKeyCount (
661 TERMINAL_DEV
*TerminalDevice
667 Tail
= TerminalDevice
->UnicodeFiFo
.Tail
;
668 Head
= TerminalDevice
->UnicodeFiFo
.Head
;
671 return (UINT8
) (Tail
- Head
);
673 return (UINT8
) (Tail
+ FIFO_MAX_NUMBER
+ 1 - Head
);
679 UnicodeToEfiKeyFlushState (
680 IN TERMINAL_DEV
*TerminalDevice
685 if (TerminalDevice
->InputState
& INPUT_STATE_ESC
) {
686 Key
.ScanCode
= SCAN_ESC
;
688 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
691 if (TerminalDevice
->InputState
& INPUT_STATE_CSI
) {
692 Key
.ScanCode
= SCAN_NULL
;
693 Key
.UnicodeChar
= CSI
;
694 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
697 if (TerminalDevice
->InputState
& INPUT_STATE_LEFTOPENBRACKET
) {
698 Key
.ScanCode
= SCAN_NULL
;
699 Key
.UnicodeChar
= LEFTOPENBRACKET
;
700 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
703 if (TerminalDevice
->InputState
& INPUT_STATE_O
) {
704 Key
.ScanCode
= SCAN_NULL
;
705 Key
.UnicodeChar
= 'O';
706 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
709 if (TerminalDevice
->InputState
& INPUT_STATE_2
) {
710 Key
.ScanCode
= SCAN_NULL
;
711 Key
.UnicodeChar
= '2';
712 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
716 TerminalDevice
->TwoSecondTimeOut
,
721 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
726 IN TERMINAL_DEV
*TerminalDevice
731 Converts a stream of Unicode characters from a terminal input device into EFI Keys that
732 can be read through the Simple Input Protocol. The table below shows the keyboard
733 input mappings that this function supports. If the ESC sequence listed in one of the
734 columns is presented, then it is translated into the coorespoding EFI Scan Code. If a
735 matching sequence is not found, then the raw key strokes are converted into EFI Keys.
737 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not
738 completed in 2 seconds, then the raw key strokes of the partial ESC sequence are
739 converted into EFI Keys.
741 There is one special input sequence that will force the system to reset.
742 This is ESC R ESC r ESC R.
746 TerminaDevice : The terminal device to use to translate raw input into EFI Keys
752 Symbols used in table below
753 ===========================
759 +=========+======+===========+==========+==========+
760 | | EFI | EFI 1.10 | | |
761 | | Scan | | VT100+ | |
762 | KEY | Code | PC ANSI | VTUTF8 | VT100 |
763 +=========+======+===========+==========+==========+
764 | NULL | 0x00 | | | |
765 | UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |
766 | DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |
767 | RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |
768 | LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |
769 | HOME | 0x05 | ESC [ H | ESC h | ESC [ H |
770 | END | 0x06 | ESC [ F | ESC k | ESC [ K |
771 | INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |
772 | | | ESC [ L | | ESC [ L |
773 | DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |
774 | PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |
776 | PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |
778 | F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |
779 | F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |
780 | F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |
781 | F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |
782 | F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |
783 | F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |
784 | F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |
785 | F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |
786 | F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |
787 | F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |
788 | Escape | 0x17 | ESC | ESC | ESC |
789 +=========+======+===========+==========+=========+
793 ESC R ESC r ESC R = Reset System
798 EFI_STATUS TimerStatus
;
801 BOOLEAN SetDefaultResetState
;
803 TimerStatus
= gBS
->CheckEvent (TerminalDevice
->TwoSecondTimeOut
);
805 if (!EFI_ERROR (TimerStatus
)) {
806 UnicodeToEfiKeyFlushState (TerminalDevice
);
807 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
810 while (!IsUnicodeFiFoEmpty(TerminalDevice
)) {
812 if (TerminalDevice
->InputState
!= INPUT_STATE_DEFAULT
) {
814 // Check to see if the 2 second timer has expired
816 TimerStatus
= gBS
->CheckEvent (TerminalDevice
->TwoSecondTimeOut
);
817 if (!EFI_ERROR (TimerStatus
)) {
818 UnicodeToEfiKeyFlushState (TerminalDevice
);
819 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
824 // Fetch one Unicode character from the Unicode FIFO
826 UnicodeFiFoRemoveOneKey (TerminalDevice
,&UnicodeChar
);
828 SetDefaultResetState
= TRUE
;
830 switch (TerminalDevice
->InputState
) {
831 case INPUT_STATE_DEFAULT
:
835 case INPUT_STATE_ESC
:
837 if (UnicodeChar
== LEFTOPENBRACKET
) {
838 TerminalDevice
->InputState
|= INPUT_STATE_LEFTOPENBRACKET
;
839 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
843 if (UnicodeChar
== 'O' && TerminalDevice
->TerminalType
== VT100Type
) {
844 TerminalDevice
->InputState
|= INPUT_STATE_O
;
845 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
849 Key
.ScanCode
= SCAN_NULL
;
851 if (TerminalDevice
->TerminalType
== VT100PlusType
||
852 TerminalDevice
->TerminalType
== VTUTF8Type
) {
853 switch (UnicodeChar
) {
855 Key
.ScanCode
= SCAN_F1
;
858 Key
.ScanCode
= SCAN_F2
;
861 Key
.ScanCode
= SCAN_F3
;
864 Key
.ScanCode
= SCAN_F4
;
867 Key
.ScanCode
= SCAN_F5
;
870 Key
.ScanCode
= SCAN_F6
;
873 Key
.ScanCode
= SCAN_F7
;
876 Key
.ScanCode
= SCAN_F8
;
879 Key
.ScanCode
= SCAN_F9
;
882 Key
.ScanCode
= SCAN_F10
;
885 Key
.ScanCode
= SCAN_HOME
;
888 Key
.ScanCode
= SCAN_END
;
891 Key
.ScanCode
= SCAN_INSERT
;
894 Key
.ScanCode
= SCAN_DELETE
;
897 Key
.ScanCode
= SCAN_PAGE_DOWN
;
900 Key
.ScanCode
= SCAN_PAGE_UP
;
907 switch (UnicodeChar
) {
909 if (TerminalDevice
->ResetState
== RESET_STATE_DEFAULT
) {
910 TerminalDevice
->ResetState
= RESET_STATE_ESC_R
;
911 SetDefaultResetState
= FALSE
;
912 } else if (TerminalDevice
->ResetState
== RESET_STATE_ESC_R_ESC_r
) {
913 gRT
->ResetSystem (EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
915 Key
.ScanCode
= SCAN_NULL
;
918 if (TerminalDevice
->ResetState
== RESET_STATE_ESC_R
) {
919 TerminalDevice
->ResetState
= RESET_STATE_ESC_R_ESC_r
;
920 SetDefaultResetState
= FALSE
;
922 Key
.ScanCode
= SCAN_NULL
;
928 if (SetDefaultResetState
) {
929 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
932 if (Key
.ScanCode
!= SCAN_NULL
) {
934 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);
935 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
936 UnicodeToEfiKeyFlushState (TerminalDevice
);
940 UnicodeToEfiKeyFlushState (TerminalDevice
);
944 case INPUT_STATE_ESC
| INPUT_STATE_O
:
946 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
948 Key
.ScanCode
= SCAN_NULL
;
950 if (TerminalDevice
->TerminalType
== VT100Type
) {
951 switch (UnicodeChar
) {
953 Key
.ScanCode
= SCAN_F1
;
956 Key
.ScanCode
= SCAN_F2
;
959 Key
.ScanCode
= SCAN_F3
;
962 Key
.ScanCode
= SCAN_F4
;
965 Key
.ScanCode
= SCAN_F5
;
968 Key
.ScanCode
= SCAN_F6
;
971 Key
.ScanCode
= SCAN_F7
;
974 Key
.ScanCode
= SCAN_F8
;
977 Key
.ScanCode
= SCAN_F9
;
980 Key
.ScanCode
= SCAN_F10
;
987 if (Key
.ScanCode
!= SCAN_NULL
) {
989 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);
990 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
991 UnicodeToEfiKeyFlushState (TerminalDevice
);
995 UnicodeToEfiKeyFlushState (TerminalDevice
);
999 case INPUT_STATE_ESC
| INPUT_STATE_LEFTOPENBRACKET
:
1001 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
1003 Key
.ScanCode
= SCAN_NULL
;
1005 if (TerminalDevice
->TerminalType
== PcAnsiType
||
1006 TerminalDevice
->TerminalType
== VT100Type
||
1007 TerminalDevice
->TerminalType
== VT100PlusType
||
1008 TerminalDevice
->TerminalType
== VTUTF8Type
) {
1009 switch (UnicodeChar
) {
1011 Key
.ScanCode
= SCAN_UP
;
1014 Key
.ScanCode
= SCAN_DOWN
;
1017 Key
.ScanCode
= SCAN_RIGHT
;
1020 Key
.ScanCode
= SCAN_LEFT
;
1023 if (TerminalDevice
->TerminalType
== PcAnsiType
||
1024 TerminalDevice
->TerminalType
== VT100Type
) {
1025 Key
.ScanCode
= SCAN_HOME
;
1029 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1030 Key
.ScanCode
= SCAN_END
;
1034 if (TerminalDevice
->TerminalType
== VT100Type
) {
1035 Key
.ScanCode
= SCAN_END
;
1040 if (TerminalDevice
->TerminalType
== PcAnsiType
||
1041 TerminalDevice
->TerminalType
== VT100Type
) {
1042 Key
.ScanCode
= SCAN_INSERT
;
1046 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1047 Key
.ScanCode
= SCAN_DELETE
;
1051 if (TerminalDevice
->TerminalType
== VT100Type
) {
1052 Key
.ScanCode
= SCAN_DELETE
;
1053 } else if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1054 Key
.ScanCode
= SCAN_F4
;
1058 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1059 Key
.ScanCode
= SCAN_PAGE_UP
;
1063 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1064 Key
.ScanCode
= SCAN_F10
;
1067 if (TerminalDevice
->TerminalType
== VT100Type
) {
1068 Key
.ScanCode
= SCAN_PAGE_UP
;
1072 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1073 Key
.ScanCode
= SCAN_PAGE_DOWN
;
1077 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1078 Key
.ScanCode
= SCAN_F9
;
1081 if (TerminalDevice
->TerminalType
== VT100Type
) {
1082 Key
.ScanCode
= SCAN_PAGE_DOWN
;
1086 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1087 Key
.ScanCode
= SCAN_F1
;
1091 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1092 Key
.ScanCode
= SCAN_F2
;
1096 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1097 Key
.ScanCode
= SCAN_F3
;
1101 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1102 Key
.ScanCode
= SCAN_F5
;
1106 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1107 Key
.ScanCode
= SCAN_F6
;
1111 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1112 Key
.ScanCode
= SCAN_F7
;
1116 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1117 Key
.ScanCode
= SCAN_F8
;
1125 if (Key
.ScanCode
!= SCAN_NULL
) {
1126 Key
.UnicodeChar
= 0;
1127 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);
1128 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
1129 UnicodeToEfiKeyFlushState (TerminalDevice
);
1133 UnicodeToEfiKeyFlushState (TerminalDevice
);
1140 // Invalid state. This should never happen.
1144 UnicodeToEfiKeyFlushState (TerminalDevice
);
1149 if (UnicodeChar
== ESC
) {
1150 TerminalDevice
->InputState
= INPUT_STATE_ESC
;
1153 if (TerminalDevice
->InputState
!= INPUT_STATE_DEFAULT
) {
1154 Status
= gBS
->SetTimer(
1155 TerminalDevice
->TwoSecondTimeOut
,
1159 ASSERT_EFI_ERROR (Status
);
1163 if (SetDefaultResetState
) {
1164 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
1167 if (UnicodeChar
== DEL
) {
1168 Key
.ScanCode
= SCAN_DELETE
;
1169 Key
.UnicodeChar
= 0;
1171 Key
.ScanCode
= SCAN_NULL
;
1172 Key
.UnicodeChar
= UnicodeChar
;
1175 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);