From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web10.1818.1571136122092606534 for ; Tue, 15 Oct 2019 03:42:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=HGTWf1TW; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: leif.lindholm@linaro.org) Received: by mail-wm1-f67.google.com with SMTP id p7so20303660wmp.4 for ; Tue, 15 Oct 2019 03:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dNt+qZgj2m2rydp641dZ9XMdrteRI2/kqnMZG4HP5/Q=; b=HGTWf1TW5KnBVhWm9ufRgban9XcocdkS+CCUZoQHN7eXWiFXFKQsi+C9jU0QXpaiB4 gt0KXfd+0bpsNRBbuWzpBG47oevRsBTk5a+ond3pxYU+yReklVElUh5DoOJWEG/B+1a2 SiczdPpkNdWkPpDFC/lQ8jkAmnu5jlujW1CWMZpHPzVQAExnykwEI0gg3fiKFwkqhrJD 4h5Rf8aOY+iJ9IW1EG/n10MKYQUOjUiEclWqvVK0MeEu87r562UmFumh+2aupBSMh0zz fNhUZ+S0MmjcekhpocQWVqA1X5WY/kS69cW6NLavvmYoMQiOsZsYpKJuaLuTMTQHw4+X 0oCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dNt+qZgj2m2rydp641dZ9XMdrteRI2/kqnMZG4HP5/Q=; b=CqHuhoNY55SuxvJZ7rLkso/GL7YKDvBNVxiPm8SBJ5CsTYOWnsrCLaDy94lZ05+h2U IKTKsNCPlolSEhK4ZeUZWX3hZrAeuESbqquuFVhzv+R0FTXFNDu92hEj1qejcmfw2wUN 85AoW62i/2UoBgu9B+FvSHYYpmL98cb/lOdWAbGwX9DYmwlUQ3e+lsQ7e5EV2jpUrJ+z CdNH1i96CaMvDf4jFsEUz2cYrtEF/pKnLRjwE8GnIrqSnoVOfShxXh9kUEYB7aX8lPkk +dXLCK9v/2I6OasJQ0NWVj/gEC5gXlEHz0CL+mYl5foYSSF+YGUUiHxuG1S99GN50jEF d8SQ== X-Gm-Message-State: APjAAAWlAzr/Vj87Nyf4ABP6kHp7ns2isoqMCo8+bK5QxnTk4zU3UMhU 7akbEgujaXgOw/OOH21lHWhcOw== X-Google-Smtp-Source: APXvYqxFS+fLQDU18crL5i1oqJSruJ35yuFOlUT3w19VMC0O1mQLnhamrEzypifLJYzmyqRE8mFb8g== X-Received: by 2002:a1c:a546:: with SMTP id o67mr18950182wme.57.1571136120505; Tue, 15 Oct 2019 03:42:00 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id h18sm8973951wrr.78.2019.10.15.03.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 03:41:59 -0700 (PDT) Date: Tue, 15 Oct 2019 11:41:58 +0100 From: "Leif Lindholm" 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. Message-ID: <20191015104158.GJ25504@bivouac.eciton.net> 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> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > > > 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? There is never a good reason to duplicate code. You will always end up changing one and forgetting the other. 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. / Leif