X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PcAtChipsetPkg%2FIsaAcpiDxe%2FPcatIsaAcpi.c;h=035bfaf0f16d43a7960790c7e5776036c602631d;hb=8b6f0b5cd3d97f6f385804344f6795e5fbdb753e;hp=a0f4cdfd40a0df99cc57d04552843ae072737709;hpb=81727f38ed0d37bf6f5110def397220a8c207182;p=mirror_edk2.git diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c index a0f4cdfd40..035bfaf0f1 100644 --- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c +++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c @@ -1,26 +1,10 @@ -/*++ +/** @file + EFI PCAT ISA ACPI Driver for a Generic PC Platform -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent - -Module Name: - - PcatIsaAcpi.c - -Abstract: - - EFI PCAT ISA ACPI Driver for a Generic PC Platform - -Revision History - ---*/ +**/ #include "PcatIsaAcpi.h" @@ -36,26 +20,24 @@ EFI_DRIVER_BINDING_PROTOCOL gPcatIsaAcpiDriverBinding = { NULL }; +/** + the entry point of the PcatIsaAcpi driver. + + @param ImageHandle Handle for driver image + @param SystemTable Point to EFI_SYSTEM_TABLE + + @return Success or not for installing driver binding protocol +**/ EFI_STATUS EFIAPI PcatIsaAcpiDriverEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - - Routine Description: - the entry point of the PcatIsaAcpi driver - - Arguments: - - Returns: - ---*/ { return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, + ImageHandle, + SystemTable, &gPcatIsaAcpiDriverBinding, ImageHandle, &gPcatIsaAcpiComponentName, @@ -63,6 +45,17 @@ PcatIsaAcpiDriverEntryPoint ( ); } +/** + ControllerDriver Protocol Method + + @param This Driver Binding protocol instance pointer. + @param Controller Handle of device to test. + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + @retval EFI_SUCCESS This driver supports this device. + @retval other This driver does not support this device. + +**/ EFI_STATUS EFIAPI PcatIsaAcpiDriverBindingSupported ( @@ -70,28 +63,21 @@ PcatIsaAcpiDriverBindingSupported ( IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) -/*++ - -Routine Description: - - ControllerDriver Protocol Method - -Arguments: - -Returns: - ---*/ { EFI_STATUS Status; EFI_PCI_IO_PROTOCOL *PciIo; PCI_TYPE00 Pci; + UINTN SegmentNumber; + UINTN BusNumber; + UINTN DeviceNumber; + UINTN FunctionNumber; // // Get PciIo protocol instance - // + // Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, + Controller, + &gEfiPciIoProtocolGuid, (VOID**)&PciIo, This->DriverBindingHandle, Controller, @@ -105,9 +91,9 @@ Returns: PciIo, EfiPciIoWidthUint32, 0, - sizeof(Pci) / sizeof(UINT32), + sizeof(Pci) / sizeof(UINT32), &Pci); - + if (!EFI_ERROR (Status)) { Status = EFI_UNSUPPORTED; if ((Pci.Hdr.Command & 0x03) == 0x03) { @@ -117,30 +103,57 @@ Returns: // if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) { Status = EFI_SUCCESS; - } + } // // See if this is an Intel PCI to ISA bridge in Positive Decode Mode // if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE && - Pci.Hdr.VendorId == 0x8086 && - Pci.Hdr.DeviceId == 0x7110) { - Status = EFI_SUCCESS; + Pci.Hdr.VendorId == 0x8086 ) { + // + // See if this is on Function #0 to avoid false positives on + // PCI_CLASS_BRIDGE_OTHER that has the same value as + // PCI_CLASS_BRIDGE_ISA_PDECODE + // + Status = PciIo->GetLocation ( + PciIo, + &SegmentNumber, + &BusNumber, + &DeviceNumber, + &FunctionNumber + ); + if (!EFI_ERROR (Status) && FunctionNumber == 0) { + Status = EFI_SUCCESS; + } else { + Status = EFI_UNSUPPORTED; + } } - } + } } } gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller + Controller, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + Controller ); - + return Status; } +/** + Install EFI_ISA_ACPI_PROTOCOL. + + @param This Driver Binding protocol instance pointer. + @param ControllerHandle Handle of device to bind driver to. + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS This driver is added to ControllerHandle + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle + @retval other This driver does not support this device +**/ EFI_STATUS EFIAPI PcatIsaAcpiDriverBindingStart ( @@ -148,48 +161,74 @@ PcatIsaAcpiDriverBindingStart ( IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) -/*++ - -Routine Description: - Install EFI_ISA_ACPI_PROTOCOL - -Arguments: - -Returns: - ---*/ { EFI_STATUS Status; EFI_PCI_IO_PROTOCOL *PciIo; PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev; - + UINT64 Supports; + UINT64 OriginalAttributes; + BOOLEAN Enabled; + + Enabled = FALSE; + Supports = 0; PcatIsaAcpiDev = NULL; + OriginalAttributes = 0; // // Open the PCI I/O Protocol Interface // PciIo = NULL; Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, + Controller, + &gEfiPciIoProtocolGuid, (VOID**)&PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER + This->DriverBindingHandle, + Controller, + EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { goto Done; } + // + // Get supported PCI attributes + // + Status = PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationSupported, + 0, + &Supports + ); + if (EFI_ERROR (Status)) { + goto Done; + } + + Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16); + if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) { + Status = EFI_UNSUPPORTED; + goto Done; + } + + Status = PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationGet, + 0, + &OriginalAttributes + ); + if (EFI_ERROR (Status)) { + goto Done; + } + Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, - NULL + PciIo, + EfiPciIoAttributeOperationEnable, + EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, + NULL ); if (EFI_ERROR (Status)) { goto Done; } - + + Enabled = TRUE; // // Allocate memory for the PCAT ISA ACPI Device structure // @@ -206,10 +245,16 @@ Returns: // // Initialize the PCAT ISA ACPI Device structure // - PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE; - PcatIsaAcpiDev->Handle = Controller; - PcatIsaAcpiDev->PciIo = PciIo; - + PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE; + PcatIsaAcpiDev->Handle = Controller; + PcatIsaAcpiDev->PciIo = PciIo; + PcatIsaAcpiDev->OriginalAttributes = OriginalAttributes; + + // + // Initialize PcatIsaAcpiDeviceList + // + InitializePcatIsaAcpiDeviceList (); + // // IsaAcpi interface // @@ -221,7 +266,7 @@ Returns: (PcatIsaAcpiDev->IsaAcpi).EnableDevice = IsaEnableDevice; (PcatIsaAcpiDev->IsaAcpi).InitDevice = IsaInitDevice; (PcatIsaAcpiDev->IsaAcpi).InterfaceInit = IsaInterfaceInit; - + // // Install the ISA ACPI Protocol interface // @@ -233,18 +278,18 @@ Returns: Done: if (EFI_ERROR (Status)) { - if (PciIo) { + if (PciIo != NULL && Enabled) { PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, - NULL + PciIo, + EfiPciIoAttributeOperationSet, + OriginalAttributes, + NULL ); } gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, + Controller, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, Controller ); if (PcatIsaAcpiDev != NULL) { @@ -252,10 +297,25 @@ Done: } return Status; } - + return EFI_SUCCESS; } + +/** + Stop this driver on ControllerHandle. Support stopping any child handles + created by this driver. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to stop driver on + @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of + children is zero stop the entire bus driver. + @param ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCESS This driver is removed ControllerHandle + @retval other This driver was not removed from this device + +**/ EFI_STATUS EFIAPI PcatIsaAcpiDriverBindingStop ( @@ -264,29 +324,20 @@ PcatIsaAcpiDriverBindingStop ( IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) -/*++ - - Routine Description: - - Arguments: - - Returns: - ---*/ { EFI_STATUS Status; EFI_ISA_ACPI_PROTOCOL *IsaAcpi; PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev; - + // // Get the ISA ACPI Protocol Interface - // + // Status = gBS->OpenProtocol ( - Controller, - &gEfiIsaAcpiProtocolGuid, + Controller, + &gEfiIsaAcpiProtocolGuid, (VOID**)&IsaAcpi, - This->DriverBindingHandle, - Controller, + This->DriverBindingHandle, + Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { @@ -298,13 +349,19 @@ PcatIsaAcpiDriverBindingStop ( // PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi); - PcatIsaAcpiDev->PciIo->Attributes ( - PcatIsaAcpiDev->PciIo, - EfiPciIoAttributeOperationDisable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, - NULL - ); - + // + // Restore PCI attributes + // + Status = PcatIsaAcpiDev->PciIo->Attributes ( + PcatIsaAcpiDev->PciIo, + EfiPciIoAttributeOperationSet, + PcatIsaAcpiDev->OriginalAttributes, + NULL + ); + if (EFI_ERROR (Status)) { + return Status; + } + // // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL // @@ -317,13 +374,13 @@ PcatIsaAcpiDriverBindingStop ( } gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, + Controller, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, Controller ); - + gBS->FreePool (PcatIsaAcpiDev); - + return EFI_SUCCESS; }