From: Jeremy Linton <jeremy.linton@arm.com>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, ryan.harkin@linaro.org,
linaro-uefi@lists.linaro.org, ard.biesheuvel@linaro.org,
Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH v4 5/6] EmbeddedPkg: SiI3132: Cleanup device node creation
Date: Tue, 7 Mar 2017 16:15:10 -0600 [thread overview]
Message-ID: <20170307221512.5180-6-jeremy.linton@arm.com> (raw)
In-Reply-To: <20170307221512.5180-1-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 | 69 +++++++++++++---------
1 file changed, 41 insertions(+), 28 deletions(-)
diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
index 601583d..ce33438 100644
--- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
+++ b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2017, 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
@@ -61,7 +61,7 @@ SiI3231DeviceReady (
} while (Timeout && !(Value32 & SII3132_PORT_STATUS_PORTREADY));
if (Timeout == 0) {
DEBUG ((DEBUG_WARN, "SiI3132AtaPassThru() Device not ready, try anyway\n"));
- //Consider doing a device reset here.
+ // Consider doing a device reset here.
}
return Timeout;
@@ -76,7 +76,8 @@ SiI3132IssueCommand (
)
{
UINT32 IrqMask;
- UINT32 Value32, Error;
+ UINT32 Value32;
+ UINT32 Error;
UINTN EmptySlot;
EFI_STATUS Status;
@@ -89,15 +90,15 @@ SiI3132IssueCommand (
if (!FeaturePcdGet (PcdSataSiI3132FeatureDirectCommandIssuing)) {
// Indirect Command Issuance
- //TODO: Find which slot is free (maybe use the Cmd FIFO)
- //SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_CMDEXECFIFO_REG, &EmptySlot);
+ // TODO: Find which slot is free (maybe use the Cmd FIFO)
+ // SATA_PORT_READ32 (SataPort->RegBase + SII3132_PORT_CMDEXECFIFO_REG, &EmptySlot);
SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CMDACTIV_REG + (EmptySlot * 8),
(UINT32)(SataPort->PhysAddrHostPRB & 0xFFFFFFFF));
SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CMDACTIV_REG + (EmptySlot * 8) + 4,
(UINT32)((SataPort->PhysAddrHostPRB >> 32) & 0xFFFFFFFF));
} else {
// Direct Command Issuance
- DEBUG ((DEBUG_ERROR ,"SiI3132AtaPassThru() Untested path\n"));
+ DEBUG ((DEBUG_ERROR, "SiI3132AtaPassThru() Untested path\n"));
Status = PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 1, // Bar 1
SataPort->RegBase + (EmptySlot * 0x80),
sizeof (SATA_SI3132_PRB) / 4,
@@ -128,7 +129,7 @@ SiI3132IssueCommand (
StatusBlock);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "SiI3132AtaPassThru() status (%d) block %X %X\n",Status, SataPort->RegBase, StatusBlock));
+ DEBUG ((DEBUG_ERROR, "SiI3132AtaPassThru() status (%d) block %X %X\n", Status, SataPort->RegBase, StatusBlock));
}
if (Timeout == 0) {
@@ -146,7 +147,7 @@ SiI3132IssueCommand (
SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, Value32 & 0xFF00); //clear error bits
DEBUG ((DEBUG_INFO, "SiI3132AtaPassThru() CmdErr:0x%X (SiI3132 Err:0x%X) (STATUS: %X ERROR:%X) SERROR=%X\n",
- Value32, Error, SataPort->HostPRB->Fis.Command,SataPort->HostPRB->Fis.Features, Serror));
+ Value32, Error, SataPort->HostPRB->Fis.Command, SataPort->HostPRB->Fis.Features, Serror));
// clear port status
SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CONTROLSET_REG, SII3132_PORT_CONTROL_INT);
@@ -182,6 +183,7 @@ SiI3132AtaPassThruCommand (
EFI_STATUS Status;
VOID* PciAllocMapping = NULL;
EFI_PCI_IO_PROTOCOL *PciIo;
+ ATA_IDENTIFY_DATA *IdentifyData;
PciIo = SataSiI3132Instance->PciIo;
ZeroMem (SataPort->HostPRB, sizeof (SATA_SI3132_PRB));
@@ -311,7 +313,7 @@ SiI3132AtaPassThruCommand (
{
// If the command was ATA_CMD_IDENTIFY_DRIVE then we need to update the BlockSize
if (Packet->Acb->AtaCommand == ATA_CMD_IDENTIFY_DRIVE) {
- ATA_IDENTIFY_DATA *IdentifyData = (ATA_IDENTIFY_DATA*)Packet->InDataBuffer;
+ IdentifyData = (ATA_IDENTIFY_DATA*)Packet->InDataBuffer;
// Get the corresponding Block Device
SataDevice = GetSataDevice (SataSiI3132Instance, SataPort->Index, PortMultiplierPort);
@@ -446,9 +448,9 @@ SiI3132GetNextPort (
*Port = 0;
} else {
if (PrevPort < SATA_SII3132_MAXPORT) {
- *Port = PrevPort + 1;
+ *Port = PrevPort + 1;
} else {
- Status = EFI_NOT_FOUND;
+ Status = EFI_NOT_FOUND;
}
}
return Status;
@@ -521,16 +523,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) {
@@ -589,8 +594,6 @@ SiI3132BuildDevicePath (
SATA_SI3132_DEVICE *SataDevice;
EFI_DEVICE_PATH_PROTOCOL *SiI3132DevicePath;
- SATA_TRACE ("SiI3132BuildDevicePath()");
-
SataSiI3132Instance = INSTANCE_FROM_ATAPASSTHRU_THIS (This);
if (!SataSiI3132Instance) {
return EFI_INVALID_PARAMETER;
@@ -601,20 +604,30 @@ 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) {
+ DEBUG ((DEBUG_INFO, "SiI3132BuildDevicePath() Atapi %d:%d\n", Port, PortMultiplierPort));
+ 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)
+ DEBUG ((DEBUG_VERBOSE, "SiI3132BuildDevicePath() ATA %d:%d\n", Port, PortMultiplierPort));
+ 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 {
+ ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber = 0;
+ }
+ ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun = 0; // Only support lun0 on ATA
+ }
*DevicePath = SiI3132DevicePath;
return EFI_SUCCESS;
}
@@ -680,7 +693,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;
}
@@ -688,7 +701,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.9.3
next prev parent reply other threads:[~2017-03-07 22:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 22:15 [PATCH v4 0/6] ATAPI support on SiI SATA adapter Jeremy Linton
2017-03-07 22:15 ` [PATCH v4 1/6] EmbeddedPkg: SiI3132: Note that ARM is using this Dxe Jeremy Linton
2017-03-16 13:34 ` Leif Lindholm
2017-03-07 22:15 ` [PATCH v4 2/6] EmbeddedPkg: SiI3132: Add ScsiProtocol callbacks Jeremy Linton
2017-03-16 14:09 ` Leif Lindholm
2017-03-07 22:15 ` [PATCH v4 3/6] EmbeddedPkg: SiI3132: Add SCSI protocol support to header Jeremy Linton
2017-03-16 14:19 ` Leif Lindholm
2017-03-07 22:15 ` [PATCH v4 4/6] EmbeddedPkg: SiI3132: Break out FIS command submission Jeremy Linton
2017-03-17 16:31 ` Leif Lindholm
2017-03-07 22:15 ` Jeremy Linton [this message]
2017-03-17 16:37 ` [PATCH v4 5/6] EmbeddedPkg: SiI3132: Cleanup device node creation Leif Lindholm
2017-03-07 22:15 ` [PATCH v4 6/6] EmbeddedPkg: SiI3132: Enable SCSI pass-through protocol Jeremy Linton
2017-03-17 16:40 ` Leif Lindholm
2017-03-07 22:15 ` [PATCH] Platforms/ARM/Juno: Add " Jeremy Linton
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=20170307221512.5180-6-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