Home | History | Annotate | Download | only in Protocol
      1 /** @file
      2   Simple Text Out protocol from the UEFI 2.0 specification.
      3 
      4   Abstraction of a very simple text based output device like VGA text mode or
      5   a serial terminal. The Simple Text Out protocol instance can represent
      6   a single hardware device or a virtual device that is an aggregation
      7   of multiple physical devices.
      8 
      9 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
     10 This program and the accompanying materials are licensed and made available under
     11 the terms and conditions of the BSD License that accompanies this distribution.
     12 The full text of the license may be found at
     13 http://opensource.org/licenses/bsd-license.php.
     14 
     15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     17 
     18 **/
     19 
     20 #ifndef __SIMPLE_TEXT_OUT_H__
     21 #define __SIMPLE_TEXT_OUT_H__
     22 
     23 #define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
     24   { \
     25     0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
     26   }
     27 
     28 ///
     29 /// Protocol GUID defined in EFI1.1.
     30 ///
     31 #define SIMPLE_TEXT_OUTPUT_PROTOCOL   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID
     32 
     33 typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
     34 
     35 ///
     36 /// Backward-compatible with EFI1.1.
     37 ///
     38 typedef EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   SIMPLE_TEXT_OUTPUT_INTERFACE;
     39 
     40 //
     41 // Define's for required EFI Unicode Box Draw characters
     42 //
     43 #define BOXDRAW_HORIZONTAL                  0x2500
     44 #define BOXDRAW_VERTICAL                    0x2502
     45 #define BOXDRAW_DOWN_RIGHT                  0x250c
     46 #define BOXDRAW_DOWN_LEFT                   0x2510
     47 #define BOXDRAW_UP_RIGHT                    0x2514
     48 #define BOXDRAW_UP_LEFT                     0x2518
     49 #define BOXDRAW_VERTICAL_RIGHT              0x251c
     50 #define BOXDRAW_VERTICAL_LEFT               0x2524
     51 #define BOXDRAW_DOWN_HORIZONTAL             0x252c
     52 #define BOXDRAW_UP_HORIZONTAL               0x2534
     53 #define BOXDRAW_VERTICAL_HORIZONTAL         0x253c
     54 #define BOXDRAW_DOUBLE_HORIZONTAL           0x2550
     55 #define BOXDRAW_DOUBLE_VERTICAL             0x2551
     56 #define BOXDRAW_DOWN_RIGHT_DOUBLE           0x2552
     57 #define BOXDRAW_DOWN_DOUBLE_RIGHT           0x2553
     58 #define BOXDRAW_DOUBLE_DOWN_RIGHT           0x2554
     59 #define BOXDRAW_DOWN_LEFT_DOUBLE            0x2555
     60 #define BOXDRAW_DOWN_DOUBLE_LEFT            0x2556
     61 #define BOXDRAW_DOUBLE_DOWN_LEFT            0x2557
     62 #define BOXDRAW_UP_RIGHT_DOUBLE             0x2558
     63 #define BOXDRAW_UP_DOUBLE_RIGHT             0x2559
     64 #define BOXDRAW_DOUBLE_UP_RIGHT             0x255a
     65 #define BOXDRAW_UP_LEFT_DOUBLE              0x255b
     66 #define BOXDRAW_UP_DOUBLE_LEFT              0x255c
     67 #define BOXDRAW_DOUBLE_UP_LEFT              0x255d
     68 #define BOXDRAW_VERTICAL_RIGHT_DOUBLE       0x255e
     69 #define BOXDRAW_VERTICAL_DOUBLE_RIGHT       0x255f
     70 #define BOXDRAW_DOUBLE_VERTICAL_RIGHT       0x2560
     71 #define BOXDRAW_VERTICAL_LEFT_DOUBLE        0x2561
     72 #define BOXDRAW_VERTICAL_DOUBLE_LEFT        0x2562
     73 #define BOXDRAW_DOUBLE_VERTICAL_LEFT        0x2563
     74 #define BOXDRAW_DOWN_HORIZONTAL_DOUBLE      0x2564
     75 #define BOXDRAW_DOWN_DOUBLE_HORIZONTAL      0x2565
     76 #define BOXDRAW_DOUBLE_DOWN_HORIZONTAL      0x2566
     77 #define BOXDRAW_UP_HORIZONTAL_DOUBLE        0x2567
     78 #define BOXDRAW_UP_DOUBLE_HORIZONTAL        0x2568
     79 #define BOXDRAW_DOUBLE_UP_HORIZONTAL        0x2569
     80 #define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE  0x256a
     81 #define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL  0x256b
     82 #define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL  0x256c
     83 
     84 //
     85 // EFI Required Block Elements Code Chart
     86 //
     87 #define BLOCKELEMENT_FULL_BLOCK   0x2588
     88 #define BLOCKELEMENT_LIGHT_SHADE  0x2591
     89 
     90 //
     91 // EFI Required Geometric Shapes Code Chart
     92 //
     93 #define GEOMETRICSHAPE_UP_TRIANGLE    0x25b2
     94 #define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba
     95 #define GEOMETRICSHAPE_DOWN_TRIANGLE  0x25bc
     96 #define GEOMETRICSHAPE_LEFT_TRIANGLE  0x25c4
     97 
     98 //
     99 // EFI Required Arrow shapes
    100 //
    101 #define ARROW_LEFT  0x2190
    102 #define ARROW_UP    0x2191
    103 #define ARROW_RIGHT 0x2192
    104 #define ARROW_DOWN  0x2193
    105 
    106 //
    107 // EFI Console Colours
    108 //
    109 #define EFI_BLACK                 0x00
    110 #define EFI_BLUE                  0x01
    111 #define EFI_GREEN                 0x02
    112 #define EFI_CYAN                  (EFI_BLUE | EFI_GREEN)
    113 #define EFI_RED                   0x04
    114 #define EFI_MAGENTA               (EFI_BLUE | EFI_RED)
    115 #define EFI_BROWN                 (EFI_GREEN | EFI_RED)
    116 #define EFI_LIGHTGRAY             (EFI_BLUE | EFI_GREEN | EFI_RED)
    117 #define EFI_BRIGHT                0x08
    118 #define EFI_DARKGRAY              (EFI_BLACK | EFI_BRIGHT)
    119 #define EFI_LIGHTBLUE             (EFI_BLUE | EFI_BRIGHT)
    120 #define EFI_LIGHTGREEN            (EFI_GREEN | EFI_BRIGHT)
    121 #define EFI_LIGHTCYAN             (EFI_CYAN | EFI_BRIGHT)
    122 #define EFI_LIGHTRED              (EFI_RED | EFI_BRIGHT)
    123 #define EFI_LIGHTMAGENTA          (EFI_MAGENTA | EFI_BRIGHT)
    124 #define EFI_YELLOW                (EFI_BROWN | EFI_BRIGHT)
    125 #define EFI_WHITE                 (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
    126 
    127 //
    128 // Macro to accept color values in their raw form to create
    129 // a value that represents both a foreground and background
    130 // color in a single byte.
    131 // For Foreground, and EFI_* value is valid from EFI_BLACK(0x00) to
    132 // EFI_WHITE (0x0F).
    133 // For Background, only EFI_BLACK, EFI_BLUE, EFI_GREEN, EFI_CYAN,
    134 // EFI_RED, EFI_MAGENTA, EFI_BROWN, and EFI_LIGHTGRAY are acceptable
    135 //
    136 // Do not use EFI_BACKGROUND_xxx values with this macro.
    137 //
    138 #define EFI_TEXT_ATTR(Foreground,Background) ((Foreground) | ((Background) << 4))
    139 
    140 #define EFI_BACKGROUND_BLACK      0x00
    141 #define EFI_BACKGROUND_BLUE       0x10
    142 #define EFI_BACKGROUND_GREEN      0x20
    143 #define EFI_BACKGROUND_CYAN       (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
    144 #define EFI_BACKGROUND_RED        0x40
    145 #define EFI_BACKGROUND_MAGENTA    (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
    146 #define EFI_BACKGROUND_BROWN      (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
    147 #define EFI_BACKGROUND_LIGHTGRAY  (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
    148 
    149 //
    150 // We currently define attributes from 0 - 7F for color manipulations
    151 // To internally handle the local display characteristics for a particular character,
    152 // Bit 7 signifies the local glyph representation for a character.  If turned on, glyphs will be
    153 // pulled from the wide glyph database and will display locally as a wide character (16 X 19 versus 8 X 19)
    154 // If bit 7 is off, the narrow glyph database will be used.  This does NOT affect information that is sent to
    155 // non-local displays, such as serial or LAN consoles.
    156 //
    157 #define EFI_WIDE_ATTRIBUTE  0x80
    158 
    159 /**
    160   Reset the text output device hardware and optionaly run diagnostics
    161 
    162   @param  This                 The protocol instance pointer.
    163   @param  ExtendedVerification Driver may perform more exhaustive verfication
    164                                operation of the device during reset.
    165 
    166   @retval EFI_SUCCESS          The text output device was reset.
    167   @retval EFI_DEVICE_ERROR     The text output device is not functioning correctly and
    168                                could not be reset.
    169 
    170 **/
    171 typedef
    172 EFI_STATUS
    173 (EFIAPI *EFI_TEXT_RESET)(
    174   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    175   IN BOOLEAN                                ExtendedVerification
    176   );
    177 
    178 /**
    179   Write a string to the output device.
    180 
    181   @param  This   The protocol instance pointer.
    182   @param  String The NULL-terminated string to be displayed on the output
    183                  device(s). All output devices must also support the Unicode
    184                  drawing character codes defined in this file.
    185 
    186   @retval EFI_SUCCESS             The string was output to the device.
    187   @retval EFI_DEVICE_ERROR        The device reported an error while attempting to output
    188                                   the text.
    189   @retval EFI_UNSUPPORTED         The output device's mode is not currently in a
    190                                   defined text mode.
    191   @retval EFI_WARN_UNKNOWN_GLYPH  This warning code indicates that some of the
    192                                   characters in the string could not be
    193                                   rendered and were skipped.
    194 
    195 **/
    196 typedef
    197 EFI_STATUS
    198 (EFIAPI *EFI_TEXT_STRING)(
    199   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    200   IN CHAR16                                 *String
    201   );
    202 
    203 /**
    204   Verifies that all characters in a string can be output to the
    205   target device.
    206 
    207   @param  This   The protocol instance pointer.
    208   @param  String The NULL-terminated string to be examined for the output
    209                  device(s).
    210 
    211   @retval EFI_SUCCESS      The device(s) are capable of rendering the output string.
    212   @retval EFI_UNSUPPORTED  Some of the characters in the string cannot be
    213                            rendered by one or more of the output devices mapped
    214                            by the EFI handle.
    215 
    216 **/
    217 typedef
    218 EFI_STATUS
    219 (EFIAPI *EFI_TEXT_TEST_STRING)(
    220   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    221   IN CHAR16                                 *String
    222   );
    223 
    224 /**
    225   Returns information for an available text mode that the output device(s)
    226   supports.
    227 
    228   @param  This       The protocol instance pointer.
    229   @param  ModeNumber The mode number to return information on.
    230   @param  Columns    Returns the geometry of the text output device for the
    231                      requested ModeNumber.
    232   @param  Rows       Returns the geometry of the text output device for the
    233                      requested ModeNumber.
    234 
    235   @retval EFI_SUCCESS      The requested mode information was returned.
    236   @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
    237   @retval EFI_UNSUPPORTED  The mode number was not valid.
    238 
    239 **/
    240 typedef
    241 EFI_STATUS
    242 (EFIAPI *EFI_TEXT_QUERY_MODE)(
    243   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    244   IN UINTN                                  ModeNumber,
    245   OUT UINTN                                 *Columns,
    246   OUT UINTN                                 *Rows
    247   );
    248 
    249 /**
    250   Sets the output device(s) to a specified mode.
    251 
    252   @param  This       The protocol instance pointer.
    253   @param  ModeNumber The mode number to set.
    254 
    255   @retval EFI_SUCCESS      The requested text mode was set.
    256   @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
    257   @retval EFI_UNSUPPORTED  The mode number was not valid.
    258 
    259 **/
    260 typedef
    261 EFI_STATUS
    262 (EFIAPI *EFI_TEXT_SET_MODE)(
    263   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    264   IN UINTN                                  ModeNumber
    265   );
    266 
    267 /**
    268   Sets the background and foreground colors for the OutputString () and
    269   ClearScreen () functions.
    270 
    271   @param  This      The protocol instance pointer.
    272   @param  Attribute The attribute to set. Bits 0..3 are the foreground color, and
    273                     bits 4..6 are the background color. All other bits are undefined
    274                     and must be zero. The valid Attributes are defined in this file.
    275 
    276   @retval EFI_SUCCESS       The attribute was set.
    277   @retval EFI_DEVICE_ERROR  The device had an error and could not complete the request.
    278   @retval EFI_UNSUPPORTED   The attribute requested is not defined.
    279 
    280 **/
    281 typedef
    282 EFI_STATUS
    283 (EFIAPI *EFI_TEXT_SET_ATTRIBUTE)(
    284   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    285   IN UINTN                                  Attribute
    286   );
    287 
    288 /**
    289   Clears the output device(s) display to the currently selected background
    290   color.
    291 
    292   @param  This              The protocol instance pointer.
    293 
    294   @retval  EFI_SUCCESS      The operation completed successfully.
    295   @retval  EFI_DEVICE_ERROR The device had an error and could not complete the request.
    296   @retval  EFI_UNSUPPORTED  The output device is not in a valid text mode.
    297 
    298 **/
    299 typedef
    300 EFI_STATUS
    301 (EFIAPI *EFI_TEXT_CLEAR_SCREEN)(
    302   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *This
    303   );
    304 
    305 /**
    306   Sets the current coordinates of the cursor position
    307 
    308   @param  This        The protocol instance pointer.
    309   @param  Column      The position to set the cursor to. Must be greater than or
    310                       equal to zero and less than the number of columns and rows
    311                       by QueryMode ().
    312   @param  Row         The position to set the cursor to. Must be greater than or
    313                       equal to zero and less than the number of columns and rows
    314                       by QueryMode ().
    315 
    316   @retval EFI_SUCCESS      The operation completed successfully.
    317   @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
    318   @retval EFI_UNSUPPORTED  The output device is not in a valid text mode, or the
    319                            cursor position is invalid for the current mode.
    320 
    321 **/
    322 typedef
    323 EFI_STATUS
    324 (EFIAPI *EFI_TEXT_SET_CURSOR_POSITION)(
    325   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    326   IN UINTN                                  Column,
    327   IN UINTN                                  Row
    328   );
    329 
    330 /**
    331   Makes the cursor visible or invisible
    332 
    333   @param  This    The protocol instance pointer.
    334   @param  Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is
    335                   set to be invisible.
    336 
    337   @retval EFI_SUCCESS      The operation completed successfully.
    338   @retval EFI_DEVICE_ERROR The device had an error and could not complete the
    339                            request, or the device does not support changing
    340                            the cursor mode.
    341   @retval EFI_UNSUPPORTED  The output device is not in a valid text mode.
    342 
    343 **/
    344 typedef
    345 EFI_STATUS
    346 (EFIAPI *EFI_TEXT_ENABLE_CURSOR)(
    347   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL        *This,
    348   IN BOOLEAN                                Visible
    349   );
    350 
    351 /**
    352   @par Data Structure Description:
    353   Mode Structure pointed to by Simple Text Out protocol.
    354 **/
    355 typedef struct {
    356   ///
    357   /// The number of modes supported by QueryMode () and SetMode ().
    358   ///
    359   INT32   MaxMode;
    360 
    361   //
    362   // current settings
    363   //
    364 
    365   ///
    366   /// The text mode of the output device(s).
    367   ///
    368   INT32   Mode;
    369   ///
    370   /// The current character output attribute.
    371   ///
    372   INT32   Attribute;
    373   ///
    374   /// The cursor's column.
    375   ///
    376   INT32   CursorColumn;
    377   ///
    378   /// The cursor's row.
    379   ///
    380   INT32   CursorRow;
    381   ///
    382   /// The cursor is currently visbile or not.
    383   ///
    384   BOOLEAN CursorVisible;
    385 } EFI_SIMPLE_TEXT_OUTPUT_MODE;
    386 
    387 ///
    388 /// The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
    389 /// It is the minimum required protocol for any handle supplied as the ConsoleOut
    390 /// or StandardError device. In addition, the minimum supported text mode of such
    391 /// devices is at least 80 x 25 characters.
    392 ///
    393 struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
    394   EFI_TEXT_RESET                Reset;
    395 
    396   EFI_TEXT_STRING               OutputString;
    397   EFI_TEXT_TEST_STRING          TestString;
    398 
    399   EFI_TEXT_QUERY_MODE           QueryMode;
    400   EFI_TEXT_SET_MODE             SetMode;
    401   EFI_TEXT_SET_ATTRIBUTE        SetAttribute;
    402 
    403   EFI_TEXT_CLEAR_SCREEN         ClearScreen;
    404   EFI_TEXT_SET_CURSOR_POSITION  SetCursorPosition;
    405   EFI_TEXT_ENABLE_CURSOR        EnableCursor;
    406 
    407   ///
    408   /// Pointer to SIMPLE_TEXT_OUTPUT_MODE data.
    409   ///
    410   EFI_SIMPLE_TEXT_OUTPUT_MODE   *Mode;
    411 };
    412 
    413 extern EFI_GUID gEfiSimpleTextOutProtocolGuid;
    414 
    415 #endif
    416