2 Header file for Terminal driver.
4 Copyright (c) 2006 - 2008, 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 #include <Protocol/SimpleTextOut.h>
21 #include <Protocol/SerialIo.h>
22 #include <Guid/GlobalVariable.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/SimpleTextIn.h>
25 #include <Protocol/SimpleTextInEx.h>
26 #include <Guid/HotPlugDevice.h>
27 #include <Guid/PcAnsi.h>
28 #include <Library/DebugLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/UefiLib.h>
31 #include <Library/ReportStatusCodeLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/UefiBootServicesTableLib.h>
35 #include <Library/UefiRuntimeServicesTableLib.h>
36 #include <Library/DevicePathLib.h>
37 #include <Library/PcdLib.h>
38 #include <Library/BaseLib.h>
41 #define RAW_FIFO_MAX_NUMBER 256
42 #define FIFO_MAX_NUMBER 128
47 UINT8 Data
[RAW_FIFO_MAX_NUMBER
+ 1];
53 UINT16 Data
[FIFO_MAX_NUMBER
+ 1];
59 EFI_INPUT_KEY Data
[FIFO_MAX_NUMBER
+ 1];
62 #define TERMINAL_DEV_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'n', 'l')
64 #define TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('t', 'm', 'e', 'n')
66 typedef struct _TERMINAL_CONSOLE_IN_EX_NOTIFY
{
68 EFI_HANDLE NotifyHandle
;
70 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn
;
71 LIST_ENTRY NotifyEntry
;
72 } TERMINAL_CONSOLE_IN_EX_NOTIFY
;
77 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
78 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
79 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput
;
80 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput
;
81 EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode
;
82 UINTN SerialInTimeOut
;
83 RAW_DATA_FIFO RawFiFo
;
84 UNICODE_FIFO UnicodeFiFo
;
85 EFI_KEY_FIFO EfiKeyFiFo
;
86 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
87 EFI_EVENT TwoSecondTimeOut
;
92 // Esc could not be output to the screen by user,
93 // but the terminal driver need to output it to
94 // the terminal emulation software to send control sequence.
95 // This boolean is used by the terminal driver only
96 // to indicate whether the Esc could be sent or not.
98 BOOLEAN OutputEscChar
;
99 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx
;
100 LIST_ENTRY NotifyList
;
103 #define INPUT_STATE_DEFAULT 0x00
104 #define INPUT_STATE_ESC 0x01
105 #define INPUT_STATE_CSI 0x02
106 #define INPUT_STATE_LEFTOPENBRACKET 0x04
107 #define INPUT_STATE_O 0x08
108 #define INPUT_STATE_2 0x10
110 #define RESET_STATE_DEFAULT 0x00
111 #define RESET_STATE_ESC_R 0x01
112 #define RESET_STATE_ESC_R_ESC_r 0x02
114 #define TERMINAL_CON_IN_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInput, TERMINAL_DEV_SIGNATURE)
115 #define TERMINAL_CON_OUT_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleTextOutput, TERMINAL_DEV_SIGNATURE)
116 #define TERMINAL_CON_IN_EX_DEV_FROM_THIS(a) CR (a, TERMINAL_DEV, SimpleInputEx, TERMINAL_DEV_SIGNATURE)
126 #define VT100PLUSTYPE 2
129 #define LEFTOPENBRACKET 0x5b // '['
135 #define MODE0_COLUMN_COUNT 80
136 #define MODE0_ROW_COUNT 25
138 #define MODE1_COLUMN_COUNT 80
139 #define MODE1_ROW_COUNT 50
141 #define MODE2_COLUMN_COUNT 100
142 #define MODE2_ROW_COUNT 31
148 #define BRIGHT_CONTROL_OFFSET 2
149 #define FOREGROUND_CONTROL_OFFSET 6
150 #define BACKGROUND_CONTROL_OFFSET 11
152 #define COLUMN_OFFSET 5
163 extern EFI_DRIVER_BINDING_PROTOCOL gTerminalDriverBinding
;
164 extern EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName
;
165 extern EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2
;
167 extern EFI_GUID gSimpleTextInExNotifyGuid
;
170 The user Entry Point for module Terminal. The user code starts with this function.
172 @param[in] ImageHandle The firmware allocated handle for the EFI image.
173 @param[in] SystemTable A pointer to the EFI System Table.
175 @retval EFI_SUCCESS The entry point is executed successfully.
176 @retval other Some error occurs when executing this entry point.
182 IN EFI_HANDLE ImageHandle
,
183 IN EFI_SYSTEM_TABLE
*SystemTable
188 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset().
189 This driver only perform dependent serial device reset regardless of
190 the value of ExtendeVerification
192 @param This Indicates the calling context.
193 @param ExtendedVerification Skip by this driver.
196 @return The reset operation succeeds.
197 @return EFI_DEVICE_ERROR
198 @return The dependent serial port reset fails.
204 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
205 IN BOOLEAN ExtendedVerification
211 Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke().
213 @param This Indicates the calling context.
214 @param Key A pointer to a buffer that is filled in with the
215 keystroke information for the key that was sent
219 @return The keystroke information is returned successfully.
220 @return EFI_NOT_READY
221 @return There is no keystroke data available.
222 @return EFI_DEVICE_ERROR
223 @return The dependent serial device encounters error.
228 TerminalConInReadKeyStroke (
229 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
230 OUT EFI_INPUT_KEY
*Key
237 @param RegsiteredData A pointer to a buffer that is filled in with the
238 keystroke state data for the key that was
240 @param InputData A pointer to a buffer that is filled in with the
241 keystroke state data for the key that was
244 @retval TRUE Key be pressed matches a registered key.
245 @retval FLASE Match failed.
250 IN EFI_KEY_DATA
*RegsiteredData
,
251 IN EFI_KEY_DATA
*InputData
256 Event notification function for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
257 Signal the event if there is key available
259 @param Event Indicates the event that invoke this function.
260 @param Context Indicates the calling context.
267 TerminalConInWaitForKeyEx (
274 // Simple Text Input Ex protocol prototypes
278 Reset the input device and optionaly run diagnostics
280 @param This Protocol instance pointer.
281 @param ExtendedVerification Driver may perform diagnostics on reset.
283 @retval EFI_SUCCESS The device was reset.
284 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
290 TerminalConInResetEx (
291 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
292 IN BOOLEAN ExtendedVerification
297 Reads the next keystroke from the input device. The WaitForKey Event can
298 be used to test for existance of a keystroke via WaitForEvent () call.
300 @param This Protocol instance pointer.
301 @param KeyData A pointer to a buffer that is filled in with the
302 keystroke state data for the key that was
305 @retval EFI_SUCCESS The keystroke information was returned.
306 @retval EFI_NOT_READY There was no keystroke data availiable.
307 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
309 @retval EFI_INVALID_PARAMETER KeyData is NULL.
314 TerminalConInReadKeyStrokeEx (
315 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
316 OUT EFI_KEY_DATA
*KeyData
321 Set certain state for the input device.
323 @param This Protocol instance pointer.
324 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
325 state for the input device.
327 @retval EFI_SUCCESS The device state was set successfully.
328 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
329 could not have the setting adjusted.
330 @retval EFI_UNSUPPORTED The device does not have the ability to set its
332 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
337 TerminalConInSetState (
338 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
339 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
344 Register a notification function for a particular keystroke for the input device.
346 @param This Protocol instance pointer.
347 @param KeyData A pointer to a buffer that is filled in with the
348 keystroke information data for the key that was
350 @param KeyNotificationFunction Points to the function to be called when the key
351 sequence is typed specified by KeyData.
352 @param NotifyHandle Points to the unique handle assigned to the
353 registered notification.
355 @retval EFI_SUCCESS The notification function was registered
357 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
359 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.
364 TerminalConInRegisterKeyNotify (
365 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
366 IN EFI_KEY_DATA
*KeyData
,
367 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
368 OUT EFI_HANDLE
*NotifyHandle
373 Remove a registered notification function from a particular keystroke.
375 @param This Protocol instance pointer.
376 @param NotificationHandle The handle of the notification function being
379 @retval EFI_SUCCESS The notification function was unregistered
381 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
382 @retval EFI_NOT_FOUND Can not find the matching entry in database.
387 TerminalConInUnregisterKeyNotify (
388 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
389 IN EFI_HANDLE NotificationHandle
394 Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event
395 Signal the event if there is key available
397 @param Event Indicates the event that invoke this function.
398 @param Context Indicates the calling context.
405 TerminalConInWaitForKey (
412 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
413 If ExtendeVerification is TRUE, then perform dependent serial device reset,
414 and set display mode to mode 0.
415 If ExtendedVerification is FALSE, only set display mode to mode 0.
417 @param This Indicates the calling context.
418 @param ExtendedVerification Indicates that the driver may perform a more
419 exhaustive verification operation of the device
423 @return The reset operation succeeds.
424 @return EFI_DEVICE_ERROR
425 @return The terminal is not functioning correctly or the serial port reset fails.
430 TerminalConOutReset (
431 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
432 IN BOOLEAN ExtendedVerification
437 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
438 The Unicode string will be converted to terminal expressible data stream
439 and send to terminal via serial port.
441 @param This Indicates the calling context.
442 @param WString The Null-terminated Unicode string to be displayed
443 on the terminal screen.
445 @return EFI_SUCCESS The string is output successfully.
446 @return EFI_DEVICE_ERROR The serial port fails to send the string out.
447 @return EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
448 be rendered and are skipped.
449 @return EFI_UNSUPPORTED
454 TerminalConOutOutputString (
455 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
461 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
462 If one of the characters in the *Wstring is
463 neither valid Unicode drawing characters,
464 not ASCII code, then this function will return
467 @param This Indicates the calling context.
468 @param WString The Null-terminated Unicode string to be tested.
470 @return EFI_SUCCESS The terminal is capable of rendering the output string.
471 @return EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.
476 TerminalConOutTestString (
477 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
483 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
484 It returns information for an available text mode
485 that the terminal supports.
486 In this driver, we support text mode 80x25 (mode 0),
487 80x50 (mode 1), 100x31 (mode 2).
489 @param This Indicates the calling context.
490 @param ModeNumber The mode number to return information on.
491 @param Columns The returned columns of the requested mode.
492 @param Rows The returned rows of the requested mode.
494 @return EFI_SUCCESS The requested mode information is returned.
495 @return EFI_UNSUPPORTED The mode number is not valid.
496 @return EFI_DEVICE_ERROR
501 TerminalConOutQueryMode (
502 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
510 Implements EFI_SIMPLE_TEXT_OUT.SetMode().
511 Set the terminal to a specified display mode.
512 In this driver, we only support mode 0.
514 @param This Indicates the calling context.
515 @param ModeNumber The text mode to set.
517 @return EFI_SUCCESS The requested text mode is set.
518 @return EFI_DEVICE_ERROR The requested text mode cannot be set
519 because of serial device error.
520 @return EFI_UNSUPPORTED The text mode number is not valid.
525 TerminalConOutSetMode (
526 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
532 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
534 @param This Indicates the calling context.
535 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits
536 are undefined and must be zero.
538 @return EFI_SUCCESS The requested attribute is set.
539 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.
540 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
545 TerminalConOutSetAttribute (
546 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
552 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
553 It clears the ANSI terminal's display to the
554 currently selected background color.
556 @param This Indicates the calling context.
558 @return EFI_SUCCESS The operation completed successfully.
559 @return EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.
560 @return EFI_UNSUPPORTED The terminal is not in a valid display mode.
565 TerminalConOutClearScreen (
566 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
571 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
573 @param This Indicates the calling context.
574 @param Column The row to set cursor to.
575 @param Row The column to set cursor to.
577 @return EFI_SUCCESS The operation completed successfully.
578 @return EFI_DEVICE_ERROR The request fails due to serial port error.
579 @return EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position
580 is invalid for current mode.
585 TerminalConOutSetCursorPosition (
586 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
593 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
594 In this driver, the cursor cannot be hidden.
596 @param This Indicates the calling context.
597 @param Visible If TRUE, the cursor is set to be visible,
598 If FALSE, the cursor is set to be invisible.
600 @return EFI_SUCCESS The request is valid.
601 @return EFI_UNSUPPORTED The terminal does not support cursor hidden.
606 TerminalConOutEnableCursor (
607 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
614 TerminalDriverBindingSupported (
615 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
616 IN EFI_HANDLE Controller
,
617 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
622 TerminalDriverBindingStart (
623 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
624 IN EFI_HANDLE Controller
,
625 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
630 TerminalDriverBindingStop (
631 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
632 IN EFI_HANDLE Controller
,
633 IN UINTN NumberOfChildren
,
634 IN EFI_HANDLE
*ChildHandleBuffer
638 Retrieves a Unicode string that is the user readable name of the driver.
640 This function retrieves the user readable name of a driver in the form of a
641 Unicode string. If the driver specified by This has a user readable name in
642 the language specified by Language, then a pointer to the driver name is
643 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
644 by This does not support the language specified by Language,
645 then EFI_UNSUPPORTED is returned.
647 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
648 EFI_COMPONENT_NAME_PROTOCOL instance.
650 @param Language[in] A pointer to a Null-terminated ASCII string
651 array indicating the language. This is the
652 language of the driver name that the caller is
653 requesting, and it must match one of the
654 languages specified in SupportedLanguages. The
655 number of languages supported by a driver is up
656 to the driver writer. Language is specified
657 in RFC 3066 or ISO 639-2 language code format.
659 @param DriverName[out] A pointer to the Unicode string to return.
660 This Unicode string is the name of the
661 driver specified by This in the language
662 specified by Language.
664 @retval EFI_SUCCESS The Unicode string for the Driver specified by
665 This and the language specified by Language was
666 returned in DriverName.
668 @retval EFI_INVALID_PARAMETER Language is NULL.
670 @retval EFI_INVALID_PARAMETER DriverName is NULL.
672 @retval EFI_UNSUPPORTED The driver specified by This does not support
673 the language specified by Language.
678 TerminalComponentNameGetDriverName (
679 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
681 OUT CHAR16
**DriverName
686 Retrieves a Unicode string that is the user readable name of the controller
687 that is being managed by a driver.
689 This function retrieves the user readable name of the controller specified by
690 ControllerHandle and ChildHandle in the form of a Unicode string. If the
691 driver specified by This has a user readable name in the language specified by
692 Language, then a pointer to the controller name is returned in ControllerName,
693 and EFI_SUCCESS is returned. If the driver specified by This is not currently
694 managing the controller specified by ControllerHandle and ChildHandle,
695 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
696 support the language specified by Language, then EFI_UNSUPPORTED is returned.
698 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
699 EFI_COMPONENT_NAME_PROTOCOL instance.
701 @param ControllerHandle[in] The handle of a controller that the driver
702 specified by This is managing. This handle
703 specifies the controller whose name is to be
706 @param ChildHandle[in] The handle of the child controller to retrieve
707 the name of. This is an optional parameter that
708 may be NULL. It will be NULL for device
709 drivers. It will also be NULL for a bus drivers
710 that wish to retrieve the name of the bus
711 controller. It will not be NULL for a bus
712 driver that wishes to retrieve the name of a
715 @param Language[in] A pointer to a Null-terminated ASCII string
716 array indicating the language. This is the
717 language of the driver name that the caller is
718 requesting, and it must match one of the
719 languages specified in SupportedLanguages. The
720 number of languages supported by a driver is up
721 to the driver writer. Language is specified in
722 RFC 3066 or ISO 639-2 language code format.
724 @param ControllerName[out] A pointer to the Unicode string to return.
725 This Unicode string is the name of the
726 controller specified by ControllerHandle and
727 ChildHandle in the language specified by
728 Language from the point of view of the driver
731 @retval EFI_SUCCESS The Unicode string for the user readable name in
732 the language specified by Language for the
733 driver specified by This was returned in
736 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
738 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
741 @retval EFI_INVALID_PARAMETER Language is NULL.
743 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
745 @retval EFI_UNSUPPORTED The driver specified by This is not currently
746 managing the controller specified by
747 ControllerHandle and ChildHandle.
749 @retval EFI_UNSUPPORTED The driver specified by This does not support
750 the language specified by Language.
755 TerminalComponentNameGetControllerName (
756 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
757 IN EFI_HANDLE ControllerHandle
,
758 IN EFI_HANDLE ChildHandle OPTIONAL
,
760 OUT CHAR16
**ControllerName
765 // internal functions
769 Check for a pending key in the Efi Key FIFO or Serial device buffer.
771 @param This Indicates the calling context.
774 @return There is key pending.
775 @return EFI_NOT_READY
776 @return There is no key pending.
777 @return EFI_DEVICE_ERROR
781 TerminalConInCheckForKey (
782 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
787 TerminalUpdateConsoleDevVariable (
788 IN CHAR16
*VariableName
,
789 IN EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
794 Remove console device variable.
796 @param VariableName A pointer to the variable name.
797 @param ParentDevicePath A pointer to the parent device path.
803 TerminalRemoveConsoleDevVariable (
804 IN CHAR16
*VariableName
,
805 IN EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
810 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
811 buffer, and the size of the buffer. On failure return NULL.
813 @param Name String part of EFI variable name
814 @param VendorGuid GUID part of EFI variable name
815 @param VariableSize Returns the size of the EFI variable that was read
817 @return Dynamically allocated memory that contains a copy of the EFI variable.
818 @return Caller is repsoncible freeing the buffer.
819 @retval NULL Variable was not read
823 TerminalGetVariableAndSize (
825 IN EFI_GUID
*VendorGuid
,
826 OUT UINTN
*VariableSize
831 SetTerminalDevicePath (
832 IN UINT8 TerminalType
,
833 IN EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
,
834 OUT EFI_DEVICE_PATH_PROTOCOL
**TerminalDevicePath
840 IN TERMINAL_DEV
*TerminalDevice
845 InitializeUnicodeFiFo (
846 IN TERMINAL_DEV
*TerminalDevice
851 InitializeEfiKeyFiFo (
852 IN TERMINAL_DEV
*TerminalDevice
857 Get one key out of serial buffer.
859 @param SerialIo Serial I/O protocl attached to the serial device.
860 @param Input The fetched key.
862 @return EFI_NOT_READY If serial buffer is empty.
863 @return EFI_DEVICE_ERROR If reading serial buffer encounter error.
864 @return EFI_SUCCESS If reading serial buffer successfully, put
865 the fetched key to the parameter output.
869 GetOneKeyFromSerial (
870 EFI_SERIAL_IO_PROTOCOL
*SerialIo
,
876 Insert one byte raw data into the Raw Data FIFO.
878 @param TerminalDevice Terminal driver private structure.
879 @param Input The key will be input.
881 @return TRUE If insert successfully.
882 @return FLASE If Raw Data buffer is full before key insertion,
887 RawFiFoInsertOneKey (
888 TERMINAL_DEV
*TerminalDevice
,
894 Remove one pre-fetched key out of the Raw Data FIFO.
896 @param TerminalDevice Terminal driver private structure.
897 @param Output The key will be removed.
899 @return TRUE If insert successfully.
900 @return FLASE If Raw Data FIFO buffer is empty before remove operation.
904 RawFiFoRemoveOneKey (
905 TERMINAL_DEV
*TerminalDevice
,
911 Clarify whether Raw Data FIFO buffer is empty.
913 @param TerminalDevice Terminal driver private structure
915 @return TRUE If Raw Data FIFO buffer is empty.
916 @return FLASE If Raw Data FIFO buffer is not empty.
921 TERMINAL_DEV
*TerminalDevice
926 Clarify whether Raw Data FIFO buffer is full.
928 @param TerminalDevice Terminal driver private structure
930 @return TRUE If Raw Data FIFO buffer is full.
931 @return FLASE If Raw Data FIFO buffer is not full.
936 TERMINAL_DEV
*TerminalDevice
941 Insert one pre-fetched key into the FIFO buffer.
943 @param TerminalDevice Terminal driver private structure.
944 @param Key The key will be input.
946 @return TRUE If insert successfully.
947 @return FLASE If FIFO buffer is full before key insertion,
952 EfiKeyFiFoInsertOneKey (
953 TERMINAL_DEV
*TerminalDevice
,
959 Remove one pre-fetched key out of the FIFO buffer.
961 @param TerminalDevice Terminal driver private structure.
962 @param Output The key will be removed.
964 @return TRUE If insert successfully.
965 @return FLASE If FIFO buffer is empty before remove operation.
969 EfiKeyFiFoRemoveOneKey (
970 TERMINAL_DEV
*TerminalDevice
,
971 EFI_INPUT_KEY
*Output
976 Clarify whether FIFO buffer is empty.
978 @param TerminalDevice Terminal driver private structure
980 @return TRUE If FIFO buffer is empty.
981 @return FLASE If FIFO buffer is not empty.
986 TERMINAL_DEV
*TerminalDevice
991 Clarify whether FIFO buffer is full.
993 @param TerminalDevice Terminal driver private structure
995 @return TRUE If FIFO buffer is full.
996 @return FLASE If FIFO buffer is not full.
1001 TERMINAL_DEV
*TerminalDevice
1006 Insert one pre-fetched key into the Unicode FIFO buffer.
1008 @param TerminalDevice Terminal driver private structure.
1009 @param Input The key will be input.
1011 @return TRUE If insert successfully.
1012 @return FLASE If Unicode FIFO buffer is full before key insertion,
1013 and the key is lost.
1017 UnicodeFiFoInsertOneKey (
1018 TERMINAL_DEV
*TerminalDevice
,
1024 Remove one pre-fetched key out of the Unicode FIFO buffer.
1026 @param TerminalDevice Terminal driver private structure.
1027 @param Output The key will be removed.
1029 @return TRUE If insert successfully.
1030 @return FLASE If Unicode FIFO buffer is empty before remove operation.
1034 UnicodeFiFoRemoveOneKey (
1035 TERMINAL_DEV
*TerminalDevice
,
1041 Clarify whether Unicode FIFO buffer is empty.
1043 @param TerminalDevice Terminal driver private structure
1045 @return TRUE If Unicode FIFO buffer is empty.
1046 @return FLASE If Unicode FIFO buffer is not empty.
1050 IsUnicodeFiFoEmpty (
1051 TERMINAL_DEV
*TerminalDevice
1056 Clarify whether Unicode FIFO buffer is full.
1058 @param TerminalDevice Terminal driver private structure
1060 @return TRUE If Unicode FIFO buffer is full.
1061 @return FLASE If Unicode FIFO buffer is not full.
1066 TERMINAL_DEV
*TerminalDevice
1071 UnicodeFiFoGetKeyCount (
1072 TERMINAL_DEV
*TerminalDevice
1077 TranslateRawDataToEfiKey (
1078 IN TERMINAL_DEV
*TerminalDevice
1083 // internal functions for PC ANSI
1086 AnsiRawDataToUnicode (
1087 IN TERMINAL_DEV
*PcAnsiDevice
1093 IN TERMINAL_DEV
*PcAnsiDevice
1099 IN TERMINAL_DEV
*TerminalDevice
,
1105 // internal functions for VTUTF8
1108 VTUTF8RawDataToUnicode (
1109 IN TERMINAL_DEV
*VtUtf8Device
1115 IN TERMINAL_DEV
*TerminalDevice
,
1123 OUT UTF8_CHAR
*Utf8Char
,
1124 OUT UINT8
*ValidBytes
1129 GetOneValidUtf8Char (
1130 IN TERMINAL_DEV
*Utf8Device
,
1131 OUT UTF8_CHAR
*Utf8Char
,
1132 OUT UINT8
*ValidBytes
1138 IN UTF8_CHAR Utf8Char
,
1139 IN UINT8 ValidBytes
,
1140 OUT CHAR16
*UnicodeChar
1145 // functions for boxdraw unicode
1148 TerminalIsValidTextGraphics (
1150 OUT CHAR8
*PcAnsi
, OPTIONAL
1151 OUT CHAR8
*Ascii OPTIONAL
1156 TerminalIsValidAscii (
1162 TerminalIsValidEfiCntlChar (