Re: [edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol
Leif, How about using the following pragma instead if include guards? #pragma once https://en.wikipedia.org/wiki/Pragma_once This appears to be supports by GCC 3.4 and higher, clang, and VS. Might even speed up builds a bit. Mike > -Original Message- > From: Kinney, Michael D > Sent: Monday, April 15, 2019 8:53 AM > To: Leif Lindholm ; Wu, Hao A > ; Kinney, Michael D > > Cc: Ard Biesheuvel ; > devel@edk2.groups.io; Andrew Fish ; > Zeng, Star ; Dong, Eric > ; Ni, Ray ; Gao, > Liming ; Carsey, Jaben > ; Shi, Steven > ; Wang, Jian J > > Subject: RE: [PATCH v6 1/7] MdeModulePkg: introduce > PE/COFF image emulator protocol > > Hi Leif, > > This is not a macro that is to be used by C code. It > is a technique > to prevent recursive includes on a .h file. As a > result, we do not want > to use the C Coding Standard macro style. > > Are there other techniques to prevent recursive > includes? > > I agree that macros/symbols that start with single or > double '_' > are reserved by compilers/linkers, which is why the > warning is > triggered and it would be better if we use a different > technique. > > The current style assumes that the define symbol used > will not > collide with a compiler/linker symbol. The names are > verbose, > so the chances of a collision are very low. > > Mike > > > -Original Message- > > From: Leif Lindholm [mailto:leif.lindh...@linaro.org] > > Sent: Monday, April 15, 2019 2:02 AM > > To: Wu, Hao A > > Cc: Ard Biesheuvel ; > > devel@edk2.groups.io; Kinney, Michael D > > ; Andrew Fish > > ; Zeng, Star ; > > Dong, Eric ; Ni, Ray > > ; Gao, Liming > ; > > Carsey, Jaben ; Shi, Steven > > ; Wang, Jian J > > > > Subject: Re: [PATCH v6 1/7] MdeModulePkg: introduce > > PE/COFF image emulator protocol > > > > On Mon, Apr 15, 2019 at 01:23:11AM +, Wu, Hao A > > wrote: > > > > + This program and the accompanying materials > are > > licensed and made > > > > available > > > > + under the terms and conditions of the BSD > > License which 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 PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > > > +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > > > > > Hello Ard, > > > > > > Sorry for the delayed response. > > > > > > Could you help to use: > > > _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_ > > > > > > here to please the Ecc checker when you push the > > series? > > > > Hmm... > > > > Not a major issue, but I'll mention it anyway (which > I > > mentioned to > > Andrew/Mike at Linaro Connect in Vancouver last > year): > > clang has a warning, enabled by -Wreserved-id-macro, > > which complains > > about this. > > > > The Coding Style matches this, suggesting > > MACROS_SHOULD_BE_WRITTEN_THUS_. So do we need to fix > > Ecc? > > > > Regards, > > > > Leif -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39125): https://edk2.groups.io/g/devel/message/39125 Mute This Topic: https://groups.io/mt/31133140/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol
Hi Leif, This is not a macro that is to be used by C code. It is a technique to prevent recursive includes on a .h file. As a result, we do not want to use the C Coding Standard macro style. Are there other techniques to prevent recursive includes? I agree that macros/symbols that start with single or double '_' are reserved by compilers/linkers, which is why the warning is triggered and it would be better if we use a different technique. The current style assumes that the define symbol used will not collide with a compiler/linker symbol. The names are verbose, so the chances of a collision are very low. Mike > -Original Message- > From: Leif Lindholm [mailto:leif.lindh...@linaro.org] > Sent: Monday, April 15, 2019 2:02 AM > To: Wu, Hao A > Cc: Ard Biesheuvel ; > devel@edk2.groups.io; Kinney, Michael D > ; Andrew Fish > ; Zeng, Star ; > Dong, Eric ; Ni, Ray > ; Gao, Liming ; > Carsey, Jaben ; Shi, Steven > ; Wang, Jian J > > Subject: Re: [PATCH v6 1/7] MdeModulePkg: introduce > PE/COFF image emulator protocol > > On Mon, Apr 15, 2019 at 01:23:11AM +, Wu, Hao A > wrote: > > > + This program and the accompanying materials are > licensed and made > > > available > > > + under the terms and conditions of the BSD > License which 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 PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > > +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > > > Hello Ard, > > > > Sorry for the delayed response. > > > > Could you help to use: > > _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_ > > > > here to please the Ecc checker when you push the > series? > > Hmm... > > Not a major issue, but I'll mention it anyway (which I > mentioned to > Andrew/Mike at Linaro Connect in Vancouver last year): > clang has a warning, enabled by -Wreserved-id-macro, > which complains > about this. > > The Coding Style matches this, suggesting > MACROS_SHOULD_BE_WRITTEN_THUS_. So do we need to fix > Ecc? > > Regards, > > Leif -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39095): https://edk2.groups.io/g/devel/message/39095 Mute This Topic: https://groups.io/mt/31133140/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol
Leif: How about submit one BZ to catch it first? Then, revisit it later. Thanks Liming > -Original Message- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Leif > Lindholm > Sent: Monday, April 15, 2019 5:02 PM > To: Wu, Hao A > Cc: Ard Biesheuvel ; devel@edk2.groups.io; Kinney, > Michael D ; Andrew Fish > ; Zeng, Star ; Dong, Eric > ; Ni, Ray ; Gao, Liming > ; Carsey, Jaben ; Shi, Steven > ; Wang, Jian J > > Subject: Re: [edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF > image emulator protocol > > On Mon, Apr 15, 2019 at 01:23:11AM +, Wu, Hao A wrote: > > > + This program and the accompanying materials are licensed and made > > > available > > > + under the terms and conditions of the BSD License which 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 PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > > +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > > > Hello Ard, > > > > Sorry for the delayed response. > > > > Could you help to use: > > _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_ > > > > here to please the Ecc checker when you push the series? > > Hmm... > > Not a major issue, but I'll mention it anyway (which I mentioned to > Andrew/Mike at Linaro Connect in Vancouver last year): > clang has a warning, enabled by -Wreserved-id-macro, which complains > about this. > > The Coding Style matches this, suggesting > MACROS_SHOULD_BE_WRITTEN_THUS_. So do we need to fix Ecc? > > Regards, > > Leif > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39089): https://edk2.groups.io/g/devel/message/39089 Mute This Topic: https://groups.io/mt/31133140/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol
On Mon, Apr 15, 2019 at 01:23:11AM +, Wu, Hao A wrote: > > + This program and the accompanying materials are licensed and made > > available > > + under the terms and conditions of the BSD License which 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 PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > > Hello Ard, > > Sorry for the delayed response. > > Could you help to use: > _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_ > > here to please the Ecc checker when you push the series? Hmm... Not a major issue, but I'll mention it anyway (which I mentioned to Andrew/Mike at Linaro Connect in Vancouver last year): clang has a warning, enabled by -Wreserved-id-macro, which complains about this. The Coding Style matches this, suggesting MACROS_SHOULD_BE_WRITTEN_THUS_. So do we need to fix Ecc? Regards, Leif -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39064): https://edk2.groups.io/g/devel/message/39064 Mute This Topic: https://groups.io/mt/31133140/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol
> -Original Message- > From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] > Sent: Monday, April 15, 2019 3:52 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel; Kinney, Michael D; Andrew Fish; Leif Lindholm; Zeng, Star; > Dong, Eric; Ni, Ray; Gao, Liming; Carsey, Jaben; Shi, Steven; Wang, Jian J; > Wu, > Hao A > Subject: [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator > protocol > > Introduce a protocol that can be invoked by the image loading services > to execute foreign architecture PE/COFF images via an emulator. > > Signed-off-by: Ard Biesheuvel > Reviewed-by: Michael D Kinney > --- > MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h | 107 > > MdeModulePkg/MdeModulePkg.dec | 4 + > 2 files changed, 111 insertions(+) > > diff --git a/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h > b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h > new file mode 100644 > index ..1ca302440e4a > --- /dev/null > +++ b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h > @@ -0,0 +1,107 @@ > +/** @file > + Copyright (c) 2019, Linaro, Ltd. All rights reserved. > + > + This program and the accompanying materials are licensed and made > available > + under the terms and conditions of the BSD License which 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 PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H > +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H Hello Ard, Sorry for the delayed response. Could you help to use: _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_ here to please the Ecc checker when you push the series? Best Regards, Hao Wu > + > +#define EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID \ > + { 0x96F46153, 0x97A7, 0x4793, { 0xAC, 0xC1, 0xFA, 0x19, 0xBF, 0x78, 0xEA, > 0x97 } } > + > +typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL > EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL; > + > +/** > + Check whether the emulator supports executing a certain PE/COFF image > + > + @param[in] This This pointer for > EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL > + structure > + @param[in] ImageTypeWhether the image is an application, a boot time > + driver or a runtime driver. > + @param[in] DevicePath Path to device where the image originated > + (e.g., a PCI option ROM) > + > + @retval TRUEThe image is supported by the emulator > + @retval FALSE The image is not supported by the emulator. > +**/ > +typedef > +BOOLEAN > +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED) ( > + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL*This, > + IN UINT16 ImageType, > + IN EFI_DEVICE_PATH_PROTOCOL*DevicePath OPTIONAL > + ); > + > +/** > + Register a supported PE/COFF image with the emulator. After this call > + completes successfully, the PE/COFF image may be started as usual, and > + it is the responsibility of the emulator implementation that any branch > + into the code section of the image (including returns from functions called > + from the foreign code) is executed as if it were running on the machine > + type it was built for. > + > + @param[in] This This pointer for > +EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL > structure > + @param[in] ImageBase The base address in memory of the PE/COFF > image > + @param[in] ImageSize The size in memory of the PE/COFF image > + @param[in,out] EntryPointThe entry point of the PE/COFF image. Passed > by > +reference so that the emulator may modify it. > + > + @retval EFI_SUCCESS The image was registered with the emulator > and > +can be started as usual. > + @retval other The image could not be registered. > + > + If the PE/COFF machine type or image type are not supported by the > emulator, > + then ASSERT(). > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE) ( > + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL*This, > + IN EFI_PHYSICAL_ADDRESSImageBase, > + IN UINT64 ImageSize, > + IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint > + ); > + > +/** > + Unregister a PE/COFF image that has been registered with the emulator. > + This should be done before the image is unloaded from memory. > + > + @param[in] This This pointer for > EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL > + structure > + @param[in] ImageBaseThe base address in memory of the PE/COFF > ima
[edk2-devel] [PATCH v6 1/7] MdeModulePkg: introduce PE/COFF image emulator protocol
Introduce a protocol that can be invoked by the image loading services to execute foreign architecture PE/COFF images via an emulator. Signed-off-by: Ard Biesheuvel Reviewed-by: Michael D Kinney --- MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h | 107 MdeModulePkg/MdeModulePkg.dec | 4 + 2 files changed, 111 insertions(+) diff --git a/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h new file mode 100644 index ..1ca302440e4a --- /dev/null +++ b/MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h @@ -0,0 +1,107 @@ +/** @file + Copyright (c) 2019, Linaro, Ltd. All rights reserved. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which 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 PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H +#define PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H + +#define EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID \ + { 0x96F46153, 0x97A7, 0x4793, { 0xAC, 0xC1, 0xFA, 0x19, 0xBF, 0x78, 0xEA, 0x97 } } + +typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL; + +/** + Check whether the emulator supports executing a certain PE/COFF image + + @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL + structure + @param[in] ImageTypeWhether the image is an application, a boot time + driver or a runtime driver. + @param[in] DevicePath Path to device where the image originated + (e.g., a PCI option ROM) + + @retval TRUEThe image is supported by the emulator + @retval FALSE The image is not supported by the emulator. +**/ +typedef +BOOLEAN +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED) ( + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL*This, + IN UINT16 ImageType, + IN EFI_DEVICE_PATH_PROTOCOL*DevicePath OPTIONAL + ); + +/** + Register a supported PE/COFF image with the emulator. After this call + completes successfully, the PE/COFF image may be started as usual, and + it is the responsibility of the emulator implementation that any branch + into the code section of the image (including returns from functions called + from the foreign code) is executed as if it were running on the machine + type it was built for. + + @param[in] This This pointer for +EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL structure + @param[in] ImageBase The base address in memory of the PE/COFF image + @param[in] ImageSize The size in memory of the PE/COFF image + @param[in,out] EntryPointThe entry point of the PE/COFF image. Passed by +reference so that the emulator may modify it. + + @retval EFI_SUCCESS The image was registered with the emulator and +can be started as usual. + @retval other The image could not be registered. + + If the PE/COFF machine type or image type are not supported by the emulator, + then ASSERT(). +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE) ( + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL*This, + IN EFI_PHYSICAL_ADDRESSImageBase, + IN UINT64 ImageSize, + IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint + ); + +/** + Unregister a PE/COFF image that has been registered with the emulator. + This should be done before the image is unloaded from memory. + + @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL + structure + @param[in] ImageBaseThe base address in memory of the PE/COFF image + + @retval EFI_SUCCESS The image was unregistered with the emulator. + @retval other Image could not be unloaded. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE) ( + IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL*This, + IN EFI_PHYSICAL_ADDRESSImageBase + ); + +#define EDKII_PECOFF_IMAGE_EMULATOR_VERSION 0x1 + +typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL { + EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTEDIsImageSupported; + EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGERegisterImage; + EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE UnregisterImage; + + // Protocol version implemented by the emulator + UINT32Version; + // The machine type implemented by the emulato