X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FBus%2FAta%2FAtaAtapiPassThru%2FAtaAtapiPassThru.c;h=aab704bcd3796cff4ec9fb3069863ac205fe3dcd;hb=06766c0e19092eed5563caeb94576f0d4ac65fd1;hp=2389d54926e7b8a9244d8b2796967abf0c6fc53b;hpb=23a596db1bbf4ad8d4cc297965d1744937586536;p=mirror_edk2.git diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 2389d54926..aab704bcd3 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -2,7 +2,7 @@ This file implements ATA_PASSTHRU_PROCTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces for managed ATA controllers. - Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2018, 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 @@ -94,6 +94,7 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = { NULL, NULL }, + 0, // EnabledPciAttributes 0, // OriginalAttributes 0, // PreviousPort 0, // PreviousPortMultiplier @@ -141,6 +142,15 @@ UINT8 mScsiId[TARGET_MAX_BYTES] = { 0xFF, 0xFF, 0xFF, 0xFF }; +EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy; +EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy = { + EDKII_ATA_ATAPI_POLICY_VERSION, + 2, // PuisEnable + 0, // DeviceSleepEnable + 0, // AggressiveDeviceSleepEnable + 0 // Reserved +}; + /** Sends an ATA command to an ATA device that is attached to the ATA controller. This function supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required, @@ -670,7 +680,7 @@ AtaAtapiPassThruStart ( EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit; ATA_ATAPI_PASS_THRU_INSTANCE *Instance; EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 Supports; + UINT64 EnabledPciAttributes; UINT64 OriginalPciAttributes; Status = EFI_SUCCESS; @@ -722,14 +732,14 @@ AtaAtapiPassThruStart ( PciIo, EfiPciIoAttributeOperationSupported, 0, - &Supports + &EnabledPciAttributes ); if (!EFI_ERROR (Status)) { - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; + EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE; Status = PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationEnable, - Supports, + EnabledPciAttributes, NULL ); } @@ -738,6 +748,14 @@ AtaAtapiPassThruStart ( goto ErrorExit; } + Status = gBS->LocateProtocol (&gEdkiiAtaAtapiPolicyProtocolGuid, NULL, (VOID **)&mAtaAtapiPolicy); + if (EFI_ERROR (Status)) { + // + // If there is no AtaAtapiPolicy exposed, use the default policy. + // + mAtaAtapiPolicy = &mDefaultAtaAtapiPolicy; + } + // // Allocate a buffer to store the ATA_ATAPI_PASS_THRU_INSTANCE data structure // @@ -749,6 +767,7 @@ AtaAtapiPassThruStart ( Instance->ControllerHandle = Controller; Instance->IdeControllerInit = IdeControllerInit; Instance->PciIo = PciIo; + Instance->EnabledPciAttributes = EnabledPciAttributes; Instance->OriginalPciAttributes = OriginalPciAttributes; Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode; Instance->ExtScsiPassThru.Mode = &Instance->ExtScsiPassThruMode; @@ -859,7 +878,6 @@ AtaAtapiPassThruStop ( EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru; EFI_PCI_IO_PROTOCOL *PciIo; EFI_AHCI_REGISTERS *AhciRegisters; - UINT64 Supports; DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller)); @@ -912,12 +930,22 @@ AtaAtapiPassThruStop ( // DestroyDeviceInfoList (Instance); + PciIo = Instance->PciIo; + + // + // Disable this ATA host controller. + // + PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationDisable, + Instance->EnabledPciAttributes, + NULL + ); + // // If the current working mode is AHCI mode, then pre-allocated resource // for AHCI initialization should be released. // - PciIo = Instance->PciIo; - if (Instance->Mode == EfiAtaAhciMode) { AhciRegisters = &Instance->AhciRegisters; PciIo->Unmap ( @@ -949,25 +977,6 @@ AtaAtapiPassThruStop ( ); } - // - // Disable this ATA host controller. - // - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); - if (!EFI_ERROR (Status)) { - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - Supports, - NULL - ); - } - // // Restore original PCI attributes // @@ -1878,7 +1887,7 @@ AtaPassThruResetDevice ( } /** - Sumbit ATAPI request sense command. + Submit ATAPI request sense command. @param[in] This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. @param[in] Target The Target is an array of size TARGET_MAX_BYTES and it represents