From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 D794F1A1E89 for ; Wed, 26 Oct 2016 20:17:56 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 26 Oct 2016 20:17:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,404,1473145200"; d="scan'208";a="778315960" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 26 Oct 2016 20:17:56 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 26 Oct 2016 20:17:56 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 26 Oct 2016 20:17:55 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.2]) with mapi id 14.03.0248.002; Thu, 27 Oct 2016 11:17:54 +0800 From: "Gao, Liming" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] MdePkg/PciSegmentLib: Optimize PCI_SEGMENT_LIB_ADDRESS() Thread-Index: AQHSL858Z3FO9AyuLki4kdwyQFfLYqC7ocRw Date: Thu, 27 Oct 2016 03:17:52 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B49A46B@shsmsx102.ccr.corp.intel.com> References: <1477516692-8972-1-git-send-email-michael.d.kinney@intel.com> In-Reply-To: <1477516692-8972-1-git-send-email-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdePkg/PciSegmentLib: Optimize PCI_SEGMENT_LIB_ADDRESS() 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, 27 Oct 2016 03:17:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Kinney, Michael D > Sent: Thursday, October 27, 2016 5:18 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [Patch] MdePkg/PciSegmentLib: Optimize > PCI_SEGMENT_LIB_ADDRESS() >=20 > The PCI_SEGMENT_LIB_ADDRESS() macro puts the Segment number > into bits 32..47 of the logical address that is returned. > The portable method to put Segment in this bit range is to > use LShitU64(). For 64-bit CPUs, this is optimized well > by the compiler. For 32-bit CPUs, a call to LSHiftU64() > is included in the generated binaries. However, if the > Segment parameter is 0, then no shift is required. Add > a check for Segment set to 0 and provide an optimized > macro implementation that does not call LShiftU64(). >=20 > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Michael Kinney > --- > MdePkg/Include/Library/PciSegmentLib.h | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) >=20 > diff --git a/MdePkg/Include/Library/PciSegmentLib.h > b/MdePkg/Include/Library/PciSegmentLib.h > index 1135010..5175e07 100644 > --- a/MdePkg/Include/Library/PciSegmentLib.h > +++ b/MdePkg/Include/Library/PciSegmentLib.h > @@ -23,7 +23,7 @@ > access method. Modules will typically use the PCI Segment Library for= its > PCI configuration > accesses when PCI Segments other than Segment #0 must be accessed. >=20 > -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at > @@ -56,11 +56,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF > ANY KIND, EITHER EXPRESS OR IMPLIED. >=20 > **/ > #define > PCI_SEGMENT_LIB_ADDRESS(Segment,Bus,Device,Function,Register) \ > - ( ((Register) & 0xfff) | \ > - (((Function) & 0x07) << 12) | \ > - (((Device) & 0x1f) << 15) | \ > - (((Bus) & 0xff) << 20) | \ > - (LShiftU64((Segment) & 0xffff, 32)) \ > + ((Segment !=3D 0) ? \ > + ( ((Register) & 0xfff) | \ > + (((Function) & 0x07) << 12) | \ > + (((Device) & 0x1f) << 15) | \ > + (((Bus) & 0xff) << 20) | \ > + (LShiftU64 ((Segment) & 0xffff, 32)) \ > + ) : \ > + ( ((Register) & 0xfff) | \ > + (((Function) & 0x07) << 12) | \ > + (((Device) & 0x1f) << 15) | \ > + (((Bus) & 0xff) << 20) \ > + ) \ > ) >=20 > /** > -- > 2.6.3.windows.1