]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
MdeModulePkg/Bus/Ata: Fix various typos
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / AtaAtapiPassThru.c
index a48b295d26aad4182641887eac68d5f74ebb1d3b..86fe9d954fdb54e6bde60d1fb8919ffe59c8388b 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
-  This file implements ATA_PASSTHRU_PROCTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces\r
+  This file implements ATA_PASSTHRU_PROTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces\r
   for managed ATA controllers.\r
 \r
-  Copyright (c) 2010 - 2016, 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
-  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
+  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -142,6 +136,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
@@ -401,7 +404,7 @@ AsyncNonBlockingTransferRoutine (
   Instance   = (ATA_ATAPI_PASS_THRU_INSTANCE *) Context;\r
   EntryHeader = &Instance->NonBlockingTaskList;\r
   //\r
-  // Get the Taks from the Taks List and execute it, until there is\r
+  // Get the Tasks from the Tasks List and execute it, until there is\r
   // no task in the list or the device is busy with task (EFI_NOT_READY).\r
   //\r
   while (TRUE) {\r
@@ -535,7 +538,7 @@ AtaAtapiPassThruSupported (
   EFI_IDE_CONTROLLER_INIT_PROTOCOL  *IdeControllerInit;\r
 \r
   //\r
-  // SATA Controller is a device driver, and should ingore the\r
+  // SATA Controller is a device driver, and should ignore the\r
   // "RemainingDevicePath" according to UEFI spec\r
   //\r
   Status = gBS->OpenProtocol (\r
@@ -656,7 +659,7 @@ AtaAtapiPassThruSupported (
   @retval EFI_SUCCESS              The device was started.\r
   @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
   @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
+  @retval Others                   The driver failed to start the device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -739,6 +742,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
@@ -810,12 +821,11 @@ ErrorExit:
     gBS->CloseEvent (Instance->TimerEvent);\r
   }\r
 \r
-  //\r
-  // Remove all inserted ATA devices.\r
-  //\r
-  DestroyDeviceInfoList(Instance);\r
-\r
   if (Instance != NULL) {\r
+    //\r
+    // Remove all inserted ATA devices.\r
+    //\r
+    DestroyDeviceInfoList (Instance);\r
     FreePool (Instance);\r
   }\r
   return EFI_UNSUPPORTED;\r