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