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