From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 96D7E82195 for ; Thu, 23 Feb 2017 14:04:19 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7AB69C7A; Thu, 23 Feb 2017 14:04:19 -0800 (PST) Received: from u200856.usa.arm.com (u201426.usa.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1CE503F483; Thu, 23 Feb 2017 14:04:19 -0800 (PST) From: Jeremy Linton To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ryan.harkin@linaro.org, linaro-uefi@lists.linaro.org, ard.biesheuvel@linaro.org, Steve.Capper@arm.com, Jeremy Linton Date: Thu, 23 Feb 2017 16:04:03 -0600 Message-Id: <20170223220405.1954-7-jeremy.linton@arm.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170223220405.1954-1-jeremy.linton@arm.com> References: <20170223220405.1954-1-jeremy.linton@arm.com> Subject: [PATCH v2 6/7] EmbeddedPkg: SiI3132: Cleanup device node creation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2017 22:04:19 -0000 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 --- .../Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c | 43 ++++++++++++++-------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c index b14a8aa..8c65a73 100644 --- a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c +++ b/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c @@ -521,16 +521,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) { @@ -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) { + 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 = 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