]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
MdeModulePkg/AtaAtapiPassThru: enable/disable PUIS per policy
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / AtaAtapiPassThru.c
index e10e0d4e65f6b2fb3af03b781adbd1851e622850..aab704bcd3796cff4ec9fb3069863ac205fe3dcd 100644 (file)
@@ -2,7 +2,7 @@
   This file implements ATA_PASSTHRU_PROCTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces\r
   for managed ATA controllers.\r
 \r
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
   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
@@ -104,8 +104,7 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
   {                   // NonBlocking TaskList\r
     NULL,\r
     NULL\r
-  },\r
-  NULL,               // ExitBootEvent\r
+  }\r
 };\r
 \r
 ATAPI_DEVICE_PATH    mAtapiDevicePathTemplate = {\r
@@ -143,6 +142,15 @@ UINT8 mScsiId[TARGET_MAX_BYTES] = {
   0xFF, 0xFF, 0xFF, 0xFF\r
 };\r
 \r
+EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;\r
+EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy = {\r
+  EDKII_ATA_ATAPI_POLICY_VERSION,\r
+  2,  // PuisEnable\r
+  0,  // DeviceSleepEnable\r
+  0,  // AggressiveDeviceSleepEnable\r
+  0   // Reserved\r
+};\r
+\r
 /**\r
   Sends an ATA command to an ATA device that is attached to the ATA controller. This function\r
   supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,\r
@@ -479,37 +487,6 @@ InitializeAtaAtapiPassThru (
   return Status;\r
 }\r
 \r
-/**\r
-  Disable Bus Master DMA on the device when exiting the boot services.\r
-\r
-  @param[in] Event    Event for which this notification function is being\r
-                      called.\r
-  @param[in] Context  Pointer to the ATA_ATAPI_PASS_THRU_INSTANCE that\r
-                      represents the HBA.\r
-**/\r
-VOID\r
-EFIAPI\r
-AtaPassThruExitBootServices (\r
-  IN EFI_EVENT Event,\r
-  IN VOID      *Context\r
-  )\r
-{\r
-  ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r
-  EFI_PCI_IO_PROTOCOL          *PciIo;\r
-\r
-  DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));\r
-\r
-  Instance = Context;\r
-  PciIo = Instance->PciIo;\r
-\r
-  PciIo->Attributes (\r
-           PciIo,\r
-           EfiPciIoAttributeOperationDisable,\r
-           Instance->EnabledPciAttributes & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER,\r
-           NULL\r
-           );\r
-}\r
-\r
 /**\r
   Tests to see if this driver supports a given controller. If a child device is provided,\r
   it further tests to see if this driver supports creating a handle for the specified child device.\r
@@ -771,6 +748,14 @@ AtaAtapiPassThruStart (
     goto ErrorExit;\r
   }\r
 \r
+  Status = gBS->LocateProtocol (&gEdkiiAtaAtapiPolicyProtocolGuid, NULL, (VOID **)&mAtaAtapiPolicy);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If there is no AtaAtapiPolicy exposed, use the default policy.\r
+    //\r
+    mAtaAtapiPolicy = &mDefaultAtaAtapiPolicy;\r
+  }\r
+\r
   //\r
   // Allocate a buffer to store the ATA_ATAPI_PASS_THRU_INSTANCE data structure\r
   //\r
@@ -789,17 +774,6 @@ AtaAtapiPassThruStart (
   InitializeListHead(&Instance->DeviceList);\r
   InitializeListHead(&Instance->NonBlockingTaskList);\r
 \r
-  Status = gBS->CreateEvent (\r
-                  EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
-                  TPL_CALLBACK,\r
-                  AtaPassThruExitBootServices,\r
-                  Instance,\r
-                  &Instance->ExitBootEvent\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
   Instance->TimerEvent = NULL;\r
 \r
   Status = gBS->CreateEvent (\r
@@ -853,10 +827,6 @@ ErrorExit:
     gBS->CloseEvent (Instance->TimerEvent);\r
   }\r
 \r
-  if ((Instance != NULL) && (Instance->ExitBootEvent != NULL)) {\r
-    gBS->CloseEvent (Instance->ExitBootEvent);\r
-  }\r
-\r
   //\r
   // Remove all inserted ATA devices.\r
   //\r
@@ -955,15 +925,6 @@ AtaAtapiPassThruStop (
     Instance->TimerEvent = NULL;\r
   }\r
   DestroyAsynTaskList (Instance, FALSE);\r
-\r
-  //\r
-  // Close event signaled at gBS->ExitBootServices().\r
-  //\r
-  if (Instance->ExitBootEvent != NULL) {\r
-    gBS->CloseEvent (Instance->ExitBootEvent);\r
-    Instance->ExitBootEvent = NULL;\r
-  }\r
-\r
   //\r
   // Free allocated resource\r
   //\r