ueficirruslogic5430graphicsoutput.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 1,045 行 · 第 1/3 页
C
1,045 行
/*++
Copyright (c) 2004, 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.
Module Name:
UefiCirrusLogic5430GraphicsOutput.c
Abstract:
This file produces the graphics abstration of Graphics Output Protocol. It is called by
CirrusLogic5430.c file which deals with the EFI 1.1 driver model.
This file just does graphics.
--*/
#include "UefiCirrusLogic5430.h"
//
// Video Mode structure
//
typedef struct {
UINT32 Width;
UINT32 Height;
UINT32 ColorDepth;
UINT32 RefreshRate;
UINT8 *CrtcSettings;
UINT16 *SeqSettings;
UINT8 MiscSetting;
} CIRRUS_LOGIC_5430_VIDEO_MODES;
//
// Generic Attribute Controller Register Settings
//
static UINT8 AttributeController[21] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00
};
//
// Generic Graphics Controller Register Settings
//
static UINT8 GraphicsController[9] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
};
//
// 640 x 480 x 256 color @ 60 Hertz
//
static UINT8 Crtc_640_480_256_60[28] = {
0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,
0xff, 0x00, 0x00, 0x22
};
static UINT16 Seq_640_480_256_60[15] = {
0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e
};
//
// 800 x 600 x 256 color @ 60 Hertz
//
static UINT8 Crtc_800_600_256_60[28] = {
0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,
0xFF, 0x00, 0x00, 0x22
};
static UINT16 Seq_800_600_256_60[15] = {
0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e
};
//
// 1024 x 768 x 256 color @ 60 Hertz
//
static UINT8 Crtc_1024_768_256_60[28] = {
0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,
0xFF, 0x4A, 0x00, 0x22
};
static UINT16 Seq_1024_768_256_60[15] = {
0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e
};
//
// Table of supported video modes
//
static CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[] = {
{ 640, 480, 8, 60, Crtc_640_480_256_60, Seq_640_480_256_60, 0xe3 },
{ 800, 600, 8, 60, Crtc_800_600_256_60, Seq_800_600_256_60, 0xef },
{ 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }
};
//
// Local Function Prototypes
//
VOID
InitializeGraphicsMode (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
);
VOID
SetPaletteColor (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
UINTN Index,
UINT8 Red,
UINT8 Green,
UINT8 Blue
);
VOID
SetDefaultPalette (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
);
STATIC
VOID
ClearScreen (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
);
VOID
DrawLogo (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
);
VOID
outb (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
UINTN Address,
UINT8 Data
);
VOID
outw (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
UINTN Address,
UINT16 Data
);
UINT8
inb (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
UINTN Address
);
UINT16
inw (
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
UINTN Address
);
//
// Graphics Output Protocol Member Functions
//
EFI_STATUS
EFIAPI
CirrusLogic5430GraphicsOutputQueryMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber,
OUT UINTN *SizeOfInfo,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
)
/*++
Routine Description:
Graphics Output protocol interface to query 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.
--*/
{
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
EFI_STATUS Status;
Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
if (Private->HardwareNeedsStarting) {
return EFI_NOT_STARTED;
}
if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {
return EFI_INVALID_PARAMETER;
}
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
Info
);
if (EFI_ERROR (Status)) {
return Status;
}
*SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
(*Info)->Version = 0;
(*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution;
(*Info)->VerticalResolution = Private->ModeData[ModeNumber].VerticalResolution;
(*Info)->PixelFormat = PixelBltOnly;
(*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CirrusLogic5430GraphicsOutputSetMode (
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.
--*/
{
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
CIRRUS_LOGIC_5430_GRAPHICS_OUTPUT_MODE_DATA *ModeData;
Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
ModeData = &Private->ModeData[ModeNumber];
if (Private->LineBuffer) {
gBS->FreePool (Private->LineBuffer);
}
Private->LineBuffer = NULL;
Private->LineBuffer = EfiLibAllocatePool (ModeData->HorizontalResolution);
if (Private->LineBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
InitializeGraphicsMode (Private, &CirrusLogic5430VideoModes[ModeNumber]);
This->Mode->Mode = ModeNumber;
This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;
This->Mode->Info->PixelFormat = PixelBltOnly;
This->Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
This->Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL;
This->Mode->FrameBufferSize = 0;
Private->HardwareNeedsStarting = FALSE;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
CirrusLogic5430GraphicsOutputBlt (
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
)
/*++
Routine Description:
Graphics Output protocol instance to block transfer for CirrusLogic 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
--*/
{
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
EFI_TPL OriginalTPL;
UINTN DstY;
UINTN SrcY;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
UINTN X;
UINT8 Pixel;
UINT32 WidePixel;
UINTN ScreenWidth;
UINTN Offset;
UINTN SourceOffset;
UINT32 CurrentMode;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?