From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CCAB38200D for ; Mon, 6 Feb 2017 00:36:35 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP; 06 Feb 2017 00:36:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,341,1477983600"; d="scan'208";a="61621517" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 06 Feb 2017 00:36:35 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 6 Feb 2017 00:36:34 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 6 Feb 2017 00:36:34 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Mon, 6 Feb 2017 16:36:32 +0800 From: "Tian, Feng" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Fan, Jeff" , "Tian, Feng" Thread-Topic: [PATCH v2 2/6] MdeModulePkg/PciBus: Accept Spec values as BarIndex and Alignment Thread-Index: AQHSgD5r7/t8gs6Z8k+xxPyVwYa0v6Fbp6Nw Date: Mon, 6 Feb 2017 08:36:31 +0000 Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699AF6CA@SHSMSX101.ccr.corp.intel.com> References: <20170206060059.595976-1-ruiyu.ni@intel.com> <20170206060059.595976-3-ruiyu.ni@intel.com> In-Reply-To: <20170206060059.595976-3-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 2/6] MdeModulePkg/PciBus: Accept Spec values as BarIndex and Alignment 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: Mon, 06 Feb 2017 08:36:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 2/3/4 looks good to me Reviewed-by: Feng Tian Thanks Feng -----Original Message----- From: Ni, Ruiyu=20 Sent: Monday, February 6, 2017 2:01 PM To: edk2-devel@lists.01.org Cc: Fan, Jeff ; Tian, Feng Subject: [PATCH v2 2/6] MdeModulePkg/PciBus: Accept Spec values as BarIndex= and Alignment PI spec IncompatiblePciSupport part defines (UINT64) -1 as all BARs and 0 t= o use existing alignment. PciBus driver didn't accept these values. It trea= ted 0xFF as all BARs and 0xFFFFFFFFFFFFFFFFULL to use existing alignment. The patch changes the code to still accept old values while also accept val= ues defined in PI spec. So that the driver can provide backward compatibili= ty and follow spec. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Jeff Fan Cc: Feng Tian --- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 37 ++++++++++++++----= ---- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeMod= ulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index ac4d323..978116a 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -1,7 +1,7 @@ /** @file PCI emumeration support functions implementation for PCI Bus module. =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This pro= gram and the accompanying materials are licensed and made available under = the terms and conditions of the BSD License @@ -17,6 +17,12 @@ WITHOUT WARR= ANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. =20 extern CHAR16 *mBarTypeStr[]; =20 + +#define OLD_ALIGN 0xFFFFFFFFFFFFFFFFULL +#define EVEN_ALIGN 0xFFFFFFFFFFFFFFFEULL #define SQUAD_ALIGN=20 +0xFFFFFFFFFFFFFFFDULL #define DQUAD_ALIGN 0xFFFFFFFFFFFFFFFCULL + /** This routine is used to check whether the pci device is present. =20 @@ -1335,8 +1341,8 @@ UpdatePciInfo ( ) { EFI_STATUS Status; - UINTN BarIndex; - UINTN BarEndIndex; + UINT64 BarIndex; + UINT64 BarEndIndex; BOOLEAN SetFlag; VOID *Configuration; EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr; @@ -1390,18 +1396,19 @@ UpdatePc= iInfo ( break; } =20 - BarIndex =3D (UINTN) Ptr->AddrTranslationOffset; + BarIndex =3D Ptr->AddrTranslationOffset; BarEndIndex =3D BarIndex; =20 // // Update all the bars in the device + // Compare against 0xFF is to keep backward compatibility. // - if (BarIndex =3D=3D PCI_BAR_ALL) { + if ((BarIndex =3D=3D (UINT64)-1) || (BarIndex =3D=3D 0xFF)) { BarIndex =3D 0; BarEndIndex =3D PCI_MAX_BAR - 1; } =20 - if (BarIndex > PCI_MAX_BAR) { + if (BarIndex >=3D PCI_MAX_BAR) { Ptr++; continue; } @@ -1472,7 +1479,7 @@ UpdatePciInfo ( // // Update the new length for the device // - if (Ptr->AddrLen !=3D PCI_BAR_NOCHANGE) { + if (Ptr->AddrLen !=3D 0) { PciIoDevice->PciBar[BarIndex].Length =3D Ptr->AddrLen; } } @@ -1488,6 +1495,8 @@ UpdatePciInfo ( =20 /** This routine will update the alignment with the new alignment. + Compare with OLD_ALIGN/EVEN_ALIGN/SQUAD_ALIGN/DQUAD_ALIGN is to keep =20 + backward compatibility. =20 @param Alignment Input Old alignment. Output updated alignment. @param NewAlignment New alignment. @@ -1506,15 +1515,15 @@ SetNewAlign ( // The new alignment is the same as the original, // so skip it // - if (NewAlignment =3D=3D PCI_BAR_OLD_ALIGN) { + if ((NewAlignment =3D=3D 0) || (NewAlignment =3D=3D OLD_ALIGN)) { return ; } // // Check the validity of the parameter // - if (NewAlignment !=3D PCI_BAR_EVEN_ALIGN && - NewAlignment !=3D PCI_BAR_SQUAD_ALIGN && - NewAlignment !=3D PCI_BAR_DQUAD_ALIGN ) { + if (NewAlignment !=3D EVEN_ALIGN && + NewAlignment !=3D SQUAD_ALIGN && + NewAlignment !=3D DQUAD_ALIGN ) { *Alignment =3D NewAlignment; return ; } @@ -1533,15 +1542,15 @@ SetNewAlign ( // // Adjust the alignment to even, quad or double quad boundary // - if (NewAlignment =3D=3D PCI_BAR_EVEN_ALIGN) { + if (NewAlignment =3D=3D EVEN_ALIGN) { if ((OldAlignment & 0x01) !=3D 0) { OldAlignment =3D OldAlignment + 2 - (OldAlignment & 0x01); } - } else if (NewAlignment =3D=3D PCI_BAR_SQUAD_ALIGN) { + } else if (NewAlignment =3D=3D SQUAD_ALIGN) { if ((OldAlignment & 0x03) !=3D 0) { OldAlignment =3D OldAlignment + 4 - (OldAlignment & 0x03); } - } else if (NewAlignment =3D=3D PCI_BAR_DQUAD_ALIGN) { + } else if (NewAlignment =3D=3D DQUAD_ALIGN) { if ((OldAlignment & 0x07) !=3D 0) { OldAlignment =3D OldAlignment + 8 - (OldAlignment & 0x07); } -- 2.9.0.windows.1