]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
Port CirrusLogic5430 from EDK II code base.
[mirror_edk2.git] / OptionRomPkg / CirrusLogic5430Dxe / CirrusLogic5430.c
diff --git a/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c b/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
new file mode 100644 (file)
index 0000000..bfa121b
--- /dev/null
@@ -0,0 +1,803 @@
+/** @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