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