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