From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.1981.1571137158356539031 for ; Tue, 15 Oct 2019 03:59:18 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=019184da0c=abner.chang@hpe.com) Received: from pps.filterd (m0134421.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9FAuinj020236; Tue, 15 Oct 2019 10:59:16 GMT Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0b-002e3701.pphosted.com with ESMTP id 2vmy1ub87g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2019 10:59:16 +0000 Received: from G9W8456.americas.hpqcorp.net (g9w8456.houston.hp.com [16.216.161.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3425.houston.hpe.com (Postfix) with ESMTPS id 9E1A09A; Tue, 15 Oct 2019 10:59:15 +0000 (UTC) Received: from G4W9120.americas.hpqcorp.net (2002:10d2:150f::10d2:150f) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 10:59:15 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (15.241.52.10) by G4W9120.americas.hpqcorp.net (16.210.21.15) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 15 Oct 2019 10:59:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MYcdNM/Gl7eUy+Dyp6oeWmPryx5HL4IplecXdqq20zOFWOfSfgntsSfWhzrZrTvxm2R60q0yeeXw1X8PrkdIu/OUIhP8rcfhitttoPvGwEodORj3xfzMi07qa7m2Kd519CCzVu/OaoLZ8dNqhaDC0KToZIVJfQG0akwgKCZ4KGRk2uWApwEYs5jfhmHJgPWRm8FnDHuI2z2AL3pcAp67bIgpwOtzKMYHfIL+qT/7I2VEZWWQwpGQO9NDGYStVl34vgmrlznW4SS3hdMUyWRXiB6YrLdGyQvt1t89B8kIyBwh+cwxvdkFEj0N8CGqCUaevm1XLgCIuTh2TmF1jRlQYQ== 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=4WnFEgNHPKZmPmRTF8EQp/mfCKTi9PJ59hHmPlOvvfw=; b=AuxKdAZbwPMAUeBysOYpcFEckREk0SCdhMVTbJ8erq/Ifw2eUl3+/pSlUw2CqyXqhkno1JAE7HuvjYt8jwUli17dj0fhAiMA8fnlzw6Y91F8OJYHP18dOzHw2Pegt/hvv5VQRTSg3bS9y50rjW1RvwJEvk0u9Ewd2gznNBYBIXXD7d1b4iYXwiKpmAicWTspJlwwh9K+Xg9zy2zI7+I3jTzmX+P2iWs0L8tigFQ4wyBVGQsJAlxEK0g5o77DaYm0sxVOH/eYeSA/8b7KL4ecdj1cjSnDX4OOMj8S79y48Vzp05kthxeJGMQbrcTeOObxDRRdko/4bF9iJDAPKK9eKA== 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:59:14 +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:59:14 +0000 From: "Abner Chang" To: Leif Lindholm 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. 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+pdsAgByP0jCAAAZAAIAAaxQAgAAEVkA= Date: Tue, 15 Oct 2019 10:59:14 +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> <15CDB6324F411B37.30896@groups.io> <20191015104158.GJ25504@bivouac.eciton.net> In-Reply-To: <20191015104158.GJ25504@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: 83966b3b-1539-419a-75fc-08d7515eb792 x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: CS1PR8401MB1287: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; 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)(6916009)(5660300002)(14444005)(99286004)(19627235002)(256004)(6506007)(102836004)(53546011)(76176011)(7696005)(446003)(52536014)(6246003)(9686003)(55016002)(4326008)(486006)(26005)(476003)(2906002)(86362001)(76116006)(186003)(66556008)(66476007)(14454004)(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: 8QiIPGisbL6ks7Yao4kc9U252LISiIKrnJypsayXDWvtDrVqoU7KHN0+Tnx9U8gZ2E1WZm+oxgofNcONbi3nAK1Fvdmf4D5hlgSPChwEXqF5MBt5rAz6X8D9UjTDAPj4cxlweU6cqW0bSBsroaLnESOkCzF4aAK9fvZM9J37ePNbdBksMd5jfsx5/eFnOzT1D5JPuhIv21j+SX9zKj/HskMD6fIkuAMeUKrAamBpwLVmzn0BaQSlO9OpBHVnM2kaAsqlXPQo2pTu9u3vkcTOXWn6eODVEC6XS8sI7ZdyIQX17HCdm+D013ZXHbirdBJTNx9YiGm+vxae8HOO2YbhbbQ2jXYVlAvfGUi8UfFdwLJ/oIjKi+lNxoDmEtSUAV24yiWlgPIX/ds6UNQRl11QW8mVxoFsi+mX26dEpqrQm6E= x-ms-exchange-transport-forked: True X-MS-Exchange-CrossTenant-Network-Message-Id: 83966b3b-1539-419a-75fc-08d7515eb792 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Oct 2019 10:59:14.4279 (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: WZqmmlXxMKf8w+zlvs8bq2gARbnoC74hJHjVmpJtzyyirLol+Tf4Fgc/v2gf7YGhdXZ6JKOtLnUw5uiJzyyBDw== 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 phishscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 impostorscore=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: Leif Lindholm [mailto:leif.lindholm@linaro.org] > Sent: Tuesday, October 15, 2019 6:42 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:26:12AM +0000, Chang, Abner (HPS SW/FW > Technologist) wrote: > > > > > > > -----Original Message----- > > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf > > > Of Abner Chang > > > Sent: Tuesday, October 15, 2019 12:03 PM > > > 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. > > > > > > > > > > > > > -----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 >=20 > > > > > 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. > > > > Leif, seem there is no good place and the existing header file to put > > this macro unless I create a new header file under > > BaseTools/Source/C/Include. I would like to keep this duplicate macro > > in both files rather than create an header file in which only define > > this macro. Do you have good idea? >=20 > There is never a good reason to duplicate code. You will always end up > changing one and forgetting the other. Sure. >=20 > I see no problem with creating a header file which contains nothing else.= But I > also think it would be valid to put this into C/Common/PeCoffLib.h - and = this > file is already included by the affected .c files. Hmm. Then put it into PeCoffLib. I am good with this if no one opposite. >=20 > / > Leif