--- /dev/null
+/** @file\r
+ Cirrus Logic 5430 Controller Driver.\r
+ This driver is a sample implementation of the UGA Draw and Graphics Output\r
+ Protocols for the Cirrus Logic 5430 family of PCI video controllers.\r
+ This driver is only usable in the EFI pre-boot environment.\r
+ This sample is intended to show how the UGA Draw and Graphics output Protocol\r
+ is able to function. \r
+ The UGA I/O Protocol is not implemented in this sample.\r
+ A fully compliant EFI UGA driver requires both\r
+ the UGA Draw and the UGA I/O Protocol. Please refer to Microsoft's\r
+ documentation on UGA for details on how to write a UGA driver that is able\r
+ to function both in the EFI pre-boot environment and from the OS runtime.\r
+\r
+ Copyright (c) 2006, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+//\r
+// Cirrus Logic 5430 Controller Driver\r
+//\r
+#include "CirrusLogic5430.h"\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding = {\r
+ CirrusLogic5430ControllerDriverSupported,\r
+ CirrusLogic5430ControllerDriverStart,\r
+ CirrusLogic5430ControllerDriverStop,\r
+ 0x10,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+///\r
+/// Generic Attribute Controller Register Settings\r
+///\r
+UINT8 AttributeController[21] = {\r
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \r
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, \r
+ 0x41, 0x00, 0x0F, 0x00, 0x00\r
+};\r
+\r
+///\r
+/// Generic Graphics Controller Register Settings\r
+///\r
+UINT8 GraphicsController[9] = {\r
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF\r
+};\r
+\r
+//\r
+// 640 x 480 x 256 color @ 60 Hertz\r
+//\r
+UINT8 Crtc_640_480_256_60[28] = {\r
+ 0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,\r
+ 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \r
+ 0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,\r
+ 0xff, 0x00, 0x00, 0x22\r
+};\r
+\r
+UINT16 Seq_640_480_256_60[15] = {\r
+ 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b, \r
+ 0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e\r
+};\r
+\r
+//\r
+// 800 x 600 x 256 color @ 60 Hertz\r
+//\r
+UINT8 Crtc_800_600_256_60[28] = {\r
+ 0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0, \r
+ 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \r
+ 0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,\r
+ 0xFF, 0x00, 0x00, 0x22\r
+};\r
+\r
+UINT16 Seq_800_600_256_60[15] = {\r
+ 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b, \r
+ 0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e\r
+};\r
+\r
+//\r
+// 1024 x 768 x 256 color @ 60 Hertz\r
+//\r
+UINT8 Crtc_1024_768_256_60[28] = {\r
+ 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD, \r
+ 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \r
+ 0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,\r
+ 0xFF, 0x4A, 0x00, 0x22\r
+};\r
+\r
+UINT16 Seq_1024_768_256_60[15] = {\r
+ 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b, \r
+ 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e\r
+};\r
+\r
+///\r
+/// Table of supported video modes\r
+///\r
+CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[] = {\r
+ { 640, 480, 8, 60, Crtc_640_480_256_60, Seq_640_480_256_60, 0xe3 },\r
+ { 800, 600, 8, 60, Crtc_800_600_256_60, Seq_800_600_256_60, 0xef }, \r
+ { 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef } \r
+};\r
+\r
+/**\r
+ CirrusLogic5430ControllerDriverSupported\r
+\r
+ TODO: This - add argument and description to function comment\r
+ TODO: Controller - add argument and description to function comment\r
+ TODO: RemainingDevicePath - add argument and description to function comment\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ControllerDriverSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+\r
+ //\r
+ // Open the PCI I/O Protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Read the PCI Configuration Header from the PCI Device\r
+ //\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ Status = EFI_UNSUPPORTED;\r
+ //\r
+ // See if the I/O enable is on. Most systems only allow one VGA device to be turned on\r
+ // at a time, so see if this is one that is turned on.\r
+ //\r
+ // if (((Pci.Hdr.Command & 0x01) == 0x01)) {\r
+ //\r
+ // See if this is a Cirrus Logic PCI controller\r
+ //\r
+ if (Pci.Hdr.VendorId == CIRRUS_LOGIC_VENDOR_ID) {\r
+ //\r
+ // See if this is a 5430 or a 5446 PCI controller\r
+ //\r
+ if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_DEVICE_ID) {\r
+ Status = EFI_SUCCESS;\r
+ }\r
+\r
+ if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID) {\r
+ Status = EFI_SUCCESS;\r
+ }\r
+\r
+ if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5446_DEVICE_ID) {\r
+ Status = EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+Done:\r
+ //\r
+ // Close the PCI I/O Protocol\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ CirrusLogic5430ControllerDriverStart\r
+\r
+ TODO: This - add argument and description to function comment\r
+ TODO: Controller - add argument and description to function comment\r
+ TODO: RemainingDevicePath - add argument and description to function comment\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ControllerDriverStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+\r
+ //\r
+ // Allocate Private context data for UGA Draw inteface.\r
+ //\r
+ Private = AllocateZeroPool (sizeof (CIRRUS_LOGIC_5430_PRIVATE_DATA));\r
+ if (Private == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+\r
+ //\r
+ // Set up context record\r
+ //\r
+ Private->Signature = CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE;\r
+ Private->Handle = Controller;\r
+\r
+ //\r
+ // Open PCI I/O Protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Private->Handle,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &Private->PciIo,\r
+ This->DriverBindingHandle,\r
+ Private->Handle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ Status = Private->PciIo->Attributes (\r
+ Private->PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ if (FeaturePcdGet (PcdSupportUga)) {\r
+ //\r
+ // Start the UGA Draw software stack.\r
+ //\r
+ Status = CirrusLogic5430UgaDrawConstructor (Private);\r
+ ASSERT_EFI_ERROR (Status);\r
+ if (FeaturePcdGet (PcdSupportGop)) {\r
+ Status = CirrusLogic5430GraphicsOutputConstructor (Private);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Private->Handle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ &Private->UgaDraw,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &Private->GraphicsOutput,\r
+ NULL\r
+ );\r
+ } else {\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Private->Handle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ &Private->UgaDraw,\r
+ NULL\r
+ );\r
+\r
+ }\r
+ } else {\r
+ if (FeaturePcdGet (PcdSupportGop)) {\r
+ Status = CirrusLogic5430GraphicsOutputConstructor (Private);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Private->Handle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &Private->GraphicsOutput,\r
+ NULL\r
+ );\r
+ \r
+ } else {\r
+ //\r
+ // This driver must support eithor GOP or UGA or both.\r
+ // \r
+ ASSERT (FALSE);\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+ \r
+\r
+Error:\r
+ if (EFI_ERROR (Status)) {\r
+ if (Private) {\r
+ if (Private->PciIo) {\r
+ Private->PciIo->Attributes (\r
+ Private->PciIo,\r
+ EfiPciIoAttributeOperationDisable,\r
+ EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+\r
+ //\r
+ // Close the PCI I/O Protocol\r
+ //\r
+ gBS->CloseProtocol (\r
+ Private->Handle,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Private->Handle\r
+ );\r
+ if (Private) {\r
+ gBS->FreePool (Private);\r
+ }\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ CirrusLogic5430ControllerDriverStop\r
+\r
+ TODO: This - add argument and description to function comment\r
+ TODO: Controller - add argument and description to function comment\r
+ TODO: NumberOfChildren - add argument and description to function comment\r
+ TODO: ChildHandleBuffer - add argument and description to function comment\r
+ TODO: EFI_SUCCESS - add return value to function comment\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ControllerDriverStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+{\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+\r
+ EFI_STATUS Status;\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+\r
+ if (FeaturePcdGet (PcdSupportUga)) {\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &UgaDraw,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Get our private context information\r
+ //\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (UgaDraw);\r
+ CirrusLogic5430UgaDrawDestructor (Private);\r
+\r
+ if (FeaturePcdGet (PcdSupportGop)) {\r
+ CirrusLogic5430GraphicsOutputDestructor (Private);\r
+ //\r
+ // Remove the UGA and GOP protocol interface from the system\r
+ //\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ Private->Handle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ &Private->UgaDraw,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &Private->GraphicsOutput,\r
+ NULL\r
+ );\r
+ } else {\r
+ //\r
+ // Remove the UGA Draw interface from the system\r
+ //\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ Private->Handle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ &Private->UgaDraw,\r
+ NULL\r
+ );\r
+ }\r
+ } else {\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &GraphicsOutput,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get our private context information\r
+ //\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);\r
+\r
+ CirrusLogic5430GraphicsOutputDestructor (Private);\r
+ //\r
+ // Remove the GOP protocol interface from the system\r
+ //\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ Private->Handle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ &Private->UgaDraw,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &Private->GraphicsOutput,\r
+ NULL\r
+ );\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+\r
+ //\r
+ // Shutdown the hardware\r
+ //\r
+ Private->PciIo->Attributes (\r
+ Private->PciIo,\r
+ EfiPciIoAttributeOperationDisable,\r
+ EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,\r
+ NULL\r
+ );\r
+\r
+ //\r
+ // Close the PCI I/O Protocol\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ //\r
+ // Free our instance data\r
+ //\r
+ gBS->FreePool (Private);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ CirrusLogic5430UgaDrawDestructor\r
+\r
+ TODO: Private - add argument and description to function comment\r
+ TODO: EFI_SUCCESS - add return value to function comment\r
+**/\r
+EFI_STATUS\r
+CirrusLogic5430UgaDrawDestructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+ @param Address TODO: add argument description\r
+ @param Data TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+VOID\r
+outb (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address,\r
+ UINT8 Data\r
+ )\r
+{\r
+ Private->PciIo->Io.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ Address,\r
+ 1,\r
+ &Data\r
+ );\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+ @param Address TODO: add argument description\r
+ @param Data TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+VOID\r
+outw (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address,\r
+ UINT16 Data\r
+ )\r
+{\r
+ Private->PciIo->Io.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint16,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ Address,\r
+ 1,\r
+ &Data\r
+ );\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+ @param Address TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+UINT8\r
+inb (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address\r
+ )\r
+{\r
+ UINT8 Data;\r
+\r
+ Private->PciIo->Io.Read (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ Address,\r
+ 1,\r
+ &Data\r
+ );\r
+ return Data;\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+ @param Address TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+UINT16\r
+inw (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address\r
+ )\r
+{\r
+ UINT16 Data;\r
+\r
+ Private->PciIo->Io.Read (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint16,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ Address,\r
+ 1,\r
+ &Data\r
+ );\r
+ return Data;\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+ @param Index TODO: add argument description\r
+ @param Red TODO: add argument description\r
+ @param Green TODO: add argument description\r
+ @param Blue TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+VOID\r
+SetPaletteColor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Index,\r
+ UINT8 Red,\r
+ UINT8 Green,\r
+ UINT8 Blue\r
+ )\r
+{\r
+ outb (Private, PALETTE_INDEX_REGISTER, (UINT8) Index);\r
+ outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Red >> 2));\r
+ outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Green >> 2));\r
+ outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2));\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+VOID\r
+SetDefaultPalette (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ UINTN Index;\r
+ UINTN RedIndex;\r
+ UINTN GreenIndex;\r
+ UINTN BlueIndex;\r
+\r
+ Index = 0;\r
+ for (RedIndex = 0; RedIndex < 8; RedIndex++) {\r
+ for (GreenIndex = 0; GreenIndex < 8; GreenIndex++) {\r
+ for (BlueIndex = 0; BlueIndex < 4; BlueIndex++) {\r
+ SetPaletteColor (Private, Index, (UINT8) (RedIndex << 5), (UINT8) (GreenIndex << 5), (UINT8) (BlueIndex << 6));\r
+ Index++;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+STATIC\r
+VOID\r
+ClearScreen (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ UINT32 Color;\r
+\r
+ Color = 0;\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint32,\r
+ 0,\r
+ 0,\r
+ 0x100000 >> 2,\r
+ &Color\r
+ );\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+VOID\r
+DrawLogo (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN ScreenWidth,\r
+ UINTN ScreenHeight\r
+ )\r
+{\r
+ UINTN Offset;\r
+ UINTN X;\r
+ UINTN Y;\r
+ UINT8 Color;\r
+\r
+ Offset = 0;\r
+ for (Y = 0; Y < ScreenHeight; Y++) {\r
+ for (X = 0; X < ScreenWidth; X++) {\r
+ Color = (UINT8) (256 * (X + Y) / (ScreenWidth + ScreenHeight));\r
+ Private->LineBuffer[X] = Color;\r
+ }\r
+\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ Offset + (Y * ScreenWidth),\r
+ ScreenWidth >> 2,\r
+ Private->LineBuffer\r
+ );\r
+ }\r
+}\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param Private TODO: add argument description\r
+ @param ModeData TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+VOID\r
+InitializeGraphicsMode (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData\r
+ )\r
+{\r
+ UINT8 Byte;\r
+ UINTN Index;\r
+\r
+ outw (Private, SEQ_ADDRESS_REGISTER, 0x1206);\r
+ outw (Private, SEQ_ADDRESS_REGISTER, 0x0012);\r
+\r
+ for (Index = 0; Index < 15; Index++) {\r
+ outw (Private, SEQ_ADDRESS_REGISTER, ModeData->SeqSettings[Index]);\r
+ }\r
+\r
+ outb (Private, SEQ_ADDRESS_REGISTER, 0x0f);\r
+ Byte = (UINT8) ((inb (Private, SEQ_DATA_REGISTER) & 0xc7) ^ 0x30);\r
+ outb (Private, SEQ_DATA_REGISTER, Byte);\r
+\r
+ outb (Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0506);\r
+ outw (Private, SEQ_ADDRESS_REGISTER, 0x0300);\r
+ outw (Private, CRTC_ADDRESS_REGISTER, 0x2011);\r
+\r
+ for (Index = 0; Index < 28; Index++) {\r
+ outw (Private, CRTC_ADDRESS_REGISTER, (UINT16) ((ModeData->CrtcSettings[Index] << 8) | Index));\r
+ }\r
+\r
+ for (Index = 0; Index < 9; Index++) {\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((GraphicsController[Index] << 8) | Index));\r
+ }\r
+\r
+ inb (Private, INPUT_STATUS_1_REGISTER);\r
+\r
+ for (Index = 0; Index < 21; Index++) {\r
+ outb (Private, ATT_ADDRESS_REGISTER, (UINT8) Index);\r
+ outb (Private, ATT_ADDRESS_REGISTER, AttributeController[Index]);\r
+ }\r
+\r
+ outb (Private, ATT_ADDRESS_REGISTER, 0x20);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b);\r
+ outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff);\r
+\r
+ SetDefaultPalette (Private);\r
+ ClearScreen (Private);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCirrusLogic5430 (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gCirrusLogic5430DriverBinding,\r
+ ImageHandle,\r
+ &gCirrusLogic5430ComponentName,\r
+ &gCirrusLogic5430ComponentName2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Install EFI Driver Supported EFI Version Protocol required for \r
+ // EFI drivers that are on PCI and other plug in cards.\r
+ //\r
+ gCirrusLogic5430DriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &ImageHandle,\r
+ &gEfiDriverSupportedEfiVersionProtocolGuid,\r
+ &gCirrusLogic5430DriverSupportedEfiVersion,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+/** @file\r
+ Cirrus Logic 5430 Controller Driver\r
+\r
+ Copyright (c) 2006, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+//\r
+// Cirrus Logic 5430 Controller Driver\r
+//\r
+\r
+#ifndef _CIRRUS_LOGIC_5430_H_\r
+#define _CIRRUS_LOGIC_5430_H_\r
+\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/DriverSupportedEfiVersion.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#include <IndustryStandard/pci22.h>\r
+//\r
+// Cirrus Logic 5430 PCI Configuration Header values\r
+//\r
+#define CIRRUS_LOGIC_VENDOR_ID 0x1013\r
+#define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8\r
+#define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0\r
+#define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8\r
+\r
+//\r
+// Cirrus Logic Graphical Mode Data\r
+//\r
+#define CIRRUS_LOGIC_5430_MODE_COUNT 3\r
+\r
+typedef struct {\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+} CIRRUS_LOGIC_5430_MODE_DATA;\r
+\r
+#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r
+\r
+//\r
+// Cirrus Logic 5440 Private Data Structure\r
+//\r
+#define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')\r
+\r
+typedef struct {\r
+ UINT64 Signature;\r
+ EFI_HANDLE Handle;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ EFI_UGA_DRAW_PROTOCOL UgaDraw;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
+ UINTN CurrentMode;\r
+ UINTN MaxMode;\r
+ CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];\r
+ UINT8 *LineBuffer;\r
+ BOOLEAN HardwareNeedsStarting;\r
+} CIRRUS_LOGIC_5430_PRIVATE_DATA;\r
+\r
+///\r
+/// Video Mode structure\r
+///\r
+typedef struct {\r
+ UINT32 Width;\r
+ UINT32 Height;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ UINT8 *CrtcSettings;\r
+ UINT16 *SeqSettings;\r
+ UINT8 MiscSetting;\r
+} CIRRUS_LOGIC_5430_VIDEO_MODES;\r
+\r
+#define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \\r
+ CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)\r
+\r
+#define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \\r
+ CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)\r
+\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern UINT8 AttributeController[];\r
+extern UINT8 GraphicsController[];\r
+extern UINT8 Crtc_640_480_256_60[];\r
+extern UINT16 Seq_640_480_256_60[];\r
+extern UINT8 Crtc_800_600_256_60[];\r
+extern UINT16 Seq_800_600_256_60[];\r
+extern UINT8 Crtc_1024_768_256_60[];\r
+extern UINT16 Seq_1024_768_256_60[];\r
+extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[];\r
+extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2;\r
+extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion;\r
+\r
+//\r
+// Io Registers defined by VGA\r
+//\r
+#define CRTC_ADDRESS_REGISTER 0x3d4\r
+#define CRTC_DATA_REGISTER 0x3d5\r
+#define SEQ_ADDRESS_REGISTER 0x3c4\r
+#define SEQ_DATA_REGISTER 0x3c5\r
+#define GRAPH_ADDRESS_REGISTER 0x3ce\r
+#define GRAPH_DATA_REGISTER 0x3cf\r
+#define ATT_ADDRESS_REGISTER 0x3c0\r
+#define MISC_OUTPUT_REGISTER 0x3c2\r
+#define INPUT_STATUS_1_REGISTER 0x3da\r
+#define DAC_PIXEL_MASK_REGISTER 0x3c6\r
+#define PALETTE_INDEX_REGISTER 0x3c8\r
+#define PALETTE_DATA_REGISTER 0x3c9\r
+\r
+//\r
+// UGA Draw Hardware abstraction internal worker functions\r
+//\r
+EFI_STATUS\r
+CirrusLogic5430UgaDrawConstructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+CirrusLogic5430UgaDrawDestructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+//\r
+// Graphics Output Hardware abstraction internal worker functions\r
+//\r
+EFI_STATUS\r
+CirrusLogic5430GraphicsOutputConstructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+CirrusLogic5430GraphicsOutputDestructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+;\r
+\r
+\r
+//\r
+// EFI_DRIVER_BINDING_PROTOCOL Protocol Interface\r
+//\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param This TODO: add argument description\r
+ @param Controller TODO: add argument description\r
+ @param RemainingDevicePath TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ControllerDriverSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param This TODO: add argument description\r
+ @param Controller TODO: add argument description\r
+ @param RemainingDevicePath TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ControllerDriverStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+;\r
+\r
+/**\r
+ TODO: Add function description\r
+\r
+ @param This TODO: add argument description\r
+ @param Controller TODO: add argument description\r
+ @param NumberOfChildren TODO: add argument description\r
+ @param ChildHandleBuffer TODO: add argument description\r
+\r
+ TODO: add return values\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ControllerDriverStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+;\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+ This function retrieves the user readable name of a driver in the form of a\r
+ Unicode string. If the driver specified by This has a user readable name in\r
+ the language specified by Language, then a pointer to the driver name is\r
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+ by This does not support the language specified by Language,\r
+ then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified\r
+ in RFC 3066 or ISO 639-2 language code format.\r
+\r
+ @param DriverName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ driver specified by This in the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
+ This and the language specified by Language was\r
+ returned in DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by a driver.\r
+\r
+ This function retrieves the user readable name of the controller specified by\r
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+ driver specified by This has a user readable name in the language specified by\r
+ Language, then a pointer to the controller name is returned in ControllerName,\r
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
+ managing the controller specified by ControllerHandle and ChildHandle,\r
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param ControllerHandle[in] The handle of a controller that the driver\r
+ specified by This is managing. This handle\r
+ specifies the controller whose name is to be\r
+ returned.\r
+\r
+ @param ChildHandle[in] The handle of the child controller to retrieve\r
+ the name of. This is an optional parameter that\r
+ may be NULL. It will be NULL for device\r
+ drivers. It will also be NULL for a bus drivers\r
+ that wish to retrieve the name of the bus\r
+ controller. It will not be NULL for a bus\r
+ driver that wishes to retrieve the name of a\r
+ child controller.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified in\r
+ RFC 3066 or ISO 639-2 language code format.\r
+\r
+ @param ControllerName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ controller specified by ControllerHandle and\r
+ ChildHandle in the language specified by\r
+ Language from the point of view of the driver\r
+ specified by This.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the user readable name in\r
+ the language specified by Language for the\r
+ driver specified by This was returned in\r
+ DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+ EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
+ managing the controller specified by\r
+ ControllerHandle and ChildHandle.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+\r
+//\r
+// Local Function Prototypes\r
+//\r
+VOID\r
+InitializeGraphicsMode (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData\r
+ );\r
+\r
+VOID\r
+SetPaletteColor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Index,\r
+ UINT8 Red,\r
+ UINT8 Green,\r
+ UINT8 Blue\r
+ );\r
+\r
+VOID\r
+SetDefaultPalette (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ );\r
+\r
+VOID\r
+DrawLogo (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN ScreenWidth,\r
+ UINTN ScreenHeight\r
+ );\r
+\r
+VOID\r
+outb (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address,\r
+ UINT8 Data\r
+ );\r
+\r
+VOID\r
+outw (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address,\r
+ UINT16 Data\r
+ );\r
+\r
+UINT8\r
+inb (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address\r
+ );\r
+\r
+UINT16\r
+inw (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r
+ UINTN Address\r
+ );\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Component description file for CirrusLogic5430 module\r
+#\r
+# Cirrus Logic 5430 Controller Driver.This driver is a sample implementation\r
+# of the UGA Draw Protocol for the Cirrus Logic 5430 family of PCI video controllers.\r
+# This driver is only usable in the EFI pre-boot environment. This sample is\r
+# intended to show how the UGA Draw Protocol is able to function. The UGA I/O\r
+# Protocol is not implemented in this sample. A fully compliant EFI UGA driver\r
+# requires both the UGA Draw and the UGA I/O Protocol. Please refer to Microsoft's\r
+# documentation on UGA for details on how to write a UGA driver that is able\r
+# to function both in the EFI pre-boot environment and from the OS runtime.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = CirrusLogic5430UgaDraw\r
+ FILE_GUID = 555F76EA-785F-40d7-9174-153C43636C68\r
+ MODULE_TYPE = UEFI_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = InitializeCirrusLogic5430\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+# DRIVER_BINDING = gCirrusLogic5430DriverBinding \r
+# COMPONENT_NAME = gCirrusLogic5430ComponentName \r
+#\r
+\r
+[Sources.common]\r
+ ComponentName.c\r
+ DriverSupportedEfiVersion.c\r
+ CirrusLogic5430UgaDraw.c\r
+ CirrusLogic5430GraphicsOutput.c\r
+ CirrusLogic5430.c\r
+ CirrusLogic5430.h\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OptionRomPkg/OptionRomPkg.dec\r
+\r
+[LibraryClasses]\r
+ UefiBootServicesTableLib\r
+ MemoryAllocationLib\r
+ UefiLib\r
+ UefiDriverEntryPoint\r
+ DebugLib\r
+\r
+\r
+[Protocols]\r
+ gEfiDriverSupportedEfiVersionProtocolGuid # PROTOCOL ALWAYS_PRODUCED\r
+ gEfiUgaDrawProtocolGuid # PROTOCOL BY_START\r
+ gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START\r
+ gEfiPciIoProtocolGuid # PROTOCOL TO_START\r
+ \r
+[FeaturePcd.common]\r
+ gOptionRomPkgTokenSpaceGuid.PcdSupportGop\r
+ gOptionRomPkgTokenSpaceGuid.PcdSupportUga\r
+\r
+[Pcd]\r
+ gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion\r
--- /dev/null
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation \r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ UefiCirrusLogic5430GraphicsOutput.c\r
+\r
+Abstract:\r
+\r
+ This file produces the graphics abstration of Graphics Output Protocol. It is called by \r
+ CirrusLogic5430.c file which deals with the EFI 1.1 driver model. \r
+ This file just does graphics.\r
+\r
+--*/\r
+\r
+#include "CirrusLogic5430.h"\r
+\r
+//\r
+// Graphics Output Protocol Member Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430GraphicsOutputQueryMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN UINT32 ModeNumber,\r
+ OUT UINTN *SizeOfInfo,\r
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Graphics Output protocol interface to query video mode\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ModeNumber - The mode number to return information on.\r
+ Info - Caller allocated buffer that returns information about ModeNumber.\r
+ SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - Mode information returned.\r
+ EFI_BUFFER_TOO_SMALL - The Info buffer was too small.\r
+ EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.\r
+ EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()\r
+ EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+--*/\r
+{\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+ if (Private->HardwareNeedsStarting) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r
+ if (*Info == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+\r
+ (*Info)->Version = 0;\r
+ (*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution;\r
+ (*Info)->VerticalResolution = Private->ModeData[ModeNumber].VerticalResolution;\r
+ (*Info)->PixelFormat = PixelBltOnly;\r
+ (*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430GraphicsOutputSetMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN UINT32 ModeNumber\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Graphics Output protocol interface to set video mode\r
+\r
+ Arguments:\r
+ This - Protocol instance pointer.\r
+ ModeNumber - The mode number to be set.\r
+\r
+ Returns:\r
+ EFI_SUCCESS - Graphics mode was changed.\r
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
+ EFI_UNSUPPORTED - ModeNumber is not supported by this device.\r
+\r
+--*/\r
+{\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+ CIRRUS_LOGIC_5430_MODE_DATA *ModeData;\r
+\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+ if (ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ ModeData = &Private->ModeData[ModeNumber];\r
+\r
+ if (Private->LineBuffer) {\r
+ gBS->FreePool (Private->LineBuffer);\r
+ }\r
+\r
+ Private->LineBuffer = NULL;\r
+ Private->LineBuffer = AllocatePool (ModeData->HorizontalResolution);\r
+ if (Private->LineBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ InitializeGraphicsMode (Private, &CirrusLogic5430VideoModes[ModeNumber]);\r
+\r
+ This->Mode->Mode = ModeNumber;\r
+ This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;\r
+ This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;\r
+ This->Mode->Info->PixelFormat = PixelBltOnly;\r
+ This->Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;\r
+ This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+\r
+ This->Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL;\r
+ This->Mode->FrameBufferSize = 0;\r
+\r
+ Private->HardwareNeedsStarting = FALSE;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430GraphicsOutputBlt (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Graphics Output protocol instance to block transfer for CirrusLogic device\r
+\r
+Arguments:\r
+\r
+ This - Pointer to Graphics Output protocol instance\r
+ BltBuffer - The data to transfer to screen\r
+ BltOperation - The operation to perform\r
+ SourceX - The X coordinate of the source for BltOperation\r
+ SourceY - The Y coordinate of the source for BltOperation\r
+ DestinationX - The X coordinate of the destination for BltOperation\r
+ DestinationY - The Y coordinate of the destination for BltOperation\r
+ Width - The width of a rectangle in the blt rectangle in pixels\r
+ Height - The height of a rectangle in the blt rectangle in pixels\r
+ Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
+ If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
+ If a subrectangle of the BltBuffer is used, then Delta represents\r
+ the number of bytes in a row of the BltBuffer.\r
+\r
+Returns:\r
+\r
+ EFI_INVALID_PARAMETER - Invalid parameter passed in\r
+ EFI_SUCCESS - Blt operation success\r
+\r
+--*/\r
+{\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+ EFI_TPL OriginalTPL;\r
+ UINTN DstY;\r
+ UINTN SrcY;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+ UINTN X;\r
+ UINT8 Pixel;\r
+ UINT32 WidePixel;\r
+ UINTN ScreenWidth;\r
+ UINTN Offset;\r
+ UINTN SourceOffset;\r
+ UINT32 CurrentMode;\r
+\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+ if ((BltOperation < 0) || (BltOperation >= EfiGraphicsOutputBltOperationMax)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Width == 0 || Height == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // If Delta is zero, then the entire BltBuffer is being used, so Delta\r
+ // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,\r
+ // the number of bytes in each row can be computed.\r
+ //\r
+ if (Delta == 0) {\r
+ Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+ }\r
+\r
+ //\r
+ // We need to fill the Virtual Screen buffer with the blt data.\r
+ // The virtual screen is upside down, as the first row is the bootom row of\r
+ // the image.\r
+ //\r
+\r
+ CurrentMode = This->Mode->Mode;\r
+ //\r
+ // Make sure the SourceX, SourceY, DestinationX, DestinationY, Width, and Height parameters\r
+ // are valid for the operation and the current screen geometry.\r
+ //\r
+ if (BltOperation == EfiBltVideoToBltBuffer) {\r
+ //\r
+ // Video to BltBuffer: Source is Video, destination is BltBuffer\r
+ //\r
+ if (SourceY + Height > Private->ModeData[CurrentMode].VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (SourceX + Width > Private->ModeData[CurrentMode].HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ } else {\r
+ //\r
+ // BltBuffer to Video: Source is BltBuffer, destination is Video\r
+ //\r
+ if (DestinationY + Height > Private->ModeData[CurrentMode].VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (DestinationX + Width > Private->ModeData[CurrentMode].HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+ //\r
+ // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r
+ // We would not want a timer based event (Cursor, ...) to come in while we are\r
+ // doing this operation.\r
+ //\r
+ OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ switch (BltOperation) {\r
+ case EfiBltVideoToBltBuffer:\r
+ //\r
+ // Video to BltBuffer: Source is Video, destination is BltBuffer\r
+ //\r
+ for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {\r
+\r
+ Offset = (SrcY * Private->ModeData[CurrentMode].HorizontalResolution) + SourceX;\r
+ if (((Offset & 0x03) == 0) && ((Width & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Read (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ Offset,\r
+ Width >> 2,\r
+ Private->LineBuffer\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Read (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ 0,\r
+ Offset,\r
+ Width,\r
+ Private->LineBuffer\r
+ );\r
+ }\r
+\r
+ for (X = 0; X < Width; X++) {\r
+ Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+\r
+ Blt->Red = (UINT8) (Private->LineBuffer[X] & 0xe0);\r
+ Blt->Green = (UINT8) ((Private->LineBuffer[X] & 0x1c) << 3);\r
+ Blt->Blue = (UINT8) ((Private->LineBuffer[X] & 0x03) << 6);\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EfiBltVideoToVideo:\r
+ //\r
+ // Perform hardware acceleration for Video to Video operations\r
+ //\r
+ ScreenWidth = Private->ModeData[CurrentMode].HorizontalResolution;\r
+ SourceOffset = (SourceY * Private->ModeData[CurrentMode].HorizontalResolution) + (SourceX);\r
+ Offset = (DestinationY * Private->ModeData[CurrentMode].HorizontalResolution) + (DestinationX);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0000);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0010);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0012);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0014);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0001);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0011);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0013);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0015);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((Width << 8) & 0xff00) | 0x20));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((Width & 0xff00) | 0x21));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((Height << 8) & 0xff00) | 0x22));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((Height & 0xff00) | 0x23));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((ScreenWidth << 8) & 0xff00) | 0x24));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((ScreenWidth & 0xff00) | 0x25));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((ScreenWidth << 8) & 0xff00) | 0x26));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((ScreenWidth & 0xff00) | 0x27));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((Offset) << 8) & 0xff00) | 0x28));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((Offset) >> 0) & 0xff00) | 0x29));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((Offset) >> 8) & 0xff00) | 0x2a));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((SourceOffset) << 8) & 0xff00) | 0x2c));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((SourceOffset) >> 0) & 0xff00) | 0x2d));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((SourceOffset) >> 8) & 0xff00) | 0x2e));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x002f);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0030);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0d32);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0033);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0034);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0035);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0231);\r
+\r
+ outb (Private, GRAPH_ADDRESS_REGISTER, 0x31);\r
+ while ((inb (Private, GRAPH_DATA_REGISTER) & 0x01) == 0x01)\r
+ ;\r
+ break;\r
+\r
+ case EfiBltVideoFill:\r
+ Blt = BltBuffer;\r
+ Pixel = (UINT8) ((Blt->Red & 0xe0) | ((Blt->Green >> 3) & 0x1c) | ((Blt->Blue >> 6) & 0x03));\r
+ WidePixel = (Pixel << 8) | Pixel;\r
+ WidePixel = (WidePixel << 16) | WidePixel;\r
+\r
+ if (DestinationX == 0 && Width == Private->ModeData[CurrentMode].HorizontalResolution) {\r
+ Offset = DestinationY * Private->ModeData[CurrentMode].HorizontalResolution;\r
+ if (((Offset & 0x03) == 0) && (((Width * Height) & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint32,\r
+ 0,\r
+ Offset,\r
+ (Width * Height) >> 2,\r
+ &WidePixel\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint8,\r
+ 0,\r
+ Offset,\r
+ Width * Height,\r
+ &Pixel\r
+ );\r
+ }\r
+ } else {\r
+ for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
+ Offset = (DstY * Private->ModeData[CurrentMode].HorizontalResolution) + DestinationX;\r
+ if (((Offset & 0x03) == 0) && ((Width & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint32,\r
+ 0,\r
+ Offset,\r
+ Width >> 2,\r
+ &WidePixel\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint8,\r
+ 0,\r
+ Offset,\r
+ Width,\r
+ &Pixel\r
+ );\r
+ }\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EfiBltBufferToVideo:\r
+ for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
+\r
+ for (X = 0; X < Width; X++) {\r
+ Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (SrcY * Delta) + (SourceX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ Private->LineBuffer[X] = (UINT8) ((Blt->Red & 0xe0) | ((Blt->Green >> 3) & 0x1c) | ((Blt->Blue >> 6) & 0x03));\r
+ }\r
+\r
+ Offset = (DstY * Private->ModeData[CurrentMode].HorizontalResolution) + DestinationX;\r
+\r
+ if (((Offset & 0x03) == 0) && ((Width & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ Offset,\r
+ Width >> 2,\r
+ Private->LineBuffer\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ 0,\r
+ Offset,\r
+ Width,\r
+ Private->LineBuffer\r
+ );\r
+ }\r
+ }\r
+ break;\r
+ default:\r
+ ASSERT (FALSE);\r
+ }\r
+\r
+ gBS->RestoreTPL (OriginalTPL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CirrusLogic5430GraphicsOutputConstructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ UINTN Index;\r
+\r
+\r
+ GraphicsOutput = &Private->GraphicsOutput;\r
+ GraphicsOutput->QueryMode = CirrusLogic5430GraphicsOutputQueryMode;\r
+ GraphicsOutput->SetMode = CirrusLogic5430GraphicsOutputSetMode;\r
+ GraphicsOutput->Blt = CirrusLogic5430GraphicsOutputBlt;\r
+\r
+ //\r
+ // Initialize the private data\r
+ //\r
+ Status = gBS->AllocatePool (\r
+ EfiBootServicesData,\r
+ sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),\r
+ (VOID **) &Private->GraphicsOutput.Mode\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ Status = gBS->AllocatePool (\r
+ EfiBootServicesData,\r
+ sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
+ (VOID **) &Private->GraphicsOutput.Mode->Info\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ Private->GraphicsOutput.Mode->MaxMode = CIRRUS_LOGIC_5430_MODE_COUNT;\r
+ Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
+ for (Index = 0; Index < Private->GraphicsOutput.Mode->MaxMode; Index++) {\r
+ Private->ModeData[Index].HorizontalResolution = CirrusLogic5430VideoModes[Index].Width;\r
+ Private->ModeData[Index].VerticalResolution = CirrusLogic5430VideoModes[Index].Height;\r
+ Private->ModeData[Index].ColorDepth = 32;\r
+ Private->ModeData[Index].RefreshRate = CirrusLogic5430VideoModes[Index].RefreshRate;\r
+ }\r
+\r
+ Private->HardwareNeedsStarting = TRUE;\r
+ Private->LineBuffer = NULL;\r
+\r
+ //\r
+ // Initialize the hardware\r
+ //\r
+ GraphicsOutput->SetMode (GraphicsOutput, 0);\r
+ DrawLogo (\r
+ Private,\r
+ Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,\r
+ Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+CirrusLogic5430GraphicsOutputDestructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+{\r
+ if (Private->GraphicsOutput.Mode != NULL) {\r
+ if (Private->GraphicsOutput.Mode->Info != NULL) {\r
+ gBS->FreePool (Private->GraphicsOutput.Mode->Info);\r
+ }\r
+ gBS->FreePool (Private->GraphicsOutput.Mode);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
--- /dev/null
+/** @file\r
+ This file produces the graphics abstration of UGA Draw. It is called by \r
+ CirrusLogic5430.c file which deals with the EFI 1.1 driver model. \r
+ This file just does graphics.\r
+\r
+ Copyright (c) 2006, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "CirrusLogic5430.h"\r
+\r
+//\r
+// UGA Draw Protocol Member Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430UgaDrawGetMode (\r
+ IN EFI_UGA_DRAW_PROTOCOL *This,\r
+ OUT UINT32 *HorizontalResolution,\r
+ OUT UINT32 *VerticalResolution,\r
+ OUT UINT32 *ColorDepth,\r
+ OUT UINT32 *RefreshRate\r
+ )\r
+{\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This);\r
+\r
+ if (Private->HardwareNeedsStarting) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ if ((HorizontalResolution == NULL) ||\r
+ (VerticalResolution == NULL) ||\r
+ (ColorDepth == NULL) ||\r
+ (RefreshRate == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *HorizontalResolution = Private->ModeData[Private->CurrentMode].HorizontalResolution;\r
+ *VerticalResolution = Private->ModeData[Private->CurrentMode].VerticalResolution;\r
+ *ColorDepth = Private->ModeData[Private->CurrentMode].ColorDepth;\r
+ *RefreshRate = Private->ModeData[Private->CurrentMode].RefreshRate;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430UgaDrawSetMode (\r
+ IN EFI_UGA_DRAW_PROTOCOL *This,\r
+ IN UINT32 HorizontalResolution,\r
+ IN UINT32 VerticalResolution,\r
+ IN UINT32 ColorDepth,\r
+ IN UINT32 RefreshRate\r
+ )\r
+{\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+ UINTN Index;\r
+\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This);\r
+\r
+ for (Index = 0; Index < Private->MaxMode; Index++) {\r
+\r
+ if (HorizontalResolution != Private->ModeData[Index].HorizontalResolution) {\r
+ continue;\r
+ }\r
+\r
+ if (VerticalResolution != Private->ModeData[Index].VerticalResolution) {\r
+ continue;\r
+ }\r
+\r
+ if (ColorDepth != Private->ModeData[Index].ColorDepth) {\r
+ continue;\r
+ }\r
+\r
+ if (RefreshRate != Private->ModeData[Index].RefreshRate) {\r
+ continue;\r
+ }\r
+\r
+ if (Private->LineBuffer) {\r
+ gBS->FreePool (Private->LineBuffer);\r
+ }\r
+\r
+ Private->LineBuffer = NULL;\r
+ Private->LineBuffer = AllocatePool (HorizontalResolution);\r
+ if (Private->LineBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ InitializeGraphicsMode (Private, &CirrusLogic5430VideoModes[Index]);\r
+\r
+ Private->CurrentMode = Index;\r
+\r
+ Private->HardwareNeedsStarting = FALSE;\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430UgaDrawBlt (\r
+ IN EFI_UGA_DRAW_PROTOCOL *This,\r
+ IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_UGA_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta\r
+ )\r
+{\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
+ EFI_TPL OriginalTPL;\r
+ UINTN DstY;\r
+ UINTN SrcY;\r
+ EFI_UGA_PIXEL *Blt;\r
+ UINTN X;\r
+ UINT8 Pixel;\r
+ UINT32 WidePixel;\r
+ UINTN ScreenWidth;\r
+ UINTN Offset;\r
+ UINTN SourceOffset;\r
+\r
+ Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This);\r
+\r
+ if ((BltOperation < 0) || (BltOperation >= EfiUgaBltMax)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Width == 0 || Height == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // If Delta is zero, then the entire BltBuffer is being used, so Delta\r
+ // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,\r
+ // the number of bytes in each row can be computed.\r
+ //\r
+ if (Delta == 0) {\r
+ Delta = Width * sizeof (EFI_UGA_PIXEL);\r
+ }\r
+\r
+ //\r
+ // We need to fill the Virtual Screen buffer with the blt data.\r
+ // The virtual screen is upside down, as the first row is the bootom row of\r
+ // the image.\r
+ //\r
+\r
+ //\r
+ // Make sure the SourceX, SourceY, DestinationX, DestinationY, Width, and Height parameters\r
+ // are valid for the operation and the current screen geometry.\r
+ //\r
+ if (BltOperation == EfiUgaVideoToBltBuffer) {\r
+ //\r
+ // Video to BltBuffer: Source is Video, destination is BltBuffer\r
+ //\r
+ if (SourceY + Height > Private->ModeData[Private->CurrentMode].VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (SourceX + Width > Private->ModeData[Private->CurrentMode].HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ } else {\r
+ //\r
+ // BltBuffer to Video: Source is BltBuffer, destination is Video\r
+ //\r
+ if (DestinationY + Height > Private->ModeData[Private->CurrentMode].VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (DestinationX + Width > Private->ModeData[Private->CurrentMode].HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+ //\r
+ // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r
+ // We would not want a timer based event (Cursor, ...) to come in while we are\r
+ // doing this operation.\r
+ //\r
+ OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ switch (BltOperation) {\r
+ case EfiUgaVideoToBltBuffer:\r
+ //\r
+ // Video to BltBuffer: Source is Video, destination is BltBuffer\r
+ //\r
+ for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {\r
+\r
+ Offset = (SrcY * Private->ModeData[Private->CurrentMode].HorizontalResolution) + SourceX;\r
+ if (((Offset & 0x03) == 0) && ((Width & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Read (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ Offset,\r
+ Width >> 2,\r
+ Private->LineBuffer\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Read (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ 0,\r
+ Offset,\r
+ Width,\r
+ Private->LineBuffer\r
+ );\r
+ }\r
+\r
+ for (X = 0; X < Width; X++) {\r
+ Blt = (EFI_UGA_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX + X) * sizeof (EFI_UGA_PIXEL));\r
+\r
+ Blt->Red = (UINT8) (Private->LineBuffer[X] & 0xe0);\r
+ Blt->Green = (UINT8) ((Private->LineBuffer[X] & 0x1c) << 3);\r
+ Blt->Blue = (UINT8) ((Private->LineBuffer[X] & 0x03) << 6);\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EfiUgaVideoToVideo:\r
+ //\r
+ // Perform hardware acceleration for Video to Video operations\r
+ //\r
+ ScreenWidth = Private->ModeData[Private->CurrentMode].HorizontalResolution;\r
+ SourceOffset = (SourceY * Private->ModeData[Private->CurrentMode].HorizontalResolution) + (SourceX);\r
+ Offset = (DestinationY * Private->ModeData[Private->CurrentMode].HorizontalResolution) + (DestinationX);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0000);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0010);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0012);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0014);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0001);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0011);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0013);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0015);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((Width << 8) & 0xff00) | 0x20));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((Width & 0xff00) | 0x21));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((Height << 8) & 0xff00) | 0x22));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((Height & 0xff00) | 0x23));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((ScreenWidth << 8) & 0xff00) | 0x24));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((ScreenWidth & 0xff00) | 0x25));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) (((ScreenWidth << 8) & 0xff00) | 0x26));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((ScreenWidth & 0xff00) | 0x27));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((Offset) << 8) & 0xff00) | 0x28));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((Offset) >> 0) & 0xff00) | 0x29));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((Offset) >> 8) & 0xff00) | 0x2a));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((SourceOffset) << 8) & 0xff00) | 0x2c));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((SourceOffset) >> 0) & 0xff00) | 0x2d));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((((SourceOffset) >> 8) & 0xff00) | 0x2e));\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x002f);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0030);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0d32);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0033);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0034);\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0035);\r
+\r
+ outw (Private, GRAPH_ADDRESS_REGISTER, 0x0231);\r
+\r
+ outb (Private, GRAPH_ADDRESS_REGISTER, 0x31);\r
+ while ((inb (Private, GRAPH_DATA_REGISTER) & 0x01) == 0x01)\r
+ ;\r
+ break;\r
+\r
+ case EfiUgaVideoFill:\r
+ Blt = BltBuffer;\r
+ Pixel = (UINT8) ((Blt->Red & 0xe0) | ((Blt->Green >> 3) & 0x1c) | ((Blt->Blue >> 6) & 0x03));\r
+ WidePixel = (Pixel << 8) | Pixel;\r
+ WidePixel = (WidePixel << 16) | WidePixel;\r
+\r
+ if (DestinationX == 0 && Width == Private->ModeData[Private->CurrentMode].HorizontalResolution) {\r
+ Offset = DestinationY * Private->ModeData[Private->CurrentMode].HorizontalResolution;\r
+ if (((Offset & 0x03) == 0) && (((Width * Height) & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint32,\r
+ 0,\r
+ Offset,\r
+ (Width * Height) >> 2,\r
+ &WidePixel\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint8,\r
+ 0,\r
+ Offset,\r
+ Width * Height,\r
+ &Pixel\r
+ );\r
+ }\r
+ } else {\r
+ for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
+ Offset = (DstY * Private->ModeData[Private->CurrentMode].HorizontalResolution) + DestinationX;\r
+ if (((Offset & 0x03) == 0) && ((Width & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint32,\r
+ 0,\r
+ Offset,\r
+ Width >> 2,\r
+ &WidePixel\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthFillUint8,\r
+ 0,\r
+ Offset,\r
+ Width,\r
+ &Pixel\r
+ );\r
+ }\r
+ }\r
+ }\r
+ break;\r
+\r
+ case EfiUgaBltBufferToVideo:\r
+ for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
+\r
+ for (X = 0; X < Width; X++) {\r
+ Blt = (EFI_UGA_PIXEL *) ((UINT8 *) BltBuffer + (SrcY * Delta) + (SourceX + X) * sizeof (EFI_UGA_PIXEL));\r
+ Private->LineBuffer[X] = (UINT8) ((Blt->Red & 0xe0) | ((Blt->Green >> 3) & 0x1c) | ((Blt->Blue >> 6) & 0x03));\r
+ }\r
+\r
+ Offset = (DstY * Private->ModeData[Private->CurrentMode].HorizontalResolution) + DestinationX;\r
+\r
+ if (((Offset & 0x03) == 0) && ((Width & 0x03) == 0)) {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ Offset,\r
+ Width >> 2,\r
+ Private->LineBuffer\r
+ );\r
+ } else {\r
+ Private->PciIo->Mem.Write (\r
+ Private->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ 0,\r
+ Offset,\r
+ Width,\r
+ Private->LineBuffer\r
+ );\r
+ }\r
+ }\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ gBS->RestoreTPL (OriginalTPL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// Construction and Destruction functions\r
+//\r
+EFI_STATUS\r
+CirrusLogic5430UgaDrawConstructor (\r
+ CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ UINTN Index;\r
+\r
+ //\r
+ // Fill in Private->UgaDraw protocol\r
+ //\r
+ UgaDraw = &Private->UgaDraw;\r
+\r
+ UgaDraw->GetMode = CirrusLogic5430UgaDrawGetMode;\r
+ UgaDraw->SetMode = CirrusLogic5430UgaDrawSetMode;\r
+ UgaDraw->Blt = CirrusLogic5430UgaDrawBlt;\r
+\r
+ //\r
+ // Initialize the private data\r
+ //\r
+ Private->MaxMode = CIRRUS_LOGIC_5430_MODE_COUNT;\r
+ Private->CurrentMode = 0;\r
+ for (Index = 0; Index < Private->MaxMode; Index++) {\r
+ Private->ModeData[Index].HorizontalResolution = CirrusLogic5430VideoModes[Index].Width;\r
+ Private->ModeData[Index].VerticalResolution = CirrusLogic5430VideoModes[Index].Height;\r
+ Private->ModeData[Index].ColorDepth = 32;\r
+ Private->ModeData[Index].RefreshRate = CirrusLogic5430VideoModes[Index].RefreshRate;\r
+ }\r
+\r
+ Private->HardwareNeedsStarting = TRUE;\r
+ Private->LineBuffer = NULL;\r
+\r
+ //\r
+ // Initialize the hardware\r
+ //\r
+ UgaDraw->SetMode (\r
+ UgaDraw,\r
+ Private->ModeData[Private->CurrentMode].HorizontalResolution,\r
+ Private->ModeData[Private->CurrentMode].VerticalResolution,\r
+ Private->ModeData[Private->CurrentMode].ColorDepth,\r
+ Private->ModeData[Private->CurrentMode].RefreshRate\r
+ );\r
+ DrawLogo (\r
+ Private,\r
+ Private->ModeData[Private->CurrentMode].HorizontalResolution,\r
+ Private->ModeData[Private->CurrentMode].VerticalResolution\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Copyright (c) 2006, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "CirrusLogic5430.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName = {\r
+ CirrusLogic5430ComponentNameGetDriverName,\r
+ CirrusLogic5430ComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2 = {\r
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) CirrusLogic5430ComponentNameGetDriverName,\r
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) CirrusLogic5430ComponentNameGetControllerName,\r
+ "en"\r
+};\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mCirrusLogic5430DriverNameTable[] = {\r
+ { "eng;en", L"Cirrus Logic 5430 Driver" },\r
+ { NULL , NULL }\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mCirrusLogic5430ControllerNameTable[] = {\r
+ { "eng;en", L"Cirrus Logic 5430 PCI Adapter" },\r
+ { NULL , NULL }\r
+};\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+ This function retrieves the user readable name of a driver in the form of a\r
+ Unicode string. If the driver specified by This has a user readable name in\r
+ the language specified by Language, then a pointer to the driver name is\r
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+ by This does not support the language specified by Language,\r
+ then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified\r
+ in RFC 3066 or ISO 639-2 language code format.\r
+\r
+ @param DriverName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ driver specified by This in the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
+ This and the language specified by Language was\r
+ returned in DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+{\r
+ return LookupUnicodeString2 (\r
+ Language,\r
+ This->SupportedLanguages,\r
+ mCirrusLogic5430DriverNameTable,\r
+ DriverName,\r
+ (BOOLEAN)(This == &gCirrusLogic5430ComponentName)\r
+ );\r
+}\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by a driver.\r
+\r
+ This function retrieves the user readable name of the controller specified by\r
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+ driver specified by This has a user readable name in the language specified by\r
+ Language, then a pointer to the controller name is returned in ControllerName,\r
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
+ managing the controller specified by ControllerHandle and ChildHandle,\r
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param ControllerHandle[in] The handle of a controller that the driver\r
+ specified by This is managing. This handle\r
+ specifies the controller whose name is to be\r
+ returned.\r
+\r
+ @param ChildHandle[in] The handle of the child controller to retrieve\r
+ the name of. This is an optional parameter that\r
+ may be NULL. It will be NULL for device\r
+ drivers. It will also be NULL for a bus drivers\r
+ that wish to retrieve the name of the bus\r
+ controller. It will not be NULL for a bus\r
+ driver that wishes to retrieve the name of a\r
+ child controller.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified in\r
+ RFC 3066 or ISO 639-2 language code format.\r
+\r
+ @param ControllerName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ controller specified by ControllerHandle and\r
+ ChildHandle in the language specified by\r
+ Language from the point of view of the driver\r
+ specified by This.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the user readable name in\r
+ the language specified by Language for the\r
+ driver specified by This was returned in\r
+ DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+ EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
+ managing the controller specified by\r
+ ControllerHandle and ChildHandle.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CirrusLogic5430ComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+{\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIoProtocol;\r
+\r
+ //\r
+ // This is a device driver, so ChildHandle must be NULL.\r
+ //\r
+ if (ChildHandle != NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Check Controller's handle\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIoProtocol,\r
+ gCirrusLogic5430DriverBinding.DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ gCirrusLogic5430DriverBinding.DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (Status != EFI_ALREADY_STARTED) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Get the UGA Draw Protocol on Controller\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &UgaDraw,\r
+ gCirrusLogic5430DriverBinding.DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get the Cirrus Logic 5430's Device structure\r
+ //\r
+ return LookupUnicodeString2 (\r
+ Language,\r
+ This->SupportedLanguages,\r
+ mCirrusLogic5430ControllerNameTable,\r
+ ControllerName,\r
+ (BOOLEAN)(This == &gCirrusLogic5430ComponentName)\r
+ );\r
+}\r
--- /dev/null
+/** @file\r
+ Copyright (c) 2007, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+ Module Name: DriverSupportEfiVersion.c\r
+\r
+**/\r
+#include "CirrusLogic5430.h"\r
+\r
+EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion = {\r
+ sizeof (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL), // Size of Protocol structure.\r
+ 0 // Version number to be filled at start up.\r
+};\r
+\r
[PcdsFeatureFlag.common]\r
gOptionRomPkgTokenSpaceGuid.PcdSupportScsiPassThru|TRUE|BOOLEAN|0x00010001\r
gOptionRomPkgTokenSpaceGuid.PcdSupportExtScsiPassThru|TRUE|BOOLEAN|0x00010002\r
+ gOptionRomPkgTokenSpaceGuid.PcdSupportGop|TRUE|BOOLEAN|0x00010004\r
+ gOptionRomPkgTokenSpaceGuid.PcdSupportUga|TRUE|BOOLEAN|0x00010005\r
\r
[PcdsFixedAtBuild.common]\r
gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion|0x0002000a|UINT32|0x00010003\r
\r
[Components.common]\r
OptionRomPkg/AtapiPassThruDxe/AtapiPassThruDxe.inf\r
+ OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
\r
-For now, AtapiPassThru driver in this package is to test Scsi Bus support:\r
-ScsiBus driver should support both/either ScsiPassThru and ExtScsiPassThru\r
-installed on a controller handle.\r
- \r
-AtapiPassThru driver in this package can selectively produce ScsiPassThru\r
-and/or ExtScsiPassThru protocol based on feature flags of PcdSupportScsiPassThru\r
-and PcdExtScsiPassThru.\r
+AtapiPassThru:\r
+ For now, AtapiPassThru driver in this package is to test Scsi Bus support:\r
+ ScsiBus driver should support both/either ScsiPassThru and ExtScsiPassThru\r
+ installed on a controller handle.\r
+ \r
+ AtapiPassThru driver in this package can selectively produce ScsiPassThru\r
+ and/or ExtScsiPassThru protocol based on feature flags of PcdSupportScsiPassThru\r
+ and PcdExtScsiPassThru.\r
\r
-Please note that AtapiPassThru driver has not been tuned to size optimal.\r
-Neither is it feature complete: several driver model protocols required\r
-by option ROM driver, e.g. EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL Protocol. \r
+CirrusLogic5430:\r
+ Sample implementation of UGA Draw or Graphics Output Protocol for the Cirrus\r
+ Logic 5430 family of PCI video card. It provides reference code for the GOP/UGA,\r
+ Component Name (2), EFI driver supported Verison protocol.\r
\r
Build Validation:\r
MYTOOLS(VS2005) IA32 X64 IPF EBC\r