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