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