From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.1897.1571137005870392892 for ; Tue, 15 Oct 2019 03:56:46 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=019184da0c=abner.chang@hpe.com) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9FAui97025771; Tue, 15 Oct 2019 10:56:44 GMT Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by mx0b-002e3701.pphosted.com with ESMTP id 2vmrnp9qff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2019 10:56:44 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5009.houston.hpe.com (Postfix) with ESMTPS id C0529A0; Tue, 15 Oct 2019 10:56:29 +0000 (UTC) Received: from G4W9331.americas.hpqcorp.net (16.208.32.117) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 10:56:29 +0000 Received: from G2W6311.americas.hpqcorp.net (16.197.64.53) by G4W9331.americas.hpqcorp.net (16.208.32.117) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 10:56:29 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (15.241.52.12) by G2W6311.americas.hpqcorp.net (16.197.64.53) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 15 Oct 2019 10:56:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nM1DQs6cnQNpIWrDtGRiYfbuqu3GT4umT7eOtqJyUKHUWI0IiJMzZfoVBNqQ7xo2vdSSSkSesArJ0b/Dk4Zczuwqu4VgiocWx0TYRfZZywbGi4ohCcrJ8rmz8zqKxWL7GmWTPaOjFoAw8WBO0bo+xyzW3w+QJwE0uqOZXDhQH47WrEII1MHpcSBGGkNQrfp5Hunivxe82v4gnin2QNHxU4LxXPxRRHNOzlZyKgTIEo2RMjtgdHvhByqHgwxuhBR1ss7C8sonC9+WAGgKi/GvWHtr+IJQJBxzxcbmm3ZqsTMAqllJl1OlgK4rfc78yR7ucXWcl5aQZhtUBlihu4gOrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tGYlVkAuuIU/YmmiOgXKSDwhinSjyTg4tw4TYMtY4ts=; b=aJmi5aesZZ1CGi6gO4lSnCsAud/kg1Rb0+00RoErkyDIGkwf7tkJoHFAdcBMdH8OGAuczZfpKGUo5m+ZMI92+BxJNWybqWSb2lE3/ABUwUVTOgSeScBghXRojEs/I2GF8T57eHmLU25JTsVfPuKOwIpwTZ0UxCvSYgrVOWh9iiAWkXjmqfpeV5Lm8ZSQ6dtEo3h8etpmLx+bFtDoMjsx0c3JSci/jaEIAyFOmS2noVL2H9YijEMk2Fd19qWiNVzYjCvIRosVwopbMklMe/9X2IZBS/uNczeNDaZOG1hRzLbnTJdkNIDsUKI27aKsSZEFM38AZhSDKX707dSVhPq2sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from CS1PR8401MB1192.NAMPRD84.PROD.OUTLOOK.COM (10.169.12.151) by CS1PR8401MB1287.NAMPRD84.PROD.OUTLOOK.COM (10.169.98.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Tue, 15 Oct 2019 10:56:27 +0000 Received: from CS1PR8401MB1192.NAMPRD84.PROD.OUTLOOK.COM ([fe80::4fb:84b9:76e6:1cde]) by CS1PR8401MB1192.NAMPRD84.PROD.OUTLOOK.COM ([fe80::4fb:84b9:76e6:1cde%8]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 10:56:27 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "leif.lindholm@linaro.org" Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v2 10/29] MdePkg/BasePeCoff: Add RISC-V PE/Coff related code. Thread-Topic: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v2 10/29] MdePkg/BasePeCoff: Add RISC-V PE/Coff related code. Thread-Index: AQHVcaqeUWKF6VmwtkeEFp6SO0zlaqc+pdsAgByP0jCAAG5ogIAABeyA Date: Tue, 15 Oct 2019 10:56:27 +0000 Message-ID: References: <1569198715-31552-1-git-send-email-abner.chang@hpe.com> <1569198715-31552-12-git-send-email-abner.chang@hpe.com> <20190926234620.GM25504@bivouac.eciton.net> <20191015103131.GI25504@bivouac.eciton.net> In-Reply-To: <20191015103131.GI25504@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.242.247.131] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 38abcf71-b02d-443d-1795-08d7515e542f x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: CS1PR8401MB1287: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1728; x-forefront-prvs: 01917B1794 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6029001)(376002)(39860400002)(396003)(346002)(366004)(136003)(189003)(13464003)(199004)(66446008)(229853002)(64756008)(66946007)(3846002)(6436002)(11346002)(6116002)(5660300002)(14444005)(99286004)(19627235002)(256004)(6506007)(102836004)(53546011)(76176011)(7696005)(446003)(52536014)(6246003)(9686003)(55016002)(6306002)(486006)(26005)(476003)(2906002)(86362001)(76116006)(186003)(66556008)(66476007)(14454004)(110136005)(966005)(2501003)(316002)(7736002)(478600001)(305945005)(25786009)(74316002)(71200400001)(71190400001)(8936002)(8676002)(81166006)(81156014)(33656002)(66066001);DIR:OUT;SFP:1102;SCL:1;SRVR:CS1PR8401MB1287;H:CS1PR8401MB1192.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8xcQ3AdB+ySh7eB82XTT0MEU5oFGBSU/od2b4PO/KS69GmpmAzx+A02BkKHximkBrauvd2PQ2RktPpBPSAI/3a8xSZc3ZhYf0EhyRuXXf2nMbpFKgJcFwjLlYHvBiNAvEsTrhwrY+BtIM5NTiy7UcA2kYijOx3Kr4R6f5F2HyXp6TGjYXd0SXeAJjUaAELNrprffedBKUDgap1PmL4sTTHpPYegBx1+964cd4Dc4BTd4wFCGQc0YfCkjZmSQAl0SsYjFLBZjIF89Sb2f+5WLeL8iqLdiDQSyJM3CLRqXsFvnWYsUm7pdQ+fsnmNbX/9qaWzqJucS8YQyVzk8Pffpd8tJPytFqKtBUKK6ieMig2A/5M5QD79zCK999LgJYvYCHcUAg07QmOQV1ph5pyTftDE6chcmrE5RecggpYlERuYC9FGWnVw60MOxg8FwEWLr0Ctcbw2KCgjorCKMmNsaDA== x-ms-exchange-transport-forked: True X-MS-Exchange-CrossTenant-Network-Message-Id: 38abcf71-b02d-443d-1795-08d7515e542f X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Oct 2019 10:56:27.6942 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: UZ4U4Xsftbf6liXiIh2Is8uuR20zDIxaPSZzVyBDaHIZb3eL9EI49z/nl0O1ylVgEdAbpWyCpD7UE4Hb2Dfcbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB1287 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-15_05:2019-10-15,2019-10-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910150101 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Leif Lindholm > Sent: Tuesday, October 15, 2019 6:32 PM > To: Chang, Abner (HPS SW/FW Technologist) > Cc: devel@edk2.groups.io > Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v2 10/29] > MdePkg/BasePeCoff: Add RISC-V PE/Coff related code. >=20 > On Tue, Oct 15, 2019 at 04:02:47AM +0000, Chang, Abner (HPS SW/FW > Technologist) wrote: > > > -----Original Message----- > > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf > > > Of Leif Lindholm > > > Sent: Friday, September 27, 2019 7:46 AM > > > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) > > > > > > Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v2 10/29] > > > MdePkg/BasePeCoff: Add RISC-V PE/Coff related code. > > > > > > On Mon, Sep 23, 2019 at 08:31:36AM +0800, Abner Chang wrote: > > > > Support RISC-V image relocation. > > > > > > > > Signed-off-by: Abner Chang > > > > --- > > > > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 3 +- > > > > MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf | 5 + > > > > MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni | 2 + > > > > .../Library/BasePeCoffLib/BasePeCoffLibInternals.h | 1 + > > > > .../Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c | 142 > > > +++++++++++++++++++++ > > > > 5 files changed, 152 insertions(+), 1 deletion(-) create mode > > > > 100644 MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c > > > > > > > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > > index 07bb62f..97e0ff4 100644 > > > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > > > > @@ -1,6 +1,6 @@ > > > > /** @file > > > > Base PE/COFF loader supports loading any PE32/PE32+ or TE > > > > image, but > > > > - only supports relocating IA32, x64, IPF, and EBC images. > > > > + only supports relocating IA32, x64, IPF, ARM, RISC-V and EBC im= ages. > > > > > > > > Caution: This file requires additional review when modified. > > > > This library will have external input - PE/COFF image. > > > > @@ -17,6 +17,7 @@ > > > > > > > > Copyright (c) 2006 - 2019, Intel Corporation. All rights reserv= ed.
> > > > Portions copyright (c) 2008 - 2009, Apple Inc. All rights > > > > reserved.
> > > > + Portions Copyright (c) 2016, Hewlett Packard Enterprise > > > > + Development LP. All rights reserved.
> > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > **/ > > > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > > > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > > > index 395c140..b190494 100644 > > > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > > > > @@ -3,6 +3,7 @@ > > > > # The IPF version library supports loading IPF and EBC PE/COFF i= mage. > > > > # The IA32 version library support loading IA32, X64 and EBC > > > > PE/COFF > > > images. > > > > # The X64 version library support loading IA32, X64 and EBC > > > > PE/COFF > > > images. > > > > +# The RISC-V version library support loading RISC-V images. > > > > # > > > > # Caution: This module requires additional review when modified. > > > > # This library will have external input - PE/COFF image. > > > > @@ -11,6 +12,7 @@ > > > > # > > > > # Copyright (c) 2006 - 2018, Intel Corporation. All rights > > > > reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. > > > > All rights reserved.
> > > > +# Copyright (c) 2016, Hewlett Packard Enterprise Development LP. > > > > +All rights reserved.
> > > > # > > > > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -41,6 +43,9 > > > > @@ [Sources.ARM] > > > > Arm/PeCoffLoaderEx.c > > > > > > > > +[Sources.RISCV64] > > > > + RiscV/PeCoffLoaderEx.c > > > > + > > > > [Packages] > > > > MdePkg/MdePkg.dec > > > > > > > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > > > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > > > index b0ea702..8616ca3 100644 > > > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > > > > @@ -4,6 +4,7 @@ > > > > // The IPF version library supports loading IPF and EBC PE/COFF i= mage. > > > > // The IA32 version library support loading IA32, X64 and EBC > > > > PE/COFF > > > images. > > > > // The X64 version library support loading IA32, X64 and EBC > > > > PE/COFF > > > images. > > > > +// The RISC-V version library support loading RISC-V32 and > > > > +RISC-V64 > > > PE/COFF images. > > > > // > > > > // Caution: This module requires additional review when modified. > > > > // This library will have external input - PE/COFF image. > > > > @@ -12,6 +13,7 @@ > > > > // > > > > // Copyright (c) 2006 - 2018, Intel Corporation. All rights > > > > reserved.
// Portions copyright (c) 2008 - 2009, Apple Inc. > > > > All rights reserved.
> > > > +// Copyright (c) 2016, Hewlett Packard Enterprise Development LP. > > > > +All rights reserved.
> > > > // > > > > // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git > > > > a/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h > > > > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h > > > > index b74277f..9c33703 100644 > > > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h > > > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h > > > > @@ -2,6 +2,7 @@ > > > > Declaration of internal functions in PE/COFF Lib. > > > > > > > > Copyright (c) 2006 - 2010, Intel Corporation. All rights > > > > reserved.
> > > > + Copyright (c) 2016, Hewlett Packard Enterprise Development LP. > > > > + All rights reserved.
> > > > > > You only get to add copyright when you otherwise modify the file :) > > > > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > > > **/ > > > > diff --git a/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c > > > > b/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c > > > > new file mode 100644 > > > > index 0000000..8eb37f9 > > > > --- /dev/null > > > > +++ b/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c > > > > @@ -0,0 +1,142 @@ > > > > +/** @file > > > > + PE/Coff loader for RISC-V PE image > > > > + > > > > + Copyright (c) 2016, Hewlett Packard Enterprise Development LP. > > > > +All rights reserved.
> > > > + SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include > > > > +"BasePeCoffLibInternals.h" > > > > +#include > > > > + > > > > +// > > > > +// RISC-V definition. > > > > +// > > > > +#define RV_X(x, s, n) (((x) >> (s)) & ((1<<(n))-1)) #define > > > > +RISCV_IMM_BITS 12 #define RISCV_IMM_REACH > > > (1LL< > > > +#define RISCV_CONST_HIGH_PART(VALUE) \ > > > > + (((VALUE) + (RISCV_IMM_REACH/2)) & ~(RISCV_IMM_REACH-1)) > > > > > > This looked familiar, so I had a look. > > > This block is copied around - it exists in: > > > - BaseTools/Source/C/Common/PeCoffLoaderEx.c > > > - BaseTools/Source/C/GenFw/Elf64Convert.c > > > - MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c > > > > > > This needs to be moved somewhere central and included elsewhere. > > > BaseTools and MdePkg unfortunately duplicate a lot of stuff, but > > > this still belongs in a common header file for either. > > > > I can consolidate that macro in two files under BaseTools, but not > > consolidating macro in files in both MdePkg and BaseTools. BaseTools > > and edk2 are two separate projects and could be built individually > > based on my understanding. > > > > I have no idea how to leverage one header file from both projects and > > I don't go that far to address it. >=20 > Oh, indeed. This was me bemoaning the current state of things - not > suggesting you need to fix it (beyond having only one copy for BaseTools= and > one copy for the platform code.). >=20 > I need to check my use of English subtleties: > "belongs in a common header file for either" means "one for each". Hah Hah. My bad. Ok! Then it's much easier! Let me see if I can put RISC-V specific macro = into an existing header file or a new one. >=20 > Best Regards, >=20 > Leif >=20 >=20