1*22ce4affSfengbojiang /** @file 2*22ce4affSfengbojiang Simple Text Input Ex protocol from the UEFI 2.0 specification. 3*22ce4affSfengbojiang 4*22ce4affSfengbojiang This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL 5*22ce4affSfengbojiang which exposes much more state and modifier information from the input device, 6*22ce4affSfengbojiang also allows one to register a notification for a particular keystroke. 7*22ce4affSfengbojiang 8*22ce4affSfengbojiang Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 9*22ce4affSfengbojiang SPDX-License-Identifier: BSD-2-Clause-Patent 10*22ce4affSfengbojiang 11*22ce4affSfengbojiang **/ 12*22ce4affSfengbojiang 13*22ce4affSfengbojiang #ifndef __SIMPLE_TEXT_IN_EX_H__ 14*22ce4affSfengbojiang #define __SIMPLE_TEXT_IN_EX_H__ 15*22ce4affSfengbojiang 16*22ce4affSfengbojiang #include <Protocol/SimpleTextIn.h> 17*22ce4affSfengbojiang 18*22ce4affSfengbojiang #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ 19*22ce4affSfengbojiang {0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } } 20*22ce4affSfengbojiang 21*22ce4affSfengbojiang 22*22ce4affSfengbojiang typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; 23*22ce4affSfengbojiang 24*22ce4affSfengbojiang /** 25*22ce4affSfengbojiang The Reset() function resets the input device hardware. As part 26*22ce4affSfengbojiang of initialization process, the firmware/device will make a quick 27*22ce4affSfengbojiang but reasonable attempt to verify that the device is functioning. 28*22ce4affSfengbojiang If the ExtendedVerification flag is TRUE the firmware may take 29*22ce4affSfengbojiang an extended amount of time to verify the device is operating on 30*22ce4affSfengbojiang reset. Otherwise the reset operation is to occur as quickly as 31*22ce4affSfengbojiang possible. The hardware verification process is not defined by 32*22ce4affSfengbojiang this specification and is left up to the platform firmware or 33*22ce4affSfengbojiang driver to implement. 34*22ce4affSfengbojiang 35*22ce4affSfengbojiang @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 36*22ce4affSfengbojiang 37*22ce4affSfengbojiang @param ExtendedVerification Indicates that the driver may 38*22ce4affSfengbojiang perform a more exhaustive 39*22ce4affSfengbojiang verification operation of the 40*22ce4affSfengbojiang device during reset. 41*22ce4affSfengbojiang 42*22ce4affSfengbojiang 43*22ce4affSfengbojiang @retval EFI_SUCCESS The device was reset. 44*22ce4affSfengbojiang 45*22ce4affSfengbojiang @retval EFI_DEVICE_ERROR The device is not functioning 46*22ce4affSfengbojiang correctly and could not be reset. 47*22ce4affSfengbojiang 48*22ce4affSfengbojiang **/ 49*22ce4affSfengbojiang typedef 50*22ce4affSfengbojiang EFI_STATUS 51*22ce4affSfengbojiang (EFIAPI *EFI_INPUT_RESET_EX)( 52*22ce4affSfengbojiang IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 53*22ce4affSfengbojiang IN BOOLEAN ExtendedVerification 54*22ce4affSfengbojiang ); 55*22ce4affSfengbojiang 56*22ce4affSfengbojiang 57*22ce4affSfengbojiang /// 58*22ce4affSfengbojiang /// EFI_KEY_TOGGLE_STATE. The toggle states are defined. 59*22ce4affSfengbojiang /// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE 60*22ce4affSfengbojiang /// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE 61*22ce4affSfengbojiang /// 62*22ce4affSfengbojiang typedef UINT8 EFI_KEY_TOGGLE_STATE; 63*22ce4affSfengbojiang 64*22ce4affSfengbojiang typedef struct _EFI_KEY_STATE { 65*22ce4affSfengbojiang /// 66*22ce4affSfengbojiang /// Reflects the currently pressed shift 67*22ce4affSfengbojiang /// modifiers for the input device. The 68*22ce4affSfengbojiang /// returned value is valid only if the high 69*22ce4affSfengbojiang /// order bit has been set. 70*22ce4affSfengbojiang /// 71*22ce4affSfengbojiang UINT32 KeyShiftState; 72*22ce4affSfengbojiang /// 73*22ce4affSfengbojiang /// Reflects the current internal state of 74*22ce4affSfengbojiang /// various toggled attributes. The returned 75*22ce4affSfengbojiang /// value is valid only if the high order 76*22ce4affSfengbojiang /// bit has been set. 77*22ce4affSfengbojiang /// 78*22ce4affSfengbojiang EFI_KEY_TOGGLE_STATE KeyToggleState; 79*22ce4affSfengbojiang } EFI_KEY_STATE; 80*22ce4affSfengbojiang 81*22ce4affSfengbojiang typedef struct { 82*22ce4affSfengbojiang /// 83*22ce4affSfengbojiang /// The EFI scan code and Unicode value returned from the input device. 84*22ce4affSfengbojiang /// 85*22ce4affSfengbojiang EFI_INPUT_KEY Key; 86*22ce4affSfengbojiang /// 87*22ce4affSfengbojiang /// The current state of various toggled attributes as well as input modifier values. 88*22ce4affSfengbojiang /// 89*22ce4affSfengbojiang EFI_KEY_STATE KeyState; 90*22ce4affSfengbojiang } EFI_KEY_DATA; 91*22ce4affSfengbojiang 92*22ce4affSfengbojiang // 93*22ce4affSfengbojiang // Any Shift or Toggle State that is valid should have 94*22ce4affSfengbojiang // high order bit set. 95*22ce4affSfengbojiang // 96*22ce4affSfengbojiang // Shift state 97*22ce4affSfengbojiang // 98*22ce4affSfengbojiang #define EFI_SHIFT_STATE_VALID 0x80000000 99*22ce4affSfengbojiang #define EFI_RIGHT_SHIFT_PRESSED 0x00000001 100*22ce4affSfengbojiang #define EFI_LEFT_SHIFT_PRESSED 0x00000002 101*22ce4affSfengbojiang #define EFI_RIGHT_CONTROL_PRESSED 0x00000004 102*22ce4affSfengbojiang #define EFI_LEFT_CONTROL_PRESSED 0x00000008 103*22ce4affSfengbojiang #define EFI_RIGHT_ALT_PRESSED 0x00000010 104*22ce4affSfengbojiang #define EFI_LEFT_ALT_PRESSED 0x00000020 105*22ce4affSfengbojiang #define EFI_RIGHT_LOGO_PRESSED 0x00000040 106*22ce4affSfengbojiang #define EFI_LEFT_LOGO_PRESSED 0x00000080 107*22ce4affSfengbojiang #define EFI_MENU_KEY_PRESSED 0x00000100 108*22ce4affSfengbojiang #define EFI_SYS_REQ_PRESSED 0x00000200 109*22ce4affSfengbojiang 110*22ce4affSfengbojiang // 111*22ce4affSfengbojiang // Toggle state 112*22ce4affSfengbojiang // 113*22ce4affSfengbojiang #define EFI_TOGGLE_STATE_VALID 0x80 114*22ce4affSfengbojiang #define EFI_KEY_STATE_EXPOSED 0x40 115*22ce4affSfengbojiang #define EFI_SCROLL_LOCK_ACTIVE 0x01 116*22ce4affSfengbojiang #define EFI_NUM_LOCK_ACTIVE 0x02 117*22ce4affSfengbojiang #define EFI_CAPS_LOCK_ACTIVE 0x04 118*22ce4affSfengbojiang 119*22ce4affSfengbojiang // 120*22ce4affSfengbojiang // EFI Scan codes 121*22ce4affSfengbojiang // 122*22ce4affSfengbojiang #define SCAN_F11 0x0015 123*22ce4affSfengbojiang #define SCAN_F12 0x0016 124*22ce4affSfengbojiang #define SCAN_PAUSE 0x0048 125*22ce4affSfengbojiang #define SCAN_F13 0x0068 126*22ce4affSfengbojiang #define SCAN_F14 0x0069 127*22ce4affSfengbojiang #define SCAN_F15 0x006A 128*22ce4affSfengbojiang #define SCAN_F16 0x006B 129*22ce4affSfengbojiang #define SCAN_F17 0x006C 130*22ce4affSfengbojiang #define SCAN_F18 0x006D 131*22ce4affSfengbojiang #define SCAN_F19 0x006E 132*22ce4affSfengbojiang #define SCAN_F20 0x006F 133*22ce4affSfengbojiang #define SCAN_F21 0x0070 134*22ce4affSfengbojiang #define SCAN_F22 0x0071 135*22ce4affSfengbojiang #define SCAN_F23 0x0072 136*22ce4affSfengbojiang #define SCAN_F24 0x0073 137*22ce4affSfengbojiang #define SCAN_MUTE 0x007F 138*22ce4affSfengbojiang #define SCAN_VOLUME_UP 0x0080 139*22ce4affSfengbojiang #define SCAN_VOLUME_DOWN 0x0081 140*22ce4affSfengbojiang #define SCAN_BRIGHTNESS_UP 0x0100 141*22ce4affSfengbojiang #define SCAN_BRIGHTNESS_DOWN 0x0101 142*22ce4affSfengbojiang #define SCAN_SUSPEND 0x0102 143*22ce4affSfengbojiang #define SCAN_HIBERNATE 0x0103 144*22ce4affSfengbojiang #define SCAN_TOGGLE_DISPLAY 0x0104 145*22ce4affSfengbojiang #define SCAN_RECOVERY 0x0105 146*22ce4affSfengbojiang #define SCAN_EJECT 0x0106 147*22ce4affSfengbojiang 148*22ce4affSfengbojiang /** 149*22ce4affSfengbojiang The function reads the next keystroke from the input device. If 150*22ce4affSfengbojiang there is no pending keystroke the function returns 151*22ce4affSfengbojiang EFI_NOT_READY. If there is a pending keystroke, then 152*22ce4affSfengbojiang KeyData.Key.ScanCode is the EFI scan code defined in Error! 153*22ce4affSfengbojiang Reference source not found. The KeyData.Key.UnicodeChar is the 154*22ce4affSfengbojiang actual printable character or is zero if the key does not 155*22ce4affSfengbojiang represent a printable character (control key, function key, 156*22ce4affSfengbojiang etc.). The KeyData.KeyState is shift state for the character 157*22ce4affSfengbojiang reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode . 158*22ce4affSfengbojiang When interpreting the data from this function, it should be 159*22ce4affSfengbojiang noted that if a class of printable characters that are 160*22ce4affSfengbojiang normally adjusted by shift modifiers (e.g. Shift Key + "f" 161*22ce4affSfengbojiang key) would be presented solely as a KeyData.Key.UnicodeChar 162*22ce4affSfengbojiang without the associated shift state. So in the previous example 163*22ce4affSfengbojiang of a Shift Key + "f" key being pressed, the only pertinent 164*22ce4affSfengbojiang data returned would be KeyData.Key.UnicodeChar with the value 165*22ce4affSfengbojiang of "F". This of course would not typically be the case for 166*22ce4affSfengbojiang non-printable characters such as the pressing of the Right 167*22ce4affSfengbojiang Shift Key + F10 key since the corresponding returned data 168*22ce4affSfengbojiang would be reflected both in the KeyData.KeyState.KeyShiftState 169*22ce4affSfengbojiang and KeyData.Key.ScanCode values. UEFI drivers which implement 170*22ce4affSfengbojiang the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return 171*22ce4affSfengbojiang KeyData.Key and KeyData.KeyState values. These drivers must 172*22ce4affSfengbojiang always return the most current state of 173*22ce4affSfengbojiang KeyData.KeyState.KeyShiftState and 174*22ce4affSfengbojiang KeyData.KeyState.KeyToggleState. It should also be noted that 175*22ce4affSfengbojiang certain input devices may not be able to produce shift or toggle 176*22ce4affSfengbojiang state information, and in those cases the high order bit in the 177*22ce4affSfengbojiang respective Toggle and Shift state fields should not be active. 178*22ce4affSfengbojiang 179*22ce4affSfengbojiang 180*22ce4affSfengbojiang @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 181*22ce4affSfengbojiang 182*22ce4affSfengbojiang @param KeyData A pointer to a buffer that is filled in with 183*22ce4affSfengbojiang the keystroke state data for the key that was 184*22ce4affSfengbojiang pressed. 185*22ce4affSfengbojiang 186*22ce4affSfengbojiang 187*22ce4affSfengbojiang @retval EFI_SUCCESS The keystroke information was returned. 188*22ce4affSfengbojiang @retval EFI_NOT_READY There was no keystroke data available. 189*22ce4affSfengbojiang @retval EFI_DEVICE_ERROR The keystroke information was not returned due to 190*22ce4affSfengbojiang hardware errors. 191*22ce4affSfengbojiang 192*22ce4affSfengbojiang 193*22ce4affSfengbojiang **/ 194*22ce4affSfengbojiang typedef 195*22ce4affSfengbojiang EFI_STATUS 196*22ce4affSfengbojiang (EFIAPI *EFI_INPUT_READ_KEY_EX)( 197*22ce4affSfengbojiang IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 198*22ce4affSfengbojiang OUT EFI_KEY_DATA *KeyData 199*22ce4affSfengbojiang ); 200*22ce4affSfengbojiang 201*22ce4affSfengbojiang /** 202*22ce4affSfengbojiang The SetState() function allows the input device hardware to 203*22ce4affSfengbojiang have state settings adjusted. 204*22ce4affSfengbojiang 205*22ce4affSfengbojiang @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 206*22ce4affSfengbojiang 207*22ce4affSfengbojiang @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to 208*22ce4affSfengbojiang set the state for the input device. 209*22ce4affSfengbojiang 210*22ce4affSfengbojiang 211*22ce4affSfengbojiang @retval EFI_SUCCESS The device state was set appropriately. 212*22ce4affSfengbojiang 213*22ce4affSfengbojiang @retval EFI_DEVICE_ERROR The device is not functioning 214*22ce4affSfengbojiang correctly and could not have the 215*22ce4affSfengbojiang setting adjusted. 216*22ce4affSfengbojiang 217*22ce4affSfengbojiang @retval EFI_UNSUPPORTED The device does not support the 218*22ce4affSfengbojiang ability to have its state set. 219*22ce4affSfengbojiang 220*22ce4affSfengbojiang **/ 221*22ce4affSfengbojiang typedef 222*22ce4affSfengbojiang EFI_STATUS 223*22ce4affSfengbojiang (EFIAPI *EFI_SET_STATE)( 224*22ce4affSfengbojiang IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 225*22ce4affSfengbojiang IN EFI_KEY_TOGGLE_STATE *KeyToggleState 226*22ce4affSfengbojiang ); 227*22ce4affSfengbojiang 228*22ce4affSfengbojiang /// 229*22ce4affSfengbojiang /// The function will be called when the key sequence is typed specified by KeyData. 230*22ce4affSfengbojiang /// 231*22ce4affSfengbojiang typedef 232*22ce4affSfengbojiang EFI_STATUS 233*22ce4affSfengbojiang (EFIAPI *EFI_KEY_NOTIFY_FUNCTION)( 234*22ce4affSfengbojiang IN EFI_KEY_DATA *KeyData 235*22ce4affSfengbojiang ); 236*22ce4affSfengbojiang 237*22ce4affSfengbojiang /** 238*22ce4affSfengbojiang The RegisterKeystrokeNotify() function registers a function 239*22ce4affSfengbojiang which will be called when a specified keystroke will occur. 240*22ce4affSfengbojiang 241*22ce4affSfengbojiang @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 242*22ce4affSfengbojiang 243*22ce4affSfengbojiang @param KeyData A pointer to a buffer that is filled in with 244*22ce4affSfengbojiang the keystroke information for the key that was 245*22ce4affSfengbojiang pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState 246*22ce4affSfengbojiang and KeyData.KeyState.KeyShiftState are 0, then any incomplete 247*22ce4affSfengbojiang keystroke will trigger a notification of the KeyNotificationFunction. 248*22ce4affSfengbojiang 249*22ce4affSfengbojiang @param KeyNotificationFunction Points to the function to be called when the key sequence 250*22ce4affSfengbojiang is typed specified by KeyData. This notification function 251*22ce4affSfengbojiang should be called at <=TPL_CALLBACK. 252*22ce4affSfengbojiang 253*22ce4affSfengbojiang 254*22ce4affSfengbojiang @param NotifyHandle Points to the unique handle assigned to 255*22ce4affSfengbojiang the registered notification. 256*22ce4affSfengbojiang 257*22ce4affSfengbojiang @retval EFI_SUCCESS Key notify was registered successfully. 258*22ce4affSfengbojiang 259*22ce4affSfengbojiang @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary 260*22ce4affSfengbojiang data structures. 261*22ce4affSfengbojiang 262*22ce4affSfengbojiang **/ 263*22ce4affSfengbojiang typedef 264*22ce4affSfengbojiang EFI_STATUS 265*22ce4affSfengbojiang (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)( 266*22ce4affSfengbojiang IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 267*22ce4affSfengbojiang IN EFI_KEY_DATA *KeyData, 268*22ce4affSfengbojiang IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, 269*22ce4affSfengbojiang OUT VOID **NotifyHandle 270*22ce4affSfengbojiang ); 271*22ce4affSfengbojiang 272*22ce4affSfengbojiang /** 273*22ce4affSfengbojiang The UnregisterKeystrokeNotify() function removes the 274*22ce4affSfengbojiang notification which was previously registered. 275*22ce4affSfengbojiang 276*22ce4affSfengbojiang @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 277*22ce4affSfengbojiang 278*22ce4affSfengbojiang @param NotificationHandle The handle of the notification 279*22ce4affSfengbojiang function being unregistered. 280*22ce4affSfengbojiang 281*22ce4affSfengbojiang @retval EFI_SUCCESS Key notify was unregistered successfully. 282*22ce4affSfengbojiang 283*22ce4affSfengbojiang @retval EFI_INVALID_PARAMETER The NotificationHandle is 284*22ce4affSfengbojiang invalid. 285*22ce4affSfengbojiang 286*22ce4affSfengbojiang **/ 287*22ce4affSfengbojiang typedef 288*22ce4affSfengbojiang EFI_STATUS 289*22ce4affSfengbojiang (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)( 290*22ce4affSfengbojiang IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 291*22ce4affSfengbojiang IN VOID *NotificationHandle 292*22ce4affSfengbojiang ); 293*22ce4affSfengbojiang 294*22ce4affSfengbojiang 295*22ce4affSfengbojiang /// 296*22ce4affSfengbojiang /// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn 297*22ce4affSfengbojiang /// device. It is an extension to the Simple Text Input protocol 298*22ce4affSfengbojiang /// which allows a variety of extended shift state information to be 299*22ce4affSfengbojiang /// returned. 300*22ce4affSfengbojiang /// 301*22ce4affSfengbojiang struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{ 302*22ce4affSfengbojiang EFI_INPUT_RESET_EX Reset; 303*22ce4affSfengbojiang EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; 304*22ce4affSfengbojiang /// 305*22ce4affSfengbojiang /// Event to use with WaitForEvent() to wait for a key to be available. 306*22ce4affSfengbojiang /// 307*22ce4affSfengbojiang EFI_EVENT WaitForKeyEx; 308*22ce4affSfengbojiang EFI_SET_STATE SetState; 309*22ce4affSfengbojiang EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; 310*22ce4affSfengbojiang EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; 311*22ce4affSfengbojiang }; 312*22ce4affSfengbojiang 313*22ce4affSfengbojiang 314*22ce4affSfengbojiang extern EFI_GUID gEfiSimpleTextInputExProtocolGuid; 315*22ce4affSfengbojiang 316*22ce4affSfengbojiang #endif 317*22ce4affSfengbojiang 318