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