]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootPayloadPkg/FbGop/FbGop.h
CorebootPayloadPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / CorebootPayloadPkg / FbGop / FbGop.h
CommitLineData
9c228fb0
MM
1/** @file\r
2\r
3Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
4\r
d2e8b7e1 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
9c228fb0
MM
6\r
7**/\r
8\r
9#ifndef _FB_GOP_H_\r
10#define _FB_GOP_H_\r
11\r
12#include <Protocol/PciIo.h>\r
13#include <Protocol/DevicePath.h>\r
14#include <Protocol/GraphicsOutput.h>\r
15#include <Protocol/EdidActive.h>\r
16#include <Protocol/EdidDiscovered.h>\r
17\r
18#include <Guid/StatusCodeDataTypeId.h>\r
19#include <Guid/EventGroup.h>\r
20#include <Guid/FrameBufferInfoGuid.h>\r
21\r
22#include <Library/PcdLib.h>\r
23#include <Library/HobLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/ReportStatusCodeLib.h>\r
26#include <Library/BaseMemoryLib.h>\r
27#include <Library/UefiDriverEntryPoint.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/UefiLib.h>\r
30#include <Library/DevicePathLib.h>\r
31#include <Library/MemoryAllocationLib.h>\r
32\r
33#include <IndustryStandard/Pci.h>\r
34\r
35//\r
36// Packed format support: The number of bits reserved for each of the colors and the actual\r
37// position of RGB in the frame buffer is specified in the VBE Mode information\r
38//\r
39typedef struct {\r
40 UINT8 Position; // Position of the color\r
41 UINT8 Mask; // The number of bits expressed as a mask\r
42} FB_VIDEO_COLOR_PLACEMENT;\r
43\r
44//\r
45// BIOS Graphics Output Graphical Mode Data\r
46//\r
47typedef struct {\r
48 UINT16 VbeModeNumber;\r
49 UINT16 BytesPerScanLine;\r
50 VOID *LinearFrameBuffer;\r
51 UINTN FrameBufferSize;\r
52 UINT32 HorizontalResolution;\r
53 UINT32 VerticalResolution;\r
54 UINT32 ColorDepth;\r
55 UINT32 RefreshRate;\r
56 UINT32 BitsPerPixel;\r
57 FB_VIDEO_COLOR_PLACEMENT Red;\r
58 FB_VIDEO_COLOR_PLACEMENT Green;\r
59 FB_VIDEO_COLOR_PLACEMENT Blue;\r
60 FB_VIDEO_COLOR_PLACEMENT Reserved;\r
61 EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;\r
62 EFI_PIXEL_BITMASK PixelBitMask;\r
63} FB_VIDEO_MODE_DATA;\r
64\r
65//\r
66// BIOS video child handle private data Structure\r
67//\r
68#define FB_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p')\r
69\r
70typedef struct {\r
71 UINTN Signature;\r
72 EFI_HANDLE Handle;\r
73\r
74 //\r
75 // Consumed Protocols\r
76 //\r
77 EFI_PCI_IO_PROTOCOL *PciIo; \r
78\r
79 //\r
80 // Produced Protocols\r
81 //\r
82 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
83 EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;\r
84 EFI_EDID_ACTIVE_PROTOCOL EdidActive;\r
85\r
86 //\r
87 // Graphics Output Protocol related fields\r
88 //\r
89 UINTN CurrentMode;\r
90 UINTN MaxMode;\r
91 FB_VIDEO_MODE_DATA *ModeData;\r
92 \r
93 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;\r
94 \r
95 //\r
96 // Status code\r
97 //\r
98 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
99 \r
100} FB_VIDEO_DEV;\r
101\r
102#define FB_VIDEO_DEV_FROM_PCI_IO_THIS(a) CR (a, FB_VIDEO_DEV, PciIo, FB_VIDEO_DEV_SIGNATURE)\r
103#define FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a) CR (a, FB_VIDEO_DEV, GraphicsOutput, FB_VIDEO_DEV_SIGNATURE)\r
104\r
105#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r
106\r
107//\r
108// Global Variables\r
109//\r
110extern EFI_DRIVER_BINDING_PROTOCOL gFbGopDriverBinding;\r
111extern EFI_COMPONENT_NAME_PROTOCOL gFbGopComponentName;\r
112extern EFI_COMPONENT_NAME2_PROTOCOL gFbGopComponentName2;\r
113\r
114//\r
115// Driver Binding Protocol functions\r
116//\r
117\r
118/**\r
119 Supported.\r
120\r
121 @param This Pointer to driver binding protocol\r
122 @param Controller Controller handle to connect\r
123 @param RemainingDevicePath A pointer to the remaining portion of a device\r
124 path\r
125\r
126 @retval EFI_STATUS EFI_SUCCESS:This controller can be managed by this\r
127 driver, Otherwise, this controller cannot be\r
128 managed by this driver\r
129\r
130**/\r
131EFI_STATUS\r
132EFIAPI\r
133FbGopDriverBindingSupported (\r
134 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
135 IN EFI_HANDLE Controller,\r
136 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
137 );\r
138\r
139\r
140/**\r
141 Install Graphics Output Protocol onto VGA device handles.\r
142\r
143 @param This Pointer to driver binding protocol\r
144 @param Controller Controller handle to connect\r
145 @param RemainingDevicePath A pointer to the remaining portion of a device\r
146 path\r
147\r
148 @return EFI_STATUS\r
149\r
150**/\r
151EFI_STATUS\r
152EFIAPI\r
153FbGopDriverBindingStart (\r
154 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
155 IN EFI_HANDLE Controller,\r
156 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
157 );\r
158\r
159\r
160/**\r
161 Stop.\r
162\r
163 @param This Pointer to driver binding protocol\r
164 @param Controller Controller handle to connect\r
165 @param NumberOfChildren Number of children handle created by this driver\r
166 @param ChildHandleBuffer Buffer containing child handle created\r
167\r
168 @retval EFI_SUCCESS Driver disconnected successfully from controller\r
169 @retval EFI_UNSUPPORTED Cannot find FB_VIDEO_DEV structure\r
170\r
171**/\r
172EFI_STATUS\r
173EFIAPI\r
174FbGopDriverBindingStop (\r
175 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
176 IN EFI_HANDLE Controller,\r
177 IN UINTN NumberOfChildren,\r
178 IN EFI_HANDLE *ChildHandleBuffer\r
179 );\r
180\r
181//\r
182// Private worker functions\r
183//\r
184\r
185/**\r
186 Check for VBE device.\r
187\r
188 @param FbGopPrivate Pointer to FB_VIDEO_DEV structure\r
189\r
190 @retval EFI_SUCCESS VBE device found\r
191\r
192**/\r
193EFI_STATUS\r
194FbGopCheckForVbe (\r
195 IN OUT FB_VIDEO_DEV *FbGopPrivate\r
196 );\r
197\r
198\r
199\r
200/**\r
68f87b25 201 Release resource for bios video instance.\r
9c228fb0
MM
202\r
203 @param FbGopPrivate Video child device private data structure\r
204\r
205**/\r
206VOID\r
207FbGopDeviceReleaseResource (\r
208 FB_VIDEO_DEV *FbGopPrivate\r
209 );\r
210\r
211//\r
212// BIOS Graphics Output Protocol functions\r
213//\r
214\r
215/**\r
216 Graphics Output protocol interface to get video mode.\r
217\r
218 @param This Protocol instance pointer.\r
219 @param ModeNumber The mode number to return information on.\r
220 @param SizeOfInfo A pointer to the size, in bytes, of the Info\r
221 buffer.\r
222 @param Info Caller allocated buffer that returns information\r
223 about ModeNumber.\r
224\r
225 @retval EFI_SUCCESS Mode information returned.\r
226 @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.\r
227 @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the\r
228 video mode.\r
229 @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()\r
230 @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r
231\r
232**/\r
233EFI_STATUS\r
234EFIAPI\r
235FbGopGraphicsOutputQueryMode (\r
236 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
237 IN UINT32 ModeNumber,\r
238 OUT UINTN *SizeOfInfo,\r
239 OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
240 );\r
241\r
242\r
243/**\r
244 Graphics Output protocol interface to set video mode.\r
245\r
246 @param This Protocol instance pointer.\r
247 @param ModeNumber The mode number to be set.\r
248\r
249 @retval EFI_SUCCESS Graphics mode was changed.\r
250 @retval EFI_DEVICE_ERROR The device had an error and could not complete the\r
251 request.\r
252 @retval EFI_UNSUPPORTED ModeNumber is not supported by this device.\r
253\r
254**/\r
255EFI_STATUS\r
256EFIAPI\r
257FbGopGraphicsOutputSetMode (\r
258 IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
259 IN UINT32 ModeNumber\r
260 );\r
261\r
262\r
263/**\r
264 Graphics Output protocol instance to block transfer for VBE device.\r
265\r
266 @param This Pointer to Graphics Output protocol instance\r
267 @param BltBuffer The data to transfer to screen\r
268 @param BltOperation The operation to perform\r
269 @param SourceX The X coordinate of the source for BltOperation\r
270 @param SourceY The Y coordinate of the source for BltOperation\r
271 @param DestinationX The X coordinate of the destination for\r
272 BltOperation\r
273 @param DestinationY The Y coordinate of the destination for\r
274 BltOperation\r
275 @param Width The width of a rectangle in the blt rectangle in\r
276 pixels\r
277 @param Height The height of a rectangle in the blt rectangle in\r
278 pixels\r
279 @param Delta Not used for EfiBltVideoFill and\r
280 EfiBltVideoToVideo operation. If a Delta of 0 is\r
281 used, the entire BltBuffer will be operated on. If\r
282 a subrectangle of the BltBuffer is used, then\r
283 Delta represents the number of bytes in a row of\r
284 the BltBuffer.\r
285\r
286 @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
287 @retval EFI_SUCCESS Blt operation success\r
288\r
289**/\r
290EFI_STATUS\r
291EFIAPI\r
292FbGopGraphicsOutputVbeBlt (\r
293 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
294 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
295 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
296 IN UINTN SourceX,\r
297 IN UINTN SourceY,\r
298 IN UINTN DestinationX,\r
299 IN UINTN DestinationY,\r
300 IN UINTN Width,\r
301 IN UINTN Height,\r
302 IN UINTN Delta\r
303 );\r
304\r
305\r
306/**\r
68f87b25 307 Graphics Output protocol instance to block transfer for VGA device.\r
9c228fb0 308\r
68f87b25 309 @param This Pointer to Graphics Output protocol instance\r
9c228fb0
MM
310 @param BltBuffer The data to transfer to screen\r
311 @param BltOperation The operation to perform\r
312 @param SourceX The X coordinate of the source for BltOperation\r
313 @param SourceY The Y coordinate of the source for BltOperation\r
314 @param DestinationX The X coordinate of the destination for\r
315 BltOperation\r
316 @param DestinationY The Y coordinate of the destination for\r
317 BltOperation\r
318 @param Width The width of a rectangle in the blt rectangle in\r
319 pixels\r
320 @param Height The height of a rectangle in the blt rectangle in\r
321 pixels\r
322 @param Delta Not used for EfiBltVideoFill and\r
323 EfiBltVideoToVideo operation. If a Delta of 0 is\r
324 used, the entire BltBuffer will be operated on. If\r
325 a subrectangle of the BltBuffer is used, then\r
326 Delta represents the number of bytes in a row of\r
327 the BltBuffer.\r
328\r
329 @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
330 @retval EFI_SUCCESS Blt operation success\r
331\r
332**/\r
333EFI_STATUS\r
334EFIAPI\r
335FbGopGraphicsOutputVgaBlt (\r
336 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
337 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
338 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
339 IN UINTN SourceX,\r
340 IN UINTN SourceY,\r
341 IN UINTN DestinationX,\r
342 IN UINTN DestinationY,\r
343 IN UINTN Width,\r
344 IN UINTN Height,\r
345 IN UINTN Delta\r
346 );\r
347\r
348/**\r
349 Install child handles if the Handle supports MBR format.\r
350\r
351 @param This Calling context.\r
352 @param ParentHandle Parent Handle\r
353 @param ParentPciIo Parent PciIo interface\r
354 @param ParentLegacyBios Parent LegacyBios interface\r
355 @param ParentDevicePath Parent Device Path\r
356 @param RemainingDevicePath Remaining Device Path\r
357\r
358 @retval EFI_SUCCESS If a child handle was added\r
359 @retval other A child handle was not added\r
360\r
361**/\r
362EFI_STATUS\r
363FbGopChildHandleInstall (\r
364 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
365 IN EFI_HANDLE ParentHandle,\r
366 IN EFI_PCI_IO_PROTOCOL *ParentPciIo,\r
367 IN VOID *ParentLegacyBios,\r
368 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
369 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
370 );\r
371\r
372/**\r
373 Deregister an video child handle and free resources.\r
374\r
375 @param This Protocol instance pointer.\r
376 @param Controller Video controller handle\r
377 @param Handle Video child handle\r
378\r
379 @return EFI_STATUS\r
380\r
381**/\r
382EFI_STATUS\r
383FbGopChildHandleUninstall (\r
384 EFI_DRIVER_BINDING_PROTOCOL *This,\r
385 EFI_HANDLE Controller,\r
386 EFI_HANDLE Handle\r
387 );\r
388\r
389/**\r
68f87b25 390 Release resource for bios video instance.\r
9c228fb0
MM
391\r
392 @param FbGopPrivate Video child device private data structure\r
393\r
394**/\r
395VOID\r
396FbGopDeviceReleaseResource (\r
397 FB_VIDEO_DEV *FbGopPrivate\r
398 );\r
399\r
400/**\r
401 Check if all video child handles have been uninstalled.\r
402\r
403 @param Controller Video controller handle\r
404\r
405 @return TRUE Child handles exist.\r
406 @return FALSE All video child handles have been uninstalled.\r
407\r
408**/\r
409BOOLEAN\r
410HasChildHandle (\r
411 IN EFI_HANDLE Controller\r
412 );\r
413#endif\r