public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: "Ni, Ruiyu" <ruiyu.ni@Intel.com>
Cc: edk2-devel@lists.01.org,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Eric Dong <eric.dong@intel.com>, Star Zeng <star.zeng@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH 1/3] MdePkg: break #defines out of Uefi/UefiMultiPhase.h
Date: Thu, 14 Dec 2017 12:03:56 +0000	[thread overview]
Message-ID: <20171214120356.gmlqyz5qrhue7ww6@bivouac.eciton.net> (raw)
In-Reply-To: <59f1f807-a54c-9f4f-ce9f-aa83409dea8c@Intel.com>

On Thu, Dec 14, 2017 at 10:44:04AM +0800, Ni, Ruiyu wrote:
> On 12/13/2017 8:26 PM, Leif Lindholm wrote:
> > Turns out all .vfr files in the tree interacting with DynamicPcds
> > manually copy the same set of EFI_VARIABLE_* definitions, since the rest
> > of UefiMultiPhase.h is incompatible with VfrCompile.
> > 
> > Split these out into a separate header file UefiMultiPhaseDefinitions.h
> > in order to make it possible to include just that portion into .vfr
> > files. Then include that from UefiMultiPhase.h.
> > 
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <liming.gao@intel.com>
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Cc: Star Zeng <star.zeng@intel.com>
> > Cc: Eric Dong <eric.dong@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >   MdePkg/Include/Uefi/UefiMultiPhase.h            | 23 +-----------
> >   MdePkg/Include/Uefi/UefiMultiPhaseDefinitions.h | 39 ++++++++++++++++++++
> >   2 files changed, 41 insertions(+), 21 deletions(-)
> > 
> > diff --git a/MdePkg/Include/Uefi/UefiMultiPhase.h b/MdePkg/Include/Uefi/UefiMultiPhase.h
> > index 0dcbb1b9ee..b360c9513b 100644
> > --- a/MdePkg/Include/Uefi/UefiMultiPhase.h
> > +++ b/MdePkg/Include/Uefi/UefiMultiPhase.h
> > @@ -15,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> >   #ifndef __UEFI_MULTIPHASE_H__
> >   #define __UEFI_MULTIPHASE_H__
> > +#include "UefiMultiPhaseDefinitions.h"
> > +
> >   #include <Guid/WinCertificate.h>
> >   ///
> >   /// Enumeration of memory types introduced in UEFI.
> > @@ -156,27 +158,6 @@ typedef struct {
> >   } EFI_TABLE_HEADER;
> >   ///
> > -/// Attributes of variable.
> > -///
> > -#define EFI_VARIABLE_NON_VOLATILE                            0x00000001
> > -#define EFI_VARIABLE_BOOTSERVICE_ACCESS                      0x00000002
> > -#define EFI_VARIABLE_RUNTIME_ACCESS                          0x00000004
> > -///
> > -/// This attribute is identified by the mnemonic 'HR'
> > -/// elsewhere in this specification.
> > -///
> > -#define EFI_VARIABLE_HARDWARE_ERROR_RECORD                   0x00000008
> > -///
> > -/// Attributes of Authenticated Variable
> > -///
> > -#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS   0x00000020
> > -#define EFI_VARIABLE_APPEND_WRITE                            0x00000040
> > -///
> > -/// NOTE: EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and should be considered reserved.
> > -///
> > -#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS              0x00000010
> > -
> > -///
> >   /// AuthInfo is a WIN_CERTIFICATE using the wCertificateType
> >   /// WIN_CERTIFICATE_UEFI_GUID and the CertType
> >   /// EFI_CERT_TYPE_RSA2048_SHA256_GUID. If the attribute specifies
> > diff --git a/MdePkg/Include/Uefi/UefiMultiPhaseDefinitions.h b/MdePkg/Include/Uefi/UefiMultiPhaseDefinitions.h
> > new file mode 100644
> > index 0000000000..df55a92dfa
> > --- /dev/null
> > +++ b/MdePkg/Include/Uefi/UefiMultiPhaseDefinitions.h
> > @@ -0,0 +1,39 @@
> > +/** @file
> > +  This includes some definitions introduced in UEFI that will be used in both PEI and DXE phases.
> > +
> > +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> > +This program and the accompanying materials are licensed and made available under
> > +the terms and conditions of the BSD License that accompanies this distribution.
> > +The full text of the license may be found at
> > +http://opensource.org/licenses/bsd-license.php.
> > +
> > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> > +
> > +**/
> > +
> > +#ifndef __UEFI_MULTIPHASE_DEFS_H__
> > +#define __UEFI_MULTIPHASE_DEFS_H__
> > +
> > +///
> > +/// Attributes of variable.
> > +///
> > +#define EFI_VARIABLE_NON_VOLATILE                            0x00000001
> > +#define EFI_VARIABLE_BOOTSERVICE_ACCESS                      0x00000002
> > +#define EFI_VARIABLE_RUNTIME_ACCESS                          0x00000004
> > +///
> > +/// This attribute is identified by the mnemonic 'HR'
> > +/// elsewhere in this specification.
> > +///
> > +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD                   0x00000008
> > +///
> > +/// Attributes of Authenticated Variable
> > +///
> > +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS   0x00000020
> > +#define EFI_VARIABLE_APPEND_WRITE                            0x00000040
> > +///
> > +/// NOTE: EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and should be considered reserved.
> > +///
> > +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS              0x00000010
> > +
> > +#endif
> > 
> Can we just move the definitions to UefiBaseTypes.h?

There is nothing in UefiBaseTypes.h that is fundamentally easier to
deal with than what is in UefiMultiPhase.h to begin with.

> Even vfrcompiler still complains, the syntax enhancement to
> vfrcompiler should be simple.

It's (probably) not VfrCompile that would need to change.
The problem is that the build runs the C preprocessor on the .vfr
source files before passing them to VfrCompile. #defines that just
replace text work fine, but typedefs and struct definitions make no
sense in vfr source.

It runs the preprocessor in C mode (for gpp, -x c) which means we
cannot use __ASSEMBLER__ to filter out typedefs and struct
definitions.

We could perhaps switch to -x assembler-with-cpp (and filter
UefiMultiPhase.h on __ASSEMBLER__), like we do for DTC.
It _seems_ to work in my test, but I do not know what a corresponding
change for VS would be.

> I personally do not like creating more and more files.

I am sort of with you on that one.
But I consider it a much lesser evil than duplicated definitions.

/
    Leif



  reply	other threads:[~2017-12-14 11:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 12:26 [PATCH 0/3] Use central definitions for EFI_VARIABLE_* Leif Lindholm
2017-12-13 12:26 ` [PATCH 1/3] MdePkg: break #defines out of Uefi/UefiMultiPhase.h Leif Lindholm
2017-12-14  2:44   ` Ni, Ruiyu
2017-12-14 12:03     ` Leif Lindholm [this message]
2017-12-14 16:59       ` Leif Lindholm
2017-12-15  2:06         ` Gao, Liming
2017-12-13 12:26 ` [PATCH 2/3] MdeModulePkg: use central variable definitions in DriverSampleDxe Leif Lindholm
2017-12-14  2:36   ` Zeng, Star
2017-12-13 12:26 ` [PATCH 3/3] EmbeddedPkg: use central variable definitions in .vfr files Leif Lindholm
2017-12-13 12:42 ` [PATCH 0/3] Use central definitions for EFI_VARIABLE_* Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171214120356.gmlqyz5qrhue7ww6@bivouac.eciton.net \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox