]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
MdeModulePkg TerminalDxe: Remove a redundant function
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Terminal.h
index 9387998e01d6428b00addec8c033b96d43c09616..84808d55a06b9a3e473c9caae324901bd125e140 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Header file for Terminal driver.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,6 +21,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/PcAnsi.h>\r
+#include <Guid/TtyTerm.h>\r
+#include <Guid/StatusCodeDataTypeVariable.h>\r
 \r
 #include <Protocol/SimpleTextOut.h>\r
 #include <Protocol/SerialIo.h>\r
@@ -74,15 +77,23 @@ typedef struct {
 \r
 typedef struct _TERMINAL_CONSOLE_IN_EX_NOTIFY {\r
   UINTN                                 Signature;\r
-  EFI_HANDLE                            NotifyHandle;\r
   EFI_KEY_DATA                          KeyData;\r
   EFI_KEY_NOTIFY_FUNCTION               KeyNotificationFn;\r
   LIST_ENTRY                            NotifyEntry;\r
 } TERMINAL_CONSOLE_IN_EX_NOTIFY;\r
+\r
+typedef enum {\r
+  TerminalTypePcAnsi,\r
+  TerminalTypeVt100,\r
+  TerminalTypeVt100Plus,\r
+  TerminalTypeVtUtf8,\r
+  TerminalTypeTtyTerm\r
+} TERMINAL_TYPE;\r
+\r
 typedef struct {\r
   UINTN                               Signature;\r
   EFI_HANDLE                          Handle;\r
-  UINT8                               TerminalType;\r
+  TERMINAL_TYPE                       TerminalType;\r
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
   EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL      SimpleInput;\r
@@ -93,11 +104,14 @@ typedef struct {
   RAW_DATA_FIFO                       *RawFiFo;\r
   UNICODE_FIFO                        *UnicodeFiFo;\r
   EFI_KEY_FIFO                        *EfiKeyFiFo;\r
+  EFI_KEY_FIFO                        *EfiKeyFiFoForNotify;\r
   EFI_UNICODE_STRING_TABLE            *ControllerNameTable;\r
   EFI_EVENT                           TimerEvent;\r
   EFI_EVENT                           TwoSecondTimeOut;\r
   UINT32                              InputState;\r
   UINT32                              ResetState;\r
+  UINT16                              TtyEscapeStr[3];\r
+  INTN                                TtyEscapeIndex;\r
 \r
   //\r
   // Esc could not be output to the screen by user,\r
@@ -109,6 +123,7 @@ typedef struct {
   BOOLEAN                             OutputEscChar;\r
   EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL   SimpleInputEx;\r
   LIST_ENTRY                          NotifyList;\r
+  EFI_EVENT                           KeyNotifyProcessEvent;\r
 } TERMINAL_DEV;\r
 \r
 #define INPUT_STATE_DEFAULT               0x00\r
@@ -117,6 +132,7 @@ typedef struct {
 #define INPUT_STATE_LEFTOPENBRACKET       0x04\r
 #define INPUT_STATE_O                     0x08\r
 #define INPUT_STATE_2                     0x10\r
+#define INPUT_STATE_LEFTOPENBRACKET_2     0x20\r
 \r
 #define RESET_STATE_DEFAULT               0x00\r
 #define RESET_STATE_ESC_R                 0x01\r
@@ -132,11 +148,6 @@ typedef union {
   UINT8 Utf8_3[3];\r
 } UTF8_CHAR;\r
 \r
-#define PCANSITYPE                0\r
-#define VT100TYPE                 1\r
-#define VT100PLUSTYPE             2\r
-#define VTUTF8TYPE                3\r
-\r
 #define LEFTOPENBRACKET           0x5b  // '['\r
 #define ACAP                      0x41\r
 #define BCAP                      0x42\r
@@ -152,6 +163,7 @@ typedef union {
 #define BACKGROUND_CONTROL_OFFSET 11\r
 #define ROW_OFFSET                2\r
 #define COLUMN_OFFSET             5\r
+#define FW_BACK_OFFSET            2\r
 \r
 typedef struct {\r
   UINT16  Unicode;\r
@@ -234,7 +246,7 @@ TerminalConInReadKeyStroke (
                                    pressed.\r
 \r
   @retval TRUE                     Key be pressed matches a registered key.\r
-  @retval FLASE                    Match failed.\r
+  @retval FALSE                    Match failed.\r
 \r
 **/\r
 BOOLEAN\r
@@ -331,9 +343,12 @@ TerminalConInSetState (
   @param  This                     Protocol instance pointer.\r
   @param  KeyData                  A pointer to a buffer that is filled in with the\r
                                    keystroke information data for the key that was\r
-                                   pressed.\r
+                                   pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState\r
+                                   and KeyData.KeyState.KeyShiftState are 0, then any incomplete\r
+                                   keystroke will trigger a notification of the KeyNotificationFunction.\r
   @param  KeyNotificationFunction  Points to the function to be called when the key\r
-                                   sequence is typed specified by KeyData.\r
+                                   sequence is typed specified by KeyData. This notification function\r
+                                   should be called at <=TPL_CALLBACK.\r
   @param  NotifyHandle             Points to the unique handle assigned to the\r
                                    registered notification.\r
 \r
@@ -350,7 +365,7 @@ TerminalConInRegisterKeyNotify (
   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
   IN EFI_KEY_DATA                       *KeyData,\r
   IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
-  OUT EFI_HANDLE                        *NotifyHandle\r
+  OUT VOID                              **NotifyHandle\r
   );\r
 \r
 /**\r
@@ -370,7 +385,7 @@ EFI_STATUS
 EFIAPI\r
 TerminalConInUnregisterKeyNotify (\r
   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
-  IN EFI_HANDLE                         NotificationHandle\r
+  IN VOID                               *NotificationHandle\r
   );\r
 \r
 /**\r
@@ -850,7 +865,7 @@ TerminalRemoveConsoleDevVariable (
 **/\r
 EFI_STATUS\r
 SetTerminalDevicePath (\r
-  IN  UINT8                       TerminalType,\r
+  IN  TERMINAL_TYPE               TerminalType,\r
   IN  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL    **TerminalDevicePath\r
   );\r
@@ -880,7 +895,7 @@ GetOneKeyFromSerial (
   @param  Input                The key will be input.\r
 \r
   @retval TRUE                 If insert successfully.\r
-  @retval FLASE                If Raw Data buffer is full before key insertion,\r
+  @retval FALSE                If Raw Data buffer is full before key insertion,\r
                                and the key is lost.\r
 \r
 **/\r
@@ -897,7 +912,7 @@ RawFiFoInsertOneKey (
   @param  Output               The key will be removed.\r
 \r
   @retval TRUE                 If insert successfully.\r
-  @retval FLASE                If Raw Data FIFO buffer is empty before remove operation.\r
+  @retval FALSE                If Raw Data FIFO buffer is empty before remove operation.\r
 \r
 **/\r
 BOOLEAN\r
@@ -912,7 +927,7 @@ RawFiFoRemoveOneKey (
   @param  TerminalDevice       Terminal driver private structure\r
 \r
   @retval TRUE                 If Raw Data FIFO buffer is empty.\r
-  @retval FLASE                If Raw Data FIFO buffer is not empty.\r
+  @retval FALSE                If Raw Data FIFO buffer is not empty.\r
 \r
 **/\r
 BOOLEAN\r
@@ -926,7 +941,7 @@ IsRawFiFoEmpty (
   @param  TerminalDevice       Terminal driver private structure\r
 \r
   @retval TRUE                 If Raw Data FIFO buffer is full.\r
-  @retval FLASE                If Raw Data FIFO buffer is not full.\r
+  @retval FALSE                If Raw Data FIFO buffer is not full.\r
 \r
 **/\r
 BOOLEAN\r
@@ -934,6 +949,67 @@ IsRawFiFoFull (
   TERMINAL_DEV  *TerminalDevice\r
   );\r
 \r
+/**\r
+  Insert one pre-fetched key into the FIFO buffer.\r
+\r
+  @param  EfiKeyFiFo            Pointer to instance of EFI_KEY_FIFO.\r
+  @param  Input                 The key will be input.\r
+\r
+  @retval TRUE                  If insert successfully.\r
+  @retval FALSE                 If FIFO buffer is full before key insertion,\r
+                                and the key is lost.\r
+\r
+**/\r
+BOOLEAN\r
+EfiKeyFiFoForNotifyInsertOneKey (\r
+  EFI_KEY_FIFO                  *EfiKeyFiFo,\r
+  EFI_INPUT_KEY                 *Input\r
+  );\r
+\r
+/**\r
+  Remove one pre-fetched key out of the FIFO buffer.\r
+\r
+  @param  EfiKeyFiFo            Pointer to instance of EFI_KEY_FIFO.\r
+  @param  Output                The key will be removed.\r
+\r
+  @retval TRUE                  If insert successfully.\r
+  @retval FALSE                 If FIFO buffer is empty before remove operation.\r
+\r
+**/\r
+BOOLEAN\r
+EfiKeyFiFoForNotifyRemoveOneKey (\r
+  EFI_KEY_FIFO                  *EfiKeyFiFo,\r
+  EFI_INPUT_KEY                 *Output\r
+  );\r
+\r
+/**\r
+  Clarify whether FIFO buffer is empty.\r
+\r
+  @param  EfiKeyFiFo            Pointer to instance of EFI_KEY_FIFO.\r
+\r
+  @retval TRUE                  If FIFO buffer is empty.\r
+  @retval FALSE                 If FIFO buffer is not empty.\r
+\r
+**/\r
+BOOLEAN\r
+IsEfiKeyFiFoForNotifyEmpty (\r
+  IN EFI_KEY_FIFO               *EfiKeyFiFo\r
+  );\r
+\r
+/**\r
+  Clarify whether FIFO buffer is full.\r
+\r
+  @param  EfiKeyFiFo            Pointer to instance of EFI_KEY_FIFO.\r
+\r
+  @retval TRUE                  If FIFO buffer is full.\r
+  @retval FALSE                 If FIFO buffer is not full.\r
+\r
+**/\r
+BOOLEAN\r
+IsEfiKeyFiFoForNotifyFull (\r
+  EFI_KEY_FIFO                  *EfiKeyFiFo\r
+  );\r
+\r
 /**\r
   Insert one pre-fetched key into the FIFO buffer.\r
 \r
@@ -941,7 +1017,7 @@ IsRawFiFoFull (
   @param  Key                  The key will be input.\r
 \r
   @retval TRUE                 If insert successfully.\r
-  @retval FLASE                If FIFO buffer is full before key insertion,\r
+  @retval FALSE                If FIFO buffer is full before key insertion,\r
                                and the key is lost.\r
 \r
 **/\r
@@ -958,7 +1034,7 @@ EfiKeyFiFoInsertOneKey (
   @param  Output               The key will be removed.\r
 \r
   @retval TRUE                 If insert successfully.\r
-  @retval FLASE                If FIFO buffer is empty before remove operation.\r
+  @retval FALSE                If FIFO buffer is empty before remove operation.\r
 \r
 **/\r
 BOOLEAN\r
@@ -973,7 +1049,7 @@ EfiKeyFiFoRemoveOneKey (
   @param  TerminalDevice       Terminal driver private structure\r
 \r
   @retval TRUE                 If FIFO buffer is empty.\r
-  @retval FLASE                If FIFO buffer is not empty.\r
+  @retval FALSE                If FIFO buffer is not empty.\r
 \r
 **/\r
 BOOLEAN\r
@@ -987,7 +1063,7 @@ IsEfiKeyFiFoEmpty (
   @param  TerminalDevice       Terminal driver private structure\r
 \r
   @retval TRUE                 If FIFO buffer is full.\r
-  @retval FLASE                If FIFO buffer is not full.\r
+  @retval FALSE                If FIFO buffer is not full.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1002,7 +1078,7 @@ IsEfiKeyFiFoFull (
   @param  Input                The key will be input.\r
 \r
   @retval TRUE                 If insert successfully.\r
-  @retval FLASE                If Unicode FIFO buffer is full before key insertion,\r
+  @retval FALSE                If Unicode FIFO buffer is full before key insertion,\r
                                and the key is lost.\r
 \r
 **/\r
@@ -1014,15 +1090,14 @@ UnicodeFiFoInsertOneKey (
 \r
 /**\r
   Remove one pre-fetched key out of the Unicode FIFO buffer.\r
+  The caller should guarantee that Unicode FIFO buffer is not empty\r
+  by IsUnicodeFiFoEmpty ().\r
 \r
   @param  TerminalDevice       Terminal driver private structure.\r
   @param  Output               The key will be removed.\r
 \r
-  @retval TRUE                 If insert successfully.\r
-  @retval FLASE                If Unicode FIFO buffer is empty before remove operation.\r
-\r
 **/\r
-BOOLEAN\r
+VOID\r
 UnicodeFiFoRemoveOneKey (\r
   TERMINAL_DEV  *TerminalDevice,\r
   UINT16        *Output\r
@@ -1034,7 +1109,7 @@ UnicodeFiFoRemoveOneKey (
   @param  TerminalDevice       Terminal driver private structure\r
 \r
   @retval TRUE                 If Unicode FIFO buffer is empty.\r
-  @retval FLASE                If Unicode FIFO buffer is not empty.\r
+  @retval FALSE                If Unicode FIFO buffer is not empty.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1048,7 +1123,7 @@ IsUnicodeFiFoEmpty (
   @param  TerminalDevice       Terminal driver private structure\r
 \r
   @retval TRUE                 If Unicode FIFO buffer is full.\r
-  @retval FLASE                If Unicode FIFO buffer is not full.\r
+  @retval FALSE                If Unicode FIFO buffer is not full.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1056,18 +1131,6 @@ IsUnicodeFiFoFull (
   TERMINAL_DEV  *TerminalDevice\r
   );\r
 \r
-/**\r
-  Count Unicode FIFO buffer.\r
-\r
-  @param  TerminalDevice       Terminal driver private structure\r
-\r
-  @return The count in bytes of Unicode FIFO.\r
-\r
-**/\r
-UINT8\r
-UnicodeFiFoGetKeyCount (\r
-  TERMINAL_DEV    *TerminalDevice\r
-  );\r
 \r
 /**\r
   Translate raw data into Unicode (according to different encode), and\r
@@ -1217,10 +1280,10 @@ VTUTF8TestString (
   Translate one Unicode character into VT-UTF8 characters.\r
 \r
   UTF8 Encoding Table\r
-  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |    UTF8 Binary Encoding\r
-        0-7             |     0x0000 - 0x007F      |     00000000 0xxxxxxx        |   0xxxxxxx\r
-        8-11          |     0x0080 - 0x07FF        |     00000xxx xxxxxxxx       |   110xxxxx 10xxxxxx\r
-       12-16           |     0x0800 - 0xFFFF       |     xxxxxxxx xxxxxxxx        |   1110xxxx 10xxxxxx 10xxxxxx\r
+  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |  UTF8 Binary Encoding\r
+        0-7           |     0x0000 - 0x007F      |     00000000 0xxxxxxx     |   0xxxxxxx\r
+        8-11          |     0x0080 - 0x07FF      |     00000xxx xxxxxxxx     |   110xxxxx 10xxxxxx\r
+       12-16          |     0x0800 - 0xFFFF      |     xxxxxxxx xxxxxxxx     |   1110xxxx 10xxxxxx 10xxxxxx\r
 \r
 \r
   @param  Unicode          Unicode character need translating.\r
@@ -1256,10 +1319,10 @@ GetOneValidUtf8Char (
   Translate VT-UTF8 characters into one Unicode character.\r
 \r
   UTF8 Encoding Table\r
-  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |    UTF8 Binary Encoding\r
-        0-7             |     0x0000 - 0x007F      |     00000000 0xxxxxxx        |   0xxxxxxx\r
-        8-11          |     0x0080 - 0x07FF        |     00000xxx xxxxxxxx       |   110xxxxx 10xxxxxx\r
-       12-16           |     0x0800 - 0xFFFF       |     xxxxxxxx xxxxxxxx        |   1110xxxx 10xxxxxx 10xxxxxx\r
+  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |  UTF8 Binary Encoding\r
+        0-7           |     0x0000 - 0x007F      |     00000000 0xxxxxxx     |   0xxxxxxx\r
+        8-11          |     0x0080 - 0x07FF      |     00000xxx xxxxxxxx     |   110xxxxx 10xxxxxx\r
+       12-16          |     0x0800 - 0xFFFF      |     xxxxxxxx xxxxxxxx     |   1110xxxx 10xxxxxx 10xxxxxx\r
 \r
 \r
   @param  Utf8Char         VT-UTF8 character set needs translating.\r
@@ -1354,4 +1417,19 @@ TerminalConInTimerHandler (
   IN EFI_EVENT            Event,\r
   IN VOID                 *Context\r
   );\r
+\r
+\r
+/**\r
+  Process key notify.\r
+\r
+  @param  Event                 Indicates the event that invoke this function.\r
+  @param  Context               Indicates the calling context.\r
+**/\r
+VOID\r
+EFIAPI\r
+KeyNotifyProcessHandler (\r
+  IN  EFI_EVENT                 Event,\r
+  IN  VOID                      *Context\r
+  );\r
+\r
 #endif\r