]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - DuetPkg/BiosVideoThunkDxe/BiosVideo.h
Update BiosVideo driver to produce GOP protocol but not UgaDraw protocol which is...
[mirror_edk2.git] / DuetPkg / BiosVideoThunkDxe / BiosVideo.h
... / ...
CommitLineData
1/*++\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 UefiBiosVideo.h\r
15 \r
16Abstract: \r
17\r
18Revision History\r
19--*/\r
20\r
21#ifndef _BIOS_GRAPHICS_OUTPUT_H\r
22#define _BIOS_GRAPHICS_OUTPUT_H\r
23\r
24#include <Uefi.h>\r
25\r
26//\r
27// Driver Consumed Protocol Prototypes\r
28//\r
29#include <Protocol/DevicePath.h>\r
30#include <Protocol/PciIo.h>\r
31#include <Protocol/DriverBinding.h>\r
32#include <Protocol/ComponentName.h>\r
33#include <Protocol/ComponentName2.h>\r
34#include <Protocol/UgaDraw.h>\r
35#include <Protocol/VgaMiniPort.h>\r
36#include <Protocol/Legacy8259.h>\r
37#include <Protocol/EdidActive.h>\r
38#include <Protocol/EdidDiscovered.h>\r
39#include <Protocol/DevicePath.h>\r
40#include <Protocol/LegacyBios.h>\r
41\r
42#include <Library/UefiLib.h>\r
43#include <Library/DebugLib.h>\r
44#include <Library/UefiBootServicesTableLib.h>\r
45#include <Library/BaseMemoryLib.h>\r
46#include <Library/DevicePathLib.h>\r
47\r
48#include <IndustryStandard/Pci22.h>\r
49\r
50#include "VesaBiosExtensions.h"\r
51\r
52//\r
53// Packed format support: The number of bits reserved for each of the colors and the actual\r
54// position of RGB in the frame buffer is specified in the VBE Mode information\r
55//\r
56typedef struct {\r
57 UINT8 Position; // Position of the color\r
58 UINT8 Mask; // The number of bits expressed as a mask\r
59} BIOS_VIDEO_COLOR_PLACEMENT;\r
60\r
61//\r
62// BIOS Graphics Output Graphical Mode Data\r
63//\r
64typedef struct {\r
65 UINT16 VbeModeNumber;\r
66 UINT16 BytesPerScanLine;\r
67 VOID *LinearFrameBuffer;\r
68 UINTN FrameBufferSize;\r
69 UINT32 HorizontalResolution;\r
70 UINT32 VerticalResolution;\r
71 UINT32 RefreshRate;\r
72 UINT32 BitsPerPixel;\r
73 BIOS_VIDEO_COLOR_PLACEMENT Red;\r
74 BIOS_VIDEO_COLOR_PLACEMENT Green;\r
75 BIOS_VIDEO_COLOR_PLACEMENT Blue;\r
76 BIOS_VIDEO_COLOR_PLACEMENT Reserved;\r
77 EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;\r
78 EFI_PIXEL_BITMASK PixelBitMask;\r
79} BIOS_VIDEO_MODE_DATA;\r
80\r
81//\r
82// BIOS video child handle private data Structure\r
83//\r
84#define BIOS_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p')\r
85\r
86typedef struct {\r
87 UINTN Signature;\r
88 EFI_HANDLE Handle;\r
89\r
90 //\r
91 // Consumed Protocols\r
92 //\r
93 EFI_PCI_IO_PROTOCOL *PciIo;\r
94 EFI_LEGACY_8259_PROTOCOL *Legacy8259;\r
95\r
96 //\r
97 // Produced Protocols\r
98 //\r
99 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
100 EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;\r
101 EFI_EDID_ACTIVE_PROTOCOL EdidActive;\r
102 EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort;\r
103\r
104 //\r
105 // General fields\r
106 //\r
107 BOOLEAN VgaCompatible;\r
108 BOOLEAN ProduceGraphicsOutput;\r
109 EFI_EVENT ExitBootServicesEvent;\r
110\r
111 //\r
112 // Graphics Output Protocol related fields\r
113 //\r
114 BOOLEAN HardwareNeedsStarting;\r
115 BIOS_VIDEO_MODE_DATA *ModeData;\r
116 UINT8 *LineBuffer;\r
117 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;\r
118 UINT8 *VgaFrameBuffer;\r
119\r
120 //\r
121 // VESA Bios Extensions related fields\r
122 //\r
123 UINTN NumberOfPagesBelow1MB; // Number of 4KB pages in PagesBelow1MB\r
124 EFI_PHYSICAL_ADDRESS PagesBelow1MB; // Buffer for all VBE Information Blocks\r
125 VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *VbeInformationBlock; // 0x200 bytes. Must be allocated below 1MB\r
126 VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock; // 0x100 bytes. Must be allocated below 1MB\r
127 VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *VbeEdidDataBlock; // 0x80 bytes. Must be allocated below 1MB\r
128 VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *VbeCrtcInformationBlock; // 59 bytes. Must be allocated below 1MB\r
129 UINTN VbeSaveRestorePages; // Number of 4KB pages in VbeSaveRestoreBuffer\r
130 EFI_PHYSICAL_ADDRESS VbeSaveRestoreBuffer; // Must be allocated below 1MB\r
131 //\r
132 // Status code\r
133 //\r
134 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
135} BIOS_VIDEO_DEV;\r
136\r
137#define BIOS_VIDEO_DEV_FROM_PCI_IO_THIS(a) CR (a, BIOS_VIDEO_DEV, PciIo, BIOS_VIDEO_DEV_SIGNATURE)\r
138#define BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a) CR (a, BIOS_VIDEO_DEV, GraphicsOutput, BIOS_VIDEO_DEV_SIGNATURE)\r
139#define BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS(a) CR (a, BIOS_VIDEO_DEV, VgaMiniPort, BIOS_VIDEO_DEV_SIGNATURE)\r
140\r
141#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r
142\r
143//\r
144// Global Variables\r
145//\r
146extern EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding;\r
147extern EFI_COMPONENT_NAME_PROTOCOL gBiosVideoComponentName;\r
148extern EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2;\r
149\r
150//\r
151// Driver Binding Protocol functions\r
152//\r
153EFI_STATUS\r
154EFIAPI\r
155BiosVideoDriverBindingSupported (\r
156 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
157 IN EFI_HANDLE Controller,\r
158 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
159 )\r
160/*++\r
161\r
162Routine Description:\r
163\r
164 GC_TODO: Add function description\r
165\r
166Arguments:\r
167\r
168 This - GC_TODO: add argument description\r
169 Controller - GC_TODO: add argument description\r
170 RemainingDevicePath - GC_TODO: add argument description\r
171\r
172Returns:\r
173\r
174 GC_TODO: add return values\r
175\r
176--*/\r
177;\r
178\r
179EFI_STATUS\r
180EFIAPI\r
181BiosVideoDriverBindingStart (\r
182 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
183 IN EFI_HANDLE Controller,\r
184 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
185 )\r
186/*++\r
187\r
188Routine Description:\r
189\r
190 GC_TODO: Add function description\r
191\r
192Arguments:\r
193\r
194 This - GC_TODO: add argument description\r
195 Controller - GC_TODO: add argument description\r
196 RemainingDevicePath - GC_TODO: add argument description\r
197\r
198Returns:\r
199\r
200 GC_TODO: add return values\r
201\r
202--*/\r
203;\r
204\r
205EFI_STATUS\r
206EFIAPI\r
207BiosVideoDriverBindingStop (\r
208 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
209 IN EFI_HANDLE Controller,\r
210 IN UINTN NumberOfChildren,\r
211 IN EFI_HANDLE *ChildHandleBuffer\r
212 )\r
213/*++\r
214\r
215Routine Description:\r
216\r
217 GC_TODO: Add function description\r
218\r
219Arguments:\r
220\r
221 This - GC_TODO: add argument description\r
222 Controller - GC_TODO: add argument description\r
223 NumberOfChildren - GC_TODO: add argument description\r
224 ChildHandleBuffer - GC_TODO: add argument description\r
225\r
226Returns:\r
227\r
228 GC_TODO: add return values\r
229\r
230--*/\r
231;\r
232\r
233//\r
234// Private worker functions\r
235//\r
236EFI_STATUS\r
237BiosVideoCheckForVbe (\r
238 BIOS_VIDEO_DEV *BiosVideoPrivate\r
239 )\r
240/*++\r
241\r
242Routine Description:\r
243\r
244 GC_TODO: Add function description\r
245\r
246Arguments:\r
247\r
248 BiosVideoPrivate - GC_TODO: add argument description\r
249\r
250Returns:\r
251\r
252 GC_TODO: add return values\r
253\r
254--*/\r
255;\r
256\r
257EFI_STATUS\r
258BiosVideoCheckForVga (\r
259 BIOS_VIDEO_DEV *BiosVideoPrivate\r
260 )\r
261/*++\r
262\r
263Routine Description:\r
264\r
265 GC_TODO: Add function description\r
266\r
267Arguments:\r
268\r
269 BiosVideoPrivate - GC_TODO: add argument description\r
270\r
271Returns:\r
272\r
273 GC_TODO: add return values\r
274\r
275--*/\r
276;\r
277\r
278STATIC\r
279EFI_STATUS\r
280DeRegisterVideoChildHandle (\r
281 EFI_DRIVER_BINDING_PROTOCOL *This,\r
282 EFI_HANDLE Controller,\r
283 EFI_HANDLE Handle\r
284 )\r
285/*++\r
286\r
287Routine Description:\r
288\r
289 Deregister an video child handle and free resources\r
290\r
291Arguments:\r
292\r
293 This - Protocol instance pointer.\r
294 Controller - Video controller handle\r
295 Handle - Video child handle\r
296\r
297Returns:\r
298\r
299 EFI_STATUS\r
300\r
301--*/\r
302;\r
303\r
304VOID\r
305BiosVideoDeviceReleaseResource (\r
306 BIOS_VIDEO_DEV *BiosVideoChildPrivate\r
307 )\r
308/*++\r
309Routing Description:\r
310\r
311 Release resources of a video child device before stopping it.\r
312\r
313Arguments:\r
314\r
315 BiosVideoChildPrivate - Video child device private data structure\r
316\r
317Returns:\r
318\r
319 NONE\r
320 \r
321---*/\r
322;\r
323\r
324//\r
325// BIOS Graphics Output Protocol functions\r
326//\r
327EFI_STATUS\r
328EFIAPI\r
329BiosVideoGraphicsOutputQueryMode (\r
330 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
331 IN UINT32 ModeNumber,\r
332 OUT UINTN *SizeOfInfo,\r
333 OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
334 )\r
335/*++\r
336\r
337Routine Description:\r
338\r
339 Graphics Output protocol interface to get video mode\r
340\r
341 Arguments:\r
342 This - Protocol instance pointer.\r
343 ModeNumber - The mode number to return information on.\r
344 Info - Caller allocated buffer that returns information about ModeNumber.\r
345 SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.\r
346\r
347 Returns:\r
348 EFI_SUCCESS - Mode information returned.\r
349 EFI_BUFFER_TOO_SMALL - The Info buffer was too small.\r
350 EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.\r
351 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()\r
352 EFI_INVALID_PARAMETER - One of the input args was NULL.\r
353\r
354--*/\r
355;\r
356\r
357EFI_STATUS\r
358EFIAPI\r
359BiosVideoGraphicsOutputSetMode (\r
360 IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
361 IN UINT32 ModeNumber\r
362 )\r
363/*++\r
364\r
365Routine Description:\r
366\r
367 Graphics Output protocol interface to set video mode\r
368\r
369 Arguments:\r
370 This - Protocol instance pointer.\r
371 ModeNumber - The mode number to be set.\r
372\r
373 Returns:\r
374 EFI_SUCCESS - Graphics mode was changed.\r
375 EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
376 EFI_UNSUPPORTED - ModeNumber is not supported by this device.\r
377\r
378--*/\r
379;\r
380\r
381EFI_STATUS\r
382EFIAPI\r
383BiosVideoGraphicsOutputVbeBlt (\r
384 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
385 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
386 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
387 IN UINTN SourceX,\r
388 IN UINTN SourceY,\r
389 IN UINTN DestinationX,\r
390 IN UINTN DestinationY,\r
391 IN UINTN Width,\r
392 IN UINTN Height,\r
393 IN UINTN Delta\r
394 )\r
395/*++\r
396\r
397Routine Description:\r
398\r
399 Graphics Output protocol instance to block transfer for VBE device\r
400\r
401Arguments:\r
402\r
403 This - Pointer to Graphics Output protocol instance\r
404 BltBuffer - The data to transfer to screen\r
405 BltOperation - The operation to perform\r
406 SourceX - The X coordinate of the source for BltOperation\r
407 SourceY - The Y coordinate of the source for BltOperation\r
408 DestinationX - The X coordinate of the destination for BltOperation\r
409 DestinationY - The Y coordinate of the destination for BltOperation\r
410 Width - The width of a rectangle in the blt rectangle in pixels\r
411 Height - The height of a rectangle in the blt rectangle in pixels\r
412 Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
413 If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
414 If a subrectangle of the BltBuffer is used, then Delta represents\r
415 the number of bytes in a row of the BltBuffer.\r
416\r
417Returns:\r
418\r
419 EFI_INVALID_PARAMETER - Invalid parameter passed in\r
420 EFI_SUCCESS - Blt operation success\r
421\r
422--*/\r
423;\r
424\r
425EFI_STATUS\r
426EFIAPI\r
427BiosVideoGraphicsOutputVgaBlt (\r
428 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
429 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
430 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
431 IN UINTN SourceX,\r
432 IN UINTN SourceY,\r
433 IN UINTN DestinationX,\r
434 IN UINTN DestinationY,\r
435 IN UINTN Width,\r
436 IN UINTN Height,\r
437 IN UINTN Delta\r
438 )\r
439/*++\r
440\r
441Routine Description:\r
442\r
443 Grahpics Output protocol instance to block transfer for VGA device\r
444\r
445Arguments:\r
446\r
447 This - Pointer to Grahpics Output protocol instance\r
448 BltBuffer - The data to transfer to screen\r
449 BltOperation - The operation to perform\r
450 SourceX - The X coordinate of the source for BltOperation\r
451 SourceY - The Y coordinate of the source for BltOperation\r
452 DestinationX - The X coordinate of the destination for BltOperation\r
453 DestinationY - The Y coordinate of the destination for BltOperation\r
454 Width - The width of a rectangle in the blt rectangle in pixels\r
455 Height - The height of a rectangle in the blt rectangle in pixels\r
456 Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
457 If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
458 If a subrectangle of the BltBuffer is used, then Delta represents\r
459 the number of bytes in a row of the BltBuffer.\r
460\r
461Returns:\r
462\r
463 EFI_INVALID_PARAMETER - Invalid parameter passed in\r
464 EFI_SUCCESS - Blt operation success\r
465\r
466--*/\r
467;\r
468\r
469//\r
470// BIOS VGA Mini Port Protocol functions\r
471//\r
472EFI_STATUS\r
473EFIAPI\r
474BiosVideoVgaMiniPortSetMode (\r
475 IN EFI_VGA_MINI_PORT_PROTOCOL *This,\r
476 IN UINTN ModeNumber\r
477 )\r
478/*++\r
479\r
480Routine Description:\r
481\r
482 VgaMiniPort protocol interface to set mode\r
483\r
484Arguments:\r
485\r
486 This - Pointer to VgaMiniPort protocol instance\r
487 ModeNumber - The index of the mode\r
488\r
489Returns:\r
490\r
491 EFI_UNSUPPORTED - The requested mode is not supported\r
492 EFI_SUCCESS - The requested mode is set successfully\r
493\r
494--*/\r
495;\r
496\r
497\r
498BOOLEAN\r
499BiosVideoIsVga (\r
500 IN EFI_PCI_IO_PROTOCOL *PciIo\r
501 )\r
502;\r
503\r
504\r
505//\r
506// Standard VGA Definitions\r
507//\r
508#define VGA_HORIZONTAL_RESOLUTION 640\r
509#define VGA_VERTICAL_RESOLUTION 480\r
510#define VGA_NUMBER_OF_BIT_PLANES 4\r
511#define VGA_PIXELS_PER_BYTE 8\r
512#define VGA_BYTES_PER_SCAN_LINE (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS_PER_BYTE)\r
513#define VGA_BYTES_PER_BIT_PLANE (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PER_SCAN_LINE)\r
514\r
515#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER 0x3ce\r
516#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER 0x3cf\r
517\r
518#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER 0x00\r
519\r
520#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01\r
521\r
522#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER 0x02\r
523\r
524#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER 0x03\r
525#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE 0x00\r
526#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND 0x08\r
527#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR 0x10\r
528#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR 0x18\r
529\r
530#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER 0x04\r
531\r
532#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER 0x05\r
533#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0 0x00\r
534#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1 0x08\r
535#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0 0x00\r
536#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1 0x01\r
537#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2 0x02\r
538#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3 0x03\r
539\r
540#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER 0x06\r
541\r
542#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER 0x07\r
543\r
544#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER 0x08\r
545\r
546VOID\r
547InitializeBiosIntCaller (\r
548 IN BIOS_VIDEO_DEV *BiosDev\r
549 );\r
550 \r
551VOID\r
552InitializeInterruptRedirection (\r
553 IN BIOS_VIDEO_DEV *BiosDev\r
554 );\r
555 \r
556BOOLEAN\r
557EFIAPI\r
558LegacyBiosInt86 (\r
559 IN BIOS_VIDEO_DEV *BiosDev,\r
560 IN UINT8 BiosInt,\r
561 IN EFI_IA32_REGISTER_SET *Regs\r
562 ); \r
563 \r
564#endif\r