X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FTerminalDxe%2FTerminal.h;h=b2f0901fc167bfa941d61c3ab4517b7f21cb53a7;hb=9d510e61fceee7b92955ef9a3c20343752d8ce3f;hp=fd42138a71241edcbf21ae50e17a1821e907911c;hpb=f0368006b0d04820a44ae21b0d55ee2d0f5aee3d;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index fd42138a71..b2f0901fc1 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -1,14 +1,9 @@ /** @file Header file for Terminal driver. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -20,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include +#include #include #include @@ -61,6 +58,11 @@ typedef struct { EFI_INPUT_KEY Data[FIFO_MAX_NUMBER + 1]; } EFI_KEY_FIFO; +typedef struct { + UINTN Columns; + UINTN Rows; +} TERMINAL_CONSOLE_MODE_DATA; + #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s #define TERMINAL_DEV_SIGNATURE SIGNATURE_32 ('t', 'm', 'n', 'l') @@ -69,29 +71,41 @@ typedef struct { typedef struct _TERMINAL_CONSOLE_IN_EX_NOTIFY { UINTN Signature; - EFI_HANDLE NotifyHandle; EFI_KEY_DATA KeyData; EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn; LIST_ENTRY NotifyEntry; } TERMINAL_CONSOLE_IN_EX_NOTIFY; + +typedef enum { + TerminalTypePcAnsi, + TerminalTypeVt100, + TerminalTypeVt100Plus, + TerminalTypeVtUtf8, + TerminalTypeTtyTerm +} TERMINAL_TYPE; + typedef struct { UINTN Signature; EFI_HANDLE Handle; - UINT8 TerminalType; + TERMINAL_TYPE TerminalType; EFI_SERIAL_IO_PROTOCOL *SerialIo; EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput; EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode; + TERMINAL_CONSOLE_MODE_DATA *TerminalConsoleModeData; UINTN SerialInTimeOut; RAW_DATA_FIFO *RawFiFo; UNICODE_FIFO *UnicodeFiFo; EFI_KEY_FIFO *EfiKeyFiFo; + EFI_KEY_FIFO *EfiKeyFiFoForNotify; EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_EVENT TimerEvent; EFI_EVENT TwoSecondTimeOut; UINT32 InputState; UINT32 ResetState; + UINT16 TtyEscapeStr[3]; + INTN TtyEscapeIndex; // // Esc could not be output to the screen by user, @@ -103,6 +117,7 @@ typedef struct { BOOLEAN OutputEscChar; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx; LIST_ENTRY NotifyList; + EFI_EVENT KeyNotifyProcessEvent; } TERMINAL_DEV; #define INPUT_STATE_DEFAULT 0x00 @@ -111,6 +126,7 @@ typedef struct { #define INPUT_STATE_LEFTOPENBRACKET 0x04 #define INPUT_STATE_O 0x08 #define INPUT_STATE_2 0x10 +#define INPUT_STATE_LEFTOPENBRACKET_2 0x20 #define RESET_STATE_DEFAULT 0x00 #define RESET_STATE_ESC_R 0x01 @@ -126,32 +142,12 @@ typedef union { UINT8 Utf8_3[3]; } UTF8_CHAR; -#define PCANSITYPE 0 -#define VT100TYPE 1 -#define VT100PLUSTYPE 2 -#define VTUTF8TYPE 3 - #define LEFTOPENBRACKET 0x5b // '[' #define ACAP 0x41 #define BCAP 0x42 #define CCAP 0x43 #define DCAP 0x44 -#define MODE0_COLUMN_COUNT 80 -#define MODE0_ROW_COUNT 25 - -#define MODE1_COLUMN_COUNT 80 -#define MODE1_ROW_COUNT 50 - -#define MODE2_COLUMN_COUNT 100 -#define MODE2_ROW_COUNT 31 - -// -// MODE3 is defined by PcdConOutColumn & PcdConOutRow -// - -#define TERMINAL_MAX_MODE 4 - #define BACKSPACE 8 #define ESC 27 #define CSI 0x9B @@ -161,6 +157,7 @@ typedef union { #define BACKGROUND_CONTROL_OFFSET 11 #define ROW_OFFSET 2 #define COLUMN_OFFSET 5 +#define FW_BACK_OFFSET 2 typedef struct { UINT16 Unicode; @@ -243,7 +240,7 @@ TerminalConInReadKeyStroke ( pressed. @retval TRUE Key be pressed matches a registered key. - @retval FLASE Match failed. + @retval FALSE Match failed. **/ BOOLEAN @@ -340,9 +337,12 @@ TerminalConInSetState ( @param This Protocol instance pointer. @param KeyData A pointer to a buffer that is filled in with the keystroke information data for the key that was - pressed. + pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState + and KeyData.KeyState.KeyShiftState are 0, then any incomplete + keystroke will trigger a notification of the KeyNotificationFunction. @param KeyNotificationFunction Points to the function to be called when the key - sequence is typed specified by KeyData. + sequence is typed specified by KeyData. This notification function + should be called at <=TPL_CALLBACK. @param NotifyHandle Points to the unique handle assigned to the registered notification. @@ -359,7 +359,7 @@ TerminalConInRegisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData, IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, - OUT EFI_HANDLE *NotifyHandle + OUT VOID **NotifyHandle ); /** @@ -379,7 +379,7 @@ EFI_STATUS EFIAPI TerminalConInUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN EFI_HANDLE NotificationHandle + IN VOID *NotificationHandle ); /** @@ -770,7 +770,7 @@ TerminalComponentNameGetDriverName ( driver specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. @@ -859,7 +859,7 @@ TerminalRemoveConsoleDevVariable ( **/ EFI_STATUS SetTerminalDevicePath ( - IN UINT8 TerminalType, + IN TERMINAL_TYPE TerminalType, IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, OUT EFI_DEVICE_PATH_PROTOCOL **TerminalDevicePath ); @@ -889,7 +889,7 @@ GetOneKeyFromSerial ( @param Input The key will be input. @retval TRUE If insert successfully. - @retval FLASE If Raw Data buffer is full before key insertion, + @retval FALSE If Raw Data buffer is full before key insertion, and the key is lost. **/ @@ -906,7 +906,7 @@ RawFiFoInsertOneKey ( @param Output The key will be removed. @retval TRUE If insert successfully. - @retval FLASE If Raw Data FIFO buffer is empty before remove operation. + @retval FALSE If Raw Data FIFO buffer is empty before remove operation. **/ BOOLEAN @@ -921,7 +921,7 @@ RawFiFoRemoveOneKey ( @param TerminalDevice Terminal driver private structure @retval TRUE If Raw Data FIFO buffer is empty. - @retval FLASE If Raw Data FIFO buffer is not empty. + @retval FALSE If Raw Data FIFO buffer is not empty. **/ BOOLEAN @@ -935,7 +935,7 @@ IsRawFiFoEmpty ( @param TerminalDevice Terminal driver private structure @retval TRUE If Raw Data FIFO buffer is full. - @retval FLASE If Raw Data FIFO buffer is not full. + @retval FALSE If Raw Data FIFO buffer is not full. **/ BOOLEAN @@ -943,6 +943,67 @@ IsRawFiFoFull ( TERMINAL_DEV *TerminalDevice ); +/** + Insert one pre-fetched key into the FIFO buffer. + + @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO. + @param Input The key will be input. + + @retval TRUE If insert successfully. + @retval FALSE If FIFO buffer is full before key insertion, + and the key is lost. + +**/ +BOOLEAN +EfiKeyFiFoForNotifyInsertOneKey ( + EFI_KEY_FIFO *EfiKeyFiFo, + EFI_INPUT_KEY *Input + ); + +/** + Remove one pre-fetched key out of the FIFO buffer. + + @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO. + @param Output The key will be removed. + + @retval TRUE If insert successfully. + @retval FALSE If FIFO buffer is empty before remove operation. + +**/ +BOOLEAN +EfiKeyFiFoForNotifyRemoveOneKey ( + EFI_KEY_FIFO *EfiKeyFiFo, + EFI_INPUT_KEY *Output + ); + +/** + Clarify whether FIFO buffer is empty. + + @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO. + + @retval TRUE If FIFO buffer is empty. + @retval FALSE If FIFO buffer is not empty. + +**/ +BOOLEAN +IsEfiKeyFiFoForNotifyEmpty ( + IN EFI_KEY_FIFO *EfiKeyFiFo + ); + +/** + Clarify whether FIFO buffer is full. + + @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO. + + @retval TRUE If FIFO buffer is full. + @retval FALSE If FIFO buffer is not full. + +**/ +BOOLEAN +IsEfiKeyFiFoForNotifyFull ( + EFI_KEY_FIFO *EfiKeyFiFo + ); + /** Insert one pre-fetched key into the FIFO buffer. @@ -950,7 +1011,7 @@ IsRawFiFoFull ( @param Key The key will be input. @retval TRUE If insert successfully. - @retval FLASE If FIFO buffer is full before key insertion, + @retval FALSE If FIFO buffer is full before key insertion, and the key is lost. **/ @@ -967,7 +1028,7 @@ EfiKeyFiFoInsertOneKey ( @param Output The key will be removed. @retval TRUE If insert successfully. - @retval FLASE If FIFO buffer is empty before remove operation. + @retval FALSE If FIFO buffer is empty before remove operation. **/ BOOLEAN @@ -982,7 +1043,7 @@ EfiKeyFiFoRemoveOneKey ( @param TerminalDevice Terminal driver private structure @retval TRUE If FIFO buffer is empty. - @retval FLASE If FIFO buffer is not empty. + @retval FALSE If FIFO buffer is not empty. **/ BOOLEAN @@ -996,7 +1057,7 @@ IsEfiKeyFiFoEmpty ( @param TerminalDevice Terminal driver private structure @retval TRUE If FIFO buffer is full. - @retval FLASE If FIFO buffer is not full. + @retval FALSE If FIFO buffer is not full. **/ BOOLEAN @@ -1011,7 +1072,7 @@ IsEfiKeyFiFoFull ( @param Input The key will be input. @retval TRUE If insert successfully. - @retval FLASE If Unicode FIFO buffer is full before key insertion, + @retval FALSE If Unicode FIFO buffer is full before key insertion, and the key is lost. **/ @@ -1023,15 +1084,14 @@ UnicodeFiFoInsertOneKey ( /** Remove one pre-fetched key out of the Unicode FIFO buffer. + The caller should guarantee that Unicode FIFO buffer is not empty + by IsUnicodeFiFoEmpty (). @param TerminalDevice Terminal driver private structure. @param Output The key will be removed. - @retval TRUE If insert successfully. - @retval FLASE If Unicode FIFO buffer is empty before remove operation. - **/ -BOOLEAN +VOID UnicodeFiFoRemoveOneKey ( TERMINAL_DEV *TerminalDevice, UINT16 *Output @@ -1043,7 +1103,7 @@ UnicodeFiFoRemoveOneKey ( @param TerminalDevice Terminal driver private structure @retval TRUE If Unicode FIFO buffer is empty. - @retval FLASE If Unicode FIFO buffer is not empty. + @retval FALSE If Unicode FIFO buffer is not empty. **/ BOOLEAN @@ -1057,7 +1117,7 @@ IsUnicodeFiFoEmpty ( @param TerminalDevice Terminal driver private structure @retval TRUE If Unicode FIFO buffer is full. - @retval FLASE If Unicode FIFO buffer is not full. + @retval FALSE If Unicode FIFO buffer is not full. **/ BOOLEAN @@ -1065,18 +1125,6 @@ IsUnicodeFiFoFull ( TERMINAL_DEV *TerminalDevice ); -/** - Count Unicode FIFO buffer. - - @param TerminalDevice Terminal driver private structure - - @return The count in bytes of Unicode FIFO. - -**/ -UINT8 -UnicodeFiFoGetKeyCount ( - TERMINAL_DEV *TerminalDevice - ); /** Translate raw data into Unicode (according to different encode), and @@ -1226,10 +1274,10 @@ VTUTF8TestString ( Translate one Unicode character into VT-UTF8 characters. UTF8 Encoding Table - Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding - 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx - 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx - 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx + Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding + 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx + 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx + 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx @param Unicode Unicode character need translating. @@ -1265,10 +1313,10 @@ GetOneValidUtf8Char ( Translate VT-UTF8 characters into one Unicode character. UTF8 Encoding Table - Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding - 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx - 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx - 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx + Bits per Character | Unicode Character Range | Unicode Binary Encoding | UTF8 Binary Encoding + 0-7 | 0x0000 - 0x007F | 00000000 0xxxxxxx | 0xxxxxxx + 8-11 | 0x0080 - 0x07FF | 00000xxx xxxxxxxx | 110xxxxx 10xxxxxx + 12-16 | 0x0800 - 0xFFFF | xxxxxxxx xxxxxxxx | 1110xxxx 10xxxxxx 10xxxxxx @param Utf8Char VT-UTF8 character set needs translating. @@ -1363,4 +1411,19 @@ TerminalConInTimerHandler ( IN EFI_EVENT Event, IN VOID *Context ); + + +/** + Process key notify. + + @param Event Indicates the event that invoke this function. + @param Context Indicates the calling context. +**/ +VOID +EFIAPI +KeyNotifyProcessHandler ( + IN EFI_EVENT Event, + IN VOID *Context + ); + #endif