+++ /dev/null
-/** @file\r
- Cirrus Logic 5430 Controller Driver.\r
- This driver is a sample implementation of the UGA Draw Protocol for the\r
- Cirrus Logic 5430 family of PCI video controllers. This driver is only\r
- usable in the EFI pre-boot environment. This sample is intended to show\r
- how the UGA Draw Protocol is able to function. The UGA I/O Protocol is not\r
- implemented in this sample. 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
-\r
-#include "CirrusLogic5430.h"\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding = {\r
- CirrusLogic5430ControllerDriverSupported,\r
- CirrusLogic5430ControllerDriverStart,\r
- CirrusLogic5430ControllerDriverStop,\r
- 0xa,\r
- NULL,\r
- NULL\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 = NULL;\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
- //\r
- // Start the UGA Draw software stack.\r
- //\r
- Status = CirrusLogic5430UgaDrawConstructor (Private);\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
-\r
- //\r
- // Publish the UGA Draw interface to the world\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &Private->Handle,\r
- &gEfiUgaDrawProtocolGuid,\r
- &Private->UgaDraw,\r
- NULL\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_STATUS Status;\r
- CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;\r
-\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
- //\r
- // If the UGA Draw interface does not exist the driver is not started\r
- //\r
- return Status;\r
- }\r
-\r
- //\r
- // Get our private context information\r
- //\r
- Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (UgaDraw);\r
-\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
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Shutdown the hardware\r
- //\r
- CirrusLogic5430UgaDrawDestructor (Private);\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