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 6/7] EmbeddedPkg: SiI3132: Enable SCSI pass-through protocol
Date: Mon, 14 Nov 2016 15:09:47 -0600	[thread overview]
Message-ID: <1479157789-14674-7-git-send-email-jeremy.linton@arm.com> (raw)
In-Reply-To: <1479157789-14674-1-git-send-email-jeremy.linton@arm.com>

Now that everything is in place, lets export the protocol,
build the module, and remove the ATAPI unsupported flags.
Now when we detect an ATAPI device on a port we flag it
as such.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c   | 48 ++++++++++++++--------
 .../Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf      |  2 +
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c
index f494655..52b79fd 100644
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c
+++ b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132.c
@@ -1,7 +1,7 @@
 /** @file
 *  PCIe Sata support for the Silicon Image I3132
 *
-*  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2016, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD License
@@ -16,6 +16,7 @@
 #include "SataSiI3132.h"
 
 #include <IndustryStandard/Acpi10.h>
+#include <IndustryStandard/Atapi.h>
 
 #include <Library/MemoryAllocationLib.h>
 #include <Library/UefiBootServicesTableLib.h>
@@ -88,7 +89,6 @@ SataSiI3132Constructor (
   )
 {
   SATA_SI3132_INSTANCE    *Instance;
-  EFI_ATA_PASS_THRU_MODE  *AtaPassThruMode;
 
   if (!SataSiI3132Instance) {
     return EFI_INVALID_PARAMETER;
@@ -102,16 +102,15 @@ SataSiI3132Constructor (
   Instance->Signature           = SATA_SII3132_SIGNATURE;
   Instance->PciIo               = PciIo;
 
-  AtaPassThruMode = (EFI_ATA_PASS_THRU_MODE*)AllocatePool (sizeof (EFI_ATA_PASS_THRU_MODE));
-  AtaPassThruMode->Attributes = EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL;
-  AtaPassThruMode->IoAlign = 0x1000;
+  Instance->AtaPassThruMode.Attributes = EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL;
+  Instance->AtaPassThruMode.IoAlign = 0x1000;
 
   // Initialize SiI3132 ports
   SataSiI3132PortConstructor (Instance, 0);
   SataSiI3132PortConstructor (Instance, 1);
 
   // Set ATA Pass Thru Protocol
-  Instance->AtaPassThruProtocol.Mode            = AtaPassThruMode;
+  Instance->AtaPassThruProtocol.Mode            = &Instance->AtaPassThruMode;
   Instance->AtaPassThruProtocol.PassThru        = SiI3132AtaPassThru;
   Instance->AtaPassThruProtocol.GetNextPort     = SiI3132GetNextPort;
   Instance->AtaPassThruProtocol.GetNextDevice   = SiI3132GetNextDevice;
@@ -120,6 +119,19 @@ SataSiI3132Constructor (
   Instance->AtaPassThruProtocol.ResetPort       = SiI3132ResetPort;
   Instance->AtaPassThruProtocol.ResetDevice     = SiI3132ResetDevice;
 
+  Instance->ExtScsiPassThruMode.Attributes = EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL;
+  Instance->ExtScsiPassThruMode.IoAlign = 0x1000;
+
+  // Set SCSI Pass Thru Protocol
+  Instance->ExtScsiPassThru.Mode                = &Instance->ExtScsiPassThruMode;
+  Instance->ExtScsiPassThru.PassThru            = SiI3132ScsiPassThru;
+  Instance->ExtScsiPassThru.GetNextTargetLun    = SiI3132GetNextTargetLun;
+  Instance->ExtScsiPassThru.BuildDevicePath     = SiI3132ScsiBuildDevicePath;
+  Instance->ExtScsiPassThru.GetTargetLun        = SiI3132GetTargetLun;
+  Instance->ExtScsiPassThru.ResetChannel        = SiI3132ResetChannel;
+  Instance->ExtScsiPassThru.ResetTargetLun      = SiI3132ResetTargetLun;
+  Instance->ExtScsiPassThru.GetNextTarget       = SiI3132GetNextTarget;
+
   *SataSiI3132Instance = Instance;
 
   return EFI_SUCCESS;
@@ -165,6 +177,7 @@ SataSiI3132PortInitialization (
   UINT32                  Signature;
   EFI_STATUS              Status;
   EFI_PCI_IO_PROTOCOL*    PciIo;
+  BOOLEAN                 Atapi = FALSE;
 
   Status = SiI3132HwResetPort (Port);
   if (EFI_ERROR (Status)) {
@@ -177,24 +190,23 @@ SataSiI3132PortInitialization (
   Status = SATA_PORT_READ32 (Port->RegBase + SII3132_PORT_SSTATUS_REG, &Value32);
   if (!EFI_ERROR (Status) && (Value32 & 0x3)) {
     // Do a soft reset to see if it is a port multiplier
-    SATA_TRACE ("SataSiI3132PortInitialization: soft reset - it is a port multiplier\n");
+    SATA_TRACE ("SataSiI3132PortInitialization: soft reset - is it a port multiplier?\n");
     Status = SiI3132SoftResetCommand (Port, &Signature);
     if (!EFI_ERROR (Status)) {
       if (Signature == SII3132_PORT_SIGNATURE_PMP) {
-        SATA_TRACE ("SataSiI3132PortInitialization(): a Port Multiplier is present");
+        DEBUG ((DEBUG_ERROR, "SataSiI3132PortInitialization(): a Port Multiplier is present"));
         if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) {
           ASSERT (0); // Not supported yet
         } else {
           return EFI_UNSUPPORTED;
         }
       } else if (Signature == SII3132_PORT_SIGNATURE_ATAPI) {
-        ASSERT (0); // Not supported yet
         SATA_TRACE ("SataSiI3132PortInitialization(): an ATAPI device is present");
-        return EFI_UNSUPPORTED;
+        Atapi = TRUE;
       } else if (Signature == SII3132_PORT_SIGNATURE_ATA) {
         SATA_TRACE ("SataSiI3132PortInitialization(): an ATA device is present");
       } else {
-        SATA_TRACE ("SataSiI3132PortInitialization(): Present device unknown!");
+        DEBUG ((DEBUG_ERROR, "SataSiI3132PortInitialization(): Present device unknown!"));
         ASSERT (0); // Not supported
         return EFI_UNSUPPORTED;
       }
@@ -204,6 +216,7 @@ SataSiI3132PortInitialization (
       Device->Index     = Port->Index; //TODO: Could need to be fixed when SATA Port Multiplier support
       Device->Port      = Port;
       Device->BlockSize = 0;
+      Device->Atapi     = Atapi;
 
       // Attached the device to the Sata Port
       InsertTailList (&Port->Devices, &Device->Link);
@@ -432,13 +445,12 @@ SataSiI3132DriverBindingStart (
     return Status;
   }
 
-  // Install Ata Pass Thru Protocol
-  Status = gBS->InstallProtocolInterface (
-              &Controller,
-              &gEfiAtaPassThruProtocolGuid,
-              EFI_NATIVE_INTERFACE,
-              &(SataSiI3132Instance->AtaPassThruProtocol)
-              );
+  Status = gBS->InstallMultipleProtocolInterfaces(&Controller,
+                                                  &gEfiAtaPassThruProtocolGuid,
+                                                  &(SataSiI3132Instance->AtaPassThruProtocol),
+                                                  &gEfiExtScsiPassThruProtocolGuid,
+                                                  &(SataSiI3132Instance->ExtScsiPassThru),
+                                                  NULL);
   if (EFI_ERROR (Status)) {
     goto FREE_POOL;
   }
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
index 69aaab3..eb6e2bd 100644
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
+++ b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
@@ -35,10 +35,12 @@
   SataSiI3132.c
   ComponentName.c
   SiI3132AtaPassThru.c
+  SiI3132ScsiPassThru.c
 
 [Protocols]
   gEfiPciIoProtocolGuid                         # Consumed
   gEfiAtaPassThruProtocolGuid                   # Produced
+  gEfiExtScsiPassThruProtocolGuid               # Produced
 
 [Pcd]
   gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeaturePMPSupport
-- 
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 ` [PATCH 5/7] EmbeddedPkg: SiI3132: Cleanup device node creation Jeremy Linton
2016-11-14 21:09 ` Jeremy Linton [this message]
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-7-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