1. code scrub for ConSplitterDxe.

2. fixed some bugs when thunking UGA based on GOP.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7107 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2008-12-24 00:15:20 +00:00
parent bcb85cda9d
commit 2da292f637
4 changed files with 411 additions and 369 deletions

View File

@@ -16,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "ConSplitter.h"
@@ -80,8 +79,8 @@ ConSpliterConsoleControlGetMode (
Set the current mode to either text or graphics. Graphics is
for Quiet Boot.
@param This Protocol instance pointer.
@param Mode Mode to set the
@param This Console Control Protocol instance pointer.
@param Mode Mode to set.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@@ -152,21 +151,20 @@ ConSpliterConsoleControlSetMode (
/**
Return the current video mode information.
Returns information for an available graphics mode that the graphics device
and the set of active video output devices supports.
@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.
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
@param ModeNumber The mode number to return information on.
@param SizeOfInfo A pointer to the size, in bytes, of the Info buffer.
@param Info A pointer to callee allocated buffer that returns information about ModeNumber.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.
@retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the
video mode.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_INVALID_PARAMETER One of the input args was NULL.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.
@retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_INVALID_PARAMETER One of the input args was NULL.
@retval EFI_OUT_OF_RESOURCES No resource available.
**/
EFI_STATUS
@@ -194,7 +192,6 @@ ConSpliterGraphicsOutputQueryMode (
}
*Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (*Info == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -208,15 +205,16 @@ ConSpliterGraphicsOutputQueryMode (
/**
Graphics output protocol interface to set video mode.
Set the video device into the specified mode and clears the visible portions of
the output display to black.
@param This Protocol instance pointer.
@param ModeNumber The mode number to be set.
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
@param ModeNumber Abstraction that defines the current video mode.
@retval EFI_SUCCESS Graphics mode was changed.
@retval EFI_DEVICE_ERROR The device had an error and could not complete
the request.
@retval EFI_UNSUPPORTED ModeNumber is not supported by this device.
@retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED ModeNumber is not supported by this device.
@retval EFI_OUT_OF_RESOURCES No resource available.
**/
EFI_STATUS
@@ -293,9 +291,7 @@ ConSpliterGraphicsOutputSetMode (
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
if (EFI_ERROR (ReturnStatus) && FeaturePcdGet (PcdUgaConsumeSupport)) {
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->SetMode (
@@ -671,7 +667,7 @@ DevNullGopSync (
Private->GraphicsOutput.Mode->Info->VerticalResolution,
0
);
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
return UgaDraw->Blt (
UgaDraw,
(EFI_UGA_PIXEL *) Private->GraphicsOutputBlt,
@@ -689,19 +685,18 @@ DevNullGopSync (
}
}
/**
Return the current video mode information.
@param This Protocol instance pointer.
@param HorizontalResolution Current video horizontal resolution in pixels
@param VerticalResolution Current video vertical resolution in pixels
@param ColorDepth Current video color depth in bits per pixel
@param RefreshRate Current video refresh rate in Hz.
@param This The EFI_UGA_DRAW_PROTOCOL instance.
@param HorizontalResolution The size of video screen in pixels in the X dimension.
@param VerticalResolution The size of video screen in pixels in the Y dimension.
@param ColorDepth Number of bits per pixel, currently defined to be 32.
@param RefreshRate The refresh rate of the monitor in Hertz.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_INVALID_PARAMETER One of the input args was NULL.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_INVALID_PARAMETER One of the input args was NULL.
**/
EFI_STATUS
@@ -717,9 +712,9 @@ ConSpliterUgaDrawGetMode (
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
if ((HorizontalResolution == NULL) ||
(VerticalResolution == NULL) ||
(RefreshRate == NULL) ||
(ColorDepth == NULL)) {
(VerticalResolution == NULL) ||
(RefreshRate == NULL) ||
(ColorDepth == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
@@ -737,17 +732,17 @@ ConSpliterUgaDrawGetMode (
/**
Return the current video mode information.
Set the current video mode information.
@param This Protocol instance pointer.
@param HorizontalResolution Current video horizontal resolution in pixels
@param VerticalResolution Current video vertical resolution in pixels
@param ColorDepth Current video color depth in bits per pixel
@param RefreshRate Current video refresh rate in Hz.
@param This The EFI_UGA_DRAW_PROTOCOL instance.
@param HorizontalResolution The size of video screen in pixels in the X dimension.
@param VerticalResolution The size of video screen in pixels in the Y dimension.
@param ColorDepth Number of bits per pixel, currently defined to be 32.
@param RefreshRate The refresh rate of the monitor in Hertz.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_OUT_OF_RESOURCES Out of resources.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_OUT_OF_RESOURCES Out of resources.
**/
EFI_STATUS
@@ -812,78 +807,80 @@ ConSpliterUgaDrawSetMode (
ReturnStatus = EFI_UNSUPPORTED;
if (FeaturePcdGet (PcdUgaConsumeSupport)) {
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
Status = UgaDraw->SetMode (
UgaDraw,
HorizontalResolution,
VerticalResolution,
ColorDepth,
RefreshRate
);
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
//
// Find corresponding ModeNumber of this GraphicsOutput instance
//
for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
return Status;
}
}
}
if (EFI_ERROR (ReturnStatus)) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
//
// Find corresponding ModeNumber of this GraphicsOutput instance
//
for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
if (EFI_ERROR (Status)) {
return Status;
}
if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {
FreePool (Info);
break;
}
if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {
FreePool (Info);
break;
}
FreePool (Info);
}
Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)){
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->SetMode (
UgaDraw,
HorizontalResolution,
VerticalResolution,
ColorDepth,
RefreshRate
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
}
}
}
return ReturnStatus;
}
/**
Blt a rectangle of pixels on the graphics screen.
The following table defines actions for BltOperations.
EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)
directly to every pixel of the video display rectangle
(DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
Only one pixel will be used from the BltBuffer. Delta is NOT used.
EfiBltVideoToBltBuffer - Read data from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
the BltBuffer rectangle (DestinationX, DestinationY )
(DestinationX + Width, DestinationY + Height). If DestinationX or
DestinationY is not zero then Delta must be set to the length in bytes
of a row in the BltBuffer.
EfiBltBufferToVideo - Write data from the BltBuffer rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
not zero then Delta must be set to the length in bytes of a row in the
BltBuffer.
EfiBltVideoToVideo - Copy from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) .
to the video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
The BltBuffer and Delta are not used in this mode.
EfiUgaVideoFill:
Write data from the BltBuffer pixel (SourceX, SourceY)
directly to every pixel of the video display rectangle
(DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
Only one pixel will be used from the BltBuffer. Delta is NOT used.
EfiUgaVideoToBltBuffer:
Read data from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
the BltBuffer rectangle (DestinationX, DestinationY )
(DestinationX + Width, DestinationY + Height). If DestinationX or
DestinationY is not zero then Delta must be set to the length in bytes
of a row in the BltBuffer.
EfiUgaBltBufferToVideo:
Write data from the BltBuffer rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
not zero then Delta must be set to the length in bytes of a row in the
BltBuffer.
EfiUgaVideoToVideo:
Copy from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) .
to the video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
The BltBuffer and Delta are not used in this mode.
@param Private Protocol instance pointer.
@param Private Text Out Splitter pointer.
@param BltBuffer Buffer containing data to blit into video buffer.
This buffer has a size of
Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
@@ -1020,51 +1017,53 @@ DevNullUgaBlt (
return EFI_SUCCESS;
}
/**
Blt a rectangle of pixels on the graphics screen.
The following table defines actions for BltOperations.
EfiUgaVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)
directly to every pixel of the video display rectangle
(DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
Only one pixel will be used from the BltBuffer. Delta is NOT used.
EfiUgaVideoToBltBuffer - Read data from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
the BltBuffer rectangle (DestinationX, DestinationY )
(DestinationX + Width, DestinationY + Height). If DestinationX or
DestinationY is not zero then Delta must be set to the length in bytes
of a row in the BltBuffer.
EfiUgaBltBufferToVideo - Write data from the BltBuffer rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
not zero then Delta must be set to the length in bytes of a row in the
BltBuffer.
EfiUgaVideoToVideo - Copy from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) .
to the video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
The BltBuffer and Delta are not used in this mode.
EfiUgaVideoFill:
Write data from the BltBuffer pixel (SourceX, SourceY)
directly to every pixel of the video display rectangle
(DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
Only one pixel will be used from the BltBuffer. Delta is NOT used.
EfiUgaVideoToBltBuffer:
Read data from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
the BltBuffer rectangle (DestinationX, DestinationY )
(DestinationX + Width, DestinationY + Height). If DestinationX or
DestinationY is not zero then Delta must be set to the length in bytes
of a row in the BltBuffer.
EfiUgaBltBufferToVideo:
Write data from the BltBuffer rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
not zero then Delta must be set to the length in bytes of a row in the
BltBuffer.
EfiUgaVideoToVideo:
Copy from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) .
to the video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
The BltBuffer and Delta are not used in this mode.
@param This Protocol instance pointer.
@param BltBuffer Buffer containing data to blit into video buffer.
This buffer has a size of
Width*Height*sizeof(EFI_UGA_PIXEL)
@param BltOperation Operation to perform on BlitBuffer and video
memory
@param SourceX X coordinate of source for the BltBuffer.
@param SourceY Y coordinate of source for the BltBuffer.
@param DestinationX X coordinate of destination for the BltBuffer.
@param DestinationY Y coordinate of destination for the BltBuffer.
@param Width Width of rectangle in BltBuffer in pixels.
@param Height Hight of rectangle in BltBuffer in pixels.
@param Delta OPTIONAL.
@param This Protocol instance pointer.
@param BltBuffer Buffer containing data to blit into video buffer. This
buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
@param BltOperation Operation to perform on BlitBuffer and video memory
@param SourceX X coordinate of source for the BltBuffer.
@param SourceY Y coordinate of source for the BltBuffer.
@param DestinationX X coordinate of destination for the BltBuffer.
@param DestinationY Y coordinate of destination for the BltBuffer.
@param Width Width of rectangle in BltBuffer in pixels.
@param Height Hight of rectangle in BltBuffer in pixels.
@param Delta OPTIONAL
@retval EFI_SUCCESS The Blt operation completed.
@retval EFI_INVALID_PARAMETER BltOperation is not valid.
@retval EFI_DEVICE_ERROR A hardware error occured writting to the video
buffer.
@retval EFI_SUCCESS The Blt operation completed.
@retval EFI_INVALID_PARAMETER BltOperation is not valid.
@retval EFI_DEVICE_ERROR A hardware error occured writting to the video buffer.
**/
EFI_STATUS
@@ -1183,20 +1182,7 @@ DevNullUgaSync (
IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
)
{
if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
return UgaDraw->Blt (
UgaDraw,
Private->UgaBlt,
EfiUgaBltBufferToVideo,
0,
0,
0,
0,
Private->UgaHorizontalResolution,
Private->UgaVerticalResolution,
Private->UgaHorizontalResolution * sizeof (EFI_UGA_PIXEL)
);
} else if (GraphicsOutput != NULL) {
if (GraphicsOutput != NULL) {
return GraphicsOutput->Blt (
GraphicsOutput,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) Private->UgaBlt,
@@ -1209,6 +1195,19 @@ DevNullUgaSync (
Private->UgaVerticalResolution,
0
);
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
return UgaDraw->Blt (
UgaDraw,
Private->UgaBlt,
EfiUgaBltBufferToVideo,
0,
0,
0,
0,
Private->UgaHorizontalResolution,
Private->UgaVerticalResolution,
Private->UgaHorizontalResolution * sizeof (EFI_UGA_PIXEL)
);
} else {
return EFI_UNSUPPORTED;
}
@@ -1436,7 +1435,7 @@ DevNullTextOutOutputString (
/**
Sets the output device(s) to a specified mode.
@param Private Private data structure pointer.
@param Private Text Out Splitter pointer.
@param ModeNumber The mode number to set.
@retval EFI_SUCCESS The requested text mode was set.
@@ -1513,7 +1512,7 @@ DevNullTextOutSetMode (
Clears the output device(s) display to the currently selected background
color.
@param Private Protocol instance pointer.
@param Private Text Out Splitter pointer.
@retval EFI_SUCCESS The operation completed successfully.
@retval EFI_DEVICE_ERROR The device had an error and could not complete
@@ -1561,7 +1560,7 @@ DevNullTextOutClearScreen (
/**
Sets the current coordinates of the cursor position.
@param Private Protocol instance pointer.
@param Private Text Out Splitter pointer.
@param Column
@param Row the position to set the cursor to. Must be
greater than or equal to zero and less than the
@@ -1595,14 +1594,13 @@ DevNullTextOutSetCursorPosition (
/**
Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
In this driver, the cursor cannot be hidden.
Set cursor visibility property.
@param Private Indicates the calling context.
@param Private Text Out Splitter pointer.
@param Visible If TRUE, the cursor is set to be visible, If
FALSE, the cursor is set to be invisible.
@retval EFI_SUCCESS The request is valid.
@retval EFI_SUCCESS Returns always.
**/
EFI_STATUS
@@ -1621,7 +1619,7 @@ DevNullTextOutEnableCursor (
Take the DevNull TextOut device and update the Simple Text Out on every
UGA device.
@param Private Indicates the calling context.
@param Private Text Out Splitter pointer.
@retval EFI_SUCCESS The request is valid.
@retval other Return status of TextOut->OutputString ()