Port CirrusLogic5430 from EDK II code base.
Add GOP, Component Name 2, Efi driver supported EFI version protocol support. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4322 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
803
OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
Normal file
803
OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
Normal file
@@ -0,0 +1,803 @@
|
||||
/** @file
|
||||
Cirrus Logic 5430 Controller Driver.
|
||||
This driver is a sample implementation of the UGA Draw and Graphics Output
|
||||
Protocols for the Cirrus Logic 5430 family of PCI video controllers.
|
||||
This driver is only usable in the EFI pre-boot environment.
|
||||
This sample is intended to show how the UGA Draw and Graphics output Protocol
|
||||
is able to function.
|
||||
The UGA I/O Protocol is not implemented in this sample.
|
||||
A fully compliant EFI UGA driver requires both
|
||||
the UGA Draw and the UGA I/O Protocol. Please refer to Microsoft's
|
||||
documentation on UGA for details on how to write a UGA driver that is able
|
||||
to function both in the EFI pre-boot environment and from the OS runtime.
|
||||
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
//
|
||||
// Cirrus Logic 5430 Controller Driver
|
||||
//
|
||||
#include "CirrusLogic5430.h"
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding = {
|
||||
CirrusLogic5430ControllerDriverSupported,
|
||||
CirrusLogic5430ControllerDriverStart,
|
||||
CirrusLogic5430ControllerDriverStop,
|
||||
0x10,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
///
|
||||
/// Generic Attribute Controller Register Settings
|
||||
///
|
||||
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
|
||||
///
|
||||
UINT8 GraphicsController[9] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
|
||||
};
|
||||
|
||||
//
|
||||
// 640 x 480 x 256 color @ 60 Hertz
|
||||
//
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
//
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
//
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
///
|
||||
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 }
|
||||
};
|
||||
|
||||
/**
|
||||
CirrusLogic5430ControllerDriverSupported
|
||||
|
||||
TODO: This - add argument and description to function comment
|
||||
TODO: Controller - add argument and description to function comment
|
||||
TODO: RemainingDevicePath - add argument and description to function comment
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CirrusLogic5430ControllerDriverSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
PCI_TYPE00 Pci;
|
||||
|
||||
//
|
||||
// Open the PCI I/O Protocol
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Read the PCI Configuration Header from the PCI Device
|
||||
//
|
||||
Status = PciIo->Pci.Read (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
0,
|
||||
sizeof (Pci) / sizeof (UINT32),
|
||||
&Pci
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = EFI_UNSUPPORTED;
|
||||
//
|
||||
// See if the I/O enable is on. Most systems only allow one VGA device to be turned on
|
||||
// at a time, so see if this is one that is turned on.
|
||||
//
|
||||
// if (((Pci.Hdr.Command & 0x01) == 0x01)) {
|
||||
//
|
||||
// See if this is a Cirrus Logic PCI controller
|
||||
//
|
||||
if (Pci.Hdr.VendorId == CIRRUS_LOGIC_VENDOR_ID) {
|
||||
//
|
||||
// See if this is a 5430 or a 5446 PCI controller
|
||||
//
|
||||
if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_DEVICE_ID) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5446_DEVICE_ID) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
Done:
|
||||
//
|
||||
// Close the PCI I/O Protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
CirrusLogic5430ControllerDriverStart
|
||||
|
||||
TODO: This - add argument and description to function comment
|
||||
TODO: Controller - add argument and description to function comment
|
||||
TODO: RemainingDevicePath - add argument and description to function comment
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CirrusLogic5430ControllerDriverStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
|
||||
|
||||
//
|
||||
// Allocate Private context data for UGA Draw inteface.
|
||||
//
|
||||
Private = AllocateZeroPool (sizeof (CIRRUS_LOGIC_5430_PRIVATE_DATA));
|
||||
if (Private == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Error;
|
||||
}
|
||||
|
||||
//
|
||||
// Set up context record
|
||||
//
|
||||
Private->Signature = CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE;
|
||||
Private->Handle = Controller;
|
||||
|
||||
//
|
||||
// Open PCI I/O Protocol
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Private->Handle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &Private->PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Private->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Status = Private->PciIo->Attributes (
|
||||
Private->PciIo,
|
||||
EfiPciIoAttributeOperationEnable,
|
||||
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (FeaturePcdGet (PcdSupportUga)) {
|
||||
//
|
||||
// Start the UGA Draw software stack.
|
||||
//
|
||||
Status = CirrusLogic5430UgaDrawConstructor (Private);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (FeaturePcdGet (PcdSupportGop)) {
|
||||
Status = CirrusLogic5430GraphicsOutputConstructor (Private);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Private->Handle,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
&Private->UgaDraw,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Private->Handle,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
&Private->UgaDraw,
|
||||
NULL
|
||||
);
|
||||
|
||||
}
|
||||
} else {
|
||||
if (FeaturePcdGet (PcdSupportGop)) {
|
||||
Status = CirrusLogic5430GraphicsOutputConstructor (Private);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Private->Handle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
NULL
|
||||
);
|
||||
|
||||
} else {
|
||||
//
|
||||
// This driver must support eithor GOP or UGA or both.
|
||||
//
|
||||
ASSERT (FALSE);
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Error:
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Private) {
|
||||
if (Private->PciIo) {
|
||||
Private->PciIo->Attributes (
|
||||
Private->PciIo,
|
||||
EfiPciIoAttributeOperationDisable,
|
||||
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Close the PCI I/O Protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Private->Handle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Private->Handle
|
||||
);
|
||||
if (Private) {
|
||||
gBS->FreePool (Private);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
CirrusLogic5430ControllerDriverStop
|
||||
|
||||
TODO: This - add argument and description to function comment
|
||||
TODO: Controller - add argument and description to function comment
|
||||
TODO: NumberOfChildren - add argument and description to function comment
|
||||
TODO: ChildHandleBuffer - add argument and description to function comment
|
||||
TODO: EFI_SUCCESS - add return value to function comment
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CirrusLogic5430ControllerDriverStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
)
|
||||
{
|
||||
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
|
||||
|
||||
EFI_STATUS Status;
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
|
||||
|
||||
if (FeaturePcdGet (PcdSupportUga)) {
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
(VOID **) &UgaDraw,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get our private context information
|
||||
//
|
||||
Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (UgaDraw);
|
||||
CirrusLogic5430UgaDrawDestructor (Private);
|
||||
|
||||
if (FeaturePcdGet (PcdSupportGop)) {
|
||||
CirrusLogic5430GraphicsOutputDestructor (Private);
|
||||
//
|
||||
// Remove the UGA and GOP protocol interface from the system
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Private->Handle,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
&Private->UgaDraw,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// Remove the UGA Draw interface from the system
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Private->Handle,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
&Private->UgaDraw,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID **) &GraphicsOutput,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get our private context information
|
||||
//
|
||||
Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);
|
||||
|
||||
CirrusLogic5430GraphicsOutputDestructor (Private);
|
||||
//
|
||||
// Remove the GOP protocol interface from the system
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Private->Handle,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
&Private->UgaDraw,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Shutdown the hardware
|
||||
//
|
||||
Private->PciIo->Attributes (
|
||||
Private->PciIo,
|
||||
EfiPciIoAttributeOperationDisable,
|
||||
EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,
|
||||
NULL
|
||||
);
|
||||
|
||||
//
|
||||
// Close the PCI I/O Protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Free our instance data
|
||||
//
|
||||
gBS->FreePool (Private);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
CirrusLogic5430UgaDrawDestructor
|
||||
|
||||
TODO: Private - add argument and description to function comment
|
||||
TODO: EFI_SUCCESS - add return value to function comment
|
||||
**/
|
||||
EFI_STATUS
|
||||
CirrusLogic5430UgaDrawDestructor (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
@param Address TODO: add argument description
|
||||
@param Data TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
VOID
|
||||
outb (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
UINTN Address,
|
||||
UINT8 Data
|
||||
)
|
||||
{
|
||||
Private->PciIo->Io.Write (
|
||||
Private->PciIo,
|
||||
EfiPciIoWidthUint8,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
Address,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
@param Address TODO: add argument description
|
||||
@param Data TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
VOID
|
||||
outw (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
UINTN Address,
|
||||
UINT16 Data
|
||||
)
|
||||
{
|
||||
Private->PciIo->Io.Write (
|
||||
Private->PciIo,
|
||||
EfiPciIoWidthUint16,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
Address,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
@param Address TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
UINT8
|
||||
inb (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
UINTN Address
|
||||
)
|
||||
{
|
||||
UINT8 Data;
|
||||
|
||||
Private->PciIo->Io.Read (
|
||||
Private->PciIo,
|
||||
EfiPciIoWidthUint8,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
Address,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
return Data;
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
@param Address TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
UINT16
|
||||
inw (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
UINTN Address
|
||||
)
|
||||
{
|
||||
UINT16 Data;
|
||||
|
||||
Private->PciIo->Io.Read (
|
||||
Private->PciIo,
|
||||
EfiPciIoWidthUint16,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
Address,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
return Data;
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
@param Index TODO: add argument description
|
||||
@param Red TODO: add argument description
|
||||
@param Green TODO: add argument description
|
||||
@param Blue TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
VOID
|
||||
SetPaletteColor (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
UINTN Index,
|
||||
UINT8 Red,
|
||||
UINT8 Green,
|
||||
UINT8 Blue
|
||||
)
|
||||
{
|
||||
outb (Private, PALETTE_INDEX_REGISTER, (UINT8) Index);
|
||||
outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Red >> 2));
|
||||
outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Green >> 2));
|
||||
outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2));
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
VOID
|
||||
SetDefaultPalette (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN RedIndex;
|
||||
UINTN GreenIndex;
|
||||
UINTN BlueIndex;
|
||||
|
||||
Index = 0;
|
||||
for (RedIndex = 0; RedIndex < 8; RedIndex++) {
|
||||
for (GreenIndex = 0; GreenIndex < 8; GreenIndex++) {
|
||||
for (BlueIndex = 0; BlueIndex < 4; BlueIndex++) {
|
||||
SetPaletteColor (Private, Index, (UINT8) (RedIndex << 5), (UINT8) (GreenIndex << 5), (UINT8) (BlueIndex << 6));
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
ClearScreen (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private
|
||||
)
|
||||
{
|
||||
UINT32 Color;
|
||||
|
||||
Color = 0;
|
||||
Private->PciIo->Mem.Write (
|
||||
Private->PciIo,
|
||||
EfiPciIoWidthFillUint32,
|
||||
0,
|
||||
0,
|
||||
0x100000 >> 2,
|
||||
&Color
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
VOID
|
||||
DrawLogo (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
UINTN ScreenWidth,
|
||||
UINTN ScreenHeight
|
||||
)
|
||||
{
|
||||
UINTN Offset;
|
||||
UINTN X;
|
||||
UINTN Y;
|
||||
UINT8 Color;
|
||||
|
||||
Offset = 0;
|
||||
for (Y = 0; Y < ScreenHeight; Y++) {
|
||||
for (X = 0; X < ScreenWidth; X++) {
|
||||
Color = (UINT8) (256 * (X + Y) / (ScreenWidth + ScreenHeight));
|
||||
Private->LineBuffer[X] = Color;
|
||||
}
|
||||
|
||||
Private->PciIo->Mem.Write (
|
||||
Private->PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
0,
|
||||
Offset + (Y * ScreenWidth),
|
||||
ScreenWidth >> 2,
|
||||
Private->LineBuffer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: Add function description
|
||||
|
||||
@param Private TODO: add argument description
|
||||
@param ModeData TODO: add argument description
|
||||
|
||||
TODO: add return values
|
||||
|
||||
**/
|
||||
VOID
|
||||
InitializeGraphicsMode (
|
||||
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,
|
||||
CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData
|
||||
)
|
||||
{
|
||||
UINT8 Byte;
|
||||
UINTN Index;
|
||||
|
||||
outw (Private, SEQ_ADDRESS_REGISTER, 0x1206);
|
||||
outw (Private, SEQ_ADDRESS_REGISTER, 0x0012);
|
||||
|
||||
for (Index = 0; Index < 15; Index++) {
|
||||
outw (Private, SEQ_ADDRESS_REGISTER, ModeData->SeqSettings[Index]);
|
||||
}
|
||||
|
||||
outb (Private, SEQ_ADDRESS_REGISTER, 0x0f);
|
||||
Byte = (UINT8) ((inb (Private, SEQ_DATA_REGISTER) & 0xc7) ^ 0x30);
|
||||
outb (Private, SEQ_DATA_REGISTER, Byte);
|
||||
|
||||
outb (Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting);
|
||||
outw (Private, GRAPH_ADDRESS_REGISTER, 0x0506);
|
||||
outw (Private, SEQ_ADDRESS_REGISTER, 0x0300);
|
||||
outw (Private, CRTC_ADDRESS_REGISTER, 0x2011);
|
||||
|
||||
for (Index = 0; Index < 28; Index++) {
|
||||
outw (Private, CRTC_ADDRESS_REGISTER, (UINT16) ((ModeData->CrtcSettings[Index] << 8) | Index));
|
||||
}
|
||||
|
||||
for (Index = 0; Index < 9; Index++) {
|
||||
outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((GraphicsController[Index] << 8) | Index));
|
||||
}
|
||||
|
||||
inb (Private, INPUT_STATUS_1_REGISTER);
|
||||
|
||||
for (Index = 0; Index < 21; Index++) {
|
||||
outb (Private, ATT_ADDRESS_REGISTER, (UINT8) Index);
|
||||
outb (Private, ATT_ADDRESS_REGISTER, AttributeController[Index]);
|
||||
}
|
||||
|
||||
outb (Private, ATT_ADDRESS_REGISTER, 0x20);
|
||||
|
||||
outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009);
|
||||
outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a);
|
||||
outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b);
|
||||
outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff);
|
||||
|
||||
SetDefaultPalette (Private);
|
||||
ClearScreen (Private);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeCirrusLogic5430 (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gCirrusLogic5430DriverBinding,
|
||||
ImageHandle,
|
||||
&gCirrusLogic5430ComponentName,
|
||||
&gCirrusLogic5430ComponentName2
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Install EFI Driver Supported EFI Version Protocol required for
|
||||
// EFI drivers that are on PCI and other plug in cards.
|
||||
//
|
||||
gCirrusLogic5430DriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ImageHandle,
|
||||
&gEfiDriverSupportedEfiVersionProtocolGuid,
|
||||
&gCirrusLogic5430DriverSupportedEfiVersion,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Status;
|
||||
}
|
Reference in New Issue
Block a user