uefibiosvideo.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 2,161 行 · 第 1/5 页
C
2,161 行
/*++
Copyright (c) 2006, 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:
UefiBiosVideo.c
Abstract:
ConsoleOut Routines that speak VGA.
Revision History
--*/
#include "UefiBiosVideo.h"
//
// EFI Driver Binding Protocol Instance
//
EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding = {
BiosVideoDriverBindingSupported,
BiosVideoDriverBindingStart,
BiosVideoDriverBindingStop,
0x00000024,
NULL,
NULL
};
//
// Global lookup tables for VGA graphics modes
//
UINT8 mVgaLeftMaskTable[] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
UINT8 mVgaRightMaskTable[] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
UINT8 mVgaBitMaskTable[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
EFI_GRAPHICS_OUTPUT_BLT_PIXEL mVgaColorToGraphicsOutputColor[] = {
{
0x00,
0x00,
0x00,
0x00
},
{
0x98,
0x00,
0x00,
0x00
},
{
0x00,
0x98,
0x00,
0x00
},
{
0x98,
0x98,
0x00,
0x00
},
{
0x00,
0x00,
0x98,
0x00
},
{
0x98,
0x00,
0x98,
0x00
},
{
0x00,
0x98,
0x98,
0x00
},
{
0x98,
0x98,
0x98,
0x00
},
{
0x10,
0x10,
0x10,
0x00
},
{
0xff,
0x10,
0x10,
0x00
},
{
0x10,
0xff,
0x10,
0x00
},
{
0xff,
0xff,
0x10,
0x00
},
{
0x10,
0x10,
0xff,
0x00
},
{
0xf0,
0x10,
0xff,
0x00
},
{
0x10,
0xff,
0xff,
0x00
},
{
0xff,
0xff,
0xff,
0x00
}
};
//
// Standard timing defined by VESA EDID
//
VESA_BIOS_EXTENSIONS_EDID_TIMING mEstablishedEdidTiming[] = {
//
// Established Timing I
//
{800, 600, 60},
{800, 600, 56},
{640, 480, 75},
{640, 480, 72},
{640, 480, 67},
{640, 480, 60},
{720, 400, 88},
{720, 400, 70},
//
// Established Timing II
//
{1280, 1024, 75},
{1024, 768, 75},
{1024, 768, 70},
{1024, 768, 60},
{1024, 768, 87},
{832, 624, 75},
{800, 600, 75},
{800, 600, 72},
//
// Established Timing III
//
{1152, 870, 75}
};
EFI_STATUS
BiosVideoChildHandleInstall (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ParentHandle,
IN EFI_PCI_IO_PROTOCOL *ParentPciIo,
IN EFI_LEGACY_BIOS_THUNK_PROTOCOL *ParentLegacyBios,
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
;
EFI_STATUS
BiosVideoChildHandleUninstall (
EFI_DRIVER_BINDING_PROTOCOL *This,
EFI_HANDLE Controller,
EFI_HANDLE Handle
)
;
VOID
BiosVideoDeviceReleaseResource (
BIOS_VIDEO_DEV *BiosVideoPrivate
)
;
//
// Driver Entry Point
//
EFI_DRIVER_ENTRY_POINT (BiosVideoDriverEntryPoint)
EFI_STATUS
EFIAPI
BiosVideoDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Driver Entry Point.
Arguments:
ImageHandle - Handle of driver image.
SystemTable - Pointer to system table.
Returns:
EFI_STATUS
--*/
{
EFI_STATUS Status;
Status = EfiLibInstallAllDriverProtocols (
ImageHandle,
SystemTable,
&gBiosVideoDriverBinding,
ImageHandle,
&gBiosVideoComponentName,
NULL,
NULL
);
return Status;
}
VOID
EFIAPI
BiosVideoExitBootServices (
EFI_EVENT Event,
VOID *Context
)
/*++
Routine Description:
Callback function for exit boot service event
Arguments:
Event - EFI_EVENT structure
Context - Event context
Returns:
None
--*/
{
/*
BIOS_VIDEO_DEV *BiosVideoPrivate;
EFI_IA32_REGISTER_SET Regs;
//
// Get our context
//
BiosVideoPrivate = (BIOS_VIDEO_DEV *) Context;
//
// Set the 80x25 Text VGA Mode
//
Regs.H.AH = 0x00;
Regs.H.AL = 0x83;
BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);
Regs.H.AH = 0x11;
Regs.H.AL = 0x14;
Regs.H.BL = 0;
BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);
*/
}
EFI_STATUS
EFIAPI
BiosVideoDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Supported.
Arguments:
This - Pointer to driver binding protocol
Controller - Controller handle to connect
RemainingDevicePath - A pointer to the remaining portion of a device path
Returns:
EFI_STATUS - EFI_SUCCESS:This controller can be managed by this driver,
Otherwise, this controller cannot be managed by this driver
--*/
{
EFI_STATUS Status;
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
EFI_PCI_IO_PROTOCOL *PciIo;
//
// See if the Legacy BIOS Protocol is available
//
Status = gBS->LocateProtocol (&gEfiLegacyBiosThunkProtocolGuid, NULL, (VOID **) &LegacyBios);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
Controller,
&gEfiPciIoProtocolGuid,
(VOID **) &PciIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
if (!BiosVideoIsVga (PciIo)) {
Status = EFI_UNSUPPORTED;
}
gBS->CloseProtocol (
Controller,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
return Status;
}
EFI_STATUS
EFIAPI
BiosVideoDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Install Graphics Output Protocol onto VGA device handles
Arguments:
This - Pointer to driver binding protocol
Controller - Controller handle to connect
RemainingDevicePath - A pointer to the remaining portion of a device path
Returns:
EFI_STATUS
--*/
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_LEGACY_BIOS_THUNK_PROTOCOL *LegacyBios;
PciIo = NULL;
//
// Prepare for status code
//
Status = gBS->HandleProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
(VOID **) &ParentDevicePath
);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// Open the IO Abstraction(s) needed
//
Status = gBS->OpenProtocol (
Controller,
&gEfiPciIoProtocolGuid,
(VOID **) &PciIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// See if the Legacy BIOS Protocol is available
//
Status = gBS->LocateProtocol (&gEfiLegacyBiosThunkProtocolGuid, NULL, (VOID **) &LegacyBios);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// Create child handle and install GraphicsOutputProtocol on it
//
Status = BiosVideoChildHandleInstall (
This,
Controller,
PciIo,
LegacyBios,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?