]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/BiosVideoThunkDxe/BiosVideo.h
Should use UINTN for architecture register.
[mirror_edk2.git] / DuetPkg / BiosVideoThunkDxe / BiosVideo.h
CommitLineData
7da78b1f 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 BiosVideo.h\r
15 \r
16Abstract: \r
17\r
18Revision History\r
19--*/\r
20\r
21#ifndef _BIOS_UGA_H\r
22#define _BIOS_UGA_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/LegacyBios.h>\r
38\r
39#include <Library/UefiLib.h>\r
40#include <Library/DebugLib.h>\r
41#include <Library/UefiBootServicesTableLib.h>\r
42#include <Library/BaseMemoryLib.h>\r
43\r
44#include <IndustryStandard/Pci22.h>\r
45\r
46#include "VesaBiosExtensions.h"\r
47//\r
48// Driver Produced Protocol Prototypes\r
49//\r
50//#include EFI_PROTOCOL_DEFINITION (DriverBinding)\r
51//#include EFI_PROTOCOL_DEFINITION (ComponentName)\r
52//#include EFI_PROTOCOL_DEFINITION (ComponentName2)\r
53//#include EFI_PROTOCOL_DEFINITION (UgaDraw)\r
54//#include EFI_PROTOCOL_DEFINITION (VgaMiniPort)\r
55\r
56//\r
57// Packed format support: The number of bits reserved for each of the colors and the actual\r
58// position of RGB in the frame buffer is specified in the VBE Mode information\r
59//\r
60typedef struct {\r
61 UINT8 Position; // Position of the color\r
62 UINT8 Mask; // The number of bits expressed as a mask\r
63} BIOS_VIDEO_COLOR_PLACEMENT;\r
64\r
65//\r
66// BIOS UGA Draw Graphical Mode Data\r
67//\r
68typedef struct {\r
69 UINT16 VbeModeNumber;\r
70 UINT16 BytesPerScanLine;\r
71 VOID *LinearFrameBuffer;\r
72 UINT32 HorizontalResolution;\r
73 UINT32 VerticalResolution;\r
74 UINT32 ColorDepth;\r
75 UINT32 RefreshRate;\r
76 UINT32 BitsPerPixel;\r
77 BIOS_VIDEO_COLOR_PLACEMENT Red;\r
78 BIOS_VIDEO_COLOR_PLACEMENT Green;\r
79 BIOS_VIDEO_COLOR_PLACEMENT Blue;\r
80} BIOS_VIDEO_MODE_DATA;\r
81\r
82//\r
83// BIOS UGA Device Structure\r
84//\r
85#define BIOS_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p')\r
86\r
87typedef struct {\r
88 UINTN Signature;\r
89 EFI_HANDLE Handle;\r
90\r
91 //\r
92 // Consumed Protocols\r
93 //\r
94 EFI_PCI_IO_PROTOCOL *PciIo;\r
95 //EFI_LEGACY_BIOS_THUNK_PROTOCOL *LegacyBios;\r
96\r
97 //\r
98 // Produced Protocols\r
99 //\r
100 EFI_UGA_DRAW_PROTOCOL UgaDraw;\r
101 EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort;\r
102\r
103 //\r
104 // General fields\r
105 //\r
106 EFI_EVENT ExitBootServicesEvent;\r
107 BOOLEAN VgaCompatible;\r
108 BOOLEAN ProduceUgaDraw;\r
109\r
110 //\r
111 // UGA Draw related fields\r
112 //\r
113 BOOLEAN HardwareNeedsStarting;\r
114 UINTN CurrentMode;\r
115 UINTN MaxMode;\r
116 BIOS_VIDEO_MODE_DATA *ModeData;\r
117 UINT8 *LineBuffer;\r
118 EFI_UGA_PIXEL *VbeFrameBuffer;\r
119 UINT8 *VgaFrameBuffer;\r
120\r
121 //\r
122 // VESA Bios Extensions related fields\r
123 //\r
124 UINTN NumberOfPagesBelow1MB; // Number of 4KB pages in PagesBelow1MB\r
125 EFI_PHYSICAL_ADDRESS PagesBelow1MB; // Buffer for all VBE Information Blocks\r
126 VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *VbeInformationBlock; // 0x200 bytes. Must be allocated below 1MB\r
127 VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock; // 0x100 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_UGA_DRAW_THIS(a) CR (a, BIOS_VIDEO_DEV, UgaDraw, BIOS_VIDEO_DEV_SIGNATURE)\r
138\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//\r
142// Global Variables\r
143//\r
144extern EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding;\r
145extern EFI_COMPONENT_NAME_PROTOCOL gBiosVideoComponentName;\r
146extern EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2;\r
147\r
148//\r
149// Driver Binding Protocol functions\r
150//\r
151EFI_STATUS\r
152EFIAPI\r
153BiosVideoDriverBindingSupported (\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 Routine Description:\r
161\r
162 Supported.\r
163 \r
164 Arguments:\r
165\r
166 This - Pointer to driver binding protocol\r
167 Controller - Controller handle to connect\r
168 RemainingDevicePath - A pointer to the remaining portion of a device path\r
169 \r
170 \r
171 Returns:\r
172\r
173 EFI_STATUS - EFI_SUCCESS:This controller can be managed by this driver,\r
174 Otherwise, this controller cannot be managed by this driver\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
188 Routine Description:\r
189\r
190 Install UGA Draw Protocol onto VGA device handles\r
191 \r
192 Arguments:\r
193\r
194 This - Pointer to driver binding protocol\r
195 Controller - Controller handle to connect\r
196 RemainingDevicePath - A pointer to the remaining portion of a device path\r
197 \r
198 Returns:\r
199\r
200 EFI_STATUS\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
215 Routine Description:\r
216\r
217 Stop.\r
218 \r
219 Arguments:\r
220\r
221 This - Pointer to driver binding protocol\r
222 Controller - Controller handle to connect\r
223 NumberOfChilren - Number of children handle created by this driver\r
224 ChildHandleBuffer - Buffer containing child handle created\r
225 \r
226 Returns:\r
227\r
228 EFI_SUCCESS - Driver disconnected successfully from controller\r
229 EFI_UNSUPPORTED - Cannot find BIOS_VIDEO_DEV structure\r
230 \r
231--*/\r
232;\r
233\r
234//\r
235// Private worker functions\r
236//\r
237EFI_STATUS\r
238BiosVideoCheckForVbe (\r
239 BIOS_VIDEO_DEV *BiosVideoPrivate\r
240 )\r
241/*++\r
242 \r
243 Routine Description:\r
244\r
245 Check for VBE device \r
246 \r
247 Arguments:\r
248 \r
249 BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
250 \r
251 Returns:\r
252 \r
253 EFI_SUCCESS - VBE device found\r
254 \r
255--*/\r
256;\r
257\r
258EFI_STATUS\r
259BiosVideoCheckForVga (\r
260 BIOS_VIDEO_DEV *BiosVideoPrivate\r
261 )\r
262/*++\r
263 \r
264 Routine Description:\r
265\r
266 Check for VGA device\r
267 \r
268 Arguments:\r
269 \r
270 BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
271 \r
272 Returns:\r
273 \r
274 EFI_SUCCESS - Standard VGA device found\r
275 \r
276--*/\r
277;\r
278\r
279//\r
280// BIOS UGA Draw Protocol functions\r
281//\r
282EFI_STATUS\r
283EFIAPI\r
284BiosVideoUgaDrawGetMode (\r
285 IN EFI_UGA_DRAW_PROTOCOL *This,\r
286 OUT UINT32 *HorizontalResolution,\r
287 OUT UINT32 *VerticalResolution,\r
288 OUT UINT32 *ColorDepth,\r
289 OUT UINT32 *RefreshRate\r
290 )\r
291/*++\r
292\r
293Routine Description:\r
294\r
295 UGA protocol interface to get video mode\r
296\r
297Arguments:\r
298\r
299 This - Pointer to UGA draw protocol instance\r
300 HorizontalResolution - Horizontal Resolution, in pixels\r
301 VerticalResolution - Vertical Resolution, in pixels\r
302 ColorDepth - Bit number used to represent color value of a pixel \r
303 RefreshRate - Refresh rate, in Hertz\r
304\r
305Returns:\r
306\r
307 EFI_DEVICE_ERROR - Hardware need starting\r
308 EFI_INVALID_PARAMETER - Invalid parameter passed in\r
309 EFI_SUCCESS - Video mode query successfully\r
310\r
311--*/\r
312;\r
313\r
314EFI_STATUS\r
315EFIAPI\r
316BiosVideoUgaDrawSetMode (\r
317 IN EFI_UGA_DRAW_PROTOCOL *This,\r
318 IN UINT32 HorizontalResolution,\r
319 IN UINT32 VerticalResolution,\r
320 IN UINT32 ColorDepth,\r
321 IN UINT32 RefreshRate\r
322 )\r
323/*++\r
324\r
325Routine Description:\r
326\r
327 UGA draw protocol interface to set video mode\r
328\r
329Arguments:\r
330\r
331 This - Pointer to UGA draw protocol instance\r
332 HorizontalResolution - Horizontal Resolution, in pixels\r
333 VerticalResolution - Vertical Resolution, in pixels\r
334 ColorDepth - Bit number used to represent color value of a pixel \r
335 RefreshRate - Refresh rate, in Hertz\r
336\r
337Returns:\r
338\r
339 EFI_DEVICE_ERROR - Device error\r
340 EFI_SUCCESS - Video mode set successfully\r
341 EFI_UNSUPPORTED - Cannot support this video mode\r
342\r
343--*/\r
344;\r
345\r
346EFI_STATUS\r
347EFIAPI\r
348BiosVideoUgaDrawVbeBlt (\r
349 IN EFI_UGA_DRAW_PROTOCOL *This,\r
350 IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL\r
351 IN EFI_UGA_BLT_OPERATION BltOperation,\r
352 IN UINTN SourceX,\r
353 IN UINTN SourceY,\r
354 IN UINTN DestinationX,\r
355 IN UINTN DestinationY,\r
356 IN UINTN Width,\r
357 IN UINTN Height,\r
358 IN UINTN Delta\r
359 )\r
360/*++\r
361\r
362Routine Description:\r
363\r
364 UGA draw protocol instance to block transfer for VBE device\r
365\r
366Arguments:\r
367\r
368 This - Pointer to UGA draw protocol instance\r
369 BltBuffer - The data to transfer to screen\r
370 BltOperation - The operation to perform\r
371 SourceX - The X coordinate of the source for BltOperation\r
372 SourceY - The Y coordinate of the source for BltOperation\r
373 DestinationX - The X coordinate of the destination for BltOperation\r
374 DestinationY - The Y coordinate of the destination for BltOperation\r
375 Width - The width of a rectangle in the blt rectangle in pixels\r
376 Height - The height of a rectangle in the blt rectangle in pixels\r
377 Delta - Not used for EfiUgaVideoFill and EfiUgaVideoToVideo operation.\r
378 If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
379 If a subrectangle of the BltBuffer is used, then Delta represents \r
380 the number of bytes in a row of the BltBuffer.\r
381\r
382Returns:\r
383\r
384 EFI_INVALID_PARAMETER - Invalid parameter passed in\r
385 EFI_SUCCESS - Blt operation success\r
386\r
387--*/\r
388;\r
389\r
390EFI_STATUS\r
391EFIAPI\r
392BiosVideoUgaDrawVgaBlt (\r
393 IN EFI_UGA_DRAW_PROTOCOL *This,\r
394 IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL\r
395 IN EFI_UGA_BLT_OPERATION BltOperation,\r
396 IN UINTN SourceX,\r
397 IN UINTN SourceY,\r
398 IN UINTN DestinationX,\r
399 IN UINTN DestinationY,\r
400 IN UINTN Width,\r
401 IN UINTN Height,\r
402 IN UINTN Delta\r
403 )\r
404/*++\r
405\r
406Routine Description:\r
407\r
408 UGA draw protocol instance to block transfer for VGA device\r
409\r
410Arguments:\r
411\r
412 This - Pointer to UGA draw protocol instance\r
413 BltBuffer - The data to transfer to screen\r
414 BltOperation - The operation to perform\r
415 SourceX - The X coordinate of the source for BltOperation\r
416 SourceY - The Y coordinate of the source for BltOperation\r
417 DestinationX - The X coordinate of the destination for BltOperation\r
418 DestinationY - The Y coordinate of the destination for BltOperation\r
419 Width - The width of a rectangle in the blt rectangle in pixels\r
420 Height - The height of a rectangle in the blt rectangle in pixels\r
421 Delta - Not used for EfiUgaVideoFill and EfiUgaVideoToVideo operation.\r
422 If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
423 If a subrectangle of the BltBuffer is used, then Delta represents \r
424 the number of bytes in a row of the BltBuffer.\r
425\r
426Returns:\r
427\r
428 EFI_INVALID_PARAMETER - Invalid parameter passed in\r
429 EFI_SUCCESS - Blt operation success\r
430\r
431--*/\r
432;\r
433\r
434//\r
435// BIOS VGA Mini Port Protocol functions\r
436//\r
437EFI_STATUS\r
438EFIAPI\r
439BiosVideoVgaMiniPortSetMode (\r
440 IN EFI_VGA_MINI_PORT_PROTOCOL *This,\r
441 IN UINTN ModeNumber\r
442 )\r
443/*++\r
444\r
445Routine Description:\r
446\r
447 VgaMiniPort protocol interface to set mode\r
448\r
449Arguments:\r
450\r
451 This - Pointer to VgaMiniPort protocol instance\r
452 ModeNumber - The index of the mode\r
453\r
454Returns:\r
455\r
456 EFI_UNSUPPORTED - The requested mode is not supported\r
457 EFI_SUCCESS - The requested mode is set successfully\r
458\r
459--*/\r
460;\r
461\r
462\r
463BOOLEAN\r
464BiosVideoIsVga (\r
465 IN EFI_PCI_IO_PROTOCOL *PciIo\r
466 )\r
467;\r
468\r
469\r
470//\r
471// Standard VGA Definitions\r
472//\r
473#define VGA_HORIZONTAL_RESOLUTION 640\r
474#define VGA_VERTICAL_RESOLUTION 480\r
475#define VGA_NUMBER_OF_BIT_PLANES 4\r
476#define VGA_PIXELS_PER_BYTE 8\r
477#define VGA_BYTES_PER_SCAN_LINE (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS_PER_BYTE)\r
478#define VGA_BYTES_PER_BIT_PLANE (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PER_SCAN_LINE)\r
479\r
480#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER 0x3ce\r
481#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER 0x3cf\r
482\r
483#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER 0x00\r
484\r
485#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01\r
486\r
487#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER 0x02\r
488\r
489#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER 0x03\r
490#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE 0x00\r
491#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND 0x08\r
492#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR 0x10\r
493#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR 0x18\r
494\r
495#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER 0x04\r
496\r
497#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER 0x05\r
498#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0 0x00\r
499#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1 0x08\r
500#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0 0x00\r
501#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1 0x01\r
502#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2 0x02\r
503#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3 0x03\r
504\r
505#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER 0x06\r
506\r
507#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER 0x07\r
508\r
509#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER 0x08\r
510\r
511#endif\r