Refine the comments for BiosVideo thunk driver.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7738 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2009-03-01 07:12:53 +00:00
parent 0d92cdc200
commit f1294e4a56
3 changed files with 586 additions and 876 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/*++
/** @file
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
@ -9,14 +9,7 @@ http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UefiBiosVideo.h
Abstract:
Revision History
--*/
**/
#ifndef _BIOS_GRAPHICS_OUTPUT_H
#define _BIOS_GRAPHICS_OUTPUT_H
@ -88,11 +81,12 @@ typedef struct {
EFI_HANDLE Handle;
//
// Consumed Protocols
// Consumed Protocols inherited from parent controller.
//
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_LEGACY_8259_PROTOCOL *Legacy8259;
THUNK_CONTEXT *ThunkContext;
//
// Produced Protocols
//
@ -106,7 +100,6 @@ typedef struct {
//
BOOLEAN VgaCompatible;
BOOLEAN ProduceGraphicsOutput;
EFI_EVENT ExitBootServicesEvent;
//
// Graphics Output Protocol related fields
@ -150,6 +143,17 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2;
//
// Driver Binding Protocol functions
//
/**
Test to see if Bios Video could be supported on the Controller.
@param This Pointer to driver binding protocol
@param Controller Controller handle to connect
@param RemainingDevicePath A pointer to the remaining portion of a device path
@retval EFI_SUCCESS This driver supports this device.
@retval other This driver does not support this device.
**/
EFI_STATUS
EFIAPI
BiosVideoDriverBindingSupported (
@ -157,25 +161,18 @@ BiosVideoDriverBindingSupported (
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
GC_TODO: Add function description
Arguments:
This - GC_TODO: add argument description
Controller - GC_TODO: add argument description
RemainingDevicePath - GC_TODO: add argument description
Returns:
GC_TODO: add return values
--*/
;
/**
Install Graphics Output Protocol onto VGA device handles
@param This Pointer to driver binding protocol
@param Controller Controller handle to connect
@param RemainingDevicePath A pointer to the remaining portion of a device path
@return EFI_STATUS
**/
EFI_STATUS
EFIAPI
BiosVideoDriverBindingStart (
@ -183,25 +180,21 @@ BiosVideoDriverBindingStart (
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
GC_TODO: Add function description
Arguments:
This - GC_TODO: add argument description
Controller - GC_TODO: add argument description
RemainingDevicePath - GC_TODO: add argument description
Returns:
GC_TODO: add return values
--*/
;
/**
Stop this driver on Controller
@param This Protocol instance pointer.
@param Controller Handle of device to stop driver on
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param ChildHandleBuffer List of Child Handles to Stop.
@retval EFI_SUCCESS This driver is removed Controller.
@retval other This driver was not removed from this device.
**/
EFI_STATUS
EFIAPI
BiosVideoDriverBindingStop (
@ -210,120 +203,70 @@ BiosVideoDriverBindingStop (
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
GC_TODO: Add function description
Arguments:
This - GC_TODO: add argument description
Controller - GC_TODO: add argument description
NumberOfChildren - GC_TODO: add argument description
ChildHandleBuffer - GC_TODO: add argument description
Returns:
GC_TODO: add return values
--*/
;
//
// Private worker functions
//
/**
Check for VBE device
@param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure
@retval EFI_SUCCESS VBE device found
**/
EFI_STATUS
BiosVideoCheckForVbe (
BIOS_VIDEO_DEV *BiosVideoPrivate
)
/*++
Routine Description:
GC_TODO: Add function description
Arguments:
BiosVideoPrivate - GC_TODO: add argument description
Returns:
GC_TODO: add return values
--*/
;
/**
Check for VGA device
@param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure
@retval EFI_SUCCESS Standard VGA device found
**/
EFI_STATUS
BiosVideoCheckForVga (
BIOS_VIDEO_DEV *BiosVideoPrivate
)
/*++
Routine Description:
GC_TODO: Add function description
Arguments:
BiosVideoPrivate - GC_TODO: add argument description
Returns:
GC_TODO: add return values
--*/
;
STATIC
EFI_STATUS
DeRegisterVideoChildHandle (
EFI_DRIVER_BINDING_PROTOCOL *This,
EFI_HANDLE Controller,
EFI_HANDLE Handle
)
/*++
/**
Collect the resource from destroyed bios video device.
Routine Description:
Deregister an video child handle and free resources
Arguments:
This - Protocol instance pointer.
Controller - Video controller handle
Handle - Video child handle
Returns:
EFI_STATUS
--*/
;
@param BiosVideoPrivate Video child device private data structure
**/
VOID
BiosVideoDeviceReleaseResource (
BIOS_VIDEO_DEV *BiosVideoChildPrivate
)
/*++
Routing Description:
Release resources of a video child device before stopping it.
Arguments:
BiosVideoChildPrivate - Video child device private data structure
Returns:
NONE
---*/
;
//
// BIOS Graphics Output Protocol functions
//
/**
Graphics Output protocol interface to get video mode
@param This - Protocol instance pointer.
@param ModeNumber - The mode number to return information on.
@param SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.
@param Info - Caller allocated buffer that returns information about ModeNumber.
@return EFI_SUCCESS - Mode information returned.
EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_INVALID_PARAMETER - One of the input args was NULL.
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputQueryMode (
@ -332,52 +275,52 @@ BiosVideoGraphicsOutputQueryMode (
OUT UINTN *SizeOfInfo,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
)
/*++
Routine Description:
Graphics Output protocol interface to get video mode
Arguments:
This - Protocol instance pointer.
ModeNumber - The mode number to return information on.
Info - Caller allocated buffer that returns information about ModeNumber.
SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.
Returns:
EFI_SUCCESS - Mode information returned.
EFI_BUFFER_TOO_SMALL - The Info buffer was too small.
EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_INVALID_PARAMETER - One of the input args was NULL.
--*/
;
/**
Graphics Output protocol interface to set video mode
@param This - Protocol instance pointer.
@param ModeNumber - The mode number to be set.
@return EFI_SUCCESS - Graphics mode was changed.
EFI_DEVICE_ERROR - The device had an error and could not complete the request.
EFI_UNSUPPORTED - ModeNumber is not supported by this device.
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
IN UINT32 ModeNumber
)
/*++
Routine Description:
Graphics Output protocol interface to set video mode
Arguments:
This - Protocol instance pointer.
ModeNumber - The mode number to be set.
Returns:
EFI_SUCCESS - Graphics mode was changed.
EFI_DEVICE_ERROR - The device had an error and could not complete the request.
EFI_UNSUPPORTED - ModeNumber is not supported by this device.
--*/
;
/**
Graphics Output protocol instance to block transfer for VBE device
@param This - Pointer to Graphics Output protocol instance
@param BltBuffer - The data to transfer to screen
@param BltOperation - The operation to perform
@param SourceX - The X coordinate of the source for BltOperation
@param SourceY - The Y coordinate of the source for BltOperation
@param DestinationX - The X coordinate of the destination for BltOperation
@param DestinationY - The Y coordinate of the destination for BltOperation
@param Width - The width of a rectangle in the blt rectangle in pixels
@param Height - The height of a rectangle in the blt rectangle in pixels
@param Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
If a Delta of 0 is used, the entire BltBuffer will be operated on.
If a subrectangle of the BltBuffer is used, then Delta represents
the number of bytes in a row of the BltBuffer.
@return EFI_INVALID_PARAMETER - Invalid parameter passed in
EFI_SUCCESS - Blt operation success
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputVbeBlt (
@ -392,36 +335,29 @@ BiosVideoGraphicsOutputVbeBlt (
IN UINTN Height,
IN UINTN Delta
)
/*++
Routine Description:
Graphics Output protocol instance to block transfer for VBE device
Arguments:
This - Pointer to Graphics Output protocol instance
BltBuffer - The data to transfer to screen
BltOperation - The operation to perform
SourceX - The X coordinate of the source for BltOperation
SourceY - The Y coordinate of the source for BltOperation
DestinationX - The X coordinate of the destination for BltOperation
DestinationY - The Y coordinate of the destination for BltOperation
Width - The width of a rectangle in the blt rectangle in pixels
Height - The height of a rectangle in the blt rectangle in pixels
Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
If a Delta of 0 is used, the entire BltBuffer will be operated on.
If a subrectangle of the BltBuffer is used, then Delta represents
the number of bytes in a row of the BltBuffer.
Returns:
EFI_INVALID_PARAMETER - Invalid parameter passed in
EFI_SUCCESS - Blt operation success
--*/
;
/**
Grahpics Output protocol instance to block transfer for VGA device
@param This Pointer to Grahpics Output protocol instance
@param BltBuffer The data to transfer to screen
@param BltOperation The operation to perform
@param SourceX The X coordinate of the source for BltOperation
@param SourceY The Y coordinate of the source for BltOperation
@param DestinationX The X coordinate of the destination for BltOperation
@param DestinationY The Y coordinate of the destination for BltOperation
@param Width The width of a rectangle in the blt rectangle in pixels
@param Height The height of a rectangle in the blt rectangle in pixels
@param Delta Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
If a Delta of 0 is used, the entire BltBuffer will be operated on.
If a subrectangle of the BltBuffer is used, then Delta represents
the number of bytes in a row of the BltBuffer.
@retval EFI_INVALID_PARAMETER Invalid parameter passed in
@retval EFI_SUCCESS Blt operation success
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputVgaBlt (
@ -436,65 +372,37 @@ BiosVideoGraphicsOutputVgaBlt (
IN UINTN Height,
IN UINTN Delta
)
/*++
Routine Description:
Grahpics Output protocol instance to block transfer for VGA device
Arguments:
This - Pointer to Grahpics Output protocol instance
BltBuffer - The data to transfer to screen
BltOperation - The operation to perform
SourceX - The X coordinate of the source for BltOperation
SourceY - The Y coordinate of the source for BltOperation
DestinationX - The X coordinate of the destination for BltOperation
DestinationY - The Y coordinate of the destination for BltOperation
Width - The width of a rectangle in the blt rectangle in pixels
Height - The height of a rectangle in the blt rectangle in pixels
Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
If a Delta of 0 is used, the entire BltBuffer will be operated on.
If a subrectangle of the BltBuffer is used, then Delta represents
the number of bytes in a row of the BltBuffer.
Returns:
EFI_INVALID_PARAMETER - Invalid parameter passed in
EFI_SUCCESS - Blt operation success
--*/
;
//
// BIOS VGA Mini Port Protocol functions
//
/**
VgaMiniPort protocol interface to set mode
@param This Pointer to VgaMiniPort protocol instance
@param ModeNumber The index of the mode
@retval EFI_UNSUPPORTED The requested mode is not supported
@retval EFI_SUCCESS The requested mode is set successfully
**/
EFI_STATUS
EFIAPI
BiosVideoVgaMiniPortSetMode (
IN EFI_VGA_MINI_PORT_PROTOCOL *This,
IN UINTN ModeNumber
)
/*++
Routine Description:
VgaMiniPort protocol interface to set mode
Arguments:
This - Pointer to VgaMiniPort protocol instance
ModeNumber - The index of the mode
Returns:
EFI_UNSUPPORTED - The requested mode is not supported
EFI_SUCCESS - The requested mode is set successfully
--*/
;
/**
Judge whether this device is VGA device.
@param PciIo Parent PciIo protocol instance pointer
@retval TRUE Is vga device
@retval FALSE Is no vga device
**/
BOOLEAN
BiosVideoIsVga (
IN EFI_PCI_IO_PROTOCOL *PciIo
@ -543,16 +451,44 @@ BiosVideoIsVga (
#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER 0x08
/**
Initialize legacy environment for BIOS INI caller.
@param ThunkContext the instance pointer of THUNK_CONTEXT
**/
VOID
InitializeBiosIntCaller (
IN BIOS_VIDEO_DEV *BiosDev
THUNK_CONTEXT *ThunkContext
);
/**
Initialize interrupt redirection code and entries, because
IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
Or the interrupt will lost when we do thunk.
NOTE: We do not reset 8259 vector base, because it will cause pending
interrupt lost.
@param Legacy8259 Instance pointer for EFI_LEGACY_8259_PROTOCOL.
**/
VOID
InitializeInterruptRedirection (
IN BIOS_VIDEO_DEV *BiosDev
IN EFI_LEGACY_8259_PROTOCOL *Legacy8259
);
/**
Thunk to 16-bit real mode and execute a software interrupt with a vector
of BiosInt. Regs will contain the 16-bit register context on entry and
exit.
@param This Protocol instance pointer.
@param BiosInt Processor interrupt vector to invoke
@param Reg Register contexted passed into (and returned) from thunk to 16-bit mode
@retval TRUE Thunk completed, and there were no BIOS errors in the target code.
See Regs for status.
@retval FALSE There was a BIOS erro in the target code.
**/
BOOLEAN
EFIAPI
LegacyBiosInt86 (

View File

@ -1,13 +1,29 @@
/** @file
Provide legacy thunk interface for accessing Bios Video Rom.
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "BiosVideo.h"
#define EFI_CPU_EFLAGS_IF 0x200
THUNK_CONTEXT mThunkContext;
/**
Initialize legacy environment for BIOS INI caller.
@param ThunkContext the instance pointer of THUNK_CONTEXT
**/
VOID
InitializeBiosIntCaller (
IN BIOS_VIDEO_DEV *BiosDev
THUNK_CONTEXT *ThunkContext
)
{
EFI_STATUS Status;
@ -29,32 +45,27 @@ InitializeBiosIntCaller (
);
ASSERT_EFI_ERROR (Status);
mThunkContext.RealModeBuffer = (VOID*)(UINTN)LegacyRegionBase;
mThunkContext.RealModeBufferSize = EFI_PAGES_TO_SIZE (RealModeBufferSize);
mThunkContext.ThunkAttributes = 3;
AsmPrepareThunk16(&mThunkContext);
ThunkContext->RealModeBuffer = (VOID*)(UINTN)LegacyRegionBase;
ThunkContext->RealModeBufferSize = EFI_PAGES_TO_SIZE (RealModeBufferSize);
ThunkContext->ThunkAttributes = 3;
AsmPrepareThunk16(ThunkContext);
}
/**
Initialize interrupt redirection code and entries, because
IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
Or the interrupt will lost when we do thunk.
NOTE: We do not reset 8259 vector base, because it will cause pending
interrupt lost.
@param Legacy8259 Instance pointer for EFI_LEGACY_8259_PROTOCOL.
**/
VOID
InitializeInterruptRedirection (
IN BIOS_VIDEO_DEV *BiosDev
IN EFI_LEGACY_8259_PROTOCOL *Legacy8259
)
/*++
Routine Description:
Initialize interrupt redirection code and entries, because
IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
Or the interrupt will lost when we do thunk.
NOTE: We do not reset 8259 vector base, because it will cause pending
interrupt lost.
Arguments:
NONE
Returns:
NONE
--*/
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS LegacyRegionBase;
@ -94,7 +105,7 @@ InitializeInterruptRedirection (
//
// Get VectorBase, it should be 0x68
//
Status = BiosDev->Legacy8259->GetVector (BiosDev->Legacy8259, Efi8259Irq0, &ProtectedModeBaseVector);
Status = Legacy8259->GetVector (Legacy8259, Efi8259Irq0, &ProtectedModeBaseVector);
ASSERT_EFI_ERROR (Status);
//
@ -108,6 +119,19 @@ InitializeInterruptRedirection (
return ;
}
/**
Thunk to 16-bit real mode and execute a software interrupt with a vector
of BiosInt. Regs will contain the 16-bit register context on entry and
exit.
@param This Protocol instance pointer.
@param BiosInt Processor interrupt vector to invoke
@param Reg Register contexted passed into (and returned) from thunk to 16-bit mode
@retval TRUE Thunk completed, and there were no BIOS errors in the target code.
See Regs for status.
@retval FALSE There was a BIOS erro in the target code.
**/
BOOLEAN
EFIAPI
LegacyBiosInt86 (
@ -115,25 +139,6 @@ LegacyBiosInt86 (
IN UINT8 BiosInt,
IN EFI_IA32_REGISTER_SET *Regs
)
/*++
Routine Description:
Thunk to 16-bit real mode and execute a software interrupt with a vector
of BiosInt. Regs will contain the 16-bit register context on entry and
exit.
Arguments:
This - Protocol instance pointer.
BiosInt - Processor interrupt vector to invoke
Reg - Register contexted passed into (and returned) from thunk to
16-bit mode
Returns:
FALSE - Thunk completed, and there were no BIOS errors in the target code.
See Regs for status.
TRUE - There was a BIOS erro in the target code.
--*/
{
UINTN Status;
UINTN Eflags;
@ -178,7 +183,7 @@ LegacyBiosInt86 (
Status = BiosDev->Legacy8259->SetMode (BiosDev->Legacy8259, Efi8259LegacyMode, NULL, NULL);
ASSERT_EFI_ERROR (Status);
Stack16 = (UINT16 *)((UINT8 *) mThunkContext.RealModeBuffer + mThunkContext.RealModeBufferSize - sizeof (UINT16));
Stack16 = (UINT16 *)((UINT8 *) BiosDev->ThunkContext->RealModeBuffer + BiosDev->ThunkContext->RealModeBufferSize - sizeof (UINT16));
Stack16 -= sizeof (ThunkRegSet.E.EFLAGS) / sizeof (UINT16);
CopyMem (Stack16, &ThunkRegSet.E.EFLAGS, sizeof (ThunkRegSet.E.EFLAGS));
@ -186,8 +191,8 @@ LegacyBiosInt86 (
ThunkRegSet.E.ESP = (UINT16) (UINTN) Stack16;
ThunkRegSet.E.Eip = (UINT16)((UINT32 *)NULL)[BiosInt];
ThunkRegSet.E.CS = (UINT16)(((UINT32 *)NULL)[BiosInt] >> 16);
mThunkContext.RealModeState = &ThunkRegSet;
AsmThunk16 (&mThunkContext);
BiosDev->ThunkContext->RealModeState = &ThunkRegSet;
AsmThunk16 (BiosDev->ThunkContext);
//
// Restore protected mode interrupt state