From nobody Sat Nov 2 14:25:16 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1488924934941984.6096763154356; Tue, 7 Mar 2017 14:15:34 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BACF480369; Tue, 7 Mar 2017 14:15:32 -0800 (PST) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 57CD68034B for ; Tue, 7 Mar 2017 14:15:30 -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 445DDC28; Tue, 7 Mar 2017 14:15:30 -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 EC5483F3E1; Tue, 7 Mar 2017 14:15:29 -0800 (PST) X-Original-To: edk2-devel@lists.01.org From: Jeremy Linton To: edk2-devel@lists.01.org Date: Tue, 7 Mar 2017 16:15:10 -0600 Message-Id: <20170307221512.5180-6-jeremy.linton@arm.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170307221512.5180-1-jeremy.linton@arm.com> References: <20170307221512.5180-1-jeremy.linton@arm.com> Subject: [edk2] [PATCH v4 5/6] 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: , Cc: ryan.harkin@linaro.org, ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 | 69 +++++++++++++-----= ---- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/EmbeddedPkg/Drivers/SataSiI3132Dxe/SiI3132AtaPassThru.c b/Embe= ddedPkg/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 B= SD License @@ -61,7 +61,7 @@ SiI3231DeviceReady ( } while (Timeout && !(Value32 & SII3132_PORT_STATUS_PORTREADY)); if (Timeout =3D=3D 0) { DEBUG ((DEBUG_WARN, "SiI3132AtaPassThru() Device not ready, try anyway= \n")); - //Consider doing a device reset here. + // Consider doing a device reset here. } =20 return Timeout; @@ -76,7 +76,8 @@ SiI3132IssueCommand ( ) { UINT32 IrqMask; - UINT32 Value32, Error; + UINT32 Value32; + UINT32 Error; UINTN EmptySlot; EFI_STATUS Status; =20 @@ -89,15 +90,15 @@ SiI3132IssueCommand ( if (!FeaturePcdGet (PcdSataSiI3132FeatureDirectCommandIssuing)) { // Indirect Command Issuance =20 - //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 + (Em= ptySlot * 8), (UINT32)(SataPort->PhysAddrHostPRB & 0xFFFFFFFF)); SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CMDACTIV_REG + (Em= ptySlot * 8) + 4, (UINT32)((SataPort->PhysAddrHostPRB >> 32) & 0xFFFFFF= FF)); } else { // Direct Command Issuance - DEBUG ((DEBUG_ERROR ,"SiI3132AtaPassThru() Untested path\n")); + DEBUG ((DEBUG_ERROR, "SiI3132AtaPassThru() Untested path\n")); Status =3D PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 1, // Bar 1 SataPort->RegBase + (EmptySlot * 0x80), sizeof (SATA_SI3132_PRB) / 4, @@ -128,7 +129,7 @@ SiI3132IssueCommand ( StatusBlock); =20 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)); } =20 if (Timeout =3D=3D 0) { @@ -146,7 +147,7 @@ SiI3132IssueCommand ( SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, Val= ue32 & 0xFF00); //clear error bits =20 DEBUG ((DEBUG_INFO, "SiI3132AtaPassThru() CmdErr:0x%X (SiI3132 Err:0x%= X) (STATUS: %X ERROR:%X) SERROR=3D%X\n", - Value32, Error, SataPort->HostPRB->Fis.Command,SataPort->HostP= RB->Fis.Features, Serror)); + Value32, Error, SataPort->HostPRB->Fis.Command, SataPort->Host= PRB->Fis.Features, Serror)); =20 // clear port status SATA_PORT_WRITE32 (SataPort->RegBase + SII3132_PORT_CONTROLSET_REG, SI= I3132_PORT_CONTROL_INT); @@ -182,6 +183,7 @@ SiI3132AtaPassThruCommand ( EFI_STATUS Status; VOID* PciAllocMapping =3D NULL; EFI_PCI_IO_PROTOCOL *PciIo; + ATA_IDENTIFY_DATA *IdentifyData; =20 PciIo =3D 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 th= e BlockSize if (Packet->Acb->AtaCommand =3D=3D ATA_CMD_IDENTIFY_DRIVE) { - ATA_IDENTIFY_DATA *IdentifyData =3D (ATA_IDENTIFY_DATA*)Packet->InDa= taBuffer; + IdentifyData =3D (ATA_IDENTIFY_DATA*)Packet->InDataBuffer; =20 // Get the corresponding Block Device SataDevice =3D GetSataDevice (SataSiI3132Instance, SataPort->Index, = PortMultiplierPort); @@ -446,9 +448,9 @@ SiI3132GetNextPort ( *Port =3D 0; } else { if (PrevPort < SATA_SII3132_MAXPORT) { - *Port =3D PrevPort + 1; + *Port =3D PrevPort + 1; } else { - Status =3D EFI_NOT_FOUND; + Status =3D EFI_NOT_FOUND; } } return Status; @@ -521,16 +523,19 @@ SiI3132GetNextDevice ( SataPort =3D &(SataSiI3132Instance->Ports[Port]); =20 if (*PortMultiplierPort =3D=3D 0xFFFF) { + SATA_TRACE ("SiI3132GetNextDevice() PortMultiplier"); List =3D SataPort->Devices.ForwardLink; - if (List !=3D &SataPort->Devices) { + if ((List !=3D &SataPort->Devices) && + (((SATA_SI3132_DEVICE*)List)->Atapi =3D=3D FALSE)) { // The list is not empty, return the first device *PortMultiplierPort =3D ((SATA_SI3132_DEVICE*)List)->Index; } else { Status =3D EFI_NOT_FOUND; } } else { + SATA_TRACE ("SiI3132GetNextDevice()"); SataDevice =3D GetSataDevice (SataSiI3132Instance, Port, *PortMultipli= erPort); - if (SataDevice !=3D NULL) { + if ((SataDevice !=3D NULL) && (SataDevice->Atapi =3D=3D FALSE)) { // We have found the previous port multiplier, return the next one List =3D SataDevice->Link.ForwardLink; if (List !=3D &SataPort->Devices) { @@ -589,8 +594,6 @@ SiI3132BuildDevicePath ( SATA_SI3132_DEVICE *SataDevice; EFI_DEVICE_PATH_PROTOCOL *SiI3132DevicePath; =20 - SATA_TRACE ("SiI3132BuildDevicePath()"); - SataSiI3132Instance =3D INSTANCE_FROM_ATAPASSTHRU_THIS (This); if (!SataSiI3132Instance) { return EFI_INVALID_PARAMETER; @@ -601,20 +604,30 @@ SiI3132BuildDevicePath ( return EFI_NOT_FOUND; } =20 - SiI3132DevicePath =3D CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SATA_= DP, sizeof (SATA_DEVICE_PATH)); - if (SiI3132DevicePath =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } + if (SataDevice->Atapi) { + DEBUG ((DEBUG_INFO, "SiI3132BuildDevicePath() Atapi %d:%d\n", Port, Po= rtMultiplierPort)); + SiI3132DevicePath =3D CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SCS= I_DP, sizeof (SCSI_DEVICE_PATH)); + if (SiI3132DevicePath =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + ((SCSI_DEVICE_PATH*)SiI3132DevicePath)->Pun =3D Port; + ((SCSI_DEVICE_PATH*)SiI3132DevicePath)->Lun =3D 0; =20 - ((SATA_DEVICE_PATH*)SiI3132DevicePath)->HBAPortNumber =3D Port; - if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) { - ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber =3D P= ortMultiplierPort; } else { - //Temp:((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumbe= r =3D SATA_HBA_DIRECT_CONNECT_FLAG; - ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber =3D 0; - } - ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun =3D Port; //TODO: Search inf= ormation how to define properly LUN (Logical Unit Number) + DEBUG ((DEBUG_VERBOSE, "SiI3132BuildDevicePath() ATA %d:%d\n", Port, P= ortMultiplierPort)); + SiI3132DevicePath =3D CreateDeviceNode (MESSAGING_DEVICE_PATH, MSG_SAT= A_DP, sizeof (SATA_DEVICE_PATH)); + if (SiI3132DevicePath =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } =20 + ((SATA_DEVICE_PATH*)SiI3132DevicePath)->HBAPortNumber =3D Port; + if (FeaturePcdGet (PcdSataSiI3132FeaturePMPSupport)) { + ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber =3D= PortMultiplierPort; + } else { + ((SATA_DEVICE_PATH*)SiI3132DevicePath)->PortMultiplierPortNumber =3D= 0; + } + ((SATA_DEVICE_PATH*)SiI3132DevicePath)->Lun =3D 0; // Only support lun= 0 on ATA + } *DevicePath =3D SiI3132DevicePath; return EFI_SUCCESS; } @@ -680,7 +693,7 @@ SiI3132GetDevice ( return EFI_INVALID_PARAMETER; } =20 - if (((SATA_DEVICE_PATH*)DevicePath)->Lun >=3D SATA_SII3132_MAXPORT) { + if (((SATA_DEVICE_PATH*)DevicePath)->HBAPortNumber >=3D SATA_SII3132_MAX= PORT) { return EFI_NOT_FOUND; } =20 @@ -688,7 +701,7 @@ SiI3132GetDevice ( ASSERT (0); //TODO: Implement me! return EFI_UNSUPPORTED; } else { - *Port =3D ((SATA_DEVICE_PATH*)DevicePath)->Lun; + *Port =3D ((SATA_DEVICE_PATH*)DevicePath)->HBAPortNumber; // Return the first Sata Sevice as there should be only one directly c= onnected *PortMultiplierPort =3D ((SATA_SI3132_DEVICE*)SataSiI3132Instance->Por= ts[*Port].Devices.ForwardLink)->Index; return EFI_SUCCESS; --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel