1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include "missing_efi.h"
5 
6 enum {
7         EFI_SHIFT_PRESSED   = EFI_RIGHT_SHIFT_PRESSED|EFI_LEFT_SHIFT_PRESSED,
8         EFI_CONTROL_PRESSED = EFI_RIGHT_CONTROL_PRESSED|EFI_LEFT_CONTROL_PRESSED,
9         EFI_ALT_PRESSED     = EFI_RIGHT_ALT_PRESSED|EFI_LEFT_ALT_PRESSED,
10         EFI_LOGO_PRESSED    = EFI_RIGHT_LOGO_PRESSED|EFI_LEFT_LOGO_PRESSED,
11 };
12 
13 #define KEYPRESS(keys, scan, uni) ((((UINT64)keys) << 32) | (((UINT64)scan) << 16) | (uni))
14 #define KEYCHAR(k) ((CHAR16)(k))
15 #define CHAR_CTRL(c) ((c) - 'a' + 1)
16 
17 enum {
18         /* Console mode is a INT32 in EFI. We use INT64 to make room for our special values. */
19         CONSOLE_MODE_RANGE_MIN = 0,
20         CONSOLE_MODE_RANGE_MAX = INT32_MAX, /* This is just the theoretical limit. */
21         CONSOLE_MODE_INVALID = -1,          /* UEFI uses -1 if the device is not in a valid text mode. */
22 
23         CONSOLE_MODE_80_25 = 0,             /* 80x25 is required by UEFI spec. */
24         CONSOLE_MODE_80_50 = 1,             /* 80x50 may be supported. */
25         CONSOLE_MODE_FIRMWARE_FIRST = 2,    /* First custom mode, if supported. */
26 
27         /* These are our own mode values that map to concrete values at runtime. */
28         CONSOLE_MODE_KEEP = CONSOLE_MODE_RANGE_MAX + 1LL,
29         CONSOLE_MODE_NEXT,
30         CONSOLE_MODE_AUTO,
31         CONSOLE_MODE_FIRMWARE_MAX, /* 'max' in config. */
32 };
33 
34 EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec);
35 EFI_STATUS console_set_mode(INT64 mode);
36 EFI_STATUS console_query_mode(UINTN *x_max, UINTN *y_max);
37 EFI_STATUS query_screen_resolution(UINT32 *ret_width, UINT32 *ret_height);
38