xref: /freebsd/stand/efi/include/eficon.h (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 #ifndef _EFI_CON_H
2 #define _EFI_CON_H
3 
4 /*++
5 
6 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
7 This software and associated documentation (if any) is furnished
8 under a license and may only be used or copied in accordance
9 with the terms of the license. Except as permitted by such
10 license, no part of this software or documentation may be
11 reproduced, stored in a retrieval system, or transmitted in any
12 form or by any means without the express written consent of
13 Intel Corporation.
14 
15 Module Name:
16 
17     eficon.h
18 
19 Abstract:
20 
21     EFI console protocols
22 
23 
24 
25 Revision History
26 
27 --*/
28 
29 //
30 // Text output protocol
31 //
32 
33 #define SIMPLE_TEXT_OUTPUT_PROTOCOL \
34     { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
35 
36 INTERFACE_DECL(_SIMPLE_TEXT_OUTPUT_INTERFACE);
37 
38 typedef
39 EFI_STATUS
40 (EFIAPI *EFI_TEXT_RESET) (
41     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
42     IN BOOLEAN                      ExtendedVerification
43     );
44 
45 typedef
46 EFI_STATUS
47 (EFIAPI *EFI_TEXT_OUTPUT_STRING) (
48     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
49     IN CHAR16                       *String
50     );
51 
52 typedef
53 EFI_STATUS
54 (EFIAPI *EFI_TEXT_TEST_STRING) (
55     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
56     IN CHAR16                       *String
57     );
58 
59 typedef
60 EFI_STATUS
61 (EFIAPI *EFI_TEXT_QUERY_MODE) (
62     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
63     IN UINTN                        ModeNumber,
64     OUT UINTN                       *Columns,
65     OUT UINTN                       *Rows
66     );
67 
68 typedef
69 EFI_STATUS
70 (EFIAPI *EFI_TEXT_SET_MODE) (
71     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
72     IN UINTN                        ModeNumber
73     );
74 
75 typedef
76 EFI_STATUS
77 (EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (
78     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
79     IN UINTN                        Attribute
80     );
81 
82 #define EFI_BLACK   0x00
83 #define EFI_BLUE    0x01
84 #define EFI_GREEN   0x02
85 #define EFI_CYAN            (EFI_BLUE | EFI_GREEN)
86 #define EFI_RED     0x04
87 #define EFI_MAGENTA         (EFI_BLUE | EFI_RED)
88 #define EFI_BROWN           (EFI_GREEN | EFI_RED)
89 #define EFI_LIGHTGRAY       (EFI_BLUE | EFI_GREEN | EFI_RED)
90 #define EFI_BRIGHT  0x08
91 #define EFI_DARKGRAY        (EFI_BRIGHT)
92 #define EFI_LIGHTBLUE       (EFI_BLUE | EFI_BRIGHT)
93 #define EFI_LIGHTGREEN      (EFI_GREEN | EFI_BRIGHT)
94 #define EFI_LIGHTCYAN       (EFI_CYAN | EFI_BRIGHT)
95 #define EFI_LIGHTRED        (EFI_RED | EFI_BRIGHT)
96 #define EFI_LIGHTMAGENTA    (EFI_MAGENTA | EFI_BRIGHT)
97 #define EFI_YELLOW          (EFI_BROWN | EFI_BRIGHT)
98 #define EFI_WHITE           (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
99 
100 #define EFI_TEXT_ATTR(f,b)  ((f) | ((b) << 4))
101 
102 #define EFI_BACKGROUND_BLACK        0x00
103 #define EFI_BACKGROUND_BLUE         0x10
104 #define EFI_BACKGROUND_GREEN        0x20
105 #define EFI_BACKGROUND_CYAN         (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
106 #define EFI_BACKGROUND_RED          0x40
107 #define EFI_BACKGROUND_MAGENTA      (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
108 #define EFI_BACKGROUND_BROWN        (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
109 #define EFI_BACKGROUND_LIGHTGRAY    (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
110 
111 
112 typedef
113 EFI_STATUS
114 (EFIAPI *EFI_TEXT_CLEAR_SCREEN) (
115     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This
116     );
117 
118 typedef
119 EFI_STATUS
120 (EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (
121     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
122     IN UINTN                        Column,
123     IN UINTN                        Row
124     );
125 
126 typedef
127 EFI_STATUS
128 (EFIAPI *EFI_TEXT_ENABLE_CURSOR) (
129     IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE     *This,
130     IN BOOLEAN                      Enable
131     );
132 
133 typedef struct {
134     INT32                           MaxMode;
135     // current settings
136     INT32                           Mode;
137     INT32                           Attribute;
138     INT32                           CursorColumn;
139     INT32                           CursorRow;
140     BOOLEAN                         CursorVisible;
141 } SIMPLE_TEXT_OUTPUT_MODE;
142 
143 typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE {
144     EFI_TEXT_RESET                  Reset;
145 
146     EFI_TEXT_OUTPUT_STRING          OutputString;
147     EFI_TEXT_TEST_STRING            TestString;
148 
149     EFI_TEXT_QUERY_MODE             QueryMode;
150     EFI_TEXT_SET_MODE               SetMode;
151     EFI_TEXT_SET_ATTRIBUTE          SetAttribute;
152 
153     EFI_TEXT_CLEAR_SCREEN           ClearScreen;
154     EFI_TEXT_SET_CURSOR_POSITION    SetCursorPosition;
155     EFI_TEXT_ENABLE_CURSOR          EnableCursor;
156 
157     // Current mode
158     SIMPLE_TEXT_OUTPUT_MODE         *Mode;
159 } SIMPLE_TEXT_OUTPUT_INTERFACE;
160 
161 //
162 // Define's for required EFI Unicode Box Draw character
163 //
164 
165 #define BOXDRAW_HORIZONTAL                  0x2500
166 #define BOXDRAW_VERTICAL                    0x2502
167 #define BOXDRAW_DOWN_RIGHT                  0x250c
168 #define BOXDRAW_DOWN_LEFT                   0x2510
169 #define BOXDRAW_UP_RIGHT                    0x2514
170 #define BOXDRAW_UP_LEFT                     0x2518
171 #define BOXDRAW_VERTICAL_RIGHT              0x251c
172 #define BOXDRAW_VERTICAL_LEFT               0x2524
173 #define BOXDRAW_DOWN_HORIZONTAL             0x252c
174 #define BOXDRAW_UP_HORIZONTAL               0x2534
175 #define BOXDRAW_VERTICAL_HORIZONTAL         0x253c
176 
177 #define BOXDRAW_DOUBLE_HORIZONTAL           0x2550
178 #define BOXDRAW_DOUBLE_VERTICAL             0x2551
179 #define BOXDRAW_DOWN_RIGHT_DOUBLE           0x2552
180 #define BOXDRAW_DOWN_DOUBLE_RIGHT           0x2553
181 #define BOXDRAW_DOUBLE_DOWN_RIGHT           0x2554
182 
183 #define BOXDRAW_DOWN_LEFT_DOUBLE            0x2555
184 #define BOXDRAW_DOWN_DOUBLE_LEFT            0x2556
185 #define BOXDRAW_DOUBLE_DOWN_LEFT            0x2557
186 
187 #define BOXDRAW_UP_RIGHT_DOUBLE             0x2558
188 #define BOXDRAW_UP_DOUBLE_RIGHT             0x2559
189 #define BOXDRAW_DOUBLE_UP_RIGHT             0x255a
190 
191 #define BOXDRAW_UP_LEFT_DOUBLE              0x255b
192 #define BOXDRAW_UP_DOUBLE_LEFT              0x255c
193 #define BOXDRAW_DOUBLE_UP_LEFT              0x255d
194 
195 #define BOXDRAW_VERTICAL_RIGHT_DOUBLE       0x255e
196 #define BOXDRAW_VERTICAL_DOUBLE_RIGHT       0x255f
197 #define BOXDRAW_DOUBLE_VERTICAL_RIGHT       0x2560
198 
199 #define BOXDRAW_VERTICAL_LEFT_DOUBLE        0x2561
200 #define BOXDRAW_VERTICAL_DOUBLE_LEFT        0x2562
201 #define BOXDRAW_DOUBLE_VERTICAL_LEFT        0x2563
202 
203 #define BOXDRAW_DOWN_HORIZONTAL_DOUBLE      0x2564
204 #define BOXDRAW_DOWN_DOUBLE_HORIZONTAL      0x2565
205 #define BOXDRAW_DOUBLE_DOWN_HORIZONTAL      0x2566
206 
207 #define BOXDRAW_UP_HORIZONTAL_DOUBLE        0x2567
208 #define BOXDRAW_UP_DOUBLE_HORIZONTAL        0x2568
209 #define BOXDRAW_DOUBLE_UP_HORIZONTAL        0x2569
210 
211 #define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE  0x256a
212 #define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL  0x256b
213 #define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL  0x256c
214 
215 //
216 // EFI Required Block Elements Code Chart
217 //
218 
219 #define BLOCKELEMENT_FULL_BLOCK             0x2588
220 #define BLOCKELEMENT_LIGHT_SHADE            0x2591
221 //
222 // EFI Required Geometric Shapes Code Chart
223 //
224 
225 #define GEOMETRICSHAPE_UP_TRIANGLE           0x25b2
226 #define GEOMETRICSHAPE_RIGHT_TRIANGLE        0x25ba
227 #define GEOMETRICSHAPE_DOWN_TRIANGLE         0x25bc
228 #define GEOMETRICSHAPE_LEFT_TRIANGLE         0x25c4
229 
230 //
231 // EFI Required Arrow shapes
232 //
233 
234 #define ARROW_UP                            0x2191
235 #define ARROW_DOWN                          0x2193
236 
237 //
238 // Text input protocol
239 //
240 
241 #define SIMPLE_TEXT_INPUT_PROTOCOL \
242     { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
243 
244 INTERFACE_DECL(_SIMPLE_INPUT_INTERFACE);
245 
246 typedef struct {
247     UINT16                              ScanCode;
248     CHAR16                              UnicodeChar;
249 } EFI_INPUT_KEY;
250 
251 //
252 // Baseline unicode control chars
253 //
254 
255 #define CHAR_NULL                       0x0000
256 #define CHAR_BACKSPACE                  0x0008
257 #define CHAR_TAB                        0x0009
258 #define CHAR_LINEFEED                   0x000A
259 #define CHAR_CARRIAGE_RETURN            0x000D
260 
261 //
262 // Scan codes for base line keys
263 //
264 
265 #define SCAN_NULL		0x0000
266 #define SCAN_UP			0x0001
267 #define SCAN_DOWN		0x0002
268 #define SCAN_RIGHT		0x0003
269 #define SCAN_LEFT		0x0004
270 #define SCAN_HOME		0x0005
271 #define SCAN_END		0x0006
272 #define SCAN_INSERT		0x0007
273 #define SCAN_DELETE		0x0008
274 #define SCAN_PAGE_UP		0x0009
275 #define SCAN_PAGE_DOWN		0x000A
276 #define SCAN_F1			0x000B
277 #define SCAN_F2			0x000C
278 #define SCAN_F3			0x000D
279 #define SCAN_F4			0x000E
280 #define SCAN_F5			0x000F
281 #define SCAN_F6			0x0010
282 #define SCAN_F7			0x0011
283 #define SCAN_F8			0x0012
284 #define SCAN_F9			0x0013
285 #define SCAN_F10		0x0014
286 #define SCAN_ESC		0x0017
287 
288 //
289 // EFI Scan code Ex
290 //
291 #define SCAN_F11		0x0015
292 #define SCAN_F12		0x0016
293 #define SCAN_F13		0x0068
294 #define SCAN_F14		0x0069
295 #define SCAN_F15		0x006A
296 #define SCAN_F16		0x006B
297 #define SCAN_F17		0x006C
298 #define SCAN_F18		0x006D
299 #define SCAN_F19		0x006E
300 #define SCAN_F20		0x006F
301 #define SCAN_F21		0x0070
302 #define SCAN_F22		0x0071
303 #define SCAN_F23		0x0072
304 #define SCAN_F24		0x0073
305 #define SCAN_MUTE		0x007F
306 #define SCAN_VOLUME_UP		0x0080
307 #define SCAN_VOLUME_DOWN	0x0081
308 #define SCAN_BRIGHTNESS_UP	0x0100
309 #define SCAN_BRIGHTNESS_DOWN	0x0101
310 #define SCAN_SUSPEND		0x0102
311 #define SCAN_HIBERNATE		0x0103
312 #define SCAN_TOGGLE_DISPLAY	0x0104
313 #define SCAN_RECOVERY		0x0105
314 #define SCAN_EJECT		0x0106
315 
316 typedef
317 EFI_STATUS
318 (EFIAPI *EFI_INPUT_RESET) (
319     IN struct _SIMPLE_INPUT_INTERFACE   *This,
320     IN BOOLEAN                          ExtendedVerification
321     );
322 
323 typedef
324 EFI_STATUS
325 (EFIAPI *EFI_INPUT_READ_KEY) (
326     IN struct _SIMPLE_INPUT_INTERFACE   *This,
327     OUT EFI_INPUT_KEY                   *Key
328     );
329 
330 typedef struct _SIMPLE_INPUT_INTERFACE {
331     EFI_INPUT_RESET                     Reset;
332     EFI_INPUT_READ_KEY                  ReadKeyStroke;
333     EFI_EVENT                           WaitForKey;
334 } SIMPLE_INPUT_INTERFACE;
335 
336 #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
337   {0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, \
338   0x17, 0xa6, 0x25, 0xaa} }
339 
340 INTERFACE_DECL(_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL);
341 
342 typedef UINT8          EFI_KEY_TOGGLE_STATE;
343 //
344 // Any Shift or Toggle State that is valid should have
345 // high order bit set.
346 //
347 typedef struct EFI_KEY_STATE {
348   UINT32               KeyShiftState;
349   EFI_KEY_TOGGLE_STATE KeyToggleState;
350 } EFI_KEY_STATE;
351 
352 typedef struct {
353   EFI_INPUT_KEY        Key;
354   EFI_KEY_STATE        KeyState;
355 } EFI_KEY_DATA;
356 
357 //
358 // Shift state
359 //
360 #define EFI_SHIFT_STATE_VALID     0x80000000
361 #define EFI_RIGHT_SHIFT_PRESSED   0x00000001
362 #define EFI_LEFT_SHIFT_PRESSED    0x00000002
363 #define EFI_RIGHT_CONTROL_PRESSED 0x00000004
364 #define EFI_LEFT_CONTROL_PRESSED  0x00000008
365 #define EFI_RIGHT_ALT_PRESSED     0x00000010
366 #define EFI_LEFT_ALT_PRESSED      0x00000020
367 #define EFI_RIGHT_LOGO_PRESSED    0x00000040
368 #define EFI_LEFT_LOGO_PRESSED     0x00000080
369 #define EFI_MENU_KEY_PRESSED      0x00000100
370 #define EFI_SYS_REQ_PRESSED       0x00000200
371 
372 //
373 // Toggle state
374 //
375 #define EFI_TOGGLE_STATE_VALID    0x80
376 #define	EFI_KEY_STATE_EXPOSED     0x40
377 #define EFI_SCROLL_LOCK_ACTIVE    0x01
378 #define EFI_NUM_LOCK_ACTIVE       0x02
379 #define EFI_CAPS_LOCK_ACTIVE      0x04
380 
381 //
382 // EFI Key Notfication Function
383 //
384 typedef
385 EFI_STATUS
386 (EFIAPI *EFI_KEY_NOTIFY_FUNCTION) (
387   IN  EFI_KEY_DATA                      *KeyData
388   );
389 
390 typedef
391 EFI_STATUS
392 (EFIAPI *EFI_INPUT_RESET_EX) (
393   IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
394   IN BOOLEAN                            ExtendedVerification
395   )
396 /*++
397 
398   Routine Description:
399     Reset the input device and optionaly run diagnostics
400 
401   Arguments:
402     This                  - Protocol instance pointer.
403     ExtendedVerification  - Driver may perform diagnostics on reset.
404 
405   Returns:
406     EFI_SUCCESS           - The device was reset.
407     EFI_DEVICE_ERROR      - The device is not functioning properly and could
408                             not be reset.
409 
410 --*/
411 ;
412 
413 typedef
414 EFI_STATUS
415 (EFIAPI *EFI_INPUT_READ_KEY_EX) (
416   IN  struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
417   OUT EFI_KEY_DATA                      *KeyData
418   )
419 /*++
420 
421   Routine Description:
422     Reads the next keystroke from the input device. The WaitForKey Event can
423     be used to test for existence of a keystroke via WaitForEvent () call.
424 
425   Arguments:
426     This       - Protocol instance pointer.
427     KeyData    - A pointer to a buffer that is filled in with the keystroke
428                  state data for the key that was pressed.
429 
430   Returns:
431     EFI_SUCCESS           - The keystroke information was returned.
432     EFI_NOT_READY         - There was no keystroke data availiable.
433     EFI_DEVICE_ERROR      - The keystroke information was not returned due to
434                             hardware errors.
435     EFI_INVALID_PARAMETER - KeyData is NULL.
436 --*/
437 ;
438 
439 typedef
440 EFI_STATUS
441 (EFIAPI *EFI_SET_STATE) (
442   IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
443   IN EFI_KEY_TOGGLE_STATE               *KeyToggleState
444   )
445 /*++
446 
447   Routine Description:
448     Set certain state for the input device.
449 
450   Arguments:
451     This              - Protocol instance pointer.
452     KeyToggleState    - A pointer to the EFI_KEY_TOGGLE_STATE to set the
453                         state for the input device.
454 
455   Returns:
456     EFI_SUCCESS           - The device state was set successfully.
457     EFI_DEVICE_ERROR      - The device is not functioning correctly and could
458                             not have the setting adjusted.
459     EFI_UNSUPPORTED       - The device does not have the ability to set its state.
460     EFI_INVALID_PARAMETER - KeyToggleState is NULL.
461 
462 --*/
463 ;
464 
465 typedef
466 EFI_STATUS
467 (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) (
468   IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
469   IN EFI_KEY_DATA                       *KeyData,
470   IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,
471   OUT EFI_HANDLE                        *NotifyHandle
472   )
473 /*++
474 
475   Routine Description:
476     Register a notification function for a particular keystroke for the input device.
477 
478   Arguments:
479     This                    - Protocol instance pointer.
480     KeyData                 - A pointer to a buffer that is filled in with the keystroke
481                               information data for the key that was pressed.
482     KeyNotificationFunction - Points to the function to be called when the key
483                               sequence is typed specified by KeyData.
484     NotifyHandle            - Points to the unique handle assigned to the registered notification.
485 
486   Returns:
487     EFI_SUCCESS             - The notification function was registered successfully.
488     EFI_OUT_OF_RESOURCES    - Unable to allocate resources for necessary data structures.
489     EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.
490 
491 --*/
492 ;
493 
494 typedef
495 EFI_STATUS
496 (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) (
497   IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
498   IN EFI_HANDLE                         NotificationHandle
499   )
500 /*++
501 
502   Routine Description:
503     Remove a registered notification function from a particular keystroke.
504 
505   Arguments:
506     This                    - Protocol instance pointer.
507     NotificationHandle      - The handle of the notification function being unregistered.
508 
509   Returns:
510     EFI_SUCCESS             - The notification function was unregistered successfully.
511     EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.
512     EFI_NOT_FOUND           - Can not find the matching entry in database.
513 
514 --*/
515 ;
516 
517 typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL {
518   EFI_INPUT_RESET_EX                    Reset;
519   EFI_INPUT_READ_KEY_EX                 ReadKeyStrokeEx;
520   EFI_EVENT                             WaitForKeyEx;
521   EFI_SET_STATE                         SetState;
522   EFI_REGISTER_KEYSTROKE_NOTIFY         RegisterKeyNotify;
523   EFI_UNREGISTER_KEYSTROKE_NOTIFY       UnregisterKeyNotify;
524 } EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
525 
526 #endif
527