3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
27 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
28 IN BOOLEAN ExtendedVerification
33 Implements EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset().
34 This driver only perform dependent serial device reset regardless of
35 the value of ExtendeVerification
39 This - Indicates the calling context.
41 ExtendedVerification - Skip by this driver.
46 The reset operation succeeds.
49 The dependent serial port reset fails.
54 TERMINAL_DEV
*TerminalDevice
;
56 TerminalDevice
= TERMINAL_CON_IN_DEV_FROM_THIS (This
);
59 // Report progress code here
61 Status
= REPORT_STATUS_CODE_WITH_DEVICE_PATH (
63 EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_PC_RESET
,
64 TerminalDevice
->DevicePath
67 Status
= TerminalDevice
->SerialIo
->Reset (TerminalDevice
->SerialIo
);
70 // clear all the internal buffer for keys
72 InitializeRawFiFo (TerminalDevice
);
73 InitializeUnicodeFiFo (TerminalDevice
);
74 InitializeEfiKeyFiFo (TerminalDevice
);
76 if (EFI_ERROR (Status
)) {
77 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
78 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
79 EFI_PERIPHERAL_LOCAL_CONSOLE
| EFI_P_EC_CONTROLLER_ERROR
,
80 TerminalDevice
->DevicePath
89 TerminalConInReadKeyStroke (
90 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
91 OUT EFI_INPUT_KEY
*Key
96 Implements EFI_SIMPLE_TEXT_IN_PROTOCOL.ReadKeyStroke().
100 This - Indicates the calling context.
102 Key - A pointer to a buffer that is filled in with the keystroke
103 information for the key that was sent from terminal.
108 The keystroke information is returned successfully.
111 There is no keystroke data available.
114 The dependent serial device encounters error.
118 TERMINAL_DEV
*TerminalDevice
;
122 // Initialize *Key to nonsense value.
124 Key
->ScanCode
= SCAN_NULL
;
125 Key
->UnicodeChar
= 0;
127 // get TERMINAL_DEV from "This" parameter.
129 TerminalDevice
= TERMINAL_CON_IN_DEV_FROM_THIS (This
);
131 Status
= TerminalConInCheckForKey (This
);
132 if (EFI_ERROR (Status
)) {
133 return EFI_NOT_READY
;
136 EfiKeyFiFoRemoveOneKey (TerminalDevice
, Key
);
143 TranslateRawDataToEfiKey (
144 IN TERMINAL_DEV
*TerminalDevice
147 Step1: Turn raw data into Unicode (according to different encode).
148 Step2: Translate Unicode into key information.
149 (according to different terminal standard).
152 switch (TerminalDevice
->TerminalType
) {
157 AnsiRawDataToUnicode (TerminalDevice
);
158 UnicodeToEfiKey (TerminalDevice
);
163 // Process all the raw data in the RawFIFO,
164 // put the processed key into UnicodeFIFO.
166 VTUTF8RawDataToUnicode (TerminalDevice
);
169 // Translate all the Unicode data in the UnicodeFIFO to Efi key,
170 // then put into EfiKeyFIFO.
172 UnicodeToEfiKey (TerminalDevice
);
180 TerminalConInWaitForKey (
187 Event notification function for EFI_SIMPLE_TEXT_IN_PROTOCOL.WaitForKey event
188 Signal the event if there is key available
192 Event - Indicates the event that invoke this function.
194 Context - Indicates the calling context.
203 // Someone is waiting on the keystroke event, if there's
204 // a key pending, signal the event
206 // Context is the pointer to EFI_SIMPLE_TEXT_IN_PROTOCOL
208 if (!EFI_ERROR (TerminalConInCheckForKey (Context
))) {
210 gBS
->SignalEvent (Event
);
215 TerminalConInCheckForKey (
216 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
221 Check for a pending key in the Efi Key FIFO or Serial device buffer.
225 This - Indicates the calling context.
230 There is key pending.
233 There is no key pending.
240 TERMINAL_DEV
*TerminalDevice
;
243 EFI_SERIAL_IO_MODE
*Mode
;
244 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
245 UINTN SerialInTimeOut
;
247 TerminalDevice
= TERMINAL_CON_IN_DEV_FROM_THIS (This
);
249 SerialIo
= TerminalDevice
->SerialIo
;
250 if (SerialIo
== NULL
) {
251 return EFI_DEVICE_ERROR
;
254 // if current timeout value for serial device is not identical with
255 // the value saved in TERMINAL_DEV structure, then recalculate the
256 // timeout value again and set serial attribute according to this value.
258 Mode
= SerialIo
->Mode
;
259 if (Mode
->Timeout
!= TerminalDevice
->SerialInTimeOut
) {
262 if (Mode
->BaudRate
!= 0) {
263 SerialInTimeOut
= (1 + Mode
->DataBits
+ Mode
->StopBits
) * 2 * 1000000 / (UINTN
) Mode
->BaudRate
;
266 Status
= SerialIo
->SetAttributes (
269 Mode
->ReceiveFifoDepth
,
270 (UINT32
) SerialInTimeOut
,
272 (UINT8
) Mode
->DataBits
,
276 if (EFI_ERROR (Status
)) {
277 TerminalDevice
->SerialInTimeOut
= 0;
279 TerminalDevice
->SerialInTimeOut
= SerialInTimeOut
;
283 // check whether serial buffer is empty
285 Status
= SerialIo
->GetControl (SerialIo
, &Control
);
287 if (Control
& EFI_SERIAL_INPUT_BUFFER_EMPTY
) {
289 // Translate all the raw data in RawFIFO into EFI Key,
290 // according to different terminal type supported.
292 TranslateRawDataToEfiKey (TerminalDevice
);
295 // if there is pre-fetched Efi Key in EfiKeyFIFO buffer,
298 if (!IsEfiKeyFiFoEmpty (TerminalDevice
)) {
301 return EFI_NOT_READY
;
305 // Fetch all the keys in the serial buffer,
306 // and insert the byte stream into RawFIFO.
310 Status
= GetOneKeyFromSerial (TerminalDevice
->SerialIo
, &Input
);
312 if (EFI_ERROR (Status
)) {
313 if (Status
== EFI_DEVICE_ERROR
) {
314 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
315 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
316 EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_INPUT_ERROR
,
317 TerminalDevice
->DevicePath
323 RawFiFoInsertOneKey (TerminalDevice
, Input
);
327 // Translate all the raw data in RawFIFO into EFI Key,
328 // according to different terminal type supported.
330 TranslateRawDataToEfiKey (TerminalDevice
);
332 if (IsEfiKeyFiFoEmpty (TerminalDevice
)) {
333 return EFI_NOT_READY
;
340 GetOneKeyFromSerial (
341 EFI_SERIAL_IO_PROTOCOL
*SerialIo
,
345 Get one key out of serial buffer.
346 If serial buffer is empty, return EFI_NOT_READY;
347 if reading serial buffer encounter error, returns EFI_DEVICE_ERROR;
348 if reading serial buffer successfully, put the fetched key to
349 the parameter "Input", and return EFI_SUCCESS.
358 Status
= SerialIo
->Read (SerialIo
, &Size
, Input
);
360 if (EFI_ERROR (Status
)) {
362 if (Status
== EFI_TIMEOUT
) {
363 return EFI_NOT_READY
;
366 return EFI_DEVICE_ERROR
;
371 return EFI_NOT_READY
;
378 RawFiFoInsertOneKey (
379 TERMINAL_DEV
*TerminalDevice
,
383 Insert one byte raw data into the Raw Data FIFO.
384 If FIFO is FULL before data insertion,
385 return FALSE, and the key is lost.
390 Tail
= TerminalDevice
->RawFiFo
.Tail
;
392 if (IsRawFiFoFull (TerminalDevice
)) {
399 TerminalDevice
->RawFiFo
.Data
[Tail
] = Input
;
401 TerminalDevice
->RawFiFo
.Tail
= (UINT8
) ((Tail
+ 1) % (RAW_FIFO_MAX_NUMBER
+ 1));
407 RawFiFoRemoveOneKey (
408 TERMINAL_DEV
*TerminalDevice
,
412 Remove one byte raw data out of the Raw Data FIFO.
413 If FIFO buffer is empty before remove operation,
419 Head
= TerminalDevice
->RawFiFo
.Head
;
421 if (IsRawFiFoEmpty (TerminalDevice
)) {
429 *Output
= TerminalDevice
->RawFiFo
.Data
[Head
];
431 TerminalDevice
->RawFiFo
.Head
= (UINT8
) ((Head
+ 1) % (RAW_FIFO_MAX_NUMBER
+ 1));
438 TERMINAL_DEV
*TerminalDevice
441 Clarify whether FIFO buffer is empty.
444 if (TerminalDevice
->RawFiFo
.Head
== TerminalDevice
->RawFiFo
.Tail
) {
453 TERMINAL_DEV
*TerminalDevice
456 Clarify whether FIFO buffer is full.
462 Tail
= TerminalDevice
->RawFiFo
.Tail
;
463 Head
= TerminalDevice
->RawFiFo
.Head
;
465 if (((Tail
+ 1) % (RAW_FIFO_MAX_NUMBER
+ 1)) == Head
) {
474 EfiKeyFiFoInsertOneKey (
475 TERMINAL_DEV
*TerminalDevice
,
479 Insert one pre-fetched key into the FIFO buffer.
480 If FIFO buffer is FULL before key insertion,
481 return FALSE, and the key is lost.
486 Tail
= TerminalDevice
->EfiKeyFiFo
.Tail
;
488 if (IsEfiKeyFiFoFull (TerminalDevice
)) {
490 // Efi Key FIFO is full
495 TerminalDevice
->EfiKeyFiFo
.Data
[Tail
] = Key
;
497 TerminalDevice
->EfiKeyFiFo
.Tail
= (UINT8
) ((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1));
503 EfiKeyFiFoRemoveOneKey (
504 TERMINAL_DEV
*TerminalDevice
,
505 EFI_INPUT_KEY
*Output
508 Remove one pre-fetched key out of the FIFO buffer.
509 If FIFO buffer is empty before remove operation,
515 Head
= TerminalDevice
->EfiKeyFiFo
.Head
;
517 if (IsEfiKeyFiFoEmpty (TerminalDevice
)) {
521 Output
->ScanCode
= SCAN_NULL
;
522 Output
->UnicodeChar
= 0;
526 *Output
= TerminalDevice
->EfiKeyFiFo
.Data
[Head
];
528 TerminalDevice
->EfiKeyFiFo
.Head
= (UINT8
) ((Head
+ 1) % (FIFO_MAX_NUMBER
+ 1));
535 TERMINAL_DEV
*TerminalDevice
538 Clarify whether FIFO buffer is empty.
541 if (TerminalDevice
->EfiKeyFiFo
.Head
== TerminalDevice
->EfiKeyFiFo
.Tail
) {
550 TERMINAL_DEV
*TerminalDevice
553 Clarify whether FIFO buffer is full.
559 Tail
= TerminalDevice
->EfiKeyFiFo
.Tail
;
560 Head
= TerminalDevice
->EfiKeyFiFo
.Head
;
562 if (((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1)) == Head
) {
571 UnicodeFiFoInsertOneKey (
572 TERMINAL_DEV
*TerminalDevice
,
576 Insert one pre-fetched key into the FIFO buffer.
577 If FIFO buffer is FULL before key insertion,
578 return FALSE, and the key is lost.
583 Tail
= TerminalDevice
->UnicodeFiFo
.Tail
;
585 if (IsUnicodeFiFoFull (TerminalDevice
)) {
587 // Unicode FIFO is full
592 TerminalDevice
->UnicodeFiFo
.Data
[Tail
] = Input
;
594 TerminalDevice
->UnicodeFiFo
.Tail
= (UINT8
) ((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1));
600 UnicodeFiFoRemoveOneKey (
601 TERMINAL_DEV
*TerminalDevice
,
605 Remove one pre-fetched key out of the FIFO buffer.
606 If FIFO buffer is empty before remove operation,
612 Head
= TerminalDevice
->UnicodeFiFo
.Head
;
614 if (IsUnicodeFiFoEmpty (TerminalDevice
)) {
622 *Output
= TerminalDevice
->UnicodeFiFo
.Data
[Head
];
624 TerminalDevice
->UnicodeFiFo
.Head
= (UINT8
) ((Head
+ 1) % (FIFO_MAX_NUMBER
+ 1));
631 TERMINAL_DEV
*TerminalDevice
634 Clarify whether FIFO buffer is empty.
637 if (TerminalDevice
->UnicodeFiFo
.Head
== TerminalDevice
->UnicodeFiFo
.Tail
) {
646 TERMINAL_DEV
*TerminalDevice
649 Clarify whether FIFO buffer is full.
655 Tail
= TerminalDevice
->UnicodeFiFo
.Tail
;
656 Head
= TerminalDevice
->UnicodeFiFo
.Head
;
658 if (((Tail
+ 1) % (FIFO_MAX_NUMBER
+ 1)) == Head
) {
667 UnicodeFiFoGetKeyCount (
668 TERMINAL_DEV
*TerminalDevice
674 Tail
= TerminalDevice
->UnicodeFiFo
.Tail
;
675 Head
= TerminalDevice
->UnicodeFiFo
.Head
;
678 return (UINT8
) (Tail
- Head
);
680 return (UINT8
) (Tail
+ FIFO_MAX_NUMBER
+ 1 - Head
);
685 UnicodeToEfiKeyFlushState (
686 IN TERMINAL_DEV
*TerminalDevice
691 if (TerminalDevice
->InputState
& INPUT_STATE_ESC
) {
692 Key
.ScanCode
= SCAN_ESC
;
694 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
697 if (TerminalDevice
->InputState
& INPUT_STATE_CSI
) {
698 Key
.ScanCode
= SCAN_NULL
;
699 Key
.UnicodeChar
= CSI
;
700 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
703 if (TerminalDevice
->InputState
& INPUT_STATE_LEFTOPENBRACKET
) {
704 Key
.ScanCode
= SCAN_NULL
;
705 Key
.UnicodeChar
= LEFTOPENBRACKET
;
706 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
709 if (TerminalDevice
->InputState
& INPUT_STATE_O
) {
710 Key
.ScanCode
= SCAN_NULL
;
711 Key
.UnicodeChar
= 'O';
712 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
715 if (TerminalDevice
->InputState
& INPUT_STATE_2
) {
716 Key
.ScanCode
= SCAN_NULL
;
717 Key
.UnicodeChar
= '2';
718 EfiKeyFiFoInsertOneKey (TerminalDevice
, Key
);
722 TerminalDevice
->TwoSecondTimeOut
,
727 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
732 IN TERMINAL_DEV
*TerminalDevice
737 Converts a stream of Unicode characters from a terminal input device into EFI Keys that
738 can be read through the Simple Input Protocol. The table below shows the keyboard
739 input mappings that this function supports. If the ESC sequence listed in one of the
740 columns is presented, then it is translated into the coorespoding EFI Scan Code. If a
741 matching sequence is not found, then the raw key strokes are converted into EFI Keys.
743 2 seconds are allowed for an ESC sequence to be completed. If the ESC sequence is not
744 completed in 2 seconds, then the raw key strokes of the partial ESC sequence are
745 converted into EFI Keys.
747 There is one special input sequence that will force the system to reset.
748 This is ESC R ESC r ESC R.
752 TerminaDevice : The terminal device to use to translate raw input into EFI Keys
758 Symbols used in table below
759 ===========================
765 +=========+======+===========+==========+==========+
766 | | EFI | EFI 1.10 | | |
767 | | Scan | | VT100+ | |
768 | KEY | Code | PC ANSI | VTUTF8 | VT100 |
769 +=========+======+===========+==========+==========+
770 | NULL | 0x00 | | | |
771 | UP | 0x01 | ESC [ A | ESC [ A | ESC [ A |
772 | DOWN | 0x02 | ESC [ B | ESC [ B | ESC [ B |
773 | RIGHT | 0x03 | ESC [ C | ESC [ C | ESC [ C |
774 | LEFT | 0x04 | ESC [ D | ESC [ D | ESC [ D |
775 | HOME | 0x05 | ESC [ H | ESC h | ESC [ H |
776 | END | 0x06 | ESC [ F | ESC k | ESC [ K |
777 | INSERT | 0x07 | ESC [ @ | ESC + | ESC [ @ |
778 | | | ESC [ L | | ESC [ L |
779 | DELETE | 0x08 | ESC [ X | ESC - | ESC [ P |
780 | PG UP | 0x09 | ESC [ I | ESC ? | ESC [ V |
782 | PG DOWN | 0x0A | ESC [ G | ESC / | ESC [ U |
784 | F1 | 0x0B | ESC [ M | ESC 1 | ESC O P |
785 | F2 | 0x0C | ESC [ N | ESC 2 | ESC O Q |
786 | F3 | 0x0D | ESC [ O | ESC 3 | ESC O w |
787 | F4 | 0x0E | ESC [ P | ESC 4 | ESC O x |
788 | F5 | 0x0F | ESC [ Q | ESC 5 | ESC O t |
789 | F6 | 0x10 | ESC [ R | ESC 6 | ESC O u |
790 | F7 | 0x11 | ESC [ S | ESC 7 | ESC O q |
791 | F8 | 0x12 | ESC [ T | ESC 8 | ESC O r |
792 | F9 | 0x13 | ESC [ U | ESC 9 | ESC O p |
793 | F10 | 0x14 | ESC [ V | ESC 0 | ESC O M |
794 | Escape | 0x17 | ESC | ESC | ESC |
795 +=========+======+===========+==========+=========+
799 ESC R ESC r ESC R = Reset System
804 EFI_STATUS TimerStatus
;
807 BOOLEAN SetDefaultResetState
;
809 TimerStatus
= gBS
->CheckEvent (TerminalDevice
->TwoSecondTimeOut
);
811 if (!EFI_ERROR (TimerStatus
)) {
812 UnicodeToEfiKeyFlushState (TerminalDevice
);
813 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
816 while (!IsUnicodeFiFoEmpty(TerminalDevice
)) {
818 if (TerminalDevice
->InputState
!= INPUT_STATE_DEFAULT
) {
820 // Check to see if the 2 second timer has expired
822 TimerStatus
= gBS
->CheckEvent (TerminalDevice
->TwoSecondTimeOut
);
823 if (!EFI_ERROR (TimerStatus
)) {
824 UnicodeToEfiKeyFlushState (TerminalDevice
);
825 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
830 // Fetch one Unicode character from the Unicode FIFO
832 UnicodeFiFoRemoveOneKey (TerminalDevice
,&UnicodeChar
);
834 SetDefaultResetState
= TRUE
;
836 switch (TerminalDevice
->InputState
) {
837 case INPUT_STATE_DEFAULT
:
841 case INPUT_STATE_ESC
:
843 if (UnicodeChar
== LEFTOPENBRACKET
) {
844 TerminalDevice
->InputState
|= INPUT_STATE_LEFTOPENBRACKET
;
845 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
849 if (UnicodeChar
== 'O' && TerminalDevice
->TerminalType
== VT100Type
) {
850 TerminalDevice
->InputState
|= INPUT_STATE_O
;
851 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
855 Key
.ScanCode
= SCAN_NULL
;
857 if (TerminalDevice
->TerminalType
== VT100PlusType
||
858 TerminalDevice
->TerminalType
== VTUTF8Type
) {
859 switch (UnicodeChar
) {
861 Key
.ScanCode
= SCAN_F1
;
864 Key
.ScanCode
= SCAN_F2
;
867 Key
.ScanCode
= SCAN_F3
;
870 Key
.ScanCode
= SCAN_F4
;
873 Key
.ScanCode
= SCAN_F5
;
876 Key
.ScanCode
= SCAN_F6
;
879 Key
.ScanCode
= SCAN_F7
;
882 Key
.ScanCode
= SCAN_F8
;
885 Key
.ScanCode
= SCAN_F9
;
888 Key
.ScanCode
= SCAN_F10
;
891 Key
.ScanCode
= SCAN_HOME
;
894 Key
.ScanCode
= SCAN_END
;
897 Key
.ScanCode
= SCAN_INSERT
;
900 Key
.ScanCode
= SCAN_DELETE
;
903 Key
.ScanCode
= SCAN_PAGE_DOWN
;
906 Key
.ScanCode
= SCAN_PAGE_UP
;
913 switch (UnicodeChar
) {
915 if (TerminalDevice
->ResetState
== RESET_STATE_DEFAULT
) {
916 TerminalDevice
->ResetState
= RESET_STATE_ESC_R
;
917 SetDefaultResetState
= FALSE
;
918 } else if (TerminalDevice
->ResetState
== RESET_STATE_ESC_R_ESC_r
) {
919 gRT
->ResetSystem (EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
921 Key
.ScanCode
= SCAN_NULL
;
924 if (TerminalDevice
->ResetState
== RESET_STATE_ESC_R
) {
925 TerminalDevice
->ResetState
= RESET_STATE_ESC_R_ESC_r
;
926 SetDefaultResetState
= FALSE
;
928 Key
.ScanCode
= SCAN_NULL
;
934 if (SetDefaultResetState
) {
935 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
938 if (Key
.ScanCode
!= SCAN_NULL
) {
940 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);
941 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
942 UnicodeToEfiKeyFlushState (TerminalDevice
);
946 UnicodeToEfiKeyFlushState (TerminalDevice
);
950 case INPUT_STATE_ESC
| INPUT_STATE_O
:
952 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
954 Key
.ScanCode
= SCAN_NULL
;
956 if (TerminalDevice
->TerminalType
== VT100Type
) {
957 switch (UnicodeChar
) {
959 Key
.ScanCode
= SCAN_F1
;
962 Key
.ScanCode
= SCAN_F2
;
965 Key
.ScanCode
= SCAN_F3
;
968 Key
.ScanCode
= SCAN_F4
;
971 Key
.ScanCode
= SCAN_F5
;
974 Key
.ScanCode
= SCAN_F6
;
977 Key
.ScanCode
= SCAN_F7
;
980 Key
.ScanCode
= SCAN_F8
;
983 Key
.ScanCode
= SCAN_F9
;
986 Key
.ScanCode
= SCAN_F10
;
993 if (Key
.ScanCode
!= SCAN_NULL
) {
995 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);
996 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
997 UnicodeToEfiKeyFlushState (TerminalDevice
);
1001 UnicodeToEfiKeyFlushState (TerminalDevice
);
1005 case INPUT_STATE_ESC
| INPUT_STATE_LEFTOPENBRACKET
:
1007 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
1009 Key
.ScanCode
= SCAN_NULL
;
1011 if (TerminalDevice
->TerminalType
== PcAnsiType
||
1012 TerminalDevice
->TerminalType
== VT100Type
||
1013 TerminalDevice
->TerminalType
== VT100PlusType
||
1014 TerminalDevice
->TerminalType
== VTUTF8Type
) {
1015 switch (UnicodeChar
) {
1017 Key
.ScanCode
= SCAN_UP
;
1020 Key
.ScanCode
= SCAN_DOWN
;
1023 Key
.ScanCode
= SCAN_RIGHT
;
1026 Key
.ScanCode
= SCAN_LEFT
;
1029 if (TerminalDevice
->TerminalType
== PcAnsiType
||
1030 TerminalDevice
->TerminalType
== VT100Type
) {
1031 Key
.ScanCode
= SCAN_HOME
;
1035 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1036 Key
.ScanCode
= SCAN_END
;
1040 if (TerminalDevice
->TerminalType
== VT100Type
) {
1041 Key
.ScanCode
= SCAN_END
;
1046 if (TerminalDevice
->TerminalType
== PcAnsiType
||
1047 TerminalDevice
->TerminalType
== VT100Type
) {
1048 Key
.ScanCode
= SCAN_INSERT
;
1052 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1053 Key
.ScanCode
= SCAN_DELETE
;
1057 if (TerminalDevice
->TerminalType
== VT100Type
) {
1058 Key
.ScanCode
= SCAN_DELETE
;
1059 } else if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1060 Key
.ScanCode
= SCAN_F4
;
1064 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1065 Key
.ScanCode
= SCAN_PAGE_UP
;
1069 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1070 Key
.ScanCode
= SCAN_F10
;
1073 if (TerminalDevice
->TerminalType
== VT100Type
) {
1074 Key
.ScanCode
= SCAN_PAGE_UP
;
1078 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1079 Key
.ScanCode
= SCAN_PAGE_DOWN
;
1083 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1084 Key
.ScanCode
= SCAN_F9
;
1087 if (TerminalDevice
->TerminalType
== VT100Type
) {
1088 Key
.ScanCode
= SCAN_PAGE_DOWN
;
1092 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1093 Key
.ScanCode
= SCAN_F1
;
1097 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1098 Key
.ScanCode
= SCAN_F2
;
1102 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1103 Key
.ScanCode
= SCAN_F3
;
1107 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1108 Key
.ScanCode
= SCAN_F5
;
1112 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1113 Key
.ScanCode
= SCAN_F6
;
1117 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1118 Key
.ScanCode
= SCAN_F7
;
1122 if (TerminalDevice
->TerminalType
== PcAnsiType
) {
1123 Key
.ScanCode
= SCAN_F8
;
1131 if (Key
.ScanCode
!= SCAN_NULL
) {
1132 Key
.UnicodeChar
= 0;
1133 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);
1134 TerminalDevice
->InputState
= INPUT_STATE_DEFAULT
;
1135 UnicodeToEfiKeyFlushState (TerminalDevice
);
1139 UnicodeToEfiKeyFlushState (TerminalDevice
);
1146 // Invalid state. This should never happen.
1150 UnicodeToEfiKeyFlushState (TerminalDevice
);
1155 if (UnicodeChar
== ESC
) {
1156 TerminalDevice
->InputState
= INPUT_STATE_ESC
;
1159 if (TerminalDevice
->InputState
!= INPUT_STATE_DEFAULT
) {
1160 Status
= gBS
->SetTimer(
1161 TerminalDevice
->TwoSecondTimeOut
,
1168 if (SetDefaultResetState
) {
1169 TerminalDevice
->ResetState
= RESET_STATE_DEFAULT
;
1172 if (UnicodeChar
== DEL
) {
1173 Key
.ScanCode
= SCAN_DELETE
;
1174 Key
.UnicodeChar
= 0;
1176 Key
.ScanCode
= SCAN_NULL
;
1177 Key
.UnicodeChar
= UnicodeChar
;
1180 EfiKeyFiFoInsertOneKey (TerminalDevice
,Key
);