X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FConsole%2FTerminalDxe%2FTerminal.h;h=a4543fc8de99f6699f88e896e46de5af71710b6a;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hp=fe4ce90bbb2472fb2d28ed4b104d139b38d64393;hpb=284ee2e829ab2453293b7dc4539727ad6c047163;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index fe4ce90bbb..a4543fc8de 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -1,7 +1,8 @@ /** @file Header file for Terminal driver. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (C) 2016 Silicon Graphics, Inc. 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 @@ -20,6 +21,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include +#include #include #include @@ -61,6 +64,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 +77,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 +123,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 +132,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 +148,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 +163,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 +246,7 @@ TerminalConInReadKeyStroke ( pressed. @retval TRUE Key be pressed matches a registered key. - @retval FLASE Match failed. + @retval FALSE Match failed. **/ BOOLEAN @@ -340,9 +343,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 +365,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 +385,7 @@ EFI_STATUS EFIAPI TerminalConInUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, - IN EFI_HANDLE NotificationHandle + IN VOID *NotificationHandle ); /** @@ -859,7 +865,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 +895,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 +912,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 +927,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 +941,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 +949,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 +1017,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 +1034,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 +1049,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 +1063,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 +1078,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 +1090,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 +1109,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 +1123,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 @@ -1226,10 +1292,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 +1331,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 +1429,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