+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
- \r\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
- \r\r
-\r
-\r
-Module Name:\r
-\r
- LpcDriver.c\r
-\r
-Abstract:\r
-\r
- EFI Lpc Driver for a Generic PC Platform\r
-\r
-\r
-\r
---*/\r
-\r
-#include "LpcDriver.h"\r
-#include "IndustryStandard/Pci22.h"\r
-\r
-//\r
-// This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0)\r
-//\r
-\r
-//\r
-// Lpc Driver Global Variables\r
-//\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gLpcDriver = {\r
- LpcDriverSupported,\r
- LpcDriverStart,\r
- LpcDriverStop,\r
- 0x10,\r
- NULL,\r
- NULL\r
-};\r
-\r
-LPC_DEV mLpc = {\r
- LPC_DEV_SIGNATURE,\r
- NULL,\r
- {\r
- IsaDeviceEnumerate,\r
- IsaDeviceSetPower,\r
- IsaGetCurrentResource,\r
- IsaGetPossibleResource,\r
- IsaSetResource,\r
- IsaEnableDevice,\r
- IsaInitDevice,\r
- LpcInterfaceInit\r
- },\r
- NULL\r
-};\r
-\r
-BOOLEAN InitExecuted = FALSE;\r
-\r
-/**\r
- the entry point of the Lpc driver\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LpcDriverEntryPoint(\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
-\r
-\r
- return EfiLibInstallDriverBinding (ImageHandle, SystemTable, &gLpcDriver, ImageHandle);\r
-}\r
-\r
-/**\r
-\r
- ControllerDriver Protocol Method\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LpcDriverSupported (\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
- EFI_DEVICE_PATH_PROTOCOL *IsaBridgeDevicePath;\r
-\r
- ACPI_HID_DEVICE_PATH *AcpiNode;\r
- PCI_DEVICE_PATH *PciNode;\r
- PCI_TYPE00 Pci;\r
-\r
- //\r
- // Get the ISA bridge's Device Path and test it\r
- // the following code is specific\r
- //\r
- Status = gBS->OpenProtocol (\r
- Controller,\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **)&IsaBridgeDevicePath,\r
- This->DriverBindingHandle,\r
- Controller,\r
- EFI_OPEN_PROTOCOL_BY_DRIVER\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Status = EFI_SUCCESS;\r
- AcpiNode = (ACPI_HID_DEVICE_PATH *)IsaBridgeDevicePath;\r
- if (AcpiNode->Header.Type != ACPI_DEVICE_PATH ||\r
- AcpiNode->Header.SubType != ACPI_DP ||\r
- DevicePathNodeLength (&AcpiNode->Header) != sizeof(ACPI_HID_DEVICE_PATH) ||\r
- AcpiNode -> HID != EISA_PNP_ID(0x0A03) ||\r
- AcpiNode -> UID != 0 ) {\r
- Status = EFI_UNSUPPORTED;\r
- } else {\r
- //\r
- // Get the next node\r
- //\r
- IsaBridgeDevicePath = NextDevicePathNode (IsaBridgeDevicePath);\r
- PciNode = (PCI_DEVICE_PATH *)IsaBridgeDevicePath;\r
- if (PciNode->Header.Type != HARDWARE_DEVICE_PATH ||\r
- PciNode->Header.SubType != HW_PCI_DP ||\r
- DevicePathNodeLength (&PciNode->Header) != sizeof (PCI_DEVICE_PATH) ||\r
- PciNode -> Function != 0x00 ||\r
- PciNode -> Device != 0x1f ) {\r
- Status = EFI_UNSUPPORTED;\r
- }\r
- }\r
-\r
- gBS->CloseProtocol (\r
- Controller,\r
- &gEfiDevicePathProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- //\r
- // Get PciIo protocol instance\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
-\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
-\r
- Status = PciIo->Pci.Read (\r
- PciIo,\r
- EfiPciIoWidthUint32,\r
- 0,\r
- sizeof(Pci) / sizeof(UINT32),\r
- &Pci\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- Status = EFI_SUCCESS; //TODO: force return success as temp solution EFI_UNSUPPORTED;\r
- if ((Pci.Hdr.Command & 0x03) == 0x03) {\r
- if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {\r
- //\r
- // See if this is a standard PCI to ISA Bridge from the Base Code\r
- // and Class Code\r
- //\r
- if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) {\r
- Status = EFI_SUCCESS;\r
- } else {\r
- }\r
-\r
- //\r
- // See if this is an Intel PCI to ISA bridge in Positive Decode Mode\r
- //\r
- if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE &&\r
- Pci.Hdr.VendorId == 0x8086 &&\r
- Pci.Hdr.DeviceId == 0x7110) {\r
- Status = EFI_SUCCESS;\r
- } else {\r
- }\r
- } else {\r
- }\r
- }\r
- else {\r
- }\r
- }\r
-\r
- gBS->CloseProtocol (\r
- Controller,\r
- &gEfiPciIoProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Install EFI_ISA_ACPI_PROTOCOL\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LpcDriverStart (\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
-\r
- //\r
- // Get Pci IO\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
-\r
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
- return Status;\r
- }\r
-\r
- mLpc.PciIo = PciIo;\r
-\r
- //\r
- // Install IsaAcpi interface, the Sio interface is not installed!\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &Controller,\r
- &gEfiIsaAcpiProtocolGuid,\r
- &mLpc.IsaAcpi,\r
- NULL\r
- );\r
- return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-LpcDriverStop (\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_STATUS Status;\r
- EFI_ISA_ACPI_PROTOCOL *IsaAcpi;\r
- LPC_DEV *LpcDev;\r
-\r
- //\r
- // Get EFI_ISA_ACPI_PROTOCOL interface\r
- //\r
- Status = gBS->OpenProtocol (\r
- Controller,\r
- &gEfiIsaAcpiProtocolGuid,\r
- (VOID **)&IsaAcpi,\r
- This->DriverBindingHandle,\r
- Controller,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- LpcDev = LPC_ISA_ACPI_FROM_THIS (IsaAcpi);\r
-\r
- //\r
- // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL\r
- //\r
- Status = gBS->UninstallProtocolInterface (\r
- Controller,\r
- &gEfiIsaAcpiProtocolGuid,\r
- &LpcDev->IsaAcpi\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- gBS->CloseProtocol (\r
- Controller,\r
- &gEfiPciIoProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-LpcIoRead8 (\r
- IN UINT16 Port,\r
- OUT UINT8 *Data\r
- )\r
-{\r
- mLpc.PciIo->Io.Read(\r
- mLpc.PciIo,\r
- EfiPciWidthUint8,\r
- EFI_PCI_IO_PASS_THROUGH_BAR,\r
- Port,\r
- 1,\r
- Data\r
- );\r
-}\r
-\r
-VOID\r
-LpcIoWrite8 (\r
- IN UINT16 Port,\r
- IN UINT8 Data\r
- )\r
-{\r
- mLpc.PciIo->Io.Write(\r
- mLpc.PciIo,\r
- EfiPciWidthUint8,\r
- EFI_PCI_IO_PASS_THROUGH_BAR,\r
- Port,\r
- 1,\r
- &Data\r
- );\r
-}\r
-\r