lightconsplittergraphics.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 1,563 行 · 第 1/4 页
C
1,563 行
VerticalResolution = Private->GraphicsOutput.Mode->Info->VerticalResolution;
//
// We need to fill the Virtual Screen buffer with the blt data.
//
if (BltOperation == EfiBltVideoToBltBuffer) {
//
// Video to BltBuffer: Source is Video, destination is BltBuffer
//
if ((SourceY + Height) > VerticalResolution) {
return EFI_INVALID_PARAMETER;
}
if ((SourceX + Width) > HorizontalResolution) {
return EFI_INVALID_PARAMETER;
}
BltPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + DestinationY * Delta + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
ScreenPtr = &Private->GraphicsOutputBlt[SourceY * HorizontalResolution + SourceX];
while (Height) {
EfiCopyMem (BltPtr, ScreenPtr, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
BltPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltPtr + Delta);
ScreenPtr += HorizontalResolution;
Height--;
}
} else {
//
// BltBuffer to Video: Source is BltBuffer, destination is Video
//
if (DestinationY + Height > VerticalResolution) {
return EFI_INVALID_PARAMETER;
}
if (DestinationX + Width > HorizontalResolution) {
return EFI_INVALID_PARAMETER;
}
ScreenPtr = &Private->GraphicsOutputBlt[DestinationY * HorizontalResolution + DestinationX];
SrcY = SourceY;
while (Height) {
if (BltOperation == EfiBltVideoFill) {
for (Index = 0; Index < Width; Index++) {
ScreenPtr[Index] = *BltBuffer;
}
} else {
if (BltOperation == EfiBltBufferToVideo) {
BltPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + SrcY * Delta + SourceX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
} else {
BltPtr = &Private->GraphicsOutputBlt[SrcY * HorizontalResolution + SourceX];
}
EfiCopyMem (ScreenPtr, BltPtr, Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
ScreenPtr += HorizontalResolution;
SrcY++;
Height--;
}
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
ConSpliterGraphicsOutputBlt (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
)
/*++
Routine Description:
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.
Arguments:
This - Protocol instance pointer.
BltBuffer - Buffer containing data to blit into video buffer. This
buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
BltOperation - Operation to perform on BlitBuffer and video memory
SourceX - X coordinate of source for the BltBuffer.
SourceY - Y coordinate of source for the BltBuffer.
DestinationX - X coordinate of destination for the BltBuffer.
DestinationY - Y coordinate of destination for the BltBuffer.
Width - Width of rectangle in BltBuffer in pixels.
Height - Hight of rectangle in BltBuffer in pixels.
Delta -
Returns:
EFI_SUCCESS - The Blt operation completed.
EFI_INVALID_PARAMETER - BltOperation is not valid.
EFI_DEVICE_ERROR - A hardware error occured writting to the video
buffer.
--*/
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
//
// Sync up DevNull GOP device
//
ReturnStatus = DevNullGraphicsOutputBlt (
Private,
BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (Private->ConsoleOutputMode != EfiConsoleControlScreenGraphics) {
return ReturnStatus;
}
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
GraphicsOutput,
BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
} else if (BltOperation == EfiBltVideoToBltBuffer) {
//
// Only need to read the data into buffer one time
//
return EFI_SUCCESS;
}
}
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->Blt (
UgaDraw,
(EFI_UGA_PIXEL *) BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
} else if (BltOperation == EfiBltVideoToBltBuffer) {
//
// Only need to read the data into buffer one time
//
return EFI_SUCCESS;
}
}
}
return ReturnStatus;
}
EFI_STATUS
DevNullGopSync (
IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
)
{
if (GraphicsOutput != NULL) {
return GraphicsOutput->Blt (
GraphicsOutput,
Private->GraphicsOutputBlt,
EfiBltBufferToVideo,
0,
0,
0,
0,
Private->GraphicsOutput.Mode->Info->HorizontalResolution,
Private->GraphicsOutput.Mode->Info->VerticalResolution,
0
);
} else {
return UgaDraw->Blt (
UgaDraw,
(EFI_UGA_PIXEL *) Private->GraphicsOutputBlt,
EfiUgaBltBufferToVideo,
0,
0,
0,
0,
Private->GraphicsOutput.Mode->Info->HorizontalResolution,
Private->GraphicsOutput.Mode->Info->VerticalResolution,
0
);
}
}
#else
EFI_STATUS
EFIAPI
ConSpliterUgaDrawGetMode (
IN EFI_UGA_DRAW_PROTOCOL *This,
OUT UINT32 *HorizontalResolution,
OUT UINT32 *VerticalResolution,
OUT UINT32 *ColorDepth,
OUT UINT32 *RefreshRate
)
/*++
Routine Description:
Return the current video mode information.
Arguments:
This - Protocol instance pointer.
HorizontalResolution - Current video horizontal resolution in pixels
VerticalResolution - Current video vertical resolution in pixels
ColorDepth - Current video color depth in bits per pixel
RefreshRate - Current video refresh rate in Hz.
Returns:
EFI_SUCCESS - Mode information returned.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_INVALID_PARAMETER - One of the input args was NULL.
--*/
{
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
if (!(HorizontalResolution && VerticalResolution && RefreshRate && ColorDepth)) {
return EFI_INVALID_PARAMETER;
}
//
// retrieve private data
//
Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
*HorizontalResolution = Private->UgaHorizontalResolution;
*VerticalResolution = Private->UgaVerticalResolution;
*ColorDepth = Private->UgaColorDepth;
*RefreshRate = Private->UgaRefreshRate;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
ConSpliterUgaDrawSetMode (
IN EFI_UGA_DRAW_PROTOCOL *This,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
)
/*++
Routine Description:
Return the current video mode information.
Arguments:
This - Protocol instance pointer.
HorizontalResolution - Current video horizontal resolution in pixels
VerticalResolution - Current video vertical resolution in pixels
ColorDepth - Current video color depth in bits per pixel
RefreshRate - Current video refresh rate in Hz.
Returns:
EFI_SUCCESS - Mode information returned.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_OUT_OF_RESOURCES - Out of resources.
--*/
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
UINTN Size;
Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
//
// UgaDevNullSetMode ()
//
ReturnStatus = EFI_SUCCESS;
//
// Free the old version
//
gBS->FreePool (Private->UgaBlt);
//
// Allocate the virtual Blt buffer
//
Size = HorizontalResolution * VerticalResolution * sizeof (EFI_UGA_PIXEL);
Private->UgaBlt = EfiLibAllocateZeroPool (Size);
if (Private->UgaBlt == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Update the Mode data
//
Private->UgaHorizontalResolution = HorizontalResolution;
Private->UgaVerticalResolution = VerticalResolution;
Private->UgaColorDepth = ColorDepth;
Private->UgaRefreshRate = RefreshRate;
if (Private->ConsoleOutputMode != EfiConsoleControlScreenGraphics) {
return ReturnStatus;
}
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
if (Private->TextOutList[Index].UgaDraw != NULL) {
Status = Private->TextOutList[Index].UgaDraw->SetMode (
Private->TextOutList[Index].UgaDraw,
HorizontalResolution,
VerticalResolution,
ColorDepth,
RefreshRate
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
}
return ReturnStatus;
}
EFI_STATUS
DevNullUgaBlt (
IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?