CirrusLogic5430.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @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 - 2010, Intel Corporation. All rights reserved.<BR>
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
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"
0x10,
NULL,
};
///
/// Generic Attribute Controller Register Settings
///
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
///
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
};
//
// 640 x 480 x 256 color @ 60 Hertz
//
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
};
0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e
};
//
// 800 x 600 x 256 color @ 60 Hertz
//
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
};
0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e
};
//
// 1024 x 768 x 256 color @ 60 Hertz
//
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
};
0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e
};
///
/// Table of supported video modes
///
};
/**
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
**/
)
{
//
// Open the PCI I/O Protocol
//
);
return Status;
}
//
// Read the PCI Configuration Header from the PCI Device
//
0,
&Pci
);
goto Done;
}
//
// 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
//
//
// See if this is a 5430 or a 5446 PCI controller
//
//
// If this is an Intel 945 graphics controller,
// go further check RemainingDevicePath validation
//
if (RemainingDevicePath != NULL) {
//
// Check if RemainingDevicePath is the End of Device Path Node,
// if yes, return EFI_SUCCESS
//
if (!IsDevicePathEnd (Node)) {
//
// If RemainingDevicePath isn't the End of Device Path Node,
// check its validation
//
}
}
}
}
}
Done:
//
// Close the PCI I/O Protocol
//
gBS->CloseProtocol (
);
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
**/
)
{
//
// Allocate Private context data for UGA Draw inteface.
//
goto Error;
}
//
// Set up context record
//
//
// Open PCI I/O Protocol
//
);
goto Error;
}
//
// Get supported PCI attributes
//
0,
);
goto Error;
}
goto Error;
}
//
// Save original PCI attributes
//
0,
);
goto Error;
}
);
goto Error;
}
//
// Get ParentDevicePath
//
(VOID **) &ParentDevicePath
);
goto Error;
}
if (FeaturePcdGet (PcdSupportGop)) {
//
// Set Gop Device Path
//
if (RemainingDevicePath == NULL) {
);
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
//
// If RemainingDevicePath isn't the End of Device Path Node,
// only scan the specified device by RemainingDevicePath
//
} else {
//
// If RemainingDevicePath is the End of Device Path Node,
// don't create child device and return EFI_SUCCESS
//
}
//
// Creat child handle and device path protocol firstly
//
);
}
}
//
// Construct video mode buffer
//
goto Error;
}
if (FeaturePcdGet (PcdSupportUga)) {
//
// Start the UGA Draw software stack.
//
);
} else if (FeaturePcdGet (PcdSupportGop)) {
//
// If RemainingDevicePath is the End of Device Path Node,
// don't create child device and return EFI_SUCCESS
//
} else {
//
// Start the GOP software stack.
//
);
}
} else {
//
// This driver must support eithor GOP or UGA or both.
//
}
if (Private) {
if (PciAttributesSaved == TRUE) {
//
// Restore original PCI attributes
//
);
}
//
// Close the PCI I/O Protocol
//
gBS->CloseProtocol (
);
}
}
}
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
**/
)
{
if (FeaturePcdGet (PcdSupportUga)) {
);
return Status;
}
//
// Get our private context information
//
if (FeaturePcdGet (PcdSupportGop)) {
//
// Remove the UGA and GOP protocol interface from the system
//
);
} else {
//
// Remove the UGA Draw interface from the system
//
);
}
} else {
(VOID **) &GraphicsOutput,
);
return Status;
}
//
// Get our private context information
//
//
// Remove the GOP protocol interface from the system
//
);
}
return Status;
}
//
// Restore original PCI attributes
//
);
//
// Close the PCI I/O Protocol
//
gBS->CloseProtocol (
);
//
// Free our instance data
//
return EFI_SUCCESS;
}
/**
CirrusLogic5430UgaDrawDestructor
TODO: Private - add argument and description to function comment
TODO: EFI_SUCCESS - add return value to function comment
**/
)
{
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
**/
outb (
)
{
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
**/
outw (
)
{
1,
&Data
);
}
/**
TODO: Add function description
@param Private TODO: add argument description
@param Address TODO: add argument description
TODO: add return values
**/
inb (
)
{
1,
&Data
);
return Data;
}
/**
TODO: Add function description
@param Private TODO: add argument description
@param Address TODO: add argument description
TODO: add return values
**/
inw (
)
{
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
**/
)
{
}
/**
TODO: Add function description
@param Private TODO: add argument description
TODO: add return values
**/
)
{
Index = 0;
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
**/
)
{
Color = 0;
0,
0,
0x100000 >> 2,
);
}
/**
TODO: Add function description
@param Private TODO: add argument description
TODO: add return values
**/
DrawLogo (
)
{
}
/**
TODO: Add function description
@param Private TODO: add argument description
@param ModeData TODO: add argument description
TODO: add return values
**/
)
{
1,
);
//
// Read the PCI Configuration Header from the PCI Device
//
}
if (DeviceId != CIRRUS_LOGIC_5446_DEVICE_ID) {
}
}
}
}
}
)
{
);
//
// Install EFI Driver Supported EFI Version Protocol required for
// EFI drivers that are on PCI and other plug in cards.
//
gCirrusLogic5430DriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);
);
return Status;
}