]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/AtaBus&AtaAtapiPassThru: Update ATA drivers to follow UEFI2.4 new reques...
authorTian, Feng <feng.tian@intel.com>
Thu, 10 Oct 2013 05:57:50 +0000 (05:57 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 10 Oct 2013 05:57:50 +0000 (05:57 +0000)
Signed-off-by: Tian, Feng <feng.tian@intel.com>
reviewed-by: Ni, Ruiyu <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14761 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c

index 35477d886257285b4ea8d796eaa95dde05bc35d6..dbc44337233d7704669d203a7cd57079cc051375 100644 (file)
@@ -1764,7 +1764,10 @@ AtaPassThruResetPort (
   IN UINT16                     Port\r
   )\r
 {\r
   IN UINT16                     Port\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  //\r
+  // Return success directly then upper layer driver could think reset port operation is done.\r
+  //\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -1806,7 +1809,10 @@ AtaPassThruResetDevice (
   IN UINT16                     PortMultiplierPort\r
   )\r
 {\r
   IN UINT16                     PortMultiplierPort\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  //\r
+  // Return success directly then upper layer driver could think reset device operation is done.\r
+  //\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -2274,7 +2280,10 @@ ExtScsiPassThruResetChannel (
   IN  EFI_EXT_SCSI_PASS_THRU_PROTOCOL   *This\r
   )\r
 {\r
   IN  EFI_EXT_SCSI_PASS_THRU_PROTOCOL   *This\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  //\r
+  // Return success directly then upper layer driver could think reset channel operation is done.\r
+  //\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -2304,7 +2313,10 @@ ExtScsiPassThruResetTargetLun (
   IN UINT64                             Lun\r
   )\r
 {\r
   IN UINT64                             Lun\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  //\r
+  // Return success directly then upper layer driver could think reset target LUN operation is done.\r
+  //\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
index 6732fd5e0d38ded84c65e23e5ad6006a16ba934f..b113b8d851b298f1eb993afa9d54c70df1300a06 100644 (file)
@@ -90,7 +90,8 @@ ATA_DEVICE gAtaDeviceTemplate = {
   NULL,                        // ControllerNameTable\r
   {L'\0', },                   // ModelName\r
   {NULL, NULL},                // AtaTaskList\r
   NULL,                        // ControllerNameTable\r
   {L'\0', },                   // ModelName\r
   {NULL, NULL},                // AtaTaskList\r
-  {NULL, NULL}                 // AtaSubTaskList\r
+  {NULL, NULL},                // AtaSubTaskList\r
+  FALSE                        // Abort\r
 };\r
 \r
 /**\r
 };\r
 \r
 /**\r
@@ -172,7 +173,7 @@ ReleaseAtaResources (
        ) {\r
       DelEntry = Entry;\r
       Entry    = Entry->ForwardLink;\r
        ) {\r
       DelEntry = Entry;\r
       Entry    = Entry->ForwardLink;\r
-      SubTask  = ATA_AYNS_SUB_TASK_FROM_ENTRY (DelEntry);\r
+      SubTask  = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);\r
 \r
       RemoveEntryList (DelEntry);\r
       FreeAtaSubTask (SubTask);\r
 \r
       RemoveEntryList (DelEntry);\r
       FreeAtaSubTask (SubTask);\r
@@ -187,7 +188,7 @@ ReleaseAtaResources (
        ) {\r
       DelEntry = Entry;\r
       Entry    = Entry->ForwardLink;\r
        ) {\r
       DelEntry = Entry;\r
       Entry    = Entry->ForwardLink;\r
-      AtaTask     = ATA_AYNS_TASK_FROM_ENTRY (DelEntry);\r
+      AtaTask  = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);\r
 \r
       RemoveEntryList (DelEntry);\r
       FreePool (AtaTask);\r
 \r
       RemoveEntryList (DelEntry);\r
       FreePool (AtaTask);\r
@@ -1217,6 +1218,8 @@ AtaBlockIoResetEx (
 \r
   AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
 \r
 \r
   AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
 \r
+  AtaTerminateNonBlockingTask (AtaDevice);\r
+\r
   Status = ResetAtaDevice (AtaDevice);\r
 \r
   if (EFI_ERROR (Status)) {\r
   Status = ResetAtaDevice (AtaDevice);\r
 \r
   if (EFI_ERROR (Status)) {\r
index 4d3d9d54c7e9fd6a187cb87d86e1f02024f3fc06..04ae47ceae413a38881fe19543ed7ab29e07b0a4 100644 (file)
@@ -4,7 +4,7 @@
   This file defines common data structures, macro definitions and some module\r
   internal function header files.\r
 \r
   This file defines common data structures, macro definitions and some module\r
   internal function header files.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2013, 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
   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
@@ -148,6 +148,7 @@ typedef struct {
 \r
   LIST_ENTRY                            AtaTaskList;\r
   LIST_ENTRY                            AtaSubTaskList;\r
 \r
   LIST_ENTRY                            AtaTaskList;\r
   LIST_ENTRY                            AtaSubTaskList;\r
+  BOOLEAN                               Abort;\r
 } ATA_DEVICE;\r
 \r
 //\r
 } ATA_DEVICE;\r
 \r
 //\r
@@ -181,8 +182,8 @@ typedef struct {
 #define ATA_DEVICE_FROM_BLOCK_IO2(a)        CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)\r
 #define ATA_DEVICE_FROM_DISK_INFO(a)        CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)\r
 #define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)\r
 #define ATA_DEVICE_FROM_BLOCK_IO2(a)        CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)\r
 #define ATA_DEVICE_FROM_DISK_INFO(a)        CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)\r
 #define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)\r
-#define ATA_AYNS_SUB_TASK_FROM_ENTRY(a)     CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)\r
-#define ATA_AYNS_TASK_FROM_ENTRY(a)         CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)\r
+#define ATA_ASYN_SUB_TASK_FROM_ENTRY(a)     CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)\r
+#define ATA_ASYN_TASK_FROM_ENTRY(a)         CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)\r
 \r
 //\r
 // Global Variables\r
 \r
 //\r
 // Global Variables\r
@@ -301,6 +302,7 @@ AccessAtaDevice(
   IN BOOLEAN                        IsWrite,\r
   IN OUT EFI_BLOCK_IO2_TOKEN        *Token\r
   );\r
   IN BOOLEAN                        IsWrite,\r
   IN OUT EFI_BLOCK_IO2_TOKEN        *Token\r
   );\r
+\r
 /**\r
   Trust transfer data from/to ATA device.\r
 \r
 /**\r
   Trust transfer data from/to ATA device.\r
 \r
@@ -804,6 +806,22 @@ AtaBlockIoFlushBlocksEx (
   IN OUT EFI_BLOCK_IO2_TOKEN  *Token\r
   );\r
 \r
   IN OUT EFI_BLOCK_IO2_TOKEN  *Token\r
   );\r
 \r
+/**\r
+  Terminate any in-flight non-blocking I/O requests by signaling an EFI_ABORTED\r
+  in the TransactionStatus member of the EFI_BLOCK_IO2_TOKEN for the non-blocking\r
+  I/O. After that it is safe to free any Token or Buffer data structures that\r
+  were allocated to initiate the non-blockingI/O requests that were in-flight for\r
+  this device.\r
+\r
+  @param[in]  AtaDevice     The ATA child device involved for the operation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AtaTerminateNonBlockingTask (\r
+  IN ATA_DEVICE               *AtaDevice\r
+  );\r
+\r
 /**\r
   Provides inquiry information for the controller type.\r
 \r
 /**\r
   Provides inquiry information for the controller type.\r
 \r
@@ -940,20 +958,20 @@ AtaDiskInfoWhichIde (
   return EFI_SUCCESS. If the security protocol command completes with an error, the\r
   function shall return EFI_DEVICE_ERROR.\r
 \r
   return EFI_SUCCESS. If the security protocol command completes with an error, the\r
   function shall return EFI_DEVICE_ERROR.\r
 \r
-  @param  This                              Indicates a pointer to the calling context.\r
-  @param  MediaId                           ID of the medium to receive data from.\r
-  @param  Timeout                                 The timeout, in 100ns units, to use for the execution\r
+  @param  This                         Indicates a pointer to the calling context.\r
+  @param  MediaId                      ID of the medium to receive data from.\r
+  @param  Timeout                      The timeout, in 100ns units, to use for the execution\r
                                        of the security protocol command. A Timeout value of 0\r
                                        means that this function will wait indefinitely for the\r
                                        security protocol command to execute. If Timeout is greater\r
                                        than zero, then this function will return EFI_TIMEOUT\r
                                        of the security protocol command. A Timeout value of 0\r
                                        means that this function will wait indefinitely for the\r
                                        security protocol command to execute. If Timeout is greater\r
                                        than zero, then this function will return EFI_TIMEOUT\r
-                                                              if the time required to execute the receive data command\r
-                                                              is greater than Timeout.\r
+                                       if the time required to execute the receive data command\r
+                                       is greater than Timeout.\r
   @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
                                        the security protocol command to be sent.\r
   @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
                                        of the security protocol command to be sent.\r
   @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
                                        the security protocol command to be sent.\r
   @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
                                        of the security protocol command to be sent.\r
-  @param  PayloadBufferSize                     Size in bytes of the payload data buffer.\r
+  @param  PayloadBufferSize            Size in bytes of the payload data buffer.\r
   @param  PayloadBuffer                A pointer to a destination buffer to store the security\r
                                        protocol command specific payload data for the security\r
                                        protocol command. The caller is responsible for having\r
   @param  PayloadBuffer                A pointer to a destination buffer to store the security\r
                                        protocol command specific payload data for the security\r
                                        protocol command. The caller is responsible for having\r
@@ -1020,20 +1038,20 @@ AtaStorageSecurityReceiveData (
   EFI_SUCCESS. If the security protocol command completes with an error, the function\r
   shall return EFI_DEVICE_ERROR.\r
 \r
   EFI_SUCCESS. If the security protocol command completes with an error, the function\r
   shall return EFI_DEVICE_ERROR.\r
 \r
-  @param  This                              Indicates a pointer to the calling context.\r
-  @param  MediaId                           ID of the medium to receive data from.\r
-  @param  Timeout                                 The timeout, in 100ns units, to use for the execution\r
+  @param  This                         Indicates a pointer to the calling context.\r
+  @param  MediaId                      ID of the medium to receive data from.\r
+  @param  Timeout                      The timeout, in 100ns units, to use for the execution\r
                                        of the security protocol command. A Timeout value of 0\r
                                        means that this function will wait indefinitely for the\r
                                        security protocol command to execute. If Timeout is greater\r
                                        than zero, then this function will return EFI_TIMEOUT\r
                                        of the security protocol command. A Timeout value of 0\r
                                        means that this function will wait indefinitely for the\r
                                        security protocol command to execute. If Timeout is greater\r
                                        than zero, then this function will return EFI_TIMEOUT\r
-                                                              if the time required to execute the receive data command\r
-                                                              is greater than Timeout.\r
+                                       if the time required to execute the receive data command\r
+                                       is greater than Timeout.\r
   @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
                                        the security protocol command to be sent.\r
   @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
                                        of the security protocol command to be sent.\r
   @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
                                        the security protocol command to be sent.\r
   @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
                                        of the security protocol command to be sent.\r
-  @param  PayloadBufferSize                     Size in bytes of the payload data buffer.\r
+  @param  PayloadBufferSize            Size in bytes of the payload data buffer.\r
   @param  PayloadBuffer                A pointer to a destination buffer to store the security\r
                                        protocol command specific payload data for the security\r
                                        protocol command.\r
   @param  PayloadBuffer                A pointer to a destination buffer to store the security\r
                                        protocol command specific payload data for the security\r
                                        protocol command.\r
index b1bedd80e819a02ea72931d34a58e187bd8f8c9e..a3008f92d9e2972abc79618a367f4d66020897f7 100644 (file)
@@ -582,6 +582,62 @@ FreeAtaSubTask (
   FreePool (Task);\r
 }\r
 \r
   FreePool (Task);\r
 }\r
 \r
+/**\r
+  Terminate any in-flight non-blocking I/O requests by signaling an EFI_ABORTED\r
+  in the TransactionStatus member of the EFI_BLOCK_IO2_TOKEN for the non-blocking\r
+  I/O. After that it is safe to free any Token or Buffer data structures that\r
+  were allocated to initiate the non-blockingI/O requests that were in-flight for\r
+  this device.\r
+\r
+  @param[in]  AtaDevice     The ATA child device involved for the operation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AtaTerminateNonBlockingTask (\r
+  IN ATA_DEVICE               *AtaDevice\r
+  )\r
+{\r
+  BOOLEAN               SubTaskEmpty;\r
+  EFI_TPL               OldTpl;\r
+  ATA_BUS_ASYN_TASK     *AtaTask;\r
+  LIST_ENTRY            *Entry;\r
+  LIST_ENTRY            *List;\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+  //\r
+  // Abort all executing tasks from now.\r
+  //\r
+  AtaDevice->Abort = TRUE;\r
+\r
+  List = &AtaDevice->AtaTaskList;\r
+  for (Entry = GetFirstNode (List); !IsNull (List, Entry);) {\r
+    AtaTask  = ATA_ASYN_TASK_FROM_ENTRY (Entry);\r
+    AtaTask->Token->TransactionStatus = EFI_ABORTED;\r
+    gBS->SignalEvent (AtaTask->Token->Event);\r
+\r
+    Entry = RemoveEntryList (Entry);\r
+    FreePool (AtaTask);\r
+  }\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
+  do {\r
+    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+    //\r
+    // Wait for executing subtasks done.\r
+    //\r
+    SubTaskEmpty = IsListEmpty (&AtaDevice->AtaSubTaskList);\r
+    gBS->RestoreTPL (OldTpl);\r
+  } while (!SubTaskEmpty);\r
+\r
+  //\r
+  // Aborting operation has been done. From now on, don't need to abort normal operation.\r
+  //  \r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+  AtaDevice->Abort = FALSE;\r
+  gBS->RestoreTPL (OldTpl);\r
+}\r
+\r
 /**\r
   Call back funtion when the event is signaled.\r
 \r
 /**\r
   Call back funtion when the event is signaled.\r
 \r
@@ -617,6 +673,11 @@ AtaNonBlockingCallBack (
   if ((!(*Task->IsError)) && ((Task->Packet.Asb->AtaStatus & 0x01) == 0x01)) {\r
     Task->Token->TransactionStatus = EFI_DEVICE_ERROR;\r
   }\r
   if ((!(*Task->IsError)) && ((Task->Packet.Asb->AtaStatus & 0x01) == 0x01)) {\r
     Task->Token->TransactionStatus = EFI_DEVICE_ERROR;\r
   }\r
+\r
+  if (AtaDevice->Abort) {\r
+    Task->Token->TransactionStatus = EFI_ABORTED;\r
+  }\r
+\r
   DEBUG ((\r
     EFI_D_BLKIO,\r
     "NON-BLOCKING EVENT FINISHED!- STATUS = %r\n",\r
   DEBUG ((\r
     EFI_D_BLKIO,\r
     "NON-BLOCKING EVENT FINISHED!- STATUS = %r\n",\r
@@ -652,7 +713,7 @@ AtaNonBlockingCallBack (
     //\r
     if (!IsListEmpty (&AtaDevice->AtaTaskList)) {\r
       Entry   = GetFirstNode (&AtaDevice->AtaTaskList);\r
     //\r
     if (!IsListEmpty (&AtaDevice->AtaTaskList)) {\r
       Entry   = GetFirstNode (&AtaDevice->AtaTaskList);\r
-      AtaTask = ATA_AYNS_TASK_FROM_ENTRY (Entry);\r
+      AtaTask = ATA_ASYN_TASK_FROM_ENTRY (Entry);\r
       DEBUG ((EFI_D_BLKIO, "Start to embark a new Ata Task\n"));\r
       DEBUG ((EFI_D_BLKIO, "AtaTask->NumberOfBlocks = %x; AtaTask->Token=%x\n", AtaTask->NumberOfBlocks, AtaTask->Token));\r
       Status = AccessAtaDevice (\r
       DEBUG ((EFI_D_BLKIO, "Start to embark a new Ata Task\n"));\r
       DEBUG ((EFI_D_BLKIO, "AtaTask->NumberOfBlocks = %x; AtaTask->Token=%x\n", AtaTask->NumberOfBlocks, AtaTask->Token));\r
       Status = AccessAtaDevice (\r
@@ -737,7 +798,7 @@ AccessAtaDevice(
   SubTask    = NULL;\r
   SubEvent   = NULL;\r
   AtaTask    = NULL;\r
   SubTask    = NULL;\r
   SubEvent   = NULL;\r
   AtaTask    = NULL;\r
-  \r
+\r
   //\r
   // Ensure AtaDevice->Lba48Bit is a valid boolean value\r
   //\r
   //\r
   // Ensure AtaDevice->Lba48Bit is a valid boolean value\r
   //\r
@@ -750,6 +811,7 @@ AccessAtaDevice(
   //\r
   if ((Token != NULL) && (Token->Event != NULL)) {\r
     OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
   //\r
   if ((Token != NULL) && (Token->Event != NULL)) {\r
     OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
     if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {\r
       AtaTask = AllocateZeroPool (sizeof (ATA_BUS_ASYN_TASK));\r
       if (AtaTask == NULL) {\r
     if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {\r
       AtaTask = AllocateZeroPool (sizeof (ATA_BUS_ASYN_TASK));\r
       if (AtaTask == NULL) {\r
@@ -788,7 +850,7 @@ AccessAtaDevice(
     DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks));\r
     DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, MaxTransferBlockNumber=%x\n", MaxTransferBlockNumber));\r
     DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, EventCount=%x\n", TempCount));\r
     DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks));\r
     DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, MaxTransferBlockNumber=%x\n", MaxTransferBlockNumber));\r
     DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, EventCount=%x\n", TempCount));\r
-  }else {\r
+  } else {\r
     while (!IsListEmpty (&AtaDevice->AtaTaskList) || !IsListEmpty (&AtaDevice->AtaSubTaskList)) {\r
       //\r
       // Stall for 100us.\r
     while (!IsListEmpty (&AtaDevice->AtaTaskList) || !IsListEmpty (&AtaDevice->AtaSubTaskList)) {\r
       //\r
       // Stall for 100us.\r