+++ /dev/null
-/** @file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-**/\r
-\r
-#ifndef _BIOS_GRAPHICS_OUTPUT_H\r
-#define _BIOS_GRAPHICS_OUTPUT_H\r
-\r
-#include <Uefi.h>\r
-\r
-//\r
-// Driver Consumed Protocol Prototypes\r
-//\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/DriverBinding.h>\r
-#include <Protocol/ComponentName.h>\r
-#include <Protocol/ComponentName2.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/VgaMiniPort.h>\r
-#include <Protocol/Legacy8259.h>\r
-#include <Protocol/EdidActive.h>\r
-#include <Protocol/EdidDiscovered.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/UefiLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#include "VesaBiosExtensions.h"\r
-\r
-//\r
-// Packed format support: The number of bits reserved for each of the colors and the actual\r
-// position of RGB in the frame buffer is specified in the VBE Mode information\r
-//\r
-typedef struct {\r
- UINT8 Position; // Position of the color\r
- UINT8 Mask; // The number of bits expressed as a mask\r
-} BIOS_VIDEO_COLOR_PLACEMENT;\r
-\r
-//\r
-// BIOS Graphics Output Graphical Mode Data\r
-//\r
-typedef struct {\r
- UINT16 VbeModeNumber;\r
- UINT16 BytesPerScanLine;\r
- VOID *LinearFrameBuffer;\r
- UINTN FrameBufferSize;\r
- UINT32 HorizontalResolution;\r
- UINT32 VerticalResolution;\r
- UINT32 RefreshRate;\r
- UINT32 BitsPerPixel;\r
- BIOS_VIDEO_COLOR_PLACEMENT Red;\r
- BIOS_VIDEO_COLOR_PLACEMENT Green;\r
- BIOS_VIDEO_COLOR_PLACEMENT Blue;\r
- BIOS_VIDEO_COLOR_PLACEMENT Reserved;\r
- EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;\r
- EFI_PIXEL_BITMASK PixelBitMask;\r
-} BIOS_VIDEO_MODE_DATA;\r
-\r
-//\r
-// BIOS video child handle private data Structure\r
-//\r
-#define BIOS_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p')\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_HANDLE Handle;\r
-\r
- //\r
- // Consumed Protocols inherited from parent controller.\r
- //\r
- EFI_PCI_IO_PROTOCOL *PciIo;\r
- EFI_LEGACY_8259_PROTOCOL *Legacy8259;\r
- THUNK_CONTEXT *ThunkContext;\r
- \r
- //\r
- // Produced Protocols\r
- //\r
- EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
- EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;\r
- EFI_EDID_ACTIVE_PROTOCOL EdidActive;\r
- EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort;\r
-\r
- //\r
- // General fields\r
- //\r
- BOOLEAN VgaCompatible;\r
- BOOLEAN ProduceGraphicsOutput;\r
-\r
- //\r
- // Graphics Output Protocol related fields\r
- //\r
- BOOLEAN HardwareNeedsStarting;\r
- BIOS_VIDEO_MODE_DATA *ModeData;\r
- UINT8 *LineBuffer;\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;\r
- UINT8 *VgaFrameBuffer;\r
-\r
- //\r
- // VESA Bios Extensions related fields\r
- //\r
- UINTN NumberOfPagesBelow1MB; // Number of 4KB pages in PagesBelow1MB\r
- EFI_PHYSICAL_ADDRESS PagesBelow1MB; // Buffer for all VBE Information Blocks\r
- VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *VbeInformationBlock; // 0x200 bytes. Must be allocated below 1MB\r
- VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock; // 0x100 bytes. Must be allocated below 1MB\r
- VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *VbeEdidDataBlock; // 0x80 bytes. Must be allocated below 1MB\r
- VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *VbeCrtcInformationBlock; // 59 bytes. Must be allocated below 1MB\r
- UINTN VbeSaveRestorePages; // Number of 4KB pages in VbeSaveRestoreBuffer\r
- EFI_PHYSICAL_ADDRESS VbeSaveRestoreBuffer; // Must be allocated below 1MB\r
- //\r
- // Status code\r
- //\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-} BIOS_VIDEO_DEV;\r
-\r
-#define BIOS_VIDEO_DEV_FROM_PCI_IO_THIS(a) CR (a, BIOS_VIDEO_DEV, PciIo, BIOS_VIDEO_DEV_SIGNATURE)\r
-#define BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a) CR (a, BIOS_VIDEO_DEV, GraphicsOutput, BIOS_VIDEO_DEV_SIGNATURE)\r
-#define BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS(a) CR (a, BIOS_VIDEO_DEV, VgaMiniPort, BIOS_VIDEO_DEV_SIGNATURE)\r
-\r
-#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r
-\r
-#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)\r
-#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL gBiosVideoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2;\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-/**\r
- Test to see if Bios Video could be supported on the Controller.\r
-\r
- @param This Pointer to driver binding protocol\r
- @param Controller Controller handle to connect\r
- @param RemainingDevicePath A pointer to the remaining portion of a device path\r
-\r
- @retval EFI_SUCCESS This driver supports this device.\r
- @retval other This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- )\r
-;\r
-\r
-/**\r
- Install Graphics Output Protocol onto VGA device handles\r
-\r
- @param This Pointer to driver binding protocol\r
- @param Controller Controller handle to connect\r
- @param RemainingDevicePath A pointer to the remaining portion of a device path\r
-\r
- @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- )\r
-;\r
-\r
-/**\r
- Stop this driver on Controller \r
-\r
- @param This Protocol instance pointer.\r
- @param Controller Handle of device to stop driver on\r
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
- children is zero stop the entire bus driver.\r
- @param ChildHandleBuffer List of Child Handles to Stop.\r
-\r
- @retval EFI_SUCCESS This driver is removed Controller.\r
- @retval other This driver was not removed from this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
- )\r
-;\r
-\r
-//\r
-// Private worker functions\r
-//\r
-/**\r
- Check for VBE device\r
-\r
- @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
- @retval EFI_SUCCESS VBE device found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoCheckForVbe (\r
- IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate\r
- )\r
-;\r
-\r
-/**\r
- Check for VGA device\r
-\r
- @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
- @retval EFI_SUCCESS Standard VGA device found\r
-**/\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoCheckForVga (\r
- BIOS_VIDEO_DEV *BiosVideoPrivate\r
- )\r
-;\r
-\r
-/**\r
- Collect the resource from destroyed bios video device.\r
-\r
- @param BiosVideoPrivate Video child device private data structure\r
-\r
-**/\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
- BIOS_VIDEO_DEV *BiosVideoChildPrivate\r
- )\r
-;\r
-\r
-//\r
-// BIOS Graphics Output Protocol functions\r
-//\r
-/**\r
-\r
- Graphics Output protocol interface to get video mode\r
-\r
-\r
- @param This - Protocol instance pointer.\r
- @param ModeNumber - The mode number to return information on.\r
- @param SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.\r
- @param Info - Caller allocated buffer that returns information about ModeNumber.\r
-\r
- @return EFI_SUCCESS - Mode information returned.\r
- EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.\r
- EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()\r
- EFI_INVALID_PARAMETER - One of the input args was NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputQueryMode (\r
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
- IN UINT32 ModeNumber,\r
- OUT UINTN *SizeOfInfo,\r
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
- )\r
-;\r
-\r
-/**\r
-\r
- Graphics Output protocol interface to set video mode\r
-\r
-\r
- @param This - Protocol instance pointer.\r
- @param ModeNumber - The mode number to be set.\r
-\r
- @return EFI_SUCCESS - Graphics mode was changed.\r
- EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
- EFI_UNSUPPORTED - ModeNumber is not supported by this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputSetMode (\r
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
- IN UINT32 ModeNumber\r
- )\r
-;\r
-\r
-/**\r
-\r
- Graphics Output protocol instance to block transfer for VBE device\r
-\r
-\r
- @param This - Pointer to Graphics Output protocol instance\r
- @param BltBuffer - The data to transfer to screen\r
- @param BltOperation - The operation to perform\r
- @param SourceX - The X coordinate of the source for BltOperation\r
- @param SourceY - The Y coordinate of the source for BltOperation\r
- @param DestinationX - The X coordinate of the destination for BltOperation\r
- @param DestinationY - The Y coordinate of the destination for BltOperation\r
- @param Width - The width of a rectangle in the blt rectangle in pixels\r
- @param Height - The height of a rectangle in the blt rectangle in pixels\r
- @param Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
- If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
- If a subrectangle of the BltBuffer is used, then Delta represents\r
- the number of bytes in a row of the BltBuffer.\r
-\r
- @return EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- EFI_SUCCESS - Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVbeBlt (\r
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN UINTN Delta\r
- )\r
-;\r
-\r
-/**\r
- Grahpics Output protocol instance to block transfer for VGA device\r
-\r
- @param This Pointer to Grahpics Output protocol instance\r
- @param BltBuffer The data to transfer to screen\r
- @param BltOperation The operation to perform\r
- @param SourceX The X coordinate of the source for BltOperation\r
- @param SourceY The Y coordinate of the source for BltOperation\r
- @param DestinationX The X coordinate of the destination for BltOperation\r
- @param DestinationY The Y coordinate of the destination for BltOperation\r
- @param Width The width of a rectangle in the blt rectangle in pixels\r
- @param Height The height of a rectangle in the blt rectangle in pixels\r
- @param Delta Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
- If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
- If a subrectangle of the BltBuffer is used, then Delta represents\r
- the number of bytes in a row of the BltBuffer.\r
-\r
- @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
- @retval EFI_SUCCESS Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVgaBlt (\r
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN UINTN Delta\r
- )\r
-;\r
-\r
-//\r
-// BIOS VGA Mini Port Protocol functions\r
-//\r
-/**\r
- VgaMiniPort protocol interface to set mode\r
-\r
- @param This Pointer to VgaMiniPort protocol instance\r
- @param ModeNumber The index of the mode\r
-\r
- @retval EFI_UNSUPPORTED The requested mode is not supported\r
- @retval EFI_SUCCESS The requested mode is set successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoVgaMiniPortSetMode (\r
- IN EFI_VGA_MINI_PORT_PROTOCOL *This,\r
- IN UINTN ModeNumber\r
- )\r
-;\r
-\r
-/**\r
- Judge whether this device is VGA device.\r
-\r
- @param PciIo Parent PciIo protocol instance pointer\r
-\r
- @retval TRUE Is vga device\r
- @retval FALSE Is no vga device\r
-**/\r
-BOOLEAN\r
-BiosVideoIsVga (\r
- IN EFI_PCI_IO_PROTOCOL *PciIo\r
- )\r
-;\r
-\r
-\r
-//\r
-// Standard VGA Definitions\r
-//\r
-#define VGA_HORIZONTAL_RESOLUTION 640\r
-#define VGA_VERTICAL_RESOLUTION 480\r
-#define VGA_NUMBER_OF_BIT_PLANES 4\r
-#define VGA_PIXELS_PER_BYTE 8\r
-#define VGA_BYTES_PER_SCAN_LINE (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS_PER_BYTE)\r
-#define VGA_BYTES_PER_BIT_PLANE (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PER_SCAN_LINE)\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER 0x3ce\r
-#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER 0x3cf\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER 0x00\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER 0x02\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER 0x03\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE 0x00\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND 0x08\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR 0x10\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR 0x18\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER 0x04\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER 0x05\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0 0x00\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1 0x08\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0 0x00\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1 0x01\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2 0x02\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3 0x03\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER 0x06\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER 0x07\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER 0x08\r
-\r
-/**\r
- Initialize legacy environment for BIOS INI caller.\r
- \r
- @param ThunkContext the instance pointer of THUNK_CONTEXT\r
-**/\r
-VOID\r
-InitializeBiosIntCaller (\r
- THUNK_CONTEXT *ThunkContext\r
- );\r
- \r
-/**\r
- Initialize interrupt redirection code and entries, because\r
- IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
- Or the interrupt will lost when we do thunk.\r
- NOTE: We do not reset 8259 vector base, because it will cause pending\r
- interrupt lost.\r
- \r
- @param Legacy8259 Instance pointer for EFI_LEGACY_8259_PROTOCOL.\r
- \r
-**/ \r
-VOID\r
-InitializeInterruptRedirection (\r
- IN EFI_LEGACY_8259_PROTOCOL *Legacy8259\r
- );\r
- \r
-/**\r
- Thunk to 16-bit real mode and execute a software interrupt with a vector \r
- of BiosInt. Regs will contain the 16-bit register context on entry and \r
- exit.\r
- \r
- @param This Protocol instance pointer.\r
- @param BiosInt Processor interrupt vector to invoke\r
- @param Reg Register contexted passed into (and returned) from thunk to 16-bit mode\r
- \r
- @retval TRUE Thunk completed, and there were no BIOS errors in the target code.\r
- See Regs for status.\r
- @retval FALSE There was a BIOS erro in the target code. \r
-**/ \r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosInt86 (\r
- IN BIOS_VIDEO_DEV *BiosDev,\r
- IN UINT8 BiosInt,\r
- IN IA32_REGISTER_SET *Regs\r
- ); \r
- \r
-#endif\r