-/*++\r
+/** @file\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \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
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
-Module Name:\r
-\r
- UefiBiosVideo.h\r
- \r
-Abstract: \r
-\r
-Revision History\r
---*/\r
+**/\r
\r
#ifndef _BIOS_GRAPHICS_OUTPUT_H\r
#define _BIOS_GRAPHICS_OUTPUT_H\r
#include <Protocol/EdidActive.h>\r
#include <Protocol/EdidDiscovered.h>\r
#include <Protocol/DevicePath.h>\r
-#include <Protocol/LegacyBios.h>\r
\r
#include <Library/UefiLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/DevicePathLib.h>\r
\r
-#include <IndustryStandard/Pci22.h>\r
+#include <IndustryStandard/Pci.h>\r
\r
#include "VesaBiosExtensions.h"\r
\r
EFI_HANDLE Handle;\r
\r
//\r
- // Consumed Protocols\r
+ // Consumed Protocols inherited from parent controller.\r
//\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
EFI_LEGACY_8259_PROTOCOL *Legacy8259;\r
-\r
+ THUNK_CONTEXT *ThunkContext;\r
+ \r
//\r
// Produced Protocols\r
//\r
//\r
BOOLEAN VgaCompatible;\r
BOOLEAN ProduceGraphicsOutput;\r
- EFI_EVENT ExitBootServicesEvent;\r
\r
//\r
// Graphics Output Protocol related fields\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
+#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
// 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_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- Controller - GC_TODO: add argument description\r
- RemainingDevicePath - GC_TODO: add argument description\r
+;\r
\r
-Returns:\r
+/**\r
+ Install Graphics Output Protocol onto VGA device handles\r
\r
- GC_TODO: add return values\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
---*/\r
-;\r
+ @return EFI_STATUS\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
BiosVideoDriverBindingStart (\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- Controller - GC_TODO: add argument description\r
- RemainingDevicePath - GC_TODO: add argument description\r
+;\r
\r
-Returns:\r
+/**\r
+ Stop this driver on Controller \r
\r
- GC_TODO: add return values\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
---*/\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 UINTN NumberOfChildren,\r
IN EFI_HANDLE *ChildHandleBuffer\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- This - GC_TODO: add argument description\r
- Controller - GC_TODO: add argument description\r
- NumberOfChildren - GC_TODO: add argument description\r
- ChildHandleBuffer - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
//\r
// Private worker functions\r
//\r
-EFI_STATUS\r
-BiosVideoCheckForVbe (\r
- BIOS_VIDEO_DEV *BiosVideoPrivate\r
- )\r
-/*++\r
+/**\r
+ Check for VBE device\r
\r
-Routine Description:\r
+ @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
\r
- GC_TODO: Add function description\r
+ @retval EFI_SUCCESS VBE device found\r
\r
-Arguments:\r
-\r
- BiosVideoPrivate - GC_TODO: add argument description\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BiosVideoCheckForVbe (\r
+ IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate\r
+ )\r
+;\r
\r
-Returns:\r
+/**\r
+ Check for VGA device\r
\r
- GC_TODO: add return values\r
+ @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
\r
---*/\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
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- BiosVideoPrivate - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
-STATIC\r
-EFI_STATUS\r
-DeRegisterVideoChildHandle (\r
- EFI_DRIVER_BINDING_PROTOCOL *This,\r
- EFI_HANDLE Controller,\r
- EFI_HANDLE Handle\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Deregister an video child handle and free resources\r
-\r
-Arguments:\r
-\r
- This - Protocol instance pointer.\r
- Controller - Video controller handle\r
- Handle - Video child handle\r
-\r
-Returns:\r
-\r
- EFI_STATUS\r
+/**\r
+ Collect the resource from destroyed bios video device.\r
\r
---*/\r
-;\r
+ @param BiosVideoPrivate Video child device private data structure\r
\r
+**/\r
VOID\r
BiosVideoDeviceReleaseResource (\r
BIOS_VIDEO_DEV *BiosVideoChildPrivate\r
)\r
-/*++\r
-Routing Description:\r
+;\r
\r
- Release resources of a video child device before stopping it.\r
+//\r
+// BIOS Graphics Output Protocol functions\r
+//\r
+/**\r
\r
-Arguments:\r
+ Graphics Output protocol interface to get video mode\r
\r
- BiosVideoChildPrivate - Video child device private data structure\r
\r
-Returns:\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
- NONE\r
- \r
----*/\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
-// BIOS Graphics Output Protocol functions\r
-//\r
+**/\r
EFI_STATUS\r
EFIAPI\r
BiosVideoGraphicsOutputQueryMode (\r
OUT UINTN *SizeOfInfo,\r
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
)\r
-/*++\r
+;\r
\r
-Routine Description:\r
+/**\r
\r
- Graphics Output protocol interface to get video mode\r
+ Graphics Output protocol interface to set video mode\r
\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ModeNumber - The mode number to return information on.\r
- Info - Caller allocated buffer that returns information about ModeNumber.\r
- SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.\r
\r
- Returns:\r
- EFI_SUCCESS - Mode information returned.\r
- EFI_BUFFER_TOO_SMALL - The Info buffer was too small.\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
+ @param This - Protocol instance pointer.\r
+ @param ModeNumber - The mode number to be set.\r
\r
---*/\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
-Routine Description:\r
-\r
- Graphics Output protocol interface to set video mode\r
+;\r
\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ModeNumber - The mode number to be set.\r
+/**\r
\r
- Returns:\r
- 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
+ Graphics Output protocol instance to block transfer for VBE device\r
\r
---*/\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 UINTN Height,\r
IN UINTN Delta\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Graphics Output protocol instance to block transfer for VBE device\r
-\r
-Arguments:\r
-\r
- This - Pointer to Graphics Output protocol instance\r
- BltBuffer - The data to transfer to screen\r
- BltOperation - The operation to perform\r
- SourceX - The X coordinate of the source for BltOperation\r
- SourceY - The Y coordinate of the source for BltOperation\r
- DestinationX - The X coordinate of the destination for BltOperation\r
- DestinationY - The Y coordinate of the destination for BltOperation\r
- Width - The width of a rectangle in the blt rectangle in pixels\r
- Height - The height of a rectangle in the blt rectangle in pixels\r
- 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
-Returns:\r
-\r
- EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- EFI_SUCCESS - Blt operation success\r
-\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 UINTN Height,\r
IN UINTN Delta\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Grahpics Output protocol instance to block transfer for VGA device\r
-\r
-Arguments:\r
-\r
- This - Pointer to Grahpics Output protocol instance\r
- BltBuffer - The data to transfer to screen\r
- BltOperation - The operation to perform\r
- SourceX - The X coordinate of the source for BltOperation\r
- SourceY - The Y coordinate of the source for BltOperation\r
- DestinationX - The X coordinate of the destination for BltOperation\r
- DestinationY - The Y coordinate of the destination for BltOperation\r
- Width - The width of a rectangle in the blt rectangle in pixels\r
- Height - The height of a rectangle in the blt rectangle in pixels\r
- 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
-Returns:\r
-\r
- EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- EFI_SUCCESS - Blt operation success\r
-\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
-Routine Description:\r
-\r
- VgaMiniPort protocol interface to set mode\r
-\r
-Arguments:\r
-\r
- This - Pointer to VgaMiniPort protocol instance\r
- ModeNumber - The index of the mode\r
-\r
-Returns:\r
-\r
- EFI_UNSUPPORTED - The requested mode is not supported\r
- EFI_SUCCESS - The requested mode is set successfully\r
-\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
#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
- IN BIOS_VIDEO_DEV *BiosDev\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 BIOS_VIDEO_DEV *BiosDev\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 EFI_IA32_REGISTER_SET *Regs\r
+ IN IA32_REGISTER_SET *Regs\r
); \r
\r
#endif\r