xref: /freebsd-src/sys/contrib/edk2/Include/Protocol/SimpleTextInEx.h (revision 3245fa215aca18d135839a15c80ae1c905666a37)
10d1ba665SWarner Losh /** @file
20d1ba665SWarner Losh   Simple Text Input Ex protocol from the UEFI 2.0 specification.
30d1ba665SWarner Losh 
40d1ba665SWarner Losh   This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
50d1ba665SWarner Losh   which exposes much more state and modifier information from the input device,
60d1ba665SWarner Losh   also allows one to register a notification for a particular keystroke.
70d1ba665SWarner Losh 
8*3245fa21SMitchell Horne   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9*3245fa21SMitchell Horne   SPDX-License-Identifier: BSD-2-Clause-Patent
100d1ba665SWarner Losh 
110d1ba665SWarner Losh **/
120d1ba665SWarner Losh 
130d1ba665SWarner Losh #ifndef __SIMPLE_TEXT_IN_EX_H__
140d1ba665SWarner Losh #define __SIMPLE_TEXT_IN_EX_H__
150d1ba665SWarner Losh 
160d1ba665SWarner Losh #include <Protocol/SimpleTextIn.h>
170d1ba665SWarner Losh 
180d1ba665SWarner Losh #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
190d1ba665SWarner Losh   {0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }
200d1ba665SWarner Losh 
210d1ba665SWarner Losh 
220d1ba665SWarner Losh typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
230d1ba665SWarner Losh 
240d1ba665SWarner Losh /**
250d1ba665SWarner Losh   The Reset() function resets the input device hardware. As part
260d1ba665SWarner Losh   of initialization process, the firmware/device will make a quick
270d1ba665SWarner Losh   but reasonable attempt to verify that the device is functioning.
280d1ba665SWarner Losh   If the ExtendedVerification flag is TRUE the firmware may take
290d1ba665SWarner Losh   an extended amount of time to verify the device is operating on
300d1ba665SWarner Losh   reset. Otherwise the reset operation is to occur as quickly as
310d1ba665SWarner Losh   possible. The hardware verification process is not defined by
320d1ba665SWarner Losh   this specification and is left up to the platform firmware or
330d1ba665SWarner Losh   driver to implement.
340d1ba665SWarner Losh 
350d1ba665SWarner Losh   @param This                 A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
360d1ba665SWarner Losh 
370d1ba665SWarner Losh   @param ExtendedVerification Indicates that the driver may
380d1ba665SWarner Losh                               perform a more exhaustive
390d1ba665SWarner Losh                               verification operation of the
400d1ba665SWarner Losh                               device during reset.
410d1ba665SWarner Losh 
420d1ba665SWarner Losh 
430d1ba665SWarner Losh   @retval EFI_SUCCESS       The device was reset.
440d1ba665SWarner Losh 
450d1ba665SWarner Losh   @retval EFI_DEVICE_ERROR  The device is not functioning
460d1ba665SWarner Losh                             correctly and could not be reset.
470d1ba665SWarner Losh 
480d1ba665SWarner Losh **/
490d1ba665SWarner Losh typedef
500d1ba665SWarner Losh EFI_STATUS
510d1ba665SWarner Losh (EFIAPI *EFI_INPUT_RESET_EX)(
520d1ba665SWarner Losh   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
530d1ba665SWarner Losh   IN BOOLEAN                           ExtendedVerification
540d1ba665SWarner Losh );
550d1ba665SWarner Losh 
560d1ba665SWarner Losh 
570d1ba665SWarner Losh ///
580d1ba665SWarner Losh /// EFI_KEY_TOGGLE_STATE. The toggle states are defined.
590d1ba665SWarner Losh /// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE
600d1ba665SWarner Losh /// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE
610d1ba665SWarner Losh ///
620d1ba665SWarner Losh typedef UINT8 EFI_KEY_TOGGLE_STATE;
630d1ba665SWarner Losh 
640d1ba665SWarner Losh typedef struct _EFI_KEY_STATE {
650d1ba665SWarner Losh   ///
660d1ba665SWarner Losh   /// Reflects the currently pressed shift
670d1ba665SWarner Losh   /// modifiers for the input device. The
680d1ba665SWarner Losh   /// returned value is valid only if the high
690d1ba665SWarner Losh   /// order bit has been set.
700d1ba665SWarner Losh   ///
710d1ba665SWarner Losh   UINT32                KeyShiftState;
720d1ba665SWarner Losh   ///
730d1ba665SWarner Losh   /// Reflects the current internal state of
740d1ba665SWarner Losh   /// various toggled attributes. The returned
750d1ba665SWarner Losh   /// value is valid only if the high order
760d1ba665SWarner Losh   /// bit has been set.
770d1ba665SWarner Losh   ///
780d1ba665SWarner Losh   EFI_KEY_TOGGLE_STATE  KeyToggleState;
790d1ba665SWarner Losh } EFI_KEY_STATE;
800d1ba665SWarner Losh 
810d1ba665SWarner Losh typedef struct {
820d1ba665SWarner Losh   ///
830d1ba665SWarner Losh   /// The EFI scan code and Unicode value returned from the input device.
840d1ba665SWarner Losh   ///
850d1ba665SWarner Losh   EFI_INPUT_KEY   Key;
860d1ba665SWarner Losh   ///
870d1ba665SWarner Losh   /// The current state of various toggled attributes as well as input modifier values.
880d1ba665SWarner Losh   ///
890d1ba665SWarner Losh   EFI_KEY_STATE   KeyState;
900d1ba665SWarner Losh } EFI_KEY_DATA;
910d1ba665SWarner Losh 
920d1ba665SWarner Losh //
930d1ba665SWarner Losh // Any Shift or Toggle State that is valid should have
940d1ba665SWarner Losh // high order bit set.
950d1ba665SWarner Losh //
960d1ba665SWarner Losh // Shift state
970d1ba665SWarner Losh //
980d1ba665SWarner Losh #define EFI_SHIFT_STATE_VALID     0x80000000
990d1ba665SWarner Losh #define EFI_RIGHT_SHIFT_PRESSED   0x00000001
1000d1ba665SWarner Losh #define EFI_LEFT_SHIFT_PRESSED    0x00000002
1010d1ba665SWarner Losh #define EFI_RIGHT_CONTROL_PRESSED 0x00000004
1020d1ba665SWarner Losh #define EFI_LEFT_CONTROL_PRESSED  0x00000008
1030d1ba665SWarner Losh #define EFI_RIGHT_ALT_PRESSED     0x00000010
1040d1ba665SWarner Losh #define EFI_LEFT_ALT_PRESSED      0x00000020
1050d1ba665SWarner Losh #define EFI_RIGHT_LOGO_PRESSED    0x00000040
1060d1ba665SWarner Losh #define EFI_LEFT_LOGO_PRESSED     0x00000080
1070d1ba665SWarner Losh #define EFI_MENU_KEY_PRESSED      0x00000100
1080d1ba665SWarner Losh #define EFI_SYS_REQ_PRESSED       0x00000200
1090d1ba665SWarner Losh 
1100d1ba665SWarner Losh //
1110d1ba665SWarner Losh // Toggle state
1120d1ba665SWarner Losh //
1130d1ba665SWarner Losh #define EFI_TOGGLE_STATE_VALID    0x80
1140d1ba665SWarner Losh #define EFI_KEY_STATE_EXPOSED     0x40
1150d1ba665SWarner Losh #define EFI_SCROLL_LOCK_ACTIVE    0x01
1160d1ba665SWarner Losh #define EFI_NUM_LOCK_ACTIVE       0x02
1170d1ba665SWarner Losh #define EFI_CAPS_LOCK_ACTIVE      0x04
1180d1ba665SWarner Losh 
1190d1ba665SWarner Losh //
1200d1ba665SWarner Losh // EFI Scan codes
1210d1ba665SWarner Losh //
1220d1ba665SWarner Losh #define SCAN_F11                  0x0015
1230d1ba665SWarner Losh #define SCAN_F12                  0x0016
1240d1ba665SWarner Losh #define SCAN_PAUSE                0x0048
1250d1ba665SWarner Losh #define SCAN_F13                  0x0068
1260d1ba665SWarner Losh #define SCAN_F14                  0x0069
1270d1ba665SWarner Losh #define SCAN_F15                  0x006A
1280d1ba665SWarner Losh #define SCAN_F16                  0x006B
1290d1ba665SWarner Losh #define SCAN_F17                  0x006C
1300d1ba665SWarner Losh #define SCAN_F18                  0x006D
1310d1ba665SWarner Losh #define SCAN_F19                  0x006E
1320d1ba665SWarner Losh #define SCAN_F20                  0x006F
1330d1ba665SWarner Losh #define SCAN_F21                  0x0070
1340d1ba665SWarner Losh #define SCAN_F22                  0x0071
1350d1ba665SWarner Losh #define SCAN_F23                  0x0072
1360d1ba665SWarner Losh #define SCAN_F24                  0x0073
1370d1ba665SWarner Losh #define SCAN_MUTE                 0x007F
1380d1ba665SWarner Losh #define SCAN_VOLUME_UP            0x0080
1390d1ba665SWarner Losh #define SCAN_VOLUME_DOWN          0x0081
1400d1ba665SWarner Losh #define SCAN_BRIGHTNESS_UP        0x0100
1410d1ba665SWarner Losh #define SCAN_BRIGHTNESS_DOWN      0x0101
1420d1ba665SWarner Losh #define SCAN_SUSPEND              0x0102
1430d1ba665SWarner Losh #define SCAN_HIBERNATE            0x0103
1440d1ba665SWarner Losh #define SCAN_TOGGLE_DISPLAY       0x0104
1450d1ba665SWarner Losh #define SCAN_RECOVERY             0x0105
1460d1ba665SWarner Losh #define SCAN_EJECT                0x0106
1470d1ba665SWarner Losh 
1480d1ba665SWarner Losh /**
1490d1ba665SWarner Losh   The function reads the next keystroke from the input device. If
1500d1ba665SWarner Losh   there is no pending keystroke the function returns
1510d1ba665SWarner Losh   EFI_NOT_READY. If there is a pending keystroke, then
1520d1ba665SWarner Losh   KeyData.Key.ScanCode is the EFI scan code defined in Error!
1530d1ba665SWarner Losh   Reference source not found. The KeyData.Key.UnicodeChar is the
1540d1ba665SWarner Losh   actual printable character or is zero if the key does not
1550d1ba665SWarner Losh   represent a printable character (control key, function key,
1560d1ba665SWarner Losh   etc.). The KeyData.KeyState is shift state for the character
1570d1ba665SWarner Losh   reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
1580d1ba665SWarner Losh   When interpreting the data from this function, it should be
1590d1ba665SWarner Losh   noted that if a class of printable characters that are
1600d1ba665SWarner Losh   normally adjusted by shift modifiers (e.g. Shift Key + "f"
1610d1ba665SWarner Losh   key) would be presented solely as a KeyData.Key.UnicodeChar
1620d1ba665SWarner Losh   without the associated shift state. So in the previous example
1630d1ba665SWarner Losh   of a Shift Key + "f" key being pressed, the only pertinent
1640d1ba665SWarner Losh   data returned would be KeyData.Key.UnicodeChar with the value
1650d1ba665SWarner Losh   of "F". This of course would not typically be the case for
1660d1ba665SWarner Losh   non-printable characters such as the pressing of the Right
1670d1ba665SWarner Losh   Shift Key + F10 key since the corresponding returned data
1680d1ba665SWarner Losh   would be reflected both in the KeyData.KeyState.KeyShiftState
1690d1ba665SWarner Losh   and KeyData.Key.ScanCode values. UEFI drivers which implement
1700d1ba665SWarner Losh   the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
1710d1ba665SWarner Losh   KeyData.Key and KeyData.KeyState values. These drivers must
1720d1ba665SWarner Losh   always return the most current state of
1730d1ba665SWarner Losh   KeyData.KeyState.KeyShiftState and
1740d1ba665SWarner Losh   KeyData.KeyState.KeyToggleState. It should also be noted that
1750d1ba665SWarner Losh   certain input devices may not be able to produce shift or toggle
1760d1ba665SWarner Losh   state information, and in those cases the high order bit in the
1770d1ba665SWarner Losh   respective Toggle and Shift state fields should not be active.
1780d1ba665SWarner Losh 
1790d1ba665SWarner Losh 
1800d1ba665SWarner Losh   @param This     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
1810d1ba665SWarner Losh 
1820d1ba665SWarner Losh   @param KeyData  A pointer to a buffer that is filled in with
1830d1ba665SWarner Losh                   the keystroke state data for the key that was
1840d1ba665SWarner Losh                   pressed.
1850d1ba665SWarner Losh 
1860d1ba665SWarner Losh 
187*3245fa21SMitchell Horne   @retval EFI_SUCCESS      The keystroke information was returned.
1880d1ba665SWarner Losh   @retval EFI_NOT_READY    There was no keystroke data available.
189*3245fa21SMitchell Horne   @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
1900d1ba665SWarner Losh                            hardware errors.
1910d1ba665SWarner Losh 
1920d1ba665SWarner Losh 
1930d1ba665SWarner Losh **/
1940d1ba665SWarner Losh typedef
1950d1ba665SWarner Losh EFI_STATUS
1960d1ba665SWarner Losh (EFIAPI *EFI_INPUT_READ_KEY_EX)(
1970d1ba665SWarner Losh   IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
1980d1ba665SWarner Losh   OUT EFI_KEY_DATA                      *KeyData
1990d1ba665SWarner Losh );
2000d1ba665SWarner Losh 
2010d1ba665SWarner Losh /**
2020d1ba665SWarner Losh   The SetState() function allows the input device hardware to
2030d1ba665SWarner Losh   have state settings adjusted.
2040d1ba665SWarner Losh 
2050d1ba665SWarner Losh   @param This           A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
2060d1ba665SWarner Losh 
2070d1ba665SWarner Losh   @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
2080d1ba665SWarner Losh                         set the state for the input device.
2090d1ba665SWarner Losh 
2100d1ba665SWarner Losh 
2110d1ba665SWarner Losh   @retval EFI_SUCCESS       The device state was set appropriately.
2120d1ba665SWarner Losh 
2130d1ba665SWarner Losh   @retval EFI_DEVICE_ERROR  The device is not functioning
2140d1ba665SWarner Losh                             correctly and could not have the
2150d1ba665SWarner Losh                             setting adjusted.
2160d1ba665SWarner Losh 
2170d1ba665SWarner Losh   @retval EFI_UNSUPPORTED   The device does not support the
2180d1ba665SWarner Losh                             ability to have its state set.
2190d1ba665SWarner Losh 
2200d1ba665SWarner Losh **/
2210d1ba665SWarner Losh typedef
2220d1ba665SWarner Losh EFI_STATUS
2230d1ba665SWarner Losh (EFIAPI *EFI_SET_STATE)(
2240d1ba665SWarner Losh   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
2250d1ba665SWarner Losh   IN EFI_KEY_TOGGLE_STATE              *KeyToggleState
2260d1ba665SWarner Losh );
2270d1ba665SWarner Losh 
2280d1ba665SWarner Losh ///
2290d1ba665SWarner Losh /// The function will be called when the key sequence is typed specified by KeyData.
2300d1ba665SWarner Losh ///
2310d1ba665SWarner Losh typedef
2320d1ba665SWarner Losh EFI_STATUS
2330d1ba665SWarner Losh (EFIAPI *EFI_KEY_NOTIFY_FUNCTION)(
2340d1ba665SWarner Losh   IN EFI_KEY_DATA *KeyData
2350d1ba665SWarner Losh );
2360d1ba665SWarner Losh 
2370d1ba665SWarner Losh /**
2380d1ba665SWarner Losh   The RegisterKeystrokeNotify() function registers a function
2390d1ba665SWarner Losh   which will be called when a specified keystroke will occur.
2400d1ba665SWarner Losh 
2410d1ba665SWarner Losh   @param This                     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
2420d1ba665SWarner Losh 
2430d1ba665SWarner Losh   @param KeyData                  A pointer to a buffer that is filled in with
2440d1ba665SWarner Losh                                   the keystroke information for the key that was
245*3245fa21SMitchell Horne                                   pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
246*3245fa21SMitchell Horne                                   and KeyData.KeyState.KeyShiftState are 0, then any incomplete
247*3245fa21SMitchell Horne                                   keystroke will trigger a notification of the KeyNotificationFunction.
2480d1ba665SWarner Losh 
249*3245fa21SMitchell Horne   @param KeyNotificationFunction  Points to the function to be called when the key sequence
250*3245fa21SMitchell Horne                                   is typed specified by KeyData. This notification function
251*3245fa21SMitchell Horne                                   should be called at <=TPL_CALLBACK.
2520d1ba665SWarner Losh 
2530d1ba665SWarner Losh 
2540d1ba665SWarner Losh   @param NotifyHandle             Points to the unique handle assigned to
2550d1ba665SWarner Losh                                   the registered notification.
2560d1ba665SWarner Losh 
257*3245fa21SMitchell Horne   @retval EFI_SUCCESS           Key notify was registered successfully.
2580d1ba665SWarner Losh 
2590d1ba665SWarner Losh   @retval EFI_OUT_OF_RESOURCES  Unable to allocate necessary
2600d1ba665SWarner Losh                                 data structures.
2610d1ba665SWarner Losh 
2620d1ba665SWarner Losh **/
2630d1ba665SWarner Losh typedef
2640d1ba665SWarner Losh EFI_STATUS
2650d1ba665SWarner Losh (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)(
2660d1ba665SWarner Losh   IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
2670d1ba665SWarner Losh   IN  EFI_KEY_DATA                      *KeyData,
2680d1ba665SWarner Losh   IN  EFI_KEY_NOTIFY_FUNCTION           KeyNotificationFunction,
2690d1ba665SWarner Losh   OUT VOID                              **NotifyHandle
2700d1ba665SWarner Losh );
2710d1ba665SWarner Losh 
2720d1ba665SWarner Losh /**
2730d1ba665SWarner Losh   The UnregisterKeystrokeNotify() function removes the
2740d1ba665SWarner Losh   notification which was previously registered.
2750d1ba665SWarner Losh 
2760d1ba665SWarner Losh   @param This               A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
2770d1ba665SWarner Losh 
2780d1ba665SWarner Losh   @param NotificationHandle The handle of the notification
2790d1ba665SWarner Losh                             function being unregistered.
2800d1ba665SWarner Losh 
281*3245fa21SMitchell Horne   @retval EFI_SUCCESS           Key notify was unregistered successfully.
2820d1ba665SWarner Losh 
2830d1ba665SWarner Losh   @retval EFI_INVALID_PARAMETER The NotificationHandle is
2840d1ba665SWarner Losh                                 invalid.
2850d1ba665SWarner Losh 
2860d1ba665SWarner Losh **/
2870d1ba665SWarner Losh typedef
2880d1ba665SWarner Losh EFI_STATUS
2890d1ba665SWarner Losh (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)(
2900d1ba665SWarner Losh   IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
2910d1ba665SWarner Losh   IN VOID                               *NotificationHandle
2920d1ba665SWarner Losh );
2930d1ba665SWarner Losh 
2940d1ba665SWarner Losh 
2950d1ba665SWarner Losh ///
2960d1ba665SWarner Losh /// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
2970d1ba665SWarner Losh /// device. It is an extension to the Simple Text Input protocol
2980d1ba665SWarner Losh /// which allows a variety of extended shift state information to be
2990d1ba665SWarner Losh /// returned.
3000d1ba665SWarner Losh ///
3010d1ba665SWarner Losh struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{
3020d1ba665SWarner Losh   EFI_INPUT_RESET_EX              Reset;
3030d1ba665SWarner Losh   EFI_INPUT_READ_KEY_EX           ReadKeyStrokeEx;
3040d1ba665SWarner Losh   ///
3050d1ba665SWarner Losh   /// Event to use with WaitForEvent() to wait for a key to be available.
3060d1ba665SWarner Losh   ///
3070d1ba665SWarner Losh   EFI_EVENT                       WaitForKeyEx;
3080d1ba665SWarner Losh   EFI_SET_STATE                   SetState;
3090d1ba665SWarner Losh   EFI_REGISTER_KEYSTROKE_NOTIFY   RegisterKeyNotify;
3100d1ba665SWarner Losh   EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
3110d1ba665SWarner Losh };
3120d1ba665SWarner Losh 
3130d1ba665SWarner Losh 
3140d1ba665SWarner Losh extern EFI_GUID gEfiSimpleTextInputExProtocolGuid;
3150d1ba665SWarner Losh 
3160d1ba665SWarner Losh #endif
3170d1ba665SWarner Losh 
318