public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jeremy Linton <jeremy.linton@arm.com>
To: edk2-devel@lists.01.org
Cc: linaro-uefi@lists.linaro.org, ryan.harkin@linaro.org,
	leif.lindholm@linaro.org, steve.capper@arm.com,
	evan.lloyd@arm.com, daniil.egranov@arm.com,
	Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH 5/7] EmbeddedPkg: SiI3132: Cleanup device node creation
Date: Mon, 14 Nov 2016 15:09:46 -0600	[thread overview]
Message-ID: <1479157789-14674-6-git-send-email-jeremy.linton@arm.com> (raw)
In-Reply-To: <1479157789-14674-1-git-send-email-jeremy.linton@arm.com>

There can be either ATA or ATAPI devices connected to
each SATA port. We want to detect if the device is ATA
and create a SATA_DP path or a SCSI_DP for ATAPI devices.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 .../Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c    | 44 ++++++++++++++--------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
index 69bbdfe..d613aee 100644
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
+++ b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
@@ -518,16 +518,19 @@ SiI3132GetNextDevice (
   SataPort = &(SataSiI3132Instance->Ports[Port]);
 
   if (*PortMultiplierPort == 0xFFFF) {
+    SATA_TRACE ("SiI3132GetNextDevice() PortMultiplier");
     List = SataPort->Devices.ForwardLink;
-    if (List != &SataPort->Devices) {
+    if ((List != &SataPort->Devices) &&
+        (((SATA_SI3132_DEVICE*)List)->Atapi == FALSE)) {
       // The list is not empty, return the first device
       *PortMultiplierPort = ((SATA_SI3132_DEVICE*)List)->Index;
     } else {
       Status = EFI_NOT_FOUND;
     }
   } else {
+    SATA_TRACE ("SiI3132GetNextDevice()");
     SataDevice = GetSataDevice (SataSiI3132Instance, Port, *PortMultiplierPort);
-    if (SataDevice != NULL) {
+    if ((SataDevice != NULL) && (SataDevice->Atapi == FALSE)) {
       // We have found the previous port multiplier, return the next one
       List = SataDevice->Link.ForwardLink;
       if (List != &SataPort->Devices) {
@@ -598,20 +601,31 @@ SiI3132BuildDevicePath (
     return EFI_NOT_FOUND;
   }
 
-  SiI3132DevicePath = CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SATA_DP, sizeof (SATA_DEVICE_PATH));
-  if (SiI3132DevicePath == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
+  if (SataDevice->Atapi) {
+    SiI3132DevicePath = CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SCSI_DP, sizeof (SCSI_DEVICE_PATH));
+    if (SiI3132DevicePath == NULL) {
+        return EFI_OUT_OF_RESOURCES;
+    }
+    ((SCSI_DEVICE_PATH*)SiI3132DevicePath)->Pun = Port;
+    ((SCSI_DEVICE_PATH*)SiI3132DevicePath)->Lun = 0;
 
-  ((SATA_DEVICE_PATH*)SiI3132DevicePath)->HBAPortNumber = Port;
-  if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
-    ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = PortMultiplierPort;
-  } else {
-    //Temp:((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = SATA_HBA_DIRECT_CONNECT_FLAG;
-    ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = 0;
   }
-  ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun = Port; //TODO: Search information how to define properly LUN (Logical Unit Number)
+  else {
+    SiI3132DevicePath = CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SATA_DP, sizeof (SATA_DEVICE_PATH));
+    if (SiI3132DevicePath == NULL) {
+        return EFI_OUT_OF_RESOURCES;
+    }
 
+    ((SATA_DEVICE_PATH*)SiI3132DevicePath)->HBAPortNumber = Port;
+    if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
+        ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = PortMultiplierPort;
+    } else {
+        //Temp:((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = SATA_HBA_DIRECT_CONNECT_FLAG;
+        ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = 0;
+    }
+//  ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun = Port; //TODO: Search information how to define properly LUN (Logical Unit Number)
+    ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun = 0; // Only support lun0 on ATA
+  }
   *DevicePath = SiI3132DevicePath;
   return EFI_SUCCESS;
 }
@@ -677,7 +691,7 @@ SiI3132GetDevice (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (((SATA_DEVICE_PATH*)DevicePath)->Lun >= SATA_SII3132_MAXPORT) {
+  if (((SATA_DEVICE_PATH*)DevicePath)->HBAPortNumber >= SATA_SII3132_MAXPORT) {
     return EFI_NOT_FOUND;
   }
 
@@ -685,7 +699,7 @@ SiI3132GetDevice (
     ASSERT (0); //TODO: Implement me!
     return EFI_UNSUPPORTED;
   } else {
-    *Port = ((SATA_DEVICE_PATH*)DevicePath)->Lun;
+    *Port = ((SATA_DEVICE_PATH*)DevicePath)->HBAPortNumber;
     // Return the first Sata Sevice as there should be only one directly connected
     *PortMultiplierPort = ((SATA_SI3132_DEVICE*)SataSiI3132Instance->Ports[*Port].Devices.ForwardLink)->Index;
     return EFI_SUCCESS;
-- 
2.5.5



  parent reply	other threads:[~2016-11-14 21:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 21:09 [PATCH 0/8] ATAPI support on SiI SATA adapter Jeremy Linton
2016-11-14 21:09 ` [PATCH 1/7] MdePkg IndustryStandard/Scsi.h: Add sense code macro Jeremy Linton
2016-11-15  7:38   ` Ard Biesheuvel
2016-11-15 10:51   ` Gao, Liming
2016-11-14 21:09 ` [PATCH 2/7] EmbeddedPkg: SiI3132: Add ScsiProtocol callbacks Jeremy Linton
2016-11-15 16:04   ` Ard Biesheuvel
2016-11-14 21:09 ` [PATCH 3/7] EmbeddedPkg: SiI3132: Add SCSI protocol support to header Jeremy Linton
2016-11-14 21:24   ` Jeremy Linton
2016-11-15 17:02     ` Ard Biesheuvel
2016-11-16 15:44   ` Ryan Harkin
2016-11-14 21:09 ` [PATCH 4/7] EmbeddedPkg: SiI3132: Break out FIS command submission Jeremy Linton
2016-11-15 17:10   ` Ard Biesheuvel
2016-11-14 21:09 ` Jeremy Linton [this message]
2016-11-14 21:09 ` [PATCH 6/7] EmbeddedPkg: SiI3132: Enable SCSI pass-through protocol Jeremy Linton
2016-11-14 21:09 ` [PATCH 7/7] EmbeddedPkg: SiI3132: Correct the IoAlign Jeremy Linton
2016-11-14 21:09 ` [PATCH] Platforms/ARM/Juno: Add SCSI pass-through protocol Jeremy Linton
2016-11-15  7:43 ` [PATCH 0/8] ATAPI support on SiI SATA adapter Ard Biesheuvel
2016-11-15 14:54   ` Jeremy Linton
2016-11-15 14:57     ` Ard Biesheuvel
2016-11-15 15:05       ` Jeremy Linton
2016-11-15 15:10         ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479157789-14674-6-git-send-email-jeremy.linton@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox