]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg Ata: Use the new (incompatible) PortMultiplierPort semantics
authorHao Wu <hao.a.wu@intel.com>
Fri, 8 Apr 2016 08:23:57 +0000 (16:23 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 12 May 2016 06:18:08 +0000 (14:18 +0800)
The Mantis ticket 1353 <https://mantis.uefi.org/mantis/view.php?id=1353>
and Mantis ticket 1472 <https://mantis.uefi.org/mantis/view.php?id=1472>
updated the description of the port multiplier port number parameter in
SATA Device Path Node and ATA Pass-Through Protocol.

Now, this parameter should be set to 0xFFFF instead of 0 to indicate that
an ATA device is directly attached on the controller port.

Please note that this is an incompatible change. The consumer of SATA
device path or ATA_PASS_THRU needs to re-examine its usage to follow UEFI
2.5 mantis 1353 and 1472.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h

index f64a3407e4687d6902656d0716e748c10943006e..b278aa8189621008ad4a14e68e8dabf82244961e 100644 (file)
@@ -2513,7 +2513,7 @@ AhciModeInitialization (
       //\r
       // Found a ATA or ATAPI device, add it into the device list.\r
       //\r
-      CreateNewDeviceInfo (Instance, Port, 0, DeviceType, &Buffer);\r
+      CreateNewDeviceInfo (Instance, Port, 0xFFFF, DeviceType, &Buffer);\r
       if (DeviceType == EfiIdeHarddisk) {\r
         REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_PERIPHERAL_FIXED_MEDIA | EFI_P_PC_ENABLE));\r
       }\r
index 870900f1060db9310d4008e4bf1e1efae89dd341..2389d54926e7b8a9244d8b2796967abf0c6fc53b 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 - 2015, Intel Corporation. All rights reserved.<BR>\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
@@ -148,7 +148,7 @@ UINT8 mScsiId[TARGET_MAX_BYTES] = {
 \r
   @param[in]      Port               The port number of the ATA device to send the command.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r
-                                     If there is no port multiplier, then specify 0.\r
+                                     If there is no port multiplier, then specify 0xFFFF.\r
   @param[in, out] Packet             A pointer to the ATA command to send to the ATA device specified by Port\r
                                      and PortMultiplierPort.\r
   @param[in]      Instance           Pointer to the ATA_ATAPI_PASS_THRU_INSTANCE.\r
@@ -272,6 +272,14 @@ AtaPassThruPassThruExecute (
       }\r
       break;\r
     case EfiAtaAhciMode :\r
+      if (PortMultiplierPort == 0xFFFF) {\r
+        //\r
+        // If there is no port multiplier, PortMultiplierPort will be 0xFFFF\r
+        // according to UEFI spec. Here, we convert its value to 0 to follow\r
+        // AHCI spec.\r
+        //\r
+        PortMultiplierPort = 0;\r
+      }\r
       switch (Protocol) {\r
         case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:\r
           Status = AhciNonDataTransfer (\r
@@ -982,7 +990,7 @@ AtaAtapiPassThruStop (
   @param[in]  Instance            A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
   @param[in]  Port                The port number of the ATA device to send the command.\r
   @param[in]  PortMultiplierPort  The port multiplier port number of the ATA device to send the command.\r
-                                  If there is no port multiplier, then specify 0.\r
+                                  If there is no port multiplier, then specify 0xFFFF.\r
   @param[in]  DeviceType          The device type of the ATA device.\r
 \r
   @retval     The pointer to the data structure of the device info to access.\r
@@ -1004,6 +1012,18 @@ SearchDeviceInfoList (
   while (!IsNull (&Instance->DeviceList, Node)) {\r
     DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r
 \r
+    //\r
+    // For CD-ROM working in the AHCI mode, only 8 bits are used to record\r
+    // the PortMultiplier information. If the CD-ROM is directly attached\r
+    // on a SATA port, the PortMultiplier should be translated from 0xFF\r
+    // to 0xFFFF according to the UEFI spec.\r
+    //\r
+    if ((Instance->Mode == EfiAtaAhciMode) &&\r
+        (DeviceInfo->Type == EfiIdeCdrom) &&\r
+        (PortMultiplier == 0xFF)) {\r
+        PortMultiplier = 0xFFFF;\r
+    }\r
+\r
     if ((DeviceInfo->Type == DeviceType) &&\r
         (Port == DeviceInfo->Port) &&\r
         (PortMultiplier == DeviceInfo->PortMultiplier)) {\r
@@ -1023,7 +1043,7 @@ SearchDeviceInfoList (
   @param[in]  Instance            A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
   @param[in]  Port                The port number of the ATA device to send the command.\r
   @param[in]  PortMultiplierPort  The port multiplier port number of the ATA device to send the command.\r
-                                  If there is no port multiplier, then specify 0.\r
+                                  If there is no port multiplier, then specify 0xFFFF.\r
   @param[in]  DeviceType          The device type of the ATA device.\r
   @param[in]  IdentifyData        The data buffer to store the output of the IDENTIFY cmd.\r
 \r
@@ -1216,7 +1236,7 @@ Done:
   @param[in]      This               A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in]      Port               The port number of the ATA device to send the command.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r
-                                     If there is no port multiplier, then specify 0.\r
+                                     If there is no port multiplier, then specify 0xFFFF.\r
   @param[in, out] Packet             A pointer to the ATA command to send to the ATA device specified by Port\r
                                      and PortMultiplierPort.\r
   @param[in]      Event               If non-blocking I/O is not supported then Event is ignored, and blocking\r
@@ -1531,17 +1551,25 @@ AtaPassThruGetNextDevice (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (*PortMultiplierPort == 0xFFFF) {\r
+  if (Instance->PreviousPortMultiplier == 0xFFFF) {\r
     //\r
-    // If the PortMultiplierPort is all 0xFF's, start to traverse the device list from the beginning\r
+    // If a device is directly attached on a port, previous call to this\r
+    // function will return the value 0xFFFF for PortMultiplierPort. In\r
+    // this case, there should be no more device on the port multiplier.\r
     //\r
+    Instance->PreviousPortMultiplier = 0;\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (*PortMultiplierPort == Instance->PreviousPortMultiplier) {\r
     Node = GetFirstNode (&Instance->DeviceList);\r
 \r
     while (!IsNull (&Instance->DeviceList, Node)) {\r
       DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r
 \r
       if ((DeviceInfo->Type == EfiIdeHarddisk) &&\r
-           (DeviceInfo->Port == Port)){\r
+           (DeviceInfo->Port == Port) &&\r
+           (DeviceInfo->PortMultiplier > *PortMultiplierPort)){\r
         *PortMultiplierPort = DeviceInfo->PortMultiplier;\r
         goto Exit;\r
       }\r
@@ -1550,15 +1578,17 @@ AtaPassThruGetNextDevice (
     }\r
 \r
     return EFI_NOT_FOUND;\r
-  } else if (*PortMultiplierPort == Instance->PreviousPortMultiplier) {\r
+  } else if (*PortMultiplierPort == 0xFFFF) {\r
+    //\r
+    // If the PortMultiplierPort is all 0xFF's, start to traverse the device list from the beginning\r
+    //\r
     Node = GetFirstNode (&Instance->DeviceList);\r
 \r
     while (!IsNull (&Instance->DeviceList, Node)) {\r
       DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r
 \r
       if ((DeviceInfo->Type == EfiIdeHarddisk) &&\r
-           (DeviceInfo->Port == Port) &&\r
-           (DeviceInfo->PortMultiplier > *PortMultiplierPort)){\r
+           (DeviceInfo->Port == Port)){\r
         *PortMultiplierPort = DeviceInfo->PortMultiplier;\r
         goto Exit;\r
       }\r
@@ -1601,7 +1631,7 @@ Exit:
                                      device path node is to be allocated and built.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device for which a\r
                                      device path node is to be allocated and built. If there is no\r
-                                     port multiplier, then specify 0.\r
+                                     port multiplier, then specify 0xFFFF.\r
   @param[in, out] DevicePath         A pointer to a single device path node that describes the ATA\r
                                      device specified by Port and PortMultiplierPort. This function\r
                                      is responsible for allocating the buffer DevicePath with the\r
@@ -1812,7 +1842,7 @@ AtaPassThruResetPort (
   @param[in] This                A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in] Port                Port represents the port number of the ATA device to be reset.\r
   @param[in] PortMultiplierPort  The port multiplier port number of the ATA device to reset.\r
-                                 If there is no port multiplier, then specify 0.\r
+                                 If there is no port multiplier, then specify 0xFFFF.\r
   @retval EFI_SUCCESS            The ATA device specified by Port and PortMultiplierPort was reset.\r
   @retval EFI_UNSUPPORTED        The ATA controller does not support a device reset operation.\r
   @retval EFI_INVALID_PARAMETER  Port or PortMultiplierPort are invalid.\r
@@ -2049,6 +2079,13 @@ ExtScsiPassThruPassThru (
       Status = AtaPacketCommandExecute (Instance->PciIo, &Instance->IdeRegisters[Port], Port, PortMultiplier, Packet);\r
       break;\r
     case EfiAtaAhciMode:\r
+      if (PortMultiplier == 0xFF) {\r
+        //\r
+        // If there is no port multiplier, the PortMultiplier will be 0xFF\r
+        // Here, we convert its value to 0 to follow the AHCI spec.\r
+        //\r
+        PortMultiplier = 0;\r
+      }\r
       Status = AhciPacketCommandExecute (Instance->PciIo, &Instance->AhciRegisters, Port, PortMultiplier, Packet);\r
       break;\r
     default :\r
@@ -2186,7 +2223,7 @@ ExtScsiPassThruGetNextTargetLun (
       if ((DeviceInfo->Type == EfiIdeCdrom) &&\r
          ((Target8[0] < DeviceInfo->Port) ||\r
           ((Target8[0] == DeviceInfo->Port) &&\r
-           (Target8[1] < DeviceInfo->PortMultiplier)))) {\r
+           (Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {\r
         Target8[0] = (UINT8)DeviceInfo->Port;\r
         Target8[1] = (UINT8)DeviceInfo->PortMultiplier;\r
         goto Exit;\r
@@ -2308,7 +2345,13 @@ ExtScsiPassThruBuildDevicePath (
     }\r
 \r
     DevicePathNode->Sata.HBAPortNumber            = Port;\r
-    DevicePathNode->Sata.PortMultiplierPortNumber = PortMultiplier;\r
+    //\r
+    // For CD-ROM working in the AHCI mode, only 8 bits are used to record\r
+    // the PortMultiplier information. If the CD-ROM is directly attached\r
+    // on a SATA port, the PortMultiplier should be translated from 0xFF\r
+    // to 0xFFFF according to the UEFI spec.\r
+    //\r
+    DevicePathNode->Sata.PortMultiplierPortNumber = PortMultiplier == 0xFF ? 0xFFFF : PortMultiplier;\r
     DevicePathNode->Sata.Lun                      = (UINT16) Lun;\r
   }\r
 \r
@@ -2562,7 +2605,7 @@ ExtScsiPassThruGetNextTarget (
       if ((DeviceInfo->Type == EfiIdeCdrom) &&\r
          ((Target8[0] < DeviceInfo->Port) ||\r
           ((Target8[0] == DeviceInfo->Port) &&\r
-           (Target8[1] < DeviceInfo->PortMultiplier)))) {\r
+           (Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {\r
         Target8[0] = (UINT8)DeviceInfo->Port;\r
         Target8[1] = (UINT8)DeviceInfo->PortMultiplier;\r
         goto Exit;\r
index 6f3407c01aa8ae0d1e05d47810fe794684336065..4f327dc30b60b6bee78ceae1e48d1b69365d313e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file for ATA/ATAPI PASS THRU driver.\r
 \r
-  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\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
@@ -437,7 +437,7 @@ AtaAtapiPassThruStop (
   @param[in]  Instance            A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
   @param[in]  Port                The port number of the ATA device to send the command.\r
   @param[in]  PortMultiplierPort  The port multiplier port number of the ATA device to send the command.\r
-                                  If there is no port multiplier, then specify 0.\r
+                                  If there is no port multiplier, then specify 0xFFFF.\r
   @param[in]  DeviceType          The device type of the ATA device.\r
 \r
   @retval     The pointer to the data structure of the device info to access.\r
@@ -459,7 +459,7 @@ SearchDeviceInfoList (
   @param[in]  Instance            A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
   @param[in]  Port                The port number of the ATA device to send the command.\r
   @param[in]  PortMultiplierPort  The port multiplier port number of the ATA device to send the command.\r
-                                  If there is no port multiplier, then specify 0.\r
+                                  If there is no port multiplier, then specify 0xFFFF.\r
   @param[in]  DeviceType          The device type of the ATA device.\r
   @param[in]  IdentifyData        The data buffer to store the output of the IDENTIFY cmd.\r
 \r
@@ -544,7 +544,7 @@ AsyncNonBlockingTransferRoutine (
   @param[in]      This               A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in]      Port               The port number of the ATA device to send the command.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r
-                                     If there is no port multiplier, then specify 0.\r
+                                     If there is no port multiplier, then specify 0xFFFF.\r
   @param[in, out] Packet             A pointer to the ATA command to send to the ATA device specified by Port\r
                                      and PortMultiplierPort.\r
   @param[in]      Event              If non-blocking I/O is not supported then Event is ignored, and blocking\r
@@ -681,7 +681,7 @@ AtaPassThruGetNextDevice (
                                      device path node is to be allocated and built.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device for which a\r
                                      device path node is to be allocated and built. If there is no\r
-                                     port multiplier, then specify 0.\r
+                                     port multiplier, then specify 0xFFFF.\r
   @param[in, out] DevicePath         A pointer to a single device path node that describes the ATA\r
                                      device specified by Port and PortMultiplierPort. This function\r
                                      is responsible for allocating the buffer DevicePath with the\r
@@ -802,7 +802,7 @@ AtaPassThruResetPort (
   @param[in] This                A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in] Port                Port represents the port number of the ATA device to be reset.\r
   @param[in] PortMultiplierPort  The port multiplier port number of the ATA device to reset.\r
-                                 If there is no port multiplier, then specify 0.\r
+                                 If there is no port multiplier, then specify 0xFFFF.\r
   @retval EFI_SUCCESS            The ATA device specified by Port and PortMultiplierPort was reset.\r
   @retval EFI_UNSUPPORTED        The ATA controller does not support a device reset operation.\r
   @retval EFI_INVALID_PARAMETER  Port or PortMultiplierPort are invalid.\r