xref: /illumos-gate/usr/src/boot/efi/include/Protocol/GraphicsOutput.h (revision f334afcfaebea1b7dc3430015651d8d748fa8a3e)
1 /** @file
2   Graphics Output Protocol from the UEFI 2.0 specification.
3 
4   Abstraction of a very simple graphics device.
5 
6   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7   SPDX-License-Identifier: BSD-2-Clause-Patent
8 
9 **/
10 
11 #ifndef __GRAPHICS_OUTPUT_H__
12 #define __GRAPHICS_OUTPUT_H__
13 
14 #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
15   { \
16     0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \
17   }
18 
19 typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
20 
21 typedef struct {
22   UINT32    RedMask;
23   UINT32    GreenMask;
24   UINT32    BlueMask;
25   UINT32    ReservedMask;
26 } EFI_PIXEL_BITMASK;
27 
28 typedef enum {
29   ///
30   /// A pixel is 32-bits and byte zero represents red, byte one represents green,
31   /// byte two represents blue, and byte three is reserved. This is the definition
32   /// for the physical frame buffer. The byte values for the red, green, and blue
33   /// components represent the color intensity. This color intensity value range
34   /// from a minimum intensity of 0 to maximum intensity of 255.
35   ///
36   PixelRedGreenBlueReserved8BitPerColor,
37   ///
38   /// A pixel is 32-bits and byte zero represents blue, byte one represents green,
39   /// byte two represents red, and byte three is reserved. This is the definition
40   /// for the physical frame buffer. The byte values for the red, green, and blue
41   /// components represent the color intensity. This color intensity value range
42   /// from a minimum intensity of 0 to maximum intensity of 255.
43   ///
44   PixelBlueGreenRedReserved8BitPerColor,
45   ///
46   /// The Pixel definition of the physical frame buffer.
47   ///
48   PixelBitMask,
49   ///
50   /// This mode does not support a physical frame buffer.
51   ///
52   PixelBltOnly,
53   ///
54   /// Valid EFI_GRAPHICS_PIXEL_FORMAT enum values are less than this value.
55   ///
56   PixelFormatMax
57 } EFI_GRAPHICS_PIXEL_FORMAT;
58 
59 typedef struct {
60   ///
61   /// The version of this data structure. A value of zero represents the
62   /// EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure as defined in this specification.
63   ///
64   UINT32                       Version;
65   ///
66   /// The size of video screen in pixels in the X dimension.
67   ///
68   UINT32                       HorizontalResolution;
69   ///
70   /// The size of video screen in pixels in the Y dimension.
71   ///
72   UINT32                       VerticalResolution;
73   ///
74   /// Enumeration that defines the physical format of the pixel. A value of PixelBltOnly
75   /// implies that a linear frame buffer is not available for this mode.
76   ///
77   EFI_GRAPHICS_PIXEL_FORMAT    PixelFormat;
78   ///
79   /// This bit-mask is only valid if PixelFormat is set to PixelPixelBitMask.
80   /// A bit being set defines what bits are used for what purpose such as Red, Green, Blue, or Reserved.
81   ///
82   EFI_PIXEL_BITMASK            PixelInformation;
83   ///
84   /// Defines the number of pixel elements per video memory line.
85   ///
86   UINT32                       PixelsPerScanLine;
87 } EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
88 
89 /**
90   Returns information for an available graphics mode that the graphics device
91   and the set of active video output devices supports.
92 
93   @param  This                  The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
94   @param  ModeNumber            The mode number to return information on.
95   @param  SizeOfInfo            A pointer to the size, in bytes, of the Info buffer.
96   @param  Info                  A pointer to callee allocated buffer that returns information about ModeNumber.
97 
98   @retval EFI_SUCCESS           Valid mode information was returned.
99   @retval EFI_DEVICE_ERROR      A hardware error occurred trying to retrieve the video mode.
100   @retval EFI_INVALID_PARAMETER ModeNumber is not valid.
101 
102 **/
103 typedef
104 EFI_STATUS
105 (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE)(
106   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,
107   IN  UINT32                                ModeNumber,
108   OUT UINTN                                 *SizeOfInfo,
109   OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info
110   );
111 
112 /**
113   Set the video device into the specified mode and clears the visible portions of
114   the output display to black.
115 
116   @param  This              The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
117   @param  ModeNumber        Abstraction that defines the current video mode.
118 
119   @retval EFI_SUCCESS       The graphics mode specified by ModeNumber was selected.
120   @retval EFI_DEVICE_ERROR  The device had an error and could not complete the request.
121   @retval EFI_UNSUPPORTED   ModeNumber is not supported by this device.
122 
123 **/
124 typedef
125 EFI_STATUS
126 (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE)(
127   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
128   IN  UINT32                       ModeNumber
129   );
130 
131 typedef struct {
132   UINT8    Blue;
133   UINT8    Green;
134   UINT8    Red;
135   UINT8    Reserved;
136 } EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
137 
138 typedef union {
139   EFI_GRAPHICS_OUTPUT_BLT_PIXEL    Pixel;
140   UINT32                           Raw;
141 } EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
142 
143 ///
144 /// actions for BltOperations
145 ///
146 typedef enum {
147   ///
148   /// Write data from the BltBuffer pixel (0, 0)
149   /// directly to every pixel of the video display rectangle
150   /// (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
151   /// Only one pixel will be used from the BltBuffer. Delta is NOT used.
152   ///
153   EfiBltVideoFill,
154 
155   ///
156   /// Read data from the video display rectangle
157   /// (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
158   /// the BltBuffer rectangle (DestinationX, DestinationY )
159   /// (DestinationX + Width, DestinationY + Height). If DestinationX or
160   /// DestinationY is not zero then Delta must be set to the length in bytes
161   /// of a row in the BltBuffer.
162   ///
163   EfiBltVideoToBltBuffer,
164 
165   ///
166   /// Write data from the BltBuffer rectangle
167   /// (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
168   /// video display rectangle (DestinationX, DestinationY)
169   /// (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
170   /// not zero then Delta must be set to the length in bytes of a row in the
171   /// BltBuffer.
172   ///
173   EfiBltBufferToVideo,
174 
175   ///
176   /// Copy from the video display rectangle (SourceX, SourceY)
177   /// (SourceX + Width, SourceY + Height) to the video display rectangle
178   /// (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
179   /// The BltBuffer and Delta are not used in this mode.
180   ///
181   EfiBltVideoToVideo,
182 
183   EfiGraphicsOutputBltOperationMax
184 } EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
185 
186 /**
187   Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
188 
189   @param  This         Protocol instance pointer.
190   @param  BltBuffer    The data to transfer to the graphics screen.
191                        Size is at least Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL).
192   @param  BltOperation The operation to perform when copying BltBuffer on to the graphics screen.
193   @param  SourceX      The X coordinate of source for the BltOperation.
194   @param  SourceY      The Y coordinate of source for the BltOperation.
195   @param  DestinationX The X coordinate of destination for the BltOperation.
196   @param  DestinationY The Y coordinate of destination for the BltOperation.
197   @param  Width        The width of a rectangle in the blt rectangle in pixels.
198   @param  Height       The height of a rectangle in the blt rectangle in pixels.
199   @param  Delta        Not used for EfiBltVideoFill or the EfiBltVideoToVideo operation.
200                        If a Delta of zero is used, the entire BltBuffer is being operated on.
201                        If a subrectangle of the BltBuffer is being used then Delta
202                        represents the number of bytes in a row of the BltBuffer.
203 
204   @retval EFI_SUCCESS           BltBuffer was drawn to the graphics screen.
205   @retval EFI_INVALID_PARAMETER BltOperation is not valid.
206   @retval EFI_DEVICE_ERROR      The device had an error and could not complete the request.
207 
208 **/
209 typedef
210 EFI_STATUS
211 (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT)(
212   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL            *This,
213   IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL           *BltBuffer    OPTIONAL,
214   IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION       BltOperation,
215   IN  UINTN                                   SourceX,
216   IN  UINTN                                   SourceY,
217   IN  UINTN                                   DestinationX,
218   IN  UINTN                                   DestinationY,
219   IN  UINTN                                   Width,
220   IN  UINTN                                   Height,
221   IN  UINTN                                   Delta         OPTIONAL
222   );
223 
224 typedef struct {
225   ///
226   /// The number of modes supported by QueryMode() and SetMode().
227   ///
228   UINT32                                  MaxMode;
229   ///
230   /// Current Mode of the graphics device. Valid mode numbers are 0 to MaxMode -1.
231   ///
232   UINT32                                  Mode;
233   ///
234   /// Pointer to read-only EFI_GRAPHICS_OUTPUT_MODE_INFORMATION data.
235   ///
236   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION    *Info;
237   ///
238   /// Size of Info structure in bytes.
239   ///
240   UINTN                                   SizeOfInfo;
241   ///
242   /// Base address of graphics linear frame buffer.
243   /// Offset zero in FrameBufferBase represents the upper left pixel of the display.
244   ///
245   EFI_PHYSICAL_ADDRESS                    FrameBufferBase;
246   ///
247   /// Amount of frame buffer needed to support the active mode as defined by
248   /// PixelsPerScanLine xVerticalResolution x PixelElementSize.
249   ///
250   UINTN                                   FrameBufferSize;
251 } EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
252 
253 ///
254 /// Provides a basic abstraction to set video modes and copy pixels to and from
255 /// the graphics controller's frame buffer. The linear address of the hardware
256 /// frame buffer is also exposed so software can write directly to the video hardware.
257 ///
258 struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {
259   EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE    QueryMode;
260   EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE      SetMode;
261   EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT           Blt;
262   ///
263   /// Pointer to EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE data.
264   ///
265   EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE          *Mode;
266 };
267 
268 extern EFI_GUID  gEfiGraphicsOutputProtocolGuid;
269 
270 #endif
271