]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
MdeModulePkg/PciBus: Reserve Bus number for non-root and root HPBs
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaBusDxe / AtaBus.c
index 8fa0b3f626cea7b3b7786d45f878743235ba0624..cb7f1f031e58eb805e08b61a2192d0c6eda79716 100644 (file)
@@ -4,7 +4,7 @@
   This file implements protocol interfaces: Driver Binding protocol,\r
   Block IO protocol and DiskInfo protocol.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, 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
@@ -88,7 +88,8 @@ ATA_DEVICE gAtaDeviceTemplate = {
   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
@@ -170,7 +171,7 @@ ReleaseAtaResources (
        ) {\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
@@ -185,7 +186,7 @@ ReleaseAtaResources (
        ) {\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
@@ -292,6 +293,15 @@ RegisterAtaDevice (
   InitializeListHead (&AtaDevice->AtaTaskList);\r
   InitializeListHead (&AtaDevice->AtaSubTaskList);\r
 \r
+  //\r
+  // Report Status Code to indicate the ATA device will be enabled\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_ENABLE),\r
+    AtaBusDriverData->ParentDevicePath\r
+    );\r
+\r
   //\r
   // Try to identify the ATA device via the ATA pass through command.\r
   //\r
@@ -364,6 +374,7 @@ RegisterAtaDevice (
     if (EFI_ERROR (Status)) {\r
       goto Done;\r
     }\r
+    DEBUG ((EFI_D_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));\r
   }\r
 \r
   gBS->OpenProtocol (\r
@@ -450,6 +461,7 @@ UnregisterAtaDevice (
   if (BlockIo != NULL) {\r
     AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);\r
   } else {\r
+    ASSERT (BlockIo2 != NULL);\r
     AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (BlockIo2);\r
   }\r
 \r
@@ -605,12 +617,37 @@ AtaBusDriverBindingSupported (
     return Status;\r
   }\r
 \r
+  //\r
+  // Test to see if this ATA Pass Thru Protocol is for a LOGICAL channel\r
+  //\r
+  if ((AtaPassThru->Mode->Attributes & EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL) == 0) {\r
+    //\r
+    // Close the I/O Abstraction(s) used to perform the supported test\r
+    //\r
+    gBS->CloseProtocol (\r
+          Controller,\r
+          &gEfiAtaPassThruProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Controller\r
+          );\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   //\r
   // Test RemainingDevicePath is valid or not.\r
   //\r
   if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {\r
     Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);\r
     if (EFI_ERROR (Status)) {\r
+      //\r
+      // Close the I/O Abstraction(s) used to perform the supported test\r
+      //\r
+      gBS->CloseProtocol (\r
+            Controller,\r
+            &gEfiAtaPassThruProtocolGuid,\r
+            This->DriverBindingHandle,\r
+            Controller\r
+            );\r
       return Status;\r
     }\r
   }\r
@@ -704,6 +741,15 @@ AtaBusDriverBindingStart (
     return Status;\r
   }\r
 \r
+  //\r
+  // Report Status Code to indicate ATA bus starts\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_INIT),\r
+    ParentDevicePath\r
+    );\r
+\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
                   &gEfiAtaPassThruProtocolGuid,\r
@@ -756,6 +802,15 @@ AtaBusDriverBindingStart (
     }\r
   }\r
 \r
+  //\r
+  // Report Status Code to indicate detecting devices on bus\r
+  //\r
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_DETECT),\r
+    ParentDevicePath\r
+    );\r
+\r
   if (RemainingDevicePath == NULL) {\r
     Port = 0xFFFF;\r
     while (TRUE) {\r
@@ -950,7 +1005,7 @@ AtaBlockIoReset (
   @param[in, out]  Token      A pointer to the token associated with the transaction.\r
   @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
   @param[out]      Buffer     A pointer to the destination/source buffer for the data.\r
-  @param[in]       IsBlockIo2 Indicate the calling is from BlockIO or BlockIO2. TURE is\r
+  @param[in]       IsBlockIo2 Indicate the calling is from BlockIO or BlockIO2. TRUE is\r
                               from BlockIO2, FALSE is for BlockIO.\r
   @param[in]       IsWrite    Indicates whether it is a write operation.\r
 \r
@@ -1004,6 +1059,10 @@ BlockIoReadWrite (
   }\r
 \r
   if (BufferSize == 0) {\r
+    if ((Token != NULL) && (Token->Event != NULL)) {\r
+      Token->TransactionStatus = EFI_SUCCESS;\r
+      gBS->SignalEvent (Token->Event);\r
+    }\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -1150,6 +1209,8 @@ AtaBlockIoResetEx (
 \r
   AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
 \r
+  AtaTerminateNonBlockingTask (AtaDevice);\r
+\r
   Status = ResetAtaDevice (AtaDevice);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -1482,7 +1543,7 @@ AtaStorageSecurityReceiveData (
   ATA_DEVICE                       *Private;\r
   EFI_TPL                          OldTpl;\r
 \r
-  DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read"));\r
+  DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read\n"));\r
   if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1592,7 +1653,7 @@ AtaStorageSecuritySendData (
   ATA_DEVICE                       *Private;\r
   EFI_TPL                          OldTpl;\r
 \r
-  DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send"));\r
+  DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send\n"));\r
   if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1654,3 +1715,4 @@ InitializeAtaBus(
 \r
   return Status;\r
 }\r
+\r