Re: [edk2] [RFC] Proposal to split Pkgs

2019-01-30 Thread Ard Biesheuvel
On Thu, 31 Jan 2019 at 08:09, Ni, Ray  wrote:
>
> On 1/29/2019 10:21 PM, Leif Lindholm wrote:
> > Hi Ray,
> >
> > First of all, thank you for restarting this discussion, and putting
> > the effort in for a POC.
> >
> > On Tue, Jan 29, 2019 at 05:59:35AM +, Ni, Ray wrote:
> >> Hello,
> >> I'd like to propose to split today's BIG packages in following ways:
> >>
> >> ==Overview =
> >>
> >> 1. Separate Industry standard definitions from UEFI and PI interfaces.
> >> 2. Separate UEFI and PI interfaces from implementations.
> >>  a. Separate UEFI and PI interfaces to different packages
> >>  b. Separate PI PEI, DXE and MM phase interfaces to different packages
> >> 3. Separate different features into feature packages.
> >>  Feature interface may be in the feature package to provide minimal
> >>  common interface packages.
> >>
> >> The POC code is in https://github.com/jyao1/edk2/tree/ReOrg.
> >> It basically split the EDKII common code to three directories:
> >> Core/, Device/, and Feature/.
> >
> > I'm not sure I like the 'Device' name, but that's not that important
> > at this stage - I like that this is split up the way it is.
> >
> > I also think a lot of things currently under Feture/misc could be
> > broken out into additional subdirectories under Feature/.
> >
> >> The code is in very early POC phase and only code in Core/ directory
> >> can pass the build.
> >> I would like to gather feedbacks through this RFC to see whether
> >> this splitting direction makes sense.
> >> Is there any other better ways of splitting?
> >> Or perhaps do not split in such a small granularity?
> >
> > I think this would be my only negative(ish) feedback on the POC.
> >
> > While it has the benefit of modules requiring to specify more
> > precisely which functionality they are pulling in...
> > ...it means that they now need to list *everything*.
> >
> > And with the mechanism by which I have seen Intel engineers make use
> > of PACKAGES_PATH in the past*, we end up with a bazillion packages
> > that need to be added individually to this variable for each build.
>
> No. "PACKAGES_PATH" only contains paths pointing to the *parent*
> directory of *Pkg. In this case, it equals to:
> /work/edk2/Core:/work/edk2/Device:/work/edk2/Feature/security:/work/edk2/Feature/network:/work/edk2/Feature/misc
>

Could we *please* not do this? PACKAGES_PATH is very useful for
combining packages from different repositories, but that does not mean
we should split up the core repository in this way.

What we will end up with is platforms that use

  Core/Package/Foo.inf

and platforms that use

  Package/Foo.inf

which creates an aliasing mess where the same file is reachable in
different ways. Also, it encourages the behavior where you need to
fetch version X of repo A and version Y of repo B, and the whole point
of open sourcing is to have all code co-exist in the same source tree.





>
> >
> > * (arguably how it was designed to be used - just not how I am
> >interested in using it)
> >
> > It also means that we need *tons* of dummy .dsc files in order to run
> > through simple build tests.
>
> Yes each small package needs its own DSC and DEC.
> DSC to list all components.
> DEC to list all interfaces.
>
> OK maybe the "need" in your wording means the build test script file
> needs to reference all DSC files.
> That maybe can be solved by an advanced script to call "build" for each
> DSC files inside a directory that matches a specific pattern. So the
> build test script to build PiPeiPkg/PiDxePkg/PiMmPkg will be like:
>build-any-dsc /work/edk2/Core/ --pattern="*Pi*"
>
> >
> > My preference would be to push the packages back up to the top-level.
> > The split still makes sense, and allocating maintainers to sub-parts
> > can happen without a full-out redesign of the Maintainers.txt format.
> > (Which I will try to resurrect with a proposal over the next few weeks
> > anyway.)
>
> Combining all packages inside the Device and Feature directory to still
> one single big package but with another directory layout so that only
> single DSC/DEC is needed?
>
> >
> >> Or perhaps Mike's work to move lib-c content to edk2-libc repo,
> >> to move real platform code to edk2-platform repo is enough for
> >> now?
> >
> > I think we need this further restructuring, and renaming. Not just for
> > splitting up maintainership duties (which as I mentioned in email to
> > Laszlo, we will still need to do with this change). But to make the
> > codebase more approachable.
> >
>
> "more approachable" means more friendly to new comers? Just try to
> understand everyone's real concern to today's codebase.
>
> >> ==More explanations =
> >>
> >> There are 9 packages inside Core/ directory:
> >> 1. BasePkg
> >> Contains industry standard definitions (exclude UEFI and PI) and base
> >> libraries that non-UEFI and non-PI development can depend on.
> >> UEFI or PI development can also 

Re: [edk2] [PATCH v5] MdePkg/BaseLib: Add Base64Encode() and Base64Decode()

2019-01-30 Thread Ni, Ray



Even ECC doesn't complain, I still suggest to change 
Encoding_table/Decoding_table to a proper name, e.g.:

EncodingTable/DecodingTable.

With the rename applied in V5 patch,
Reviewed-by: Ray Ni 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] IntelSiliconPkg\Include\IndustryStandard: Update IGD_OPREGION_MBOX3 Structure

2019-01-30 Thread Ni, Ray

On 1/31/2019 2:55 PM, Ni, Ray wrote:

On 1/31/2019 1:00 PM, Digant H Solanki wrote:

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1454
Based on latest IGD OpRegion Spec, IGD_OPREGION_MBOX3 needs to be 
updated with two new members : Physical Address of Raw VBT Data (RVDA) 
and Size of Raw VBT Data (RVDS)


Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Digant H Solanki 
Cc: Liming Gao 
Cc: Chaganty, Rangasai V 
Cc: Ni, Ray 
---
  IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h 
b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h

index 5ce80a5be8..1c83efee40 100644
--- a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
+++ b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
@@ -4,9 +4,7 @@

https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
-  @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to 
0x46(70)

-
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2019, Intel Corporation. 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

@@ -118,7 +116,9 @@ typedef struct {
    UINT64 FDSS;  ///< Offset 0x3AA DSS Buffer address 
allocated for IFFS feature

    UINT32 FDSP;  ///< Offset 0x3B2 Size of DSS buffer
    UINT32 STAT;  ///< Offset 0x3B6 State Indicator
-  UINT8  RM31[0x46];    ///< Offset 0x3BA - 0x3FF  Reserved Must be 
zero. Bug in spec 0x45(69)
+  UINT64 RVDA;  ///< Offset 0x3BA Physical address of Raw VBT 
data. Added from Spec Version 0.90 to support VBT greater than 6KB.
+  UINT32 RVDS;  ///< Offset 0x3C2 Size of Raw VBT data. Added 
from Spec Version 0.90 to support VBT greater than 6KB.
+  UINT8  RM31[0x3A];    ///< Offset 0x3C6 - 0x3FF  Reserved Must be 
zero.

  } IGD_OPREGION_MBOX3;
  ///






Sorry seems my comment was missed in previous mail.
Is it possible that an existing consumer is already using
RM31 to access RVDA and RVDS? For example,
using " * (UINT64 *) RM31[0]" to access RVDA.
If it's possible, I suggest we rename "RM31" to a different name.
Otherwise, the original code that modifies RVDA using RM may
incorrectly modifies bytes at offset 0x3C6.
A build failure instead of a silent failure can be seen with the rename.

--
Thanks,
Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v5] MdePkg/BaseLib: Add Base64Encode() and Base64Decode()

2019-01-30 Thread Shenglei Zhang
From: Mike Turner 

Introduce public functions Base64Encode and Base64Decode.
https://bugzilla.tianocore.org/show_bug.cgi?id=1370

v2:1.Remove some white space.
   2.Add unit test with test vectors in RFC 4648.
 https://github.com/shenglei10/edk2/tree/encode_test
 https://github.com/shenglei10/edk2/tree/decode_test

v3:1.Align white space.
   2.Update comments of Base64Encode and Base64Decode.
   3.Change the use of macro RETURN_DEVICE_ERROR to
 RETURN_INVALID_PARAMETER in string.c.

v4:Change parameters' names.

v5:1.Update usage of variables.
   2.Remove debug message in Base64Decode().

Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang 
---
 MdePkg/Include/Library/BaseLib.h |  56 ++
 MdePkg/Library/BaseLib/String.c  | 331 +++
 2 files changed, 387 insertions(+)

diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index 1eb842384e..03173def58 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -2720,6 +2720,62 @@ AsciiStrnToUnicodeStrS (
   OUT UINTN *DestinationLength
   );
 
+/**
+  Convert binary data to a Base64 encoded ascii string based on RFC4648.
+
+  Produce a Null-terminated Ascii string in the output buffer specified by 
Destination and DestinationSize.
+  The Ascii string is produced by converting the data string specified by 
Source and SourceLength.
+
+  @param Source   Input UINT8 data
+  @param SourceLength Number of UINT8 bytes of data
+  @param Destination  Pointer to output string buffer
+  @param DestinationSize  Size of ascii buffer. Set to 0 to get the size 
needed.
+  Caller is responsible for passing in buffer of 
DestinationSize
+
+  @retval RETURN_SUCCESS When ascii buffer is filled in.
+  @retval RETURN_INVALID_PARAMETER   If Source is NULL or DestinationSize is 
NULL.
+  @retval RETURN_INVALID_PARAMETER   If SourceLength or DestinationSize is 
bigger than (MAX_ADDRESS - (UINTN)Destination).
+  @retval RETURN_BUFFER_TOO_SMALLIf SourceLength is 0 and DestinationSize 
is <1.
+  @retval RETURN_BUFFER_TOO_SMALLIf Destination is NULL or DestinationSize 
is smaller than required buffersize.
+
+**/
+RETURN_STATUS
+EFIAPI
+Base64Encode (
+  IN  CONST UINT8  *Source,
+  INUINTN   SourceLength,
+  OUT   CHAR8  *Destination  OPTIONAL,
+  IN OUTUINTN  *DestinationSize
+  );
+
+/**
+  Convert Base64 ascii string to binary data based on RFC4648.
+
+  Produce Null-terminated binary data in the output buffer specified by 
Destination and DestinationSize.
+  The binary data is produced by converting the Base64 ascii string specified 
by Source and SourceLength.
+
+  @param Source  Input ASCII characters
+  @param SourceLengthNumber of ASCII characters
+  @param Destination Pointer to output buffer
+  @param DestinationSize Caller is responsible for passing in buffer of at 
least DestinationSize.
+ Set 0 to get the size needed. Set to bytes stored on 
return.
+
+  @retval RETURN_SUCCESS When binary buffer is filled in.
+  @retval RETURN_INVALID_PARAMETER   If Source is NULL or DestinationSize is 
NULL.
+  @retval RETURN_INVALID_PARAMETER   If SourceLength or DestinationSize is 
bigger than (MAX_ADDRESS -(UINTN)Destination ).
+  @retval RETURN_INVALID_PARAMETER   If there is any invalid character in 
input stream.
+  @retval RETURN_BUFFER_TOO_SMALLIf buffer length is smaller than required 
buffer size.
+
+ **/
+RETURN_STATUS
+EFIAPI
+Base64Decode (
+  IN  CONST CHAR8  *Source,
+  INUINTN   SourceLength,
+  OUT   UINT8  *Destination  OPTIONAL,
+  IN OUTUINTN  *DestinationSize
+  );
+
 /**
   Converts an 8-bit value to an 8-bit BCD value.
 
diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index e6df12797d..87d0a9d1dc 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -1763,6 +1763,337 @@ AsciiStrToUnicodeStr (
 
 #endif
 
+//
+// The basis for Base64 encoding is RFC 4686 
https://tools.ietf.org/html/rfc4648
+//
+// RFC 4686 has a number of MAY and SHOULD cases.  This implementation chooses
+// the more restrictive versions for security concerns (see RFC 4686 section 
3.3).
+//
+// A invalid character, if encountered during the decode operation, causes the 
data
+// to be rejected. In addition, the '=' padding character is only allowed at 
the end
+// of the Base64 encoded string.
+//
+#define BAD_V  99
+
+STATIC CHAR8 Encoding_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+"abcdefghijklmnopqrstuvwxyz"
+"0123456789+/";
+
+STATIC UINT8 Decoding_table[] = {
+  //
+  // Valid characters 
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
+  // Also, set '=' as a zero for decoding
+  // 0  ,1,   2,

Re: [edk2] [RFC] Proposal to split Pkgs

2019-01-30 Thread Ni, Ray

On 1/29/2019 10:21 PM, Leif Lindholm wrote:

Hi Ray,

First of all, thank you for restarting this discussion, and putting
the effort in for a POC.

On Tue, Jan 29, 2019 at 05:59:35AM +, Ni, Ray wrote:

Hello,
I'd like to propose to split today's BIG packages in following ways:

==Overview =

1. Separate Industry standard definitions from UEFI and PI interfaces.
2. Separate UEFI and PI interfaces from implementations.
 a. Separate UEFI and PI interfaces to different packages
 b. Separate PI PEI, DXE and MM phase interfaces to different packages
3. Separate different features into feature packages.
 Feature interface may be in the feature package to provide minimal
 common interface packages.

The POC code is in https://github.com/jyao1/edk2/tree/ReOrg.
It basically split the EDKII common code to three directories:
Core/, Device/, and Feature/.


I'm not sure I like the 'Device' name, but that's not that important
at this stage - I like that this is split up the way it is.

I also think a lot of things currently under Feture/misc could be
broken out into additional subdirectories under Feature/.


The code is in very early POC phase and only code in Core/ directory
can pass the build.
I would like to gather feedbacks through this RFC to see whether
this splitting direction makes sense.
Is there any other better ways of splitting?
Or perhaps do not split in such a small granularity?


I think this would be my only negative(ish) feedback on the POC.

While it has the benefit of modules requiring to specify more
precisely which functionality they are pulling in...
...it means that they now need to list *everything*.

And with the mechanism by which I have seen Intel engineers make use
of PACKAGES_PATH in the past*, we end up with a bazillion packages
that need to be added individually to this variable for each build.


No. "PACKAGES_PATH" only contains paths pointing to the *parent* 
directory of *Pkg. In this case, it equals to:

/work/edk2/Core:/work/edk2/Device:/work/edk2/Feature/security:/work/edk2/Feature/network:/work/edk2/Feature/misc




* (arguably how it was designed to be used - just not how I am
   interested in using it)

It also means that we need *tons* of dummy .dsc files in order to run
through simple build tests.


Yes each small package needs its own DSC and DEC.
DSC to list all components.
DEC to list all interfaces.

OK maybe the "need" in your wording means the build test script file 
needs to reference all DSC files.
That maybe can be solved by an advanced script to call "build" for each 
DSC files inside a directory that matches a specific pattern. So the 
build test script to build PiPeiPkg/PiDxePkg/PiMmPkg will be like:

  build-any-dsc /work/edk2/Core/ --pattern="*Pi*"



My preference would be to push the packages back up to the top-level.
The split still makes sense, and allocating maintainers to sub-parts
can happen without a full-out redesign of the Maintainers.txt format.
(Which I will try to resurrect with a proposal over the next few weeks
anyway.)


Combining all packages inside the Device and Feature directory to still
one single big package but with another directory layout so that only 
single DSC/DEC is needed?





Or perhaps Mike's work to move lib-c content to edk2-libc repo,
to move real platform code to edk2-platform repo is enough for
now?


I think we need this further restructuring, and renaming. Not just for
splitting up maintainership duties (which as I mentioned in email to
Laszlo, we will still need to do with this change). But to make the
codebase more approachable.



"more approachable" means more friendly to new comers? Just try to 
understand everyone's real concern to today's codebase.



==More explanations =

There are 9 packages inside Core/ directory:
1. BasePkg
Contains industry standard definitions (exclude UEFI and PI) and base
libraries that non-UEFI and non-PI development can depend on.
UEFI or PI development can also depend on this package.
2. UefiPkg
Contains UEFI interfaces and libraries that UEFI driver-model driver
development can depend on.
3. PiPeiPkg
Contains PI interfaces and libraries for PEI phase that PEI module
development can depend on.
4. PiDxePkg
Contains PI interfaces and libraries for DXE phase that DXE module
development can depend on.


Really happy with the above split.


5. PiMmPkg
Contains PI interfaces and libraries for MM phase that MM/SMM
module development can depend on.


How would/should this work relative to StandaloneMmPkg?

The "Mm" is to reflect to the same word in PI spec.
But I didn't check whether "StandaloneMmPkg" can work with the this.




6. MdeModulePkg (TianoPkg? Name is still TBD)


Yes, this needs to be renamed. I don't object to the Tiano naming.



Thanks.


Contains Tiano implementation specific interfaces and libraries.
Developing modules for pure UEFI or PI should not depend on this package.
7. PeiFoundationPkg

Re: [edk2] [platforms: PATCH v3 0/5] Armada7k8k memory handling update

2019-01-30 Thread Marcin Wojtas
Hi Leif,

Thanks a lot. While at it - do you think ArmPkg/Include/Library/ArmLib.h
/ ArmPkg/Library/ArmLib/ArmLib.c would be a proper place for it?

Best regards,
Marcin

śr., 30 sty 2019 o 17:47 Leif Lindholm 
napisał(a):

> Thanks for the rework.
>
> (We should probably move that broken-out function to ArmPkg at some point.)
>
> For the series:
> Reviewed-by: Leif Lindholm 
>
> Pushed as b0bb325f20..0a7d8e7d93.
>
> On Mon, Jan 28, 2019 at 10:45:10AM +0100, Marcin Wojtas wrote:
> > Hi,
> >
> > The third version of the patchset moves the new common
> > header for Marvell SMC ID's to the IndustryStandard directory.
> > What is more important, now 3 regions (described by new PCDs)
> > are reserved separately. For that purpose a preparation
> > patch was added, which extract existing reservation code
> > into a new subroutine. More details can be found in
> > the changelog below and the commit messages.
> >
> > Patches are available in the github:
> >
> https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/dram-upstream-r20190128
> >
> > I'm looking forward to the comments and remarks.
> >
> > Best regards,
> > Marcin
> >
> > Changelog:
> > v2 -> v3
> > * 1/5
> >   - New patch - extract memory reservation to a separate routine
> >
> > * 2/2
> >   - Add new PCDs and reserve 3 regions (ARM-TF, PEI stack, OP-TEE)
> > separately
> >   - Update commit message accordingly
> >
> > * 3/5
> >   - Move MvSmc.h to Include/IndustryStandard
> >
> > * 4,5/5
> >   - Add Leif's RB
> >
> > v1 -> v2:
> > * 1/4
> >   - Improve commit log - mention single area size and new PEI stack base
> >
> > * 2/4 (new patch)
> >   - Add common header for Marvell SMC ID's
> >
> > * 3/4
> >   - Add function description comment
> >   - Define and use ARMADA7K8K_AP806_INDEX
> >   - Change function argument to EFI_PHYSICAL_ADDRESS
> >
> > * 4/4
> >   - Move new SMC ID to MvSmc.h
> >   - Include ArmadaSoCDescLib.h directly (instead indirectly via
> BoardDesc.h)
> >   - Remove ARMADA7K8K_AP806_INDEX macro
> >
> > Grzegorz Jaszczyk (2):
> >   Marvell/Library: ArmadaSoCDescLib: Add North Bridge description
> >   Marvell/Armada7k8k: Read DRAM settings from ARM-TF
> >
> > Marcin Wojtas (3):
> >   Marvell/Armada7k8k: Refactor reserving memory regions
> >   Marvell/Armada7k8k: Shift PEI stack base and extend memory reservation
> >   Marvell/Library: Introduce common header for the SMC ID's
> >
> >  Silicon/Marvell/Marvell.dec
>   |   8 +-
> >  Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
>   |  16 ++-
> >  Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLib.inf
>  |   3 +
> >
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kMemoryInitPeiLib/Armada7k8kMemoryInitPeiLib.inf
> |   8 +-
> >  Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLibMem.h
>   |  25 -
> >
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
>  |   6 ++
> >  Silicon/Marvell/Include/IndustryStandard/MvSmc.h
>  |  24 +
> >  Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h
>  |  28 +
> >  Silicon/Marvell/Library/ComPhyLib/ComPhySipSvc.h
>  |   8 +-
> >  Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLibMem.c
>   |  60 ---
> >
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kMemoryInitPeiLib/Armada7k8kMemoryInitPeiLib.c
>  | 107 +---
> >
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
>  |  34 +++
> >  Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
>   |  14 +--
> >  13 files changed, 220 insertions(+), 121 deletions(-)
> >  create mode 100644 Silicon/Marvell/Include/IndustryStandard/MvSmc.h
> >
> > --
> > 2.7.4
> >
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4] MdePkg/BaseLib: Add Base64Encode() and Base64Decode()

2019-01-30 Thread Zhang, Shenglei


> -Original Message-
> From: Ni, Ray
> Sent: Wednesday, January 30, 2019 5:49 PM
> To: Zhang, Shenglei ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Mike Turner
> ; Gao, Liming 
> Subject: Re: [edk2] [PATCH v4] MdePkg/BaseLib: Add Base64Encode() and
> Base64Decode()
> 
> Comments in below.
> 
> On 1/30/2019 2:28 PM, Shenglei Zhang wrote:
> > From: Mike Turner 
> >
> > Introduce public functions Base64Encode and Base64Decode.
> > https://bugzilla.tianocore.org/show_bug.cgi?id=1370
> >
> > v2:1.Remove some white space.
> > 2.Add unit test with test vectors in RFC 4648.
> >   https://github.com/shenglei10/edk2/tree/encode_test
> >   https://github.com/shenglei10/edk2/tree/decode_test
> >
> > v3:1.Align white space.
> > 2.Update comments of Base64Encode and Base64Decode.
> > 3.Change the use of macro RETURN_DEVICE_ERROR to
> >   RETURN_INVALID_PARAMETER in string.c.
> >
> > v4:Change parameters' names.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Shenglei Zhang 
> > ---
> >   MdePkg/Include/Library/BaseLib.h |  56 +
> >   MdePkg/Library/BaseLib/String.c  | 344
> +++
> >   2 files changed, 400 insertions(+)
> >
> > diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> > index 1eb842384e..03173def58 100644
> > --- a/MdePkg/Include/Library/BaseLib.h
> > +++ b/MdePkg/Include/Library/BaseLib.h
> > @@ -2720,6 +2720,62 @@ AsciiStrnToUnicodeStrS (
> > OUT UINTN *DestinationLength
> > );
> >
> > +/**
> > +  Convert binary data to a Base64 encoded ascii string based on RFC4648.
> > +
> > +  Produce a Null-terminated Ascii string in the output buffer specified by
> Destination and DestinationSize.
> > +  The Ascii string is produced by converting the data string specified by
> Source and SourceLength.
> > +
> > +  @param Source   Input UINT8 data
> > +  @param SourceLength Number of UINT8 bytes of data
> > +  @param Destination  Pointer to output string buffer
> > +  @param DestinationSize  Size of ascii buffer. Set to 0 to get the size
> needed.
> > +  Caller is responsible for passing in buffer of 
> > DestinationSize
> > +
> > +  @retval RETURN_SUCCESS When ascii buffer is filled in.
> > +  @retval RETURN_INVALID_PARAMETER   If Source is NULL or
> DestinationSize is NULL.
> > +  @retval RETURN_INVALID_PARAMETER   If SourceLength or
> DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).
> > +  @retval RETURN_BUFFER_TOO_SMALLIf SourceLength is 0 and
> DestinationSize is <1.
> > +  @retval RETURN_BUFFER_TOO_SMALLIf Destination is NULL or
> DestinationSize is smaller than required buffersize.
> > +
> > +**/
> > +RETURN_STATUS
> > +EFIAPI
> > +Base64Encode (
> > +  IN  CONST UINT8  *Source,
> > +  INUINTN   SourceLength,
> > +  OUT   CHAR8  *Destination  OPTIONAL,
> > +  IN OUTUINTN  *DestinationSize
> > +  );
> > +
> > +/**
> > +  Convert Base64 ascii string to binary data based on RFC4648.
> > +
> > +  Produce Null-terminated binary data in the output buffer specified by
> Destination and DestinationSize.
> > +  The binary data is produced by converting the Base64 ascii string
> specified by Source and SourceLength.
> > +
> > +  @param Source  Input ASCII characters
> > +  @param SourceLengthNumber of ASCII characters
> > +  @param Destination Pointer to output buffer
> > +  @param DestinationSize Caller is responsible for passing in buffer of at
> least DestinationSize.
> > + Set 0 to get the size needed. Set to bytes stored 
> > on return.
> > +
> > +  @retval RETURN_SUCCESS When binary buffer is filled in.
> > +  @retval RETURN_INVALID_PARAMETER   If Source is NULL or
> DestinationSize is NULL.
> > +  @retval RETURN_INVALID_PARAMETER   If SourceLength or
> DestinationSize is bigger than (MAX_ADDRESS -(UINTN)Destination ).
> > +  @retval RETURN_INVALID_PARAMETER   If there is any invalid character
> in input stream.
> > +  @retval RETURN_BUFFER_TOO_SMALLIf buffer length is smaller than
> required buffer size.
> > +
> > + **/
> > +RETURN_STATUS
> > +EFIAPI
> > +Base64Decode (
> > +  IN  CONST CHAR8  *Source,
> > +  INUINTN   SourceLength,
> > +  OUT   UINT8  *Destination  OPTIONAL,
> > +  IN OUTUINTN  *DestinationSize
> > +  );
> > +
> >   /**
> > Converts an 8-bit value to an 8-bit BCD value.
> >
> > diff --git a/MdePkg/Library/BaseLib/String.c
> b/MdePkg/Library/BaseLib/String.c
> > index e6df12797d..e4aa5a57e4 100644
> > --- a/MdePkg/Library/BaseLib/String.c
> > +++ b/MdePkg/Library/BaseLib/String.c
> > @@ -1763,6 +1763,350 @@ AsciiStrToUnicodeStr (
> >
> >   #endif
> >
> > +//
> > +// The basis for Base64 encoding is RFC 4686
> https://tools.ietf.org/html/rfc4648
> > +//
> > +// RFC 4686 has a number of MAY and SHOULD cases.  This
> 

Re: [edk2] Conditional Compilation support in INF file

2019-01-30 Thread Gao, Liming
Karunakar:
  There is one BZ https://bugzilla.tianocore.org/show_bug.cgi?id=1446 on 
Feature Flag expression in INF. INF spec has listed the syntax for it. But, 
BaseTools doesn't support it now. If you have the similar request, please add 
the information in BZ (including the usage model and expected edk2 release). 
And, stephano are working on Public Design and Bug Scrub Meetings. Then, we can 
talk the fix plan in public bug scrub meeting.

Thanks
Liming
> -Original Message-
> From: karunakarpoosapa...@dell.com [mailto:karunakarpoosapa...@dell.com]
> Sent: Monday, January 28, 2019 4:36 PM
> To: Gao, Liming ; Kinney, Michael D 
> ; ler...@redhat.com; edk2-devel@lists.01.org
> Cc: sumanth.vidyadh...@dell.com; shekar.bab...@dell.com; 
> sriramkumar.r...@dell.com; anand.jo...@dell.com
> Subject: RE: [edk2] Conditional Compilation support in INF file
> 
> +Team.
> 
> -Original Message-
> From: Poosapalli, Karunakar
> Sent: Monday, January 28, 2019 1:20 PM
> To: 'Gao, Liming'; Kinney, Michael D; ler...@redhat.com; 
> edk2-devel@lists.01.org
> Cc: Vidyadhara, Sumanth; S, Shekar Babu; Raju, SriramKumar
> Subject: RE: [edk2] Conditional Compilation support in INF file
> 
> Hi Liming/Mike and All,
> 
>   1.  Is there any plan for adding 'Feature Flag Expressions' support to 
> Basetools?
> Please let me know if you want to me to create ticket in BugZilla 
> and work on it.
>   2.  If Feature Flag Expressions is NOT supported in current INF 
> version, Can we update INF spec until we provide this support.
>Please let me know to initiate the process for updating 
> the INF spec or  let me know to create the ECR.
>   3.  Thanks for giving alternative ways to achieve the goal.
>If we're planning to provide the Feature Flag Expressions support, 
>  I would like to suggest to add 'Conditional compilation'
> support to BaseTools, So that it can provide all the requirements.
> 
> Thanks & Regards,
> Karunakar
> 
> -Original Message-
> From: Gao, Liming [mailto:liming@intel.com]
> Sent: Tuesday, January 15, 2019 8:40 PM
> To: Kinney, Michael D; Poosapalli, Karunakar; ler...@redhat.com; 
> edk2-devel@lists.01.org
> Cc: Vidyadhara, Sumanth; S, Shekar Babu; Raju, SriramKumar
> Subject: RE: [edk2] Conditional Compilation support in INF file
> 
> 
> [EXTERNAL EMAIL]
> 
> Karunakar and Mike:
>Basetools doesn't support Feature Flag Expressions in INF file. It just 
> ignores them. Because there are other solutions, I would like to
> propose to update INF spec to remove Feature Flag Expressions and avoid the 
> confuse.
> 
> Thanks
> Liming
> > -Original Message-
> > From: Kinney, Michael D
> > Sent: Saturday, January 12, 2019 2:54 AM
> > To: karunakarpoosapa...@dell.com; Gao, Liming ;
> > ler...@redhat.com; edk2-devel@lists.01.org; Kinney, Michael D
> > 
> > Cc: sumanth.vidyadh...@dell.com; shekar.bab...@dell.com; Gao, Liming
> > ; sriramkumar.r...@dell.com
> > Subject: RE: [edk2] Conditional Compilation support in INF file
> >
> > Karunakar,
> >
> > Feature Flag Expressions is a concept that is defined in the specs,
> > but is a feature that is not fully implemented.  Liming should be able
> > to provide details on what has been implemented and validated in
> > BaseTools.  I think the reason that this feature has not been
> > implemented fully is that we have been able to find alternate ways to
> > get the equivalent results.  Here are a few example techniques:
> >
> > 3a: One approach is to use multiple INF files and select the
> > Right INF for different types of platform builds in DSC file.
> > If multiple modules share source files but have different
> > elements produced/consumed/depex, then multiple INF
> > file is an approach that makes the produced/consumed/depex
> > clear and is compatible with UDP Spec.
> >
> > 3c: One approach is to use DEBUG_CODE(), DEBUG_CODE_BEGIN(),
> > and DEBUG_CODE_END() macros in a single version of the
> > source files and enable/disable the debug code using BIT2
> > in the following PCD:
> >
> >   ## The mask is used to control DebugLib behavior.
> >   #  BIT0 - Enable Debug Assert.
> >   #  BIT1 - Enable Debug Print.
> >   #  BIT2 - Enable Debug Code.
> >   #  BIT3 - Enable Clear Memory.
> >   #  BIT4 - Enable BreakPoint as ASSERT.
> >   #  BIT5 - Enable DeadLoop as ASSERT.
> >   # @Prompt Debug Property.
> >   # @Expression  0x8002 | 
> > (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
> >   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x0005
> >
> > 3c: Another approach is to use multiple INF files and select
> > the one needed for debug/release in DSC file.
> >
> > If these techniques, or other techniques that other community Member
> > may be using do not work for your use cases, and Feature Flag
> > Expressions are the best approach, then Bugzillas Can be entered with
> > supporting use cases to justify adding the feature to 

Re: [edk2] [PATCH 2/2] IntelSiliconPkg\Include\IndustryStandard: Update IGD_OPREGION_MBOX3 Structure

2019-01-30 Thread Ni, Ray

On 1/31/2019 1:00 PM, Digant H Solanki wrote:

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1454
Based on latest IGD OpRegion Spec, IGD_OPREGION_MBOX3 needs to be updated with 
two new members : Physical Address of Raw VBT Data (RVDA) and Size of Raw VBT 
Data (RVDS)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Digant H Solanki 
Cc: Liming Gao 
Cc: Chaganty, Rangasai V 
Cc: Ni, Ray 
---
  IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h 
b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
index 5ce80a5be8..1c83efee40 100644
--- a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
+++ b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
@@ -4,9 +4,7 @@
  
https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
  
-  @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to 0x46(70)

-
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2019, Intel Corporation. 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
@@ -118,7 +116,9 @@ typedef struct {
UINT64 FDSS;  ///< Offset 0x3AA DSS Buffer address allocated for 
IFFS feature
UINT32 FDSP;  ///< Offset 0x3B2 Size of DSS buffer
UINT32 STAT;  ///< Offset 0x3B6 State Indicator
-  UINT8  RM31[0x46];///< Offset 0x3BA - 0x3FF  Reserved Must be zero. Bug 
in spec 0x45(69)
+  UINT64 RVDA;  ///< Offset 0x3BA Physical address of Raw VBT data. 
Added from Spec Version 0.90 to support VBT greater than 6KB.
+  UINT32 RVDS;  ///< Offset 0x3C2 Size of Raw VBT data. Added from 
Spec Version 0.90 to support VBT greater than 6KB.
+  UINT8  RM31[0x3A];///< Offset 0x3C6 - 0x3FF  Reserved Must be zero.
  } IGD_OPREGION_MBOX3;
  
  ///





--
Thanks,
Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [edk2-platforms/devel-MinPlatform][PATCH v4 3/7] ClevoOpenBoardPkg: Add library instances

2019-01-30 Thread Michael Kubacki
Based on KabylakeOpenBoardPkg from the following branch:
https://github.com/tianocore/edk2-platforms/tree/devel-MinPlatform

Library instances shared across Clevo board instances.

* BaseGpioExpanderLib - Support for the TCA6424 IO expander.
* PeiI2cAccessLib - Provides I2C read and write services.
* PeiDTbtInitLib - PEI discrete Thunderbolt initialization services.
* PeiTbtPolicyLib - PEI Thunderbolt policy initialization.
* DxeTbtPolicyLib - DXE Thunderbolt policy initialization.
* TbtCommonLib - Common Thunderbolt services.

Cc: Hao Wu 
Cc: Liming Gao 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kubacki 
---
 .../Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf|  73 +++
 .../Library/PeiDxeSmmTbtCommonLib/TbtCommonLib.inf |  68 +++
 .../Library/PeiTbtPolicyLib/PeiTbtPolicyLib.inf|  62 +++
 .../Private/PeiDTbtInitLib/PeiDTbtInitLib.inf  |  47 ++
 .../BaseGpioExpanderLib/BaseGpioExpanderLib.inf|  39 ++
 .../Library/PeiI2cAccessLib/PeiI2cAccessLib.inf|  42 ++
 .../Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.c  | 166 ++
 .../Library/PeiDxeSmmTbtCommonLib/TbtCommonLib.c   | 321 
 .../Tbt/Library/PeiTbtPolicyLib/PeiTbtPolicyLib.c  | 210 
 .../Private/PeiDTbtInitLib/PeiDTbtInitLib.c| 572 +
 .../BaseGpioExpanderLib/BaseGpioExpanderLib.c  | 315 
 .../Library/PeiI2cAccessLib/PeiI2cAccessLib.c  | 121 +
 12 files changed, 2036 insertions(+)
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/PeiDxeSmmTbtCommonLib/TbtCommonLib.inf
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/PeiTbtPolicyLib/PeiTbtPolicyLib.inf
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/Private/PeiDTbtInitLib/PeiDTbtInitLib.inf
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.c
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/PeiDxeSmmTbtCommonLib/TbtCommonLib.c
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/PeiTbtPolicyLib/PeiTbtPolicyLib.c
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/Private/PeiDTbtInitLib/PeiDTbtInitLib.c
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.c
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Library/PeiI2cAccessLib/PeiI2cAccessLib.c

diff --git 
a/Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf
 
b/Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf
new file mode 100644
index 00..75a7473060
--- /dev/null
+++ 
b/Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf
@@ -0,0 +1,73 @@
+## @file
+# Component description file for Tbt functionality
+#
+# Copyright (c) 2019, Intel Corporation. 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.
+#
+##
+
+
+[Defines]
+INF_VERSION = 0x00010017
+BASE_NAME = DxeTbtPolicyLib
+FILE_GUID = 28ABF346-4E52-4BD3-b1FF-63BA7563C9D4
+VERSION_STRING = 1.0
+MODULE_TYPE = BASE
+LIBRARY_CLASS = DxeTbtPolicyLib
+
+
+[LibraryClasses]
+BaseMemoryLib
+UefiRuntimeServicesTableLib
+UefiBootServicesTableLib
+DebugLib
+PostCodeLib
+HobLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
+  ClevoOpenBoardPkg/OpenBoardPkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+
+[Pcd]
+gBoardModuleTokenSpaceGuid.PcdDTbtSecurityMode   ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtGpio5Filter## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtWakeupSupport  ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtHotSMI ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtHotNotify  ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtSetClkReq  ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtAspm   ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtAcDcSwitch ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdRtd3Tbt## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdRtd3TbtClkReq  ## CONSUMES
+gBoardModuleTokenSpaceGuid.PcdDTbtWin10Support   ## CONSUMES

[edk2] [edk2-platforms/devel-MinPlatform][PATCH v4 6/7] ClevoOpenBoardPkg/N1xxWU: Add DSC and build files

2019-01-30 Thread Michael Kubacki
Based on KabylakeOpenBoardPkg from the following branch:
https://github.com/tianocore/edk2-platforms/tree/devel-MinPlatform

Adds the DSC and build files necessary to build the N1xxWU Clevo
board instance.

The board follows the same build procedure as other OpenBoardPkg
instances in Platform/Intel in devel-MinPlatform.

Key files
=
* GitEdk2Clevo.bat - Sets up the local environment for build.
* OpenBoardPkg.dsc - The N1xxWU board description file.
* OpenBoardPkgConfig.dsc - Used for feature-related PCD
  customization.
* OpenBoardPkgPcd.dsc - Used for other PCD customization.
* OpenBoardPkg.fdf - The N1xxWU board flash file.
* FlashMapInclude.fdf - The N1xxWU board flash map.
* cln.bat - Cleans temporary files from the workspace.
* prep.bat - Performs pre-build steps.
* bld.bat - Performs build steps.
* postbuild.bat - Performs post-build steps.
* OpenBoardPkgBuildOption.dsc - Sets build options Based
  on PCD values.

Cc: Hao Wu 
Cc: Liming Gao 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kubacki 
---
 .../ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.dsc  | 351 ++
 .../N1xxWU/OpenBoardPkgBuildOption.dsc | 155 +
 .../N1xxWU/OpenBoardPkgConfig.dsc  | 139 
 .../ClevoOpenBoardPkg/N1xxWU/OpenBoardPkgPcd.dsc   | 268 
 .../N1xxWU/Include/Fdf/FlashMapInclude.fdf |  52 ++
 .../ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.fdf  | 716 +
 .../ClevoOpenBoardPkg/N1xxWU/GitEdk2Clevo.bat  |  85 +++
 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/bld.bat| 165 +
 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/cln.bat|  54 ++
 .../Intel/ClevoOpenBoardPkg/N1xxWU/postbuild.bat   |  45 ++
 .../Intel/ClevoOpenBoardPkg/N1xxWU/prebuild.bat| 220 +++
 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/prep.bat   |  85 +++
 12 files changed, 2335 insertions(+)
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.dsc
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkgBuildOption.dsc
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkgConfig.dsc
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkgPcd.dsc
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Include/Fdf/FlashMapInclude.fdf
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.fdf
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/GitEdk2Clevo.bat
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/bld.bat
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/cln.bat
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/postbuild.bat
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/prebuild.bat
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/prep.bat

diff --git a/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.dsc 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.dsc
new file mode 100644
index 00..81487ed58d
--- /dev/null
+++ b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.dsc
@@ -0,0 +1,351 @@
+## @file
+#  Clevo N1xxWU board description file.
+#
+# Copyright (c) 2019, Intel Corporation. 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.
+#
+##
+[Defines]
+  #
+  # Set platform specific package/folder name, same as passed from PREBUILD 
script.
+  # PLATFORM_PACKAGE would be the same as PLATFORM_NAME as well as package 
build folder
+  # DEFINE only takes effect at R9 DSC and FDF.
+  #
+  DEFINE  PLATFORM_PACKAGE= MinPlatformPkg
+  DEFINE  PLATFORM_SI_PACKAGE = KabylakeSiliconPkg
+  DEFINE  PLATFORM_SI_BIN_PACKAGE = KabylakeSiliconBinPkg
+  DEFINE  PLATFORM_FSP_BIN_PACKAGE= KabylakeFspBinPkg
+  DEFINE  PLATFORM_BOARD_PACKAGE  = ClevoOpenBoardPkg
+  DEFINE  BOARD   = N1xxWU
+  DEFINE  PROJECT = 
$(PLATFORM_BOARD_PACKAGE)/$(BOARD)
+
+  #
+  # Platform On/Off features are defined here
+  #
+  !include OpenBoardPkgConfig.dsc
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME   = $(PLATFORM_PACKAGE)
+  PLATFORM_GUID   = 465B0A0B-7AC1-443b-8F67-7B8DEC145F90
+  PLATFORM_VERSION= 0.1
+  DSC_SPECIFICATION   = 0x00010005
+  

[edk2] [edk2-platforms/devel-MinPlatform][PATCH v4 2/7] ClevoOpenBoardPkg/N1xxWU: Add headers

2019-01-30 Thread Michael Kubacki
Based on KabylakeOpenBoardPkg from the following branch:
https://github.com/tianocore/edk2-platforms/tree/devel-MinPlatform

Header files for the N1XXWU Clevo board instance.

* PeiPchPolicyUpdate.h - Shared interfaces and includes used for
  Platform Controller Hub (PCH) initialization in
  PeiSiliconPolicyUpdateLibFsp.
* PeiSaPolicyUpdate.h - Shared interfaces and includes used for
  System Agent (SA) initialization in PeiSiliconPolicyUpdateLibFsp.
* N1xxWUId.h - The board IDs for N1xxWU boards. Exposed for use
  in libraries/modules in the N1xxWU directory.
* PeiN1xxWUInitLib.h - Shared interfaces and includes for the
  N1xxWU PEI board initialization library.
* DxeGopPolicyInit.h - Shared interfaces and includes used for GOP
  policy initialization in DxeSiliconPolicyUpdateLib.
* DxeSaPolicyInit.h - Shared interfaces and includes used for
  System Agent (SA) initialization in DxeSiliconPolicyUpdateLib.

Cc: Hao Wu 
Cc: Liming Gao 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kubacki 
---
 .../PeiPchPolicyUpdate.h   | 34 +++
 .../PeiSaPolicyUpdate.h| 36 +++
 .../ClevoOpenBoardPkg/N1xxWU/Include/N1xxWUId.h| 19 ++
 .../N1xxWU/Library/BoardInitLib/PeiN1xxWUInitLib.h | 48 +++
 .../DxeSiliconPolicyUpdateLib/DxeGopPolicyInit.h   | 45 ++
 .../DxeSiliconPolicyUpdateLib/DxeSaPolicyInit.h| 70 ++
 6 files changed, 252 insertions(+)
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiPchPolicyUpdate.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.h
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Include/N1xxWUId.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Library/BoardInitLib/PeiN1xxWUInitLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Policy/Library/DxeSiliconPolicyUpdateLib/DxeGopPolicyInit.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Policy/Library/DxeSiliconPolicyUpdateLib/DxeSaPolicyInit.h

diff --git 
a/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiPchPolicyUpdate.h
 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiPchPolicyUpdate.h
new file mode 100644
index 00..b736111344
--- /dev/null
+++ 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiPchPolicyUpdate.h
@@ -0,0 +1,34 @@
+/** @file
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.
+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 _PEI_PCH_POLICY_UPDATE_H_
+#define _PEI_PCH_POLICY_UPDATE_H_
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#endif
diff --git 
a/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.h
 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.h
new file mode 100644
index 00..10122af262
--- /dev/null
+++ 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSaPolicyUpdate.h
@@ -0,0 +1,36 @@
+/** @file
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.
+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 _PEI_SA_POLICY_UPDATE_H_
+#define _PEI_SA_POLICY_UPDATE_H_
+
+//
+// External include files do NOT need to be explicitly specified in real EDKII
+// environment
+//
+#include 
+#include 
+#include 
+#include 
+#include "PeiPchPolicyUpdate.h"
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+extern EFI_GUID gTianoLogoGuid;
+
+#endif
+
diff --git a/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Include/N1xxWUId.h 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Include/N1xxWUId.h
new file mode 100644
index 00..c5cf2e3143
--- /dev/null
+++ b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Include/N1xxWUId.h
@@ 

[edk2] [edk2-platforms/devel-MinPlatform][PATCH v4 1/7] ClevoOpenBoardPkg: Add package and headers

2019-01-30 Thread Michael Kubacki
Based on KabylakeOpenBoardPkg from the following branch:
https://github.com/tianocore/edk2-platforms/tree/devel-MinPlatform

Create the ClevoOpenBoardPkg to provide an initial board package
for Clevo boards. The ClevoOpenBoardPkg is intended to contain a
series of specific Clevo board instances such as the N1XXWU and
N1XXZU series. A given board instance serves as a board
implementation for use with the MinPlatformPkg.

* Common resources are shared at the top-level of ClevoOpenBoardPkg.
* Features are organized into the Features directory.
  * Features not mandatory to load the OS in the standard hardware
configuration are considered advanced and only enabled when
gMinPlatformPkgTokenSpaceGuid.PcdBootStage is greater than 5.

Cc: Hao Wu 
Cc: Liming Gao 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kubacki 
---
 Platform/Intel/ClevoOpenBoardPkg/OpenBoardPkg.dec  | 306 +
 .../Features/PciHotPlug/PciHotPlug.h   | 136 +
 .../Features/Tbt/Include/Acpi/TbtNvsAreaDef.h  |  68 +
 .../Features/Tbt/Include/Library/DxeTbtPolicyLib.h |  52 
 .../Features/Tbt/Include/Library/PeiTbtPolicyLib.h |  47 
 .../Features/Tbt/Include/Library/TbtCommonLib.h| 247 +
 .../Features/Tbt/Include/Ppi/PeiTbtPolicy.h|  35 +++
 .../Tbt/Include/Private/Library/PeiDTbtInitLib.h   | 114 
 .../Include/Private/Library/PeiTbtCommonInitLib.h  |  47 
 .../Features/Tbt/Include/Protocol/DxeTbtPolicy.h   | 116 
 .../Features/Tbt/Include/Protocol/TbtNvsArea.h |  48 
 .../Features/Tbt/Include/TbtBoardInfo.h|  28 ++
 .../Tbt/Include/TbtPolicyCommonDefinition.h|  83 ++
 .../Library/DxeTbtPolicyLib/DxeTbtPolicyLibrary.h  |  28 ++
 .../Library/PeiTbtPolicyLib/PeiTbtPolicyLibrary.h  |  23 ++
 .../Features/Tbt/TbtInit/Smm/TbtSmiHandler.h   | 185 +
 .../Include/Acpi/GlobalNvsAreaDef.h| 122 
 .../Intel/ClevoOpenBoardPkg/Include/IoExpander.h   |  73 +
 .../Include/Library/GpioExpanderLib.h  | 128 +
 .../Include/Library/I2cAccessLib.h |  39 +++
 .../ClevoOpenBoardPkg/Include/PchHsioPtssTables.h  |  57 
 .../Include/Protocol/GlobalNvsArea.h   |  53 
 Platform/Intel/ClevoOpenBoardPkg/Include/SioRegs.h | 163 +++
 Platform/Intel/ClevoOpenBoardPkg/Contributions.txt | 218 +++
 Platform/Intel/ClevoOpenBoardPkg/License.txt   |  25 ++
 25 files changed, 2441 insertions(+)
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/OpenBoardPkg.dec
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/PciHotPlug/PciHotPlug.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Acpi/TbtNvsAreaDef.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Library/DxeTbtPolicyLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Library/PeiTbtPolicyLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Library/TbtCommonLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Ppi/PeiTbtPolicy.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Private/Library/PeiDTbtInitLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Private/Library/PeiTbtCommonInitLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Protocol/DxeTbtPolicy.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/Protocol/TbtNvsArea.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/TbtBoardInfo.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Include/TbtPolicyCommonDefinition.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLibrary.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/Library/PeiTbtPolicyLib/PeiTbtPolicyLibrary.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Features/Tbt/TbtInit/Smm/TbtSmiHandler.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Include/Acpi/GlobalNvsAreaDef.h
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/Include/IoExpander.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Include/Library/GpioExpanderLib.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Include/Library/I2cAccessLib.h
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/Include/PchHsioPtssTables.h
 create mode 100644 
Platform/Intel/ClevoOpenBoardPkg/Include/Protocol/GlobalNvsArea.h
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/Include/SioRegs.h
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/Contributions.txt
 create mode 100644 Platform/Intel/ClevoOpenBoardPkg/License.txt

diff --git a/Platform/Intel/ClevoOpenBoardPkg/OpenBoardPkg.dec 
b/Platform/Intel/ClevoOpenBoardPkg/OpenBoardPkg.dec
new 

[edk2] [edk2-platforms/devel-MinPlatform][PATCH v4 7/7] ClevoOpenBoardPkg/N1xxWU: Update DEBUG print level macro usage

2019-01-30 Thread Michael Kubacki
Uses DEBUG_INFO instead of EFI_D_INFO in all ClevoOpenBoardPkg files.

Cc: Hao Wu 
Cc: Liming Gao 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kubacki 
---
 .../ClevoOpenBoardPkg/N1xxWU/Library/BoardInitLib/PeiN1xxWUDetect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Library/BoardInitLib/PeiN1xxWUDetect.c
 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Library/BoardInitLib/PeiN1xxWUDetect.c
index edda4da7a0..2f39587ea2 100644
--- 
a/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Library/BoardInitLib/PeiN1xxWUDetect.c
+++ 
b/Platform/Intel/ClevoOpenBoardPkg/N1xxWU/Library/BoardInitLib/PeiN1xxWUDetect.c
@@ -60,7 +60,7 @@ N1xxWUBoardDetect (
 return EFI_SUCCESS;
   }
 
-  DEBUG ((EFI_D_INFO, "N1xxWUDetectionCallback\n"));
+  DEBUG ((DEBUG_INFO, "N1xxWUDetectionCallback\n"));
 
   if (IsN1xxWU ()) {
 LibPcdSetSku (BoardIdN1xxWU);
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [edk2-platforms/devel-MinPlatform][PATCH v4 0/7] Add initial ClevoOpenBoardPkg

2019-01-30 Thread Michael Kubacki
This series adds a new board package in Platform/Intel for Clevo
boards. This provides a board implementation for use with the
MinPlatformPkg. Currently, this is largely a copy of
KabylakeOpenBoardPkg with the name refactored. It is intended to
serve as a base for future community development.

A board directory for the N1xxWU series of Clevo boards based on
Kaby Lake-R is provided as this is the first board planned to be
enabled. The next board instance expected to be supported is the
N1xxZU series based on Whiskey Lake. This directory will be a
peer to N1xxWU in ClevoOpenBoardPkg. Both boards share common
resources in the ClevoOpenBoardPkg root directory.

To minimize intial delta from the source KabylakeOpenBoardPkg,
changes required for boot have not yet been made. Therefore,
in this current state boot functionality should not be expected.

The build instructions are similar to the other boards already
present in Platform/Intel and can be found in ReadMe.md on
devel-MinPlatform.
https://github.com/tianocore/edk2-platforms/tree/devel-MinPlatform

Cc: Hao Wu 
Cc: Liming Gao 
Cc: Jiewen Yao 
Cc: Michael D Kinney 

Michael Kubacki (7):
  ClevoOpenBoardPkg: Add package and headers
  ClevoOpenBoardPkg/N1xxWU: Add headers
  ClevoOpenBoardPkg: Add library instances
  ClevoOpenBoardPkg/N1xxWU: Add library instances
  ClevoOpenBoardPkg: Add modules
  ClevoOpenBoardPkg/N1xxWU: Add DSC and build files
  ClevoOpenBoardPkg/N1xxWU: Update DEBUG print level macro usage

 Platform/Intel/ClevoOpenBoardPkg/OpenBoardPkg.dec  |  306 
 .../ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.dsc  |  351 
 .../N1xxWU/OpenBoardPkgBuildOption.dsc |  155 ++
 .../N1xxWU/OpenBoardPkgConfig.dsc  |  139 ++
 .../ClevoOpenBoardPkg/N1xxWU/OpenBoardPkgPcd.dsc   |  268 +++
 .../N1xxWU/Include/Fdf/FlashMapInclude.fdf |   52 +
 .../ClevoOpenBoardPkg/N1xxWU/OpenBoardPkg.fdf  |  716 
 .../Acpi/BoardAcpiDxe/BoardAcpiDxe.inf |   75 +
 .../Features/PciHotPlug/PciHotPlug.inf |   65 +
 .../Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf|   73 +
 .../Library/PeiDxeSmmTbtCommonLib/TbtCommonLib.inf |   68 +
 .../Library/PeiTbtPolicyLib/PeiTbtPolicyLib.inf|   62 +
 .../Private/PeiDTbtInitLib/PeiDTbtInitLib.inf  |   47 +
 .../Features/Tbt/TbtInit/Dxe/TbtDxe.inf|   55 +
 .../Features/Tbt/TbtInit/Pei/PeiTbtInit.inf|   50 +
 .../Features/Tbt/TbtInit/Smm/TbtSmm.inf|   83 +
 .../BaseGpioExpanderLib/BaseGpioExpanderLib.inf|   39 +
 .../Library/PeiI2cAccessLib/PeiI2cAccessLib.inf|   42 +
 .../PeiSiliconPolicyUpdateLibFsp.inf   |  149 ++
 .../BasePlatformHookLib/BasePlatformHookLib.inf|   57 +
 .../Library/BoardAcpiLib/DxeBoardAcpiTableLib.inf  |   53 +
 .../BoardAcpiLib/DxeMultiBoardAcpiSupportLib.inf   |   54 +
 .../Library/BoardAcpiLib/SmmBoardAcpiEnableLib.inf |   53 +
 .../BoardAcpiLib/SmmMultiBoardAcpiSupportLib.inf   |   54 +
 .../BoardInitLib/PeiBoardInitPostMemLib.inf|   59 +
 .../Library/BoardInitLib/PeiBoardInitPreMemLib.inf |  138 ++
 .../BoardInitLib/PeiMultiBoardInitPostMemLib.inf   |   61 +
 .../BoardInitLib/PeiMultiBoardInitPreMemLib.inf|  140 ++
 .../DxeSiliconPolicyUpdateLib.inf  |   55 +
 .../Features/PciHotPlug/PciHotPlug.h   |  136 ++
 .../Features/Tbt/Include/Acpi/TbtNvsAreaDef.h  |   68 +
 .../Features/Tbt/Include/Library/DxeTbtPolicyLib.h |   52 +
 .../Features/Tbt/Include/Library/PeiTbtPolicyLib.h |   47 +
 .../Features/Tbt/Include/Library/TbtCommonLib.h|  247 +++
 .../Features/Tbt/Include/Ppi/PeiTbtPolicy.h|   35 +
 .../Tbt/Include/Private/Library/PeiDTbtInitLib.h   |  114 ++
 .../Include/Private/Library/PeiTbtCommonInitLib.h  |   47 +
 .../Features/Tbt/Include/Protocol/DxeTbtPolicy.h   |  116 ++
 .../Features/Tbt/Include/Protocol/TbtNvsArea.h |   48 +
 .../Features/Tbt/Include/TbtBoardInfo.h|   28 +
 .../Tbt/Include/TbtPolicyCommonDefinition.h|   83 +
 .../Library/DxeTbtPolicyLib/DxeTbtPolicyLibrary.h  |   28 +
 .../Library/PeiTbtPolicyLib/PeiTbtPolicyLibrary.h  |   23 +
 .../Features/Tbt/TbtInit/Smm/TbtSmiHandler.h   |  185 ++
 .../Include/Acpi/GlobalNvsAreaDef.h|  122 ++
 .../Intel/ClevoOpenBoardPkg/Include/IoExpander.h   |   73 +
 .../Include/Library/GpioExpanderLib.h  |  128 ++
 .../Include/Library/I2cAccessLib.h |   39 +
 .../ClevoOpenBoardPkg/Include/PchHsioPtssTables.h  |   57 +
 .../Include/Protocol/GlobalNvsArea.h   |   53 +
 Platform/Intel/ClevoOpenBoardPkg/Include/SioRegs.h |  163 ++
 .../PeiPchPolicyUpdate.h   |   34 +
 .../PeiSaPolicyUpdate.h|   36 +
 .../ClevoOpenBoardPkg/N1xxWU/Include/N1xxWUId.h|   19 +
 .../N1xxWU/Library/BoardInitLib/PeiN1xxWUInitLib.h |   48 +
 .../DxeSiliconPolicyUpdateLib/DxeGopPolicyInit.h   |   45 +
 .../DxeSiliconPolicyUpdateLib/DxeSaPolicyInit.h|   70 +
 

Re: [edk2] [PATCH v2 11/12] MdeModulePkg/SmmLockBoxLib: Support LockBox enlarge in UpdateLockBox()

2019-01-30 Thread Ni, Ruiyu

On 1/31/2019 10:48 AM, Hao Wu wrote:

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the support to enlarge a LockBox when using the
LockBoxLib API UpdateLockBox().

Please note that the new support will ONLY work for LockBox with attribute
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY set.

The functional uni-test for the commit is available at:
https://github.com/hwu25/edk2/tree/lockbox_unitest

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
  MdeModulePkg/Include/Library/LockBoxLib.h |  7 ++-
  MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c  |  7 ++-
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c |  5 +-
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c |  5 +-
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 57 
++--
  5 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Include/Library/LockBoxLib.h 
b/MdeModulePkg/Include/Library/LockBoxLib.h
index 5921731419..addce3bd4a 100644
--- a/MdeModulePkg/Include/Library/LockBoxLib.h
+++ b/MdeModulePkg/Include/Library/LockBoxLib.h
@@ -2,7 +2,7 @@
This library is only intended to be used by DXE modules that need save
confidential information to LockBox and get it by PEI modules in S3 phase.
  
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
  
  This program and the accompanying materials

  are licensed and made available under the terms and conditions
@@ -85,7 +85,10 @@ SetLockBoxAttributes (
@retval RETURN_SUCCESSthe information is saved successfully.
@retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
@retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
+no enough resource to save the information.
@retval RETURN_ACCESS_DENIED  it is too late to invoke this interface
@retval RETURN_NOT_STARTEDit is too early to invoke this interface
@retval RETURN_UNSUPPORTEDthe service is not supported by 
implementaion.
diff --git a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c 
b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
index c40dfea398..0adda1e2a9 100644
--- a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
+++ b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
@@ -1,6 +1,6 @@
  /** @file
  
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
  
  This program and the accompanying materials

  are licensed and made available under the terms and conditions
@@ -76,7 +76,10 @@ SetLockBoxAttributes (
@retval RETURN_SUCCESSthe information is saved successfully.
@retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
@retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
+no enough resource to save the information.
@retval RETURN_ACCESS_DENIED  it is too late to invoke this interface
@retval RETURN_NOT_STARTEDit is too early to invoke this interface
@retval RETURN_UNSUPPORTEDthe service is not supported by 
implementaion.
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
index 0428decbac..5ee563b71f 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
@@ -300,7 +300,10 @@ SetLockBoxAttributes (
@retval RETURN_SUCCESSthe information is saved successfully.
@retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
@retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to 

Re: [edk2] [PATCH v2 10/12] MdeModulePkg/SmmLockBox(PEI): Remove an ASSERT in RestoreLockBox()

2019-01-30 Thread Wu, Hao A
> -Original Message-
> From: Ni, Ray
> Sent: Thursday, January 31, 2019 1:50 PM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Wang, Jian J; Ni, Ray; Zeng, Star
> Subject: Re: [PATCH v2 10/12] MdeModulePkg/SmmLockBox(PEI): Remove an
> ASSERT in RestoreLockBox()
> 
> On 1/31/2019 10:48 AM, Hao Wu wrote:
> > This commit is out of the scope for BZ-1409. It is a refinement for the
> > PEI library instance within SmmLockBoxLib.
> >
> > For the below ASSERT statement within function RestoreLockBox():
> >Status = SmmCommunicationPpi->Communicate (
> >SmmCommunicationPpi,
> >[0],
> >
> >);
> >if (Status == EFI_NOT_STARTED) {
> >  //
> >  // Pei SMM communication not ready yet, so we access SMRAM directly
> >  //
> >  DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib Communicate - (%r)\n",
> Status));
> >  Status = InternalRestoreLockBoxFromSmram (Guid, Buffer, Length);
> >  LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
> >  if (Length != NULL) {
> >LockBoxParameterRestore->Length = (UINT64)*Length;
> >  }
> >}
> >ASSERT_EFI_ERROR (Status);
> >
> > It is possible for previous codes to return an error status that is
> > possible for happen. One example is that, when the 'if' statement
> > 'if (Status == EFI_NOT_STARTED) {' is entered, function
> > InternalRestoreLockBoxFromSmram() is possible to return
> 'BUFFER_TOO_SMALL'
> > if the caller of RestoreLockBox() provides a buffer that is too small to
> > hold the content of LockBox.
> >
> > Thus, this commit will remove the ASSERT here.
> >
> > Please note that the current implementation of RestoreLockBox() is
> > handling the above-mentioned error case properly, so no additional error
> > handling codes are needed here.
> >
> > Cc: Jian J Wang 
> > Cc: Ray Ni 
> > Cc: Star Zeng 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >   MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
> b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
> > index 9f73480070..9d7b4c3706 100644
> > --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
> > +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
> > @@ -623,7 +623,7 @@ RestoreLockBox (
> > LockBoxParameterRestore->Length = (UINT64)*Length;
> >   }
> > }
> > -  ASSERT_EFI_ERROR (Status);
> > +  //ASSERT_EFI_ERROR (Status);

It comes to me that the above line should be removed rather than being
commented. Will handle in the next series.

Best Regards,
Hao Wu

> >
> > if (Length != NULL) {
> >   *Length = (UINTN)LockBoxParameterRestore->Length;
> >
> Reviewed-by: Ray Ni 
> 
> --
> Thanks,
> Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 10/12] MdeModulePkg/SmmLockBox(PEI): Remove an ASSERT in RestoreLockBox()

2019-01-30 Thread Ni, Ruiyu

On 1/31/2019 10:48 AM, Hao Wu wrote:

This commit is out of the scope for BZ-1409. It is a refinement for the
PEI library instance within SmmLockBoxLib.

For the below ASSERT statement within function RestoreLockBox():
   Status = SmmCommunicationPpi->Communicate (
   SmmCommunicationPpi,
   [0],
   
   );
   if (Status == EFI_NOT_STARTED) {
 //
 // Pei SMM communication not ready yet, so we access SMRAM directly
 //
 DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib Communicate - (%r)\n", Status));
 Status = InternalRestoreLockBoxFromSmram (Guid, Buffer, Length);
 LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
 if (Length != NULL) {
   LockBoxParameterRestore->Length = (UINT64)*Length;
 }
   }
   ASSERT_EFI_ERROR (Status);

It is possible for previous codes to return an error status that is
possible for happen. One example is that, when the 'if' statement
'if (Status == EFI_NOT_STARTED) {' is entered, function
InternalRestoreLockBoxFromSmram() is possible to return 'BUFFER_TOO_SMALL'
if the caller of RestoreLockBox() provides a buffer that is too small to
hold the content of LockBox.

Thus, this commit will remove the ASSERT here.

Please note that the current implementation of RestoreLockBox() is
handling the above-mentioned error case properly, so no additional error
handling codes are needed here.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
index 9f73480070..9d7b4c3706 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
@@ -623,7 +623,7 @@ RestoreLockBox (
LockBoxParameterRestore->Length = (UINT64)*Length;
  }
}
-  ASSERT_EFI_ERROR (Status);
+  //ASSERT_EFI_ERROR (Status);
  
if (Length != NULL) {

  *Length = (UINTN)LockBoxParameterRestore->Length;


Reviewed-by: Ray Ni 

--
Thanks,
Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 09/12] MdeModulePkg/SmmLockBoxLib: Use 'DEBUG_' prefix instead of 'EFI_D_'

2019-01-30 Thread Ni, Ruiyu

On 1/31/2019 10:48 AM, Hao Wu wrote:

This commit is out of the scope for BZ-1409. It is a coding style
refinement for the SmmLockBoxLib.

More specifically, the commit will remove all the debug message display
level macros starting with 'EFI_D_' and replace them with macros starting
with 'DEBUG_'.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c | 22 +++---
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 26 +++
  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 78 
++--
  3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
index ac8bcd2ff7..0428decbac 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
@@ -1,6 +1,6 @@
  /** @file
  
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
  
  This program and the accompanying materials

  are licensed and made available under the terms and conditions
@@ -153,7 +153,7 @@ SaveLockBox (
UINT8   *CommBuffer;
UINTN   CommSize;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
  
//

// Basic check
@@ -199,7 +199,7 @@ SaveLockBox (
  
Status = (EFI_STATUS)LockBoxParameterSave->Header.ReturnStatus;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", Status));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", Status));
  
//

// Done
@@ -235,7 +235,7 @@ SetLockBoxAttributes (
UINT8 *CommBuffer;
UINTN CommSize;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));
  
//

// Basic check
@@ -281,7 +281,7 @@ SetLockBoxAttributes (
  
Status = (EFI_STATUS)LockBoxParameterSetAttributes->Header.ReturnStatus;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit (%r)\n", Status));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit (%r)\n", 
Status));
  
//

// Done
@@ -322,7 +322,7 @@ UpdateLockBox (
UINT8 *CommBuffer;
UINTN CommSize;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
  
//

// Basic check
@@ -369,7 +369,7 @@ UpdateLockBox (
  
Status = (EFI_STATUS)LockBoxParameterUpdate->Header.ReturnStatus;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", Status));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", Status));
  
//

// Done
@@ -411,7 +411,7 @@ RestoreLockBox (
UINT8  *CommBuffer;
UINTN  CommSize;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
  
//

// Basic check
@@ -467,7 +467,7 @@ RestoreLockBox (
  
Status = (EFI_STATUS)LockBoxParameterRestore->Header.ReturnStatus;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", Status));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", 
Status));
  
//

// Done
@@ -496,7 +496,7 @@ RestoreAllLockBoxInPlace (
UINT8   *CommBuffer;
UINTN   CommSize;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));
  
SmmCommunication = LockBoxGetSmmCommProtocol ();

if (SmmCommunication == NULL) {
@@ -532,7 +532,7 @@ RestoreAllLockBoxInPlace (
  
Status = (EFI_STATUS)LockBoxParameterRestoreAllInPlace->Header.ReturnStatus;
  
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status));

+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit 
(%r)\n", Status));
  
//

// Done
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
index 8a168663c4..9f73480070 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
@@ -1,6 +1,6 @@
  /** @file
  
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
  
  This program and the 

Re: [edk2] [PATCH v2 08/12] MdeModulePkg/AhciPei: Add AHCI mode ATA device support in PEI

2019-01-30 Thread Ni, Ruiyu

On 1/31/2019 10:48 AM, Hao Wu wrote:

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the AHCI mode ATA device support in the PEI phase.

More specifically, the newly add AhciPei driver will consume the ATA AHCI
host controller PPI for ATA controllers working under AHCI code within the
system. And then produces the below PPIs for each controller:

EDKII PEI ATA PassThru PPI
Storage Security Command PPI

Also, the driver will consume the S3StorageDeviceInitList LockBox in S3
phase. The purpose is to perform an on-demand (partial) ATA device
enumeration/initialization on each controller to benefit the S3 resume
performance.

The implementation of this driver is currently based on the below
specifications:
Serial ATA Revision 2.6
Serial ATA Advanced Host Controller Interface (AHCI) 1.3.1
AT Attachment with Packet Interface - 6 (ATA/ATAPI-6)

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 


Similar comments regarding the device path part.

--
Thanks,
Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox

2019-01-30 Thread Wu, Hao A
> -Original Message-
> From: Ni, Ray
> Sent: Thursday, January 31, 2019 11:45 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Wang, Jian J; Dong, Eric
> Subject: RE: [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume
> S3StorageDeviceInitList LockBox
> 
> 
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Thursday, January 31, 2019 10:49 AM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A ; Wang, Jian J ;
> > Ni, Ray ; Dong, Eric 
> > Subject: [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume
> > S3StorageDeviceInitList LockBox
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> >
> > For the NvmExpressPei driver, this commit will update the driver to consume
> > the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to perform
> > an on-demand (partial) NVM Express device enumeration/initialization to
> > benefit the S3 resume performance.
> >
> > Cc: Jian J Wang 
> > Cc: Ray Ni 
> > Cc: Eric Dong 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf |   8 +-
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h   |  16 +++
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c   |  20 
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 106
> > 
> >  4 files changed, 149 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > index 0666e5892b..22b703e971 100644
> > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > @@ -40,6 +40,7 @@
> >NvmExpressPeiHci.h
> >NvmExpressPeiPassThru.c
> >NvmExpressPeiPassThru.h
> > +  NvmExpressPeiS3.c
> >NvmExpressPeiStorageSecurity.c
> >NvmExpressPeiStorageSecurity.h
> >
> > @@ -54,6 +55,7 @@
> >BaseMemoryLib
> >IoLib
> >TimerLib
> > +  LockBoxLib
> >PeimEntryPoint
> >
> >  [Ppis]
> > @@ -64,9 +66,13 @@
> >gEfiPeiVirtualBlockIo2PpiGuid  ## SOMETIMES_PRODUCES
> >gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES
> >
> > +[Guids]
> > +  gS3StorageDeviceInitListGuid   ## SOMETIMES_CONSUMES ##
> > UNDEFINED
> > +
> >  [Depex]
> >gEfiPeiMemoryDiscoveredPpiGuid AND
> > -  gEdkiiPeiNvmExpressHostControllerPpiGuid
> > +  gEdkiiPeiNvmExpressHostControllerPpiGuid AND
> > + gEfiPeiMasterBootModePpiGuid
> >
> >  [UserExtensions.TianoCore."ExtraFiles"]
> >NvmExpressPeiExtra.uni
> > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > index 7047c4f3ff..6f01413e6d 100644
> > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > @@ -332,4 +332,20 @@ NvmeBuildDevicePath (
> >OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath
> >);
> >
> > +/**
> > +  Determine if a specific NVM Express controller can be skipped for S3 
> > phase.
> > +
> > +  @param[in]  HcDevicePath  Device path of the controller.
> > +  @param[in]  HcDevicePathLengthLength of the device path specified by
> > +HcDevicePath.
> > +
> > +  @retvalThe number of ports that need to be enumerated.
> > +
> > +**/
> > +BOOLEAN
> > +NvmeS3SkipThisController (
> > +  IN  EFI_DEVICE_PATH_PROTOCOL*HcDevicePath,
> > +  IN  UINTN   HcDevicePathLength
> > +  );
> > +
> >  #endif
> > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> > index 96622e6fd5..43b2dfc3e7 100644
> > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> > @@ -213,6 +213,7 @@ NvmExpressPeimEntry (
> >)
> >  {
> >EFI_STATUS   Status;
> > +  EFI_BOOT_MODEBootMode;
> >EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI*NvmeHcPpi;
> >UINT8Controller;
> >UINTNMmioBase;
> > @@ -224,6 +225,15 @@ NvmExpressPeimEntry (
> >DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__));
> >
> >//
> > +  // Get the current boot mode.
> > +  //
> > +  Status = PeiServicesGetBootMode ();  if (EFI_ERROR (Status))
> > + {
> > +DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n",
> > __FUNCTION__));
> > +return Status;
> > +  }
> > +
> > +  //
> >// Locate the NVME host controller PPI
> >//
> >Status = PeiServicesLocatePpi (
> > @@ -279,6 +289,16 @@ NvmExpressPeimEntry (
> >continue;
> >  }
> >
> > +if ((BootMode == BOOT_ON_S3_RESUME) &&
> > +(NvmeS3SkipThisController (DevicePath, DevicePathLength))) {
> > +  DEBUG ((
> > +DEBUG_ERROR, "%a: Controller %d is 

Re: [edk2] [PATCH v2 06/12] MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI

2019-01-30 Thread Wu, Hao A
> -Original Message-
> From: Ni, Ray
> Sent: Thursday, January 31, 2019 11:35 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Wang, Jian J; Dong, Eric
> Subject: RE: [PATCH v2 06/12] MdeModulePkg/NvmExpressPei: Add logic to
> produce SSC PPI
> 
> 
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Thursday, January 31, 2019 10:49 AM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A ; Wang, Jian J ;
> > Ni, Ray ; Dong, Eric 
> > Subject: [PATCH v2 06/12] MdeModulePkg/NvmExpressPei: Add logic to
> > produce SSC PPI
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> >
> > For the NvmExpressPei driver, this commit will add codes to produce the
> > Storage Security Command PPI if the underlying NVM Express controller
> > supports the Security Send and Security Receive commands.
> >
> > Cc: Jian J Wang 
> > Cc: Ray Ni 
> > Cc: Eric Dong 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf  |  10 +-
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h|  81
> > +++-
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h |  20 +-
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h
> > | 247 
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c   | 317
> > +++
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c| 143
> > +--
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c |  32 +-
> >  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.c
> > | 423 
> >  8 files changed, 1184 insertions(+), 89 deletions(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > index 9591572fec..0666e5892b 100644
> > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> > @@ -2,7 +2,7 @@
> >  #  The NvmExpressPei driver is used to manage non-volatile memory
> > subsystem
> >  #  which follows NVM Express specification at PEI phase.
> >  #
> > -#  Copyright (c) 2018, Intel Corporation. All rights reserved.
> > +#  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
> >  #
> >  #  This program and the accompanying materials
> >  #  are licensed and made available under the terms and conditions of the
> > BSD License
> > @@ -30,6 +30,7 @@
> >  #
> >
> >  [Sources]
> > +  DevicePath.c
> >DmaMem.c
> >NvmExpressPei.c
> >NvmExpressPei.h
> > @@ -39,6 +40,8 @@
> >NvmExpressPeiHci.h
> >NvmExpressPeiPassThru.c
> >NvmExpressPeiPassThru.h
> > +  NvmExpressPeiStorageSecurity.c
> > +  NvmExpressPeiStorageSecurity.h
> >
> >  [Packages]
> >MdePkg/MdePkg.dec
> > @@ -54,11 +57,12 @@
> >PeimEntryPoint
> >
> >  [Ppis]
> > -  gEfiPeiVirtualBlockIoPpiGuid   ## PRODUCES
> > -  gEfiPeiVirtualBlockIo2PpiGuid  ## PRODUCES
> >gEdkiiPeiNvmExpressHostControllerPpiGuid   ## CONSUMES
> >gEdkiiIoMmuPpiGuid ## CONSUMES
> >gEfiEndOfPeiSignalPpiGuid  ## CONSUMES
> > +  gEfiPeiVirtualBlockIoPpiGuid   ## SOMETIMES_PRODUCES
> > +  gEfiPeiVirtualBlockIo2PpiGuid  ## SOMETIMES_PRODUCES
> > +  gEdkiiPeiStorageSecurityCommandPpiGuid ##
> > SOMETIMES_PRODUCES
> >
> >  [Depex]
> >gEfiPeiMemoryDiscoveredPpiGuid AND
> > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > index 0135eca6f0..7047c4f3ff 100644
> > --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> > @@ -25,6 +25,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >
> > @@ -44,6 +45,7 @@ typedef struct
> > _PEI_NVME_CONTROLLER_PRIVATE_DATA
> > PEI_NVME_CONTROLLER_PRIVATE_DA
> >  #include "NvmExpressPeiHci.h"
> >  #include "NvmExpressPeiPassThru.h"
> >  #include "NvmExpressPeiBlockIo.h"
> > +#include "NvmExpressPeiStorageSecurity.h"
> >
> >  //
> >  // NVME PEI driver implementation related definitions
> > @@ -90,10 +92,15 @@ struct _PEI_NVME_NAMESPACE_INFO {
> >  struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
> >UINT32Signature;
> >UINTN MmioBase;
> > +  UINTN DevicePathLength;
> > +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> > +
> >EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
> >EFI_PEI_RECOVERY_BLOCK_IO2_PPIBlkIo2Ppi;
> > +  EDKII_PEI_STORAGE_SECURITY_CMD_PPIStorageSecurityPpi;
> >EFI_PEI_PPI_DESCRIPTORBlkIoPpiList;
> >EFI_PEI_PPI_DESCRIPTORBlkIo2PpiList;
> > +  

Re: [edk2] [PATCH v2 04/12] MdeModulePkg: Add GUID for LockBox to save storage dev to init in S3

2019-01-30 Thread Wu, Hao A
> -Original Message-
> From: Ni, Ray
> Sent: Thursday, January 31, 2019 11:27 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Wang, Jian J; Dong, Eric
> Subject: RE: [PATCH v2 04/12] MdeModulePkg: Add GUID for LockBox to save
> storage dev to init in S3
> 
> 
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Thursday, January 31, 2019 10:49 AM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A ; Wang, Jian J ;
> > Ni, Ray ; Dong, Eric 
> > Subject: [PATCH v2 04/12] MdeModulePkg: Add GUID for LockBox to save
> > storage dev to init in S3
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> >
> > This commit will add the GUID definitions for LockBox which is used to save 
> > a
> > list of storage devices that need to get initialized during the S3 resume.
> >
> > The content of the LockBox will be a DevicePath structure that contains zero
> > or more DevicePath instances. Each instance denotes a storage device that
> > needs to get initialized during the S3 resume.
> >
> > The producers of the content of this LockBox will be drivers like
> > OpalPassword DXE driver. This kind of drivers requires some specific storage
> > devices to be initialized during the PEI phase of in S3 resume.
> > (For the OpalPasword case, it requires the managing devices to be
> > automatically unlocked during the S3 resume).
> >
> > The attribute of the LockBox should be set to
> > LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY.
> >
> > The consumers of the content of this LockBox will be PEI storage device
> > controller/bus drivers (e.g. NvmExpressPei) during S3 resume. This kind of
> > drivers can use the DevicePath instances stored in the LockBox to get a 
> > list of
> > devices that need to get initialized. In such way, an on-demand
> > (partial) device enumeration/initialization can be performed to benefit the 
> > S3
> > resume performance.
> >
> > Cc: Jian J Wang 
> > Cc: Ray Ni 
> > Cc: Eric Dong 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  MdeModulePkg/MdeModulePkg.dec   |  3 ++
> >  MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h | 36
> > 
> >  2 files changed, 39 insertions(+)
> >
> > diff --git a/MdeModulePkg/MdeModulePkg.dec
> > b/MdeModulePkg/MdeModulePkg.dec index 7f646d7702..a2130bc439
> > 100644
> > --- a/MdeModulePkg/MdeModulePkg.dec
> > +++ b/MdeModulePkg/MdeModulePkg.dec
> > @@ -422,6 +422,9 @@
> >## Include/Guid/S3SmmInitDone.h
> >gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71,
> > 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } }
> >
> > +  ## Include/Guid/S3StorageDeviceInitList.h
> > +  gS3StorageDeviceInitListGuid = { 0x310e9b8c, 0xcf90, 0x421e, { 0x8e,
> > + 0x9b, 0x9e, 0xef, 0xb6, 0x17, 0xc8, 0xef } }
> > +
> >  [Ppis]
> >## Include/Ppi/AtaController.h
> >gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 
> > 0x7a,
> > 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
> > diff --git a/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
> > b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
> > new file mode 100644
> > index 00..cfbd2a78e7
> > --- /dev/null
> > +++ b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
> > @@ -0,0 +1,36 @@
> > +/** @file
> > +  Define the LockBox GUID for list of storage devices need to be
> > +initialized in
> > +  S3.
> > +
> > +  Copyright (c) 2019, Intel Corporation. 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 __S3_STORAGE_DEVICE_INIT_LIST_H__ #define
> > +__S3_STORAGE_DEVICE_INIT_LIST_H__
> > +
> > +#define S3_STORAGE_DEVICE_INIT_LIST \
> > +  { \
> > +0x310e9b8c, 0xcf90, 0x421e, { 0x8e, 0x9b, 0x9e, 0xef, 0xb6, 0x17,
> > +0xc8, 0xef } \
> > +  }
> > +
> > +//
> > +// The LockBox will store a DevicePath structure that contains zero or
> > +more // DevicePath instances. Each instance denotes a storage device
> > +that needs to // get initialized during the S3 resume.
> 
> Can you have some pseudo code to describe the structure?

Yes, I will try to draw an illustration (or an example) for the data to be
stored in this LockBox.

Best Regards,
Hao Wu

> 
> > +//
> > +// The attribute of the LockBox should be set to //
> > +'LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY'.
> > +//
> > +extern EFI_GUID  gS3StorageDeviceInitListGuid;
> > +
> > +#endif  // __S3_STORAGE_DEVICE_INIT_LIST_H__
> > --
> > 2.12.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org

Re: [edk2] [PATCH v2 02/12] MdeModulePkg: Add definitions for EDKII PEI ATA PassThru PPI

2019-01-30 Thread Wu, Hao A
> -Original Message-
> From: Ni, Ray
> Sent: Thursday, January 31, 2019 11:23 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Wang, Jian J; Dong, Eric
> Subject: RE: [PATCH v2 02/12] MdeModulePkg: Add definitions for EDKII PEI
> ATA PassThru PPI
> 
> Hao,
> You could re-use the structure definition in AtaPassThru protocol.
> For example: EFI_ATA_PASS_THRU_MODE v.s.
> EDKII_PEI_ATA_PASS_THRU_MODE
> I see more duplicated structure definitions. We can avoid them.

Got it.
I will refine this patch in the next series.

Best Regards,
Hao Wu

> 
> Thanks,
> Ray
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Thursday, January 31, 2019 10:49 AM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A ; Wang, Jian J ;
> > Ni, Ray ; Dong, Eric 
> > Subject: [PATCH v2 02/12] MdeModulePkg: Add definitions for EDKII PEI ATA
> > PassThru PPI
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> >
> > This commit will add the definitions for EDKII PEI ATA PassThru PPI. This 
> > PPI
> > will provide services that allow ATA commands to be sent to ATA devices
> > attached to an ATA controller in the PEI phase.
> >
> > More specifically, the PPI will provide services to:
> >
> > * Send ATA commands to an ATA device (by service 'PassThru');
> > * Get the list of the attached ATA device on a controller (by services
> >   'GetNextPort' and 'GetNextDevice');
> > * Get the identification information (DevicePath) of the underlying ATA
> >   host controller (by service 'GetDevicePath').
> >
> > Cc: Jian J Wang 
> > Cc: Ruiyu Ni 
> > Cc: Eric Dong 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  MdeModulePkg/MdeModulePkg.dec  |   3 +
> >  MdeModulePkg/Include/Ppi/AtaPassThru.h | 359 
> >  2 files changed, 362 insertions(+)
> >
> > diff --git a/MdeModulePkg/MdeModulePkg.dec
> > b/MdeModulePkg/MdeModulePkg.dec index 4411185073..8efb19e626
> > 100644
> > --- a/MdeModulePkg/MdeModulePkg.dec
> > +++ b/MdeModulePkg/MdeModulePkg.dec
> > @@ -483,6 +483,9 @@
> >## Include/Ppi/AtaAhciController.h
> >gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0,
> > { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
> >
> > +  ## Include/Ppi/AtaPassThru.h
> > +  gEdkiiPeiAtaPassThruPpiGuid   = { 0xa16473fd, 0xd474, 0x4c89,
> { 0xae,
> > 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
> > +
> >  [Protocols]
> >## Load File protocol provides capability to load and unload EFI image 
> > into
> > memory and execute it.
> >#  Include/Protocol/LoadPe32Image.h
> > diff --git a/MdeModulePkg/Include/Ppi/AtaPassThru.h
> > b/MdeModulePkg/Include/Ppi/AtaPassThru.h
> > new file mode 100644
> > index 00..9281f0b833
> > --- /dev/null
> > +++ b/MdeModulePkg/Include/Ppi/AtaPassThru.h
> > @@ -0,0 +1,359 @@
> > +/** @file
> > +
> > +  Copyright (c) 2019, Intel Corporation. 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 _EDKII_ATA_PASS_THRU_PPI_H_
> > +#define _EDKII_ATA_PASS_THRU_PPI_H_
> > +
> > +#include 
> > +
> > +///
> > +/// Global ID for the EDKII_PEI_ATA_PASS_THRU_PPI.
> > +///
> > +#define EDKII_PEI_ATA_PASS_THRU_PPI_GUID \
> > +  { \
> > +0xa16473fd, 0xd474, 0x4c89, { 0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73,
> > +0x86, 0x9 } \
> > +  }
> > +
> > +//
> > +// Forward declaration for the EDKII_PEI_ATA_PASS_THRU_PPI.
> > +//
> > +typedef struct _EDKII_PEI_ATA_PASS_THRU_PPI
> > +EDKII_PEI_ATA_PASS_THRU_PPI;
> > +
> > +//
> > +// Revision The revision to which the ATA Pass Thru PPI interface adheres.
> > +//  All future revisions must be backwards compatible.
> > +//  If a future version is not back wards compatible it is not the 
> > same
> > GUID.
> > +//
> > +#define EDKII_PEI_ATA_PASS_THRU_PPI_REVISION 0x0001
> > +
> > +typedef struct {
> > +  UINT32Attributes;
> > +  UINT32IoAlign;
> > +} EDKII_PEI_ATA_PASS_THRU_MODE;
> > +
> > +///
> > +/// If this bit is set, then the EDKII_PEI_ATA_PASS_THRU_PPI interface
> > +is for /// physical devices on the ATA controller.
> > +///
> > +#define EDKII_PEI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL  0x0001
> > +///
> > +/// If this bit is set, then the EDKII_PEI_ATA_PASS_THRU_PPI interface
> > +is for /// logical devices on the ATA controller.
> > +///
> > +#define EDKII_PEI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL   0x0002
> > +
> > +typedef struct {
> > +  UINT8Reserved1[2];
> > +  UINT8AtaStatus;
> > +  UINT8AtaError;
> > +  UINT8

Re: [edk2] [Patch] BaseTools: Fixed incorrect line number in PcdValueInit.c

2019-01-30 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Feng, Bob C
> Sent: Wednesday, January 30, 2019 5:13 PM
> To: edk2-devel@lists.01.org
> Cc: Feng, Bob C ; Gao, Liming 
> Subject: [Patch] BaseTools: Fixed incorrect line number in PcdValueInit.c
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1435
> This patch is going to fix the issue of incorrect line
> number in PcdValueInit.c
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng 
> Cc: Liming Gao 
> ---
>  BaseTools/Source/Python/Workspace/MetaFileTable.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py 
> b/BaseTools/Source/Python/Workspace/MetaFileTable.py
> index 823a87e057..8832fc0a8f 100644
> --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
> +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
> @@ -391,11 +391,11 @@ class PlatformTable(MetaFileTable):
>  else:
>  result = [item for item in result if item[8] < 0]
>  if FromItem is not None:
>  result = [item for item in result if item[9] == FromItem]
> 
> -result = [ [r[2],r[3],r[4],r[5],r[6],r[7],r[0],r[9]] for r in result 
> ]
> +result = [ [r[2],r[3],r[4],r[5],r[6],r[7],r[0],r[10]] for r in 
> result ]
>  return result
> 
>  def DisableComponent(self,comp_id):
>  for item in self.CurrentContent:
>  if item[0] == comp_id or item[8] == comp_id:
> --
> 2.20.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 3/3] IntelSiliconPkg\Include\IndustryStandard: Update IGD_OPREGION_MBOX3 Structure

2019-01-30 Thread Digant H Solanki
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1454
Based on latest IGD OpRegion Spec, IGD_OPREGION_MBOX3 needs to be updated with 
two new members : Physical Address of Raw VBT Data (RVDA) and Size of Raw VBT 
Data (RVDS)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Digant H Solanki 
Cc: Liming Gao 
Cc: Rangasai V Chaganty 
Cc: Ray Ni 
---
 IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h 
b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
index 5ce80a5be8..1c83efee40 100644
--- a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
+++ b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
@@ -4,9 +4,7 @@
 
   https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
 
-  @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to 0x46(70)
-
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2019, Intel Corporation. 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
@@ -118,7 +116,9 @@ typedef struct {
   UINT64 FDSS;  ///< Offset 0x3AA DSS Buffer address allocated for 
IFFS feature
   UINT32 FDSP;  ///< Offset 0x3B2 Size of DSS buffer
   UINT32 STAT;  ///< Offset 0x3B6 State Indicator
-  UINT8  RM31[0x46];///< Offset 0x3BA - 0x3FF  Reserved Must be zero. Bug 
in spec 0x45(69)
+  UINT64 RVDA;  ///< Offset 0x3BA Physical address of Raw VBT data. 
Added from Spec Version 0.90 to support VBT greater than 6KB.
+  UINT32 RVDS;  ///< Offset 0x3C2 Size of Raw VBT data. Added from 
Spec Version 0.90 to support VBT greater than 6KB.
+  UINT8  RM31[0x3A];///< Offset 0x3C6 - 0x3FF  Reserved Must be zero.
 } IGD_OPREGION_MBOX3;
 
 ///
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 2/2] IntelSiliconPkg\Include\IndustryStandard: Update IGD_OPREGION_MBOX3 Structure

2019-01-30 Thread Digant H Solanki
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1454
Based on latest IGD OpRegion Spec, IGD_OPREGION_MBOX3 needs to be updated with 
two new members : Physical Address of Raw VBT Data (RVDA) and Size of Raw VBT 
Data (RVDS)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Digant H Solanki 
Cc: Liming Gao 
Cc: Chaganty, Rangasai V 
Cc: Ni, Ray 
---
 IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h 
b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
index 5ce80a5be8..1c83efee40 100644
--- a/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
+++ b/IntelSiliconPkg/Include/IndustryStandard/IgdOpRegion.h
@@ -4,9 +4,7 @@
 
   https://01.org/sites/default/files/documentation/skl_opregion_rev0p5.pdf
 
-  @note Fixed bug in the spec Mailbox3 - RM31 size from 0x45(69) to 0x46(70)
-
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2019, Intel Corporation. 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
@@ -118,7 +116,9 @@ typedef struct {
   UINT64 FDSS;  ///< Offset 0x3AA DSS Buffer address allocated for 
IFFS feature
   UINT32 FDSP;  ///< Offset 0x3B2 Size of DSS buffer
   UINT32 STAT;  ///< Offset 0x3B6 State Indicator
-  UINT8  RM31[0x46];///< Offset 0x3BA - 0x3FF  Reserved Must be zero. Bug 
in spec 0x45(69)
+  UINT64 RVDA;  ///< Offset 0x3BA Physical address of Raw VBT data. 
Added from Spec Version 0.90 to support VBT greater than 6KB.
+  UINT32 RVDS;  ///< Offset 0x3C2 Size of Raw VBT data. Added from 
Spec Version 0.90 to support VBT greater than 6KB.
+  UINT8  RM31[0x3A];///< Offset 0x3C6 - 0x3FF  Reserved Must be zero.
 } IGD_OPREGION_MBOX3;
 
 ///
-- 
2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox

2019-01-30 Thread Ni, Ray



> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray ; Dong, Eric 
> Subject: [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume
> S3StorageDeviceInitList LockBox
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> 
> For the NvmExpressPei driver, this commit will update the driver to consume
> the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to perform
> an on-demand (partial) NVM Express device enumeration/initialization to
> benefit the S3 resume performance.
> 
> Cc: Jian J Wang 
> Cc: Ray Ni 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf |   8 +-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h   |  16 +++
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c   |  20 
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 106
> 
>  4 files changed, 149 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> index 0666e5892b..22b703e971 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> @@ -40,6 +40,7 @@
>NvmExpressPeiHci.h
>NvmExpressPeiPassThru.c
>NvmExpressPeiPassThru.h
> +  NvmExpressPeiS3.c
>NvmExpressPeiStorageSecurity.c
>NvmExpressPeiStorageSecurity.h
> 
> @@ -54,6 +55,7 @@
>BaseMemoryLib
>IoLib
>TimerLib
> +  LockBoxLib
>PeimEntryPoint
> 
>  [Ppis]
> @@ -64,9 +66,13 @@
>gEfiPeiVirtualBlockIo2PpiGuid  ## SOMETIMES_PRODUCES
>gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES
> 
> +[Guids]
> +  gS3StorageDeviceInitListGuid   ## SOMETIMES_CONSUMES ##
> UNDEFINED
> +
>  [Depex]
>gEfiPeiMemoryDiscoveredPpiGuid AND
> -  gEdkiiPeiNvmExpressHostControllerPpiGuid
> +  gEdkiiPeiNvmExpressHostControllerPpiGuid AND
> + gEfiPeiMasterBootModePpiGuid
> 
>  [UserExtensions.TianoCore."ExtraFiles"]
>NvmExpressPeiExtra.uni
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> index 7047c4f3ff..6f01413e6d 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> @@ -332,4 +332,20 @@ NvmeBuildDevicePath (
>OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath
>);
> 
> +/**
> +  Determine if a specific NVM Express controller can be skipped for S3 phase.
> +
> +  @param[in]  HcDevicePath  Device path of the controller.
> +  @param[in]  HcDevicePathLengthLength of the device path specified by
> +HcDevicePath.
> +
> +  @retvalThe number of ports that need to be enumerated.
> +
> +**/
> +BOOLEAN
> +NvmeS3SkipThisController (
> +  IN  EFI_DEVICE_PATH_PROTOCOL*HcDevicePath,
> +  IN  UINTN   HcDevicePathLength
> +  );
> +
>  #endif
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> index 96622e6fd5..43b2dfc3e7 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
> @@ -213,6 +213,7 @@ NvmExpressPeimEntry (
>)
>  {
>EFI_STATUS   Status;
> +  EFI_BOOT_MODEBootMode;
>EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI*NvmeHcPpi;
>UINT8Controller;
>UINTNMmioBase;
> @@ -224,6 +225,15 @@ NvmExpressPeimEntry (
>DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__));
> 
>//
> +  // Get the current boot mode.
> +  //
> +  Status = PeiServicesGetBootMode ();  if (EFI_ERROR (Status))
> + {
> +DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n",
> __FUNCTION__));
> +return Status;
> +  }
> +
> +  //
>// Locate the NVME host controller PPI
>//
>Status = PeiServicesLocatePpi (
> @@ -279,6 +289,16 @@ NvmExpressPeimEntry (
>continue;
>  }
> 
> +if ((BootMode == BOOT_ON_S3_RESUME) &&
> +(NvmeS3SkipThisController (DevicePath, DevicePathLength))) {
> +  DEBUG ((
> +DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n",
> +__FUNCTION__, Controller
> +));
> +  Controller++;
> +  continue;
> +}
> +
>  //
>  // Memory allocation for controller private data
>  //
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c
> new file mode 100644
> index 00..afcf5f6c0a
> --- /dev/null
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c
> @@ -0,0 +1,106 @@
> +/** @file
> +  The NvmExpressPei driver 

Re: [edk2] [PATCH v4 0/4] Introduce CapsuleApp patch v4

2019-01-30 Thread Chen, Chen A
Hi Jian.

The interface CharToUpper() is used to convert just one character, But the 
UpperCaseString is used to convert a string.

I think it's no need to call CharToUpper repeatedly in UpperCaseString function 
to convert a string.

Regards,
Chen

-Original Message-
From: Wang, Jian J 
Sent: Thursday, January 31, 2019 10:48 AM
To: Chen, Chen A ; edk2-devel@lists.01.org
Subject: RE: [edk2] [PATCH v4 0/4] Introduce CapsuleApp patch v4

Chen,

I just noticed that there's another patch series in which a new interface 
CharToUpper() is introduced in BaseLib which can be used to replace your local 
equivalent one UpperCaseString(). I would suggest to hold your patch for a 
while and use the new interface instead once that patch series is pushed. Sorry 
for the late remind.

Regards,
Jian

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Chen A Chen
> Sent: Thursday, January 31, 2019 10:34 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH v4 0/4] Introduce CapsuleApp patch v4
> 
> No functionality change.
> Fix ECC and code style issue.
> Already pass CR process.
> https://git-amr-7.devtools.intel.com/gerrit/#/c/39023/
> 
> Chen A Chen (4):
>   MdePkg/UefiSpec.h: Add definition to support Capsule-on-Disk feature
>   MdeModulePkg/CapsuleApp: Add a function used to get next DevicePath
>   MdeModulePkg/CapsuleApp: Add functions to support Capsule-on-Disk
>   MdeModulePkg/CapsuleApp: Enhance CapsuleApp to support 
> Capsule-on-Disk
> 
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 160 +++-
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   8 +
>  MdeModulePkg/Application/CapsuleApp/CapsuleDump.c  | 538
> +-
>  .../Application/CapsuleApp/CapsuleOnDisk.c | 808
> +
>  MdeModulePkg/Include/Library/UefiBootManagerLib.h  |  21 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |  24 +-
>  MdeModulePkg/MdeModulePkg.dsc  |   1 +
>  MdePkg/Include/Uefi/UefiSpec.h |   5 +
>  8 files changed, 1546 insertions(+), 19 deletions(-)  create mode 
> 100644 MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
> 
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc info is invalid

2019-01-30 Thread Gao, Liming
Push at a824c7ebde0a431413329049252b8c1d3770de82

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Gao, 
> Liming
> Sent: Thursday, January 31, 2019 11:31 AM
> To: Bi, Dandan ; Hsueh, Hong-chihX 
> ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Laszlo Ersek 
> 
> Subject: Re: [edk2] [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if 
> reloc info is invalid
> 
> Reviewed-by: Liming Gao 
> 
> > -Original Message-
> > From: Bi, Dandan
> > Sent: Thursday, January 31, 2019 8:27 AM
> > To: Hsueh, Hong-chihX ; edk2-devel@lists.01.org
> > Cc: Kinney, Michael D ; Gao, Liming 
> > ; Laszlo Ersek 
> > Subject: RE: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc 
> > info is invalid
> >
> > Reviewed-by: Bi Dandan 
> >
> > Thanks,
> > Dandan
> > > -Original Message-
> > > From: Hsueh, Hong-chihX
> > > Sent: Wednesday, January 30, 2019 9:20 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Kinney, Michael D ; Gao, Liming
> > > ; Bi, Dandan ; Laszlo Ersek
> > > 
> > > Subject: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc 
> > > info
> > > is invalid
> > >
> > > Skip runtime relocation for PE images that provide invalid relocation
> > > infomation (ex: RelocDir->Size = 0) to fix a hang observed while booting
> > > Windows.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Neo Hsueh 
> > > Cc: Michael D Kinney 
> > > Cc: Liming Gao 
> > > Cc: Dandan Bi 
> > > Cc: Laszlo Ersek 
> > > ---
> > >  MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 30
> > > --
> > >  1 file changed, 20 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > > index 1bd079ad6a..e2c62e1932 100644
> > > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > > @@ -1002,7 +1002,7 @@ PeCoffLoaderRelocateImage (
> > >   
> > >RelocDir->VirtualAddress + RelocDir-
> > > >Size - 1,
> > >   
> > >TeStrippedOffset
> > >   
> > >);
> > > -if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd <
> > > RelocBase) {
> > > +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN)
> > > + RelocBaseEnd < (UINTN) RelocBase) {
> > >ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
> > >return RETURN_LOAD_ERROR;
> > >  }
> > > @@ -1022,7 +1022,7 @@ PeCoffLoaderRelocateImage (
> > >  // Run the relocation information and apply the fixups
> > >  //
> > >  FixupData = ImageContext->FixupData;
> > > -while (RelocBase < RelocBaseEnd) {
> > > +while ((UINTN) RelocBase < (UINTN) RelocBaseEnd) {
> > >
> > >Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof
> > > (EFI_IMAGE_BASE_RELOCATION));
> > >//
> > > @@ -1051,7 +1051,7 @@ PeCoffLoaderRelocateImage (
> > >//
> > >// Run this relocation record
> > >//
> > > -  while (Reloc < RelocEnd) {
> > > +  while ((UINTN) Reloc < (UINTN) RelocEnd) {
> > >  Fixup = PeCoffLoaderImageAddress (ImageContext, RelocBase-
> > > >VirtualAddress + (*Reloc & 0xFFF), TeStrippedOffset);
> > >  if (Fixup == NULL) {
> > >ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
> > > @@ -1739,13 +1739,23 @@ PeCoffLoaderRelocateImageForRuntime (
> > >// is present in the image. You have to check the NumberOfRvaAndSizes 
> > > in
> > >// the optional header to verify a desired directory entry is there.
> > >//
> > > +  RelocBase = NULL;
> > > +  RelocBaseEnd = NULL;
> > >if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
> > >  RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
> > > -RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
> > > PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
> > > -RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
> > > PeCoffLoaderImageAddress (,
> > > - 
> > >RelocDir->VirtualAddress + RelocDir-
> > > >Size - 1,
> > > - 
> > >0
> > > - 
> > >);
> > > +if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
> > > +  RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
> > > PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
> > > +  RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
> > > PeCoffLoaderImageAddress (,
> > > + 
> > >  RelocDir->VirtualAddress + RelocDir-
> > > >Size - 1,

Re: [edk2] [PATCH v2 06/12] MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI

2019-01-30 Thread Ni, Ray



> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray ; Dong, Eric 
> Subject: [PATCH v2 06/12] MdeModulePkg/NvmExpressPei: Add logic to
> produce SSC PPI
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> 
> For the NvmExpressPei driver, this commit will add codes to produce the
> Storage Security Command PPI if the underlying NVM Express controller
> supports the Security Send and Security Receive commands.
> 
> Cc: Jian J Wang 
> Cc: Ray Ni 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf  |  10 +-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h|  81
> +++-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h |  20 +-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h
> | 247 
>  MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c   | 317
> +++
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c| 143
> +--
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c |  32 +-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.c
> | 423 
>  8 files changed, 1184 insertions(+), 89 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> index 9591572fec..0666e5892b 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
> @@ -2,7 +2,7 @@
>  #  The NvmExpressPei driver is used to manage non-volatile memory
> subsystem
>  #  which follows NVM Express specification at PEI phase.
>  #
> -#  Copyright (c) 2018, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the
> BSD License
> @@ -30,6 +30,7 @@
>  #
> 
>  [Sources]
> +  DevicePath.c
>DmaMem.c
>NvmExpressPei.c
>NvmExpressPei.h
> @@ -39,6 +40,8 @@
>NvmExpressPeiHci.h
>NvmExpressPeiPassThru.c
>NvmExpressPeiPassThru.h
> +  NvmExpressPeiStorageSecurity.c
> +  NvmExpressPeiStorageSecurity.h
> 
>  [Packages]
>MdePkg/MdePkg.dec
> @@ -54,11 +57,12 @@
>PeimEntryPoint
> 
>  [Ppis]
> -  gEfiPeiVirtualBlockIoPpiGuid   ## PRODUCES
> -  gEfiPeiVirtualBlockIo2PpiGuid  ## PRODUCES
>gEdkiiPeiNvmExpressHostControllerPpiGuid   ## CONSUMES
>gEdkiiIoMmuPpiGuid ## CONSUMES
>gEfiEndOfPeiSignalPpiGuid  ## CONSUMES
> +  gEfiPeiVirtualBlockIoPpiGuid   ## SOMETIMES_PRODUCES
> +  gEfiPeiVirtualBlockIo2PpiGuid  ## SOMETIMES_PRODUCES
> +  gEdkiiPeiStorageSecurityCommandPpiGuid ##
> SOMETIMES_PRODUCES
> 
>  [Depex]
>gEfiPeiMemoryDiscoveredPpiGuid AND
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> index 0135eca6f0..7047c4f3ff 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> 
> @@ -44,6 +45,7 @@ typedef struct
> _PEI_NVME_CONTROLLER_PRIVATE_DATA
> PEI_NVME_CONTROLLER_PRIVATE_DA
>  #include "NvmExpressPeiHci.h"
>  #include "NvmExpressPeiPassThru.h"
>  #include "NvmExpressPeiBlockIo.h"
> +#include "NvmExpressPeiStorageSecurity.h"
> 
>  //
>  // NVME PEI driver implementation related definitions
> @@ -90,10 +92,15 @@ struct _PEI_NVME_NAMESPACE_INFO {
>  struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
>UINT32Signature;
>UINTN MmioBase;
> +  UINTN DevicePathLength;
> +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> +
>EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
>EFI_PEI_RECOVERY_BLOCK_IO2_PPIBlkIo2Ppi;
> +  EDKII_PEI_STORAGE_SECURITY_CMD_PPIStorageSecurityPpi;
>EFI_PEI_PPI_DESCRIPTORBlkIoPpiList;
>EFI_PEI_PPI_DESCRIPTORBlkIo2PpiList;
> +  EFI_PEI_PPI_DESCRIPTORStorageSecurityPpiList;
>EFI_PEI_NOTIFY_DESCRIPTOR EndOfPeiNotifyList;
> 
>//
> @@ -139,11 +146,13 @@ struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
>PEI_NVME_NAMESPACE_INFO   *NamespaceInfo;
>  };
> 
> -#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a) \
> +#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a)
> \
>CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, BlkIoPpi,
> 

Re: [edk2] [PATCH v2 05/12] MdeModulePkg/NvmExpressPei: Avoid updating the module-level variable

2019-01-30 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray 
> Subject: [PATCH v2 05/12] MdeModulePkg/NvmExpressPei: Avoid updating
> the module-level variable
> 
> This commit is out of the scope for BZ-1409. The commit will remove the call
> of RegisterForShadow() at the entry point of the driver. By doing so, the
> driver is now possible to be executed without being re-loaded into
> permanent memory.
> 
> Thus, this commit will update the NvmExpressPei driver to avoid updating
> the content of a global variable.
> 
> Cc: Jian J Wang 
> Cc: Ray Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h |  12 +-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c| 153
> +++-
>  MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c |  11 +-
>  3 files changed, 92 insertions(+), 84 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> index 0bd62c2459..0135eca6f0 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
> @@ -2,7 +2,7 @@
>The NvmExpressPei driver is used to manage non-volatile memory
> subsystem
>which follows NVM Express specification at PEI phase.
> 
> -  Copyright (c) 2018, Intel Corporation. All rights reserved.
> +  Copyright (c) 2018 - 2019, Intel Corporation. All rights
> + reserved.
> 
>This program and the accompanying materials
>are licensed and made available under the terms and conditions @@ -
> 147,13 +147,9 @@ struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
>CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, EndOfPeiNotifyList,
> NVME_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
> 
> 
> -/**
> -  Initialize IOMMU.
> -**/
> -VOID
> -IoMmuInit (
> -  VOID
> -  );
> +//
> +// Internal functions
> +//
> 
>  /**
>Allocates pages that are suitable for an OperationBusMasterCommonBuffer
> or diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
> b/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
> index 51b48d38dd..cb629c16b0 100644
> --- a/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
> +++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
> @@ -1,7 +1,7 @@
>  /** @file
>The DMA memory help function.
> 
> -  Copyright (c) 2018, Intel Corporation. All rights reserved.
> +  Copyright (c) 2018 - 2019, Intel Corporation. All rights
> + reserved.
> 
>This program and the accompanying materials
>are licensed and made available under the terms and conditions @@ -16,7
> +16,33 @@
> 
>  #include "NvmExpressPei.h"
> 
> -EDKII_IOMMU_PPI  *mIoMmu;
> +/**
> +  Get IOMMU PPI.
> +
> +  @return Pointer to IOMMU PPI.
> +
> +**/
> +EDKII_IOMMU_PPI *
> +GetIoMmu (
> +  VOID
> +  )
> +{
> +  EFI_STATUS Status;
> +  EDKII_IOMMU_PPI*IoMmu;
> +
> +  IoMmu  = NULL;
> +  Status = PeiServicesLocatePpi (
> + ,
> + 0,
> + NULL,
> + (VOID **) 
> + );
> +  if (!EFI_ERROR (Status) && (IoMmu != NULL)) {
> +return IoMmu;
> +  }
> +
> +  return NULL;
> +}
> 
>  /**
>Provides the controller-specific addresses required to access system
> memory from a @@ -46,18 +72,21 @@ IoMmuMap (
>OUT VOID  **Mapping
>)
>  {
> -  EFI_STATUS  Status;
> -  UINT64  Attribute;
> -
> -  if (mIoMmu != NULL) {
> -Status = mIoMmu->Map (
> -   mIoMmu,
> -   Operation,
> -   HostAddress,
> -   NumberOfBytes,
> -   DeviceAddress,
> -   Mapping
> -   );
> +  EFI_STATUS Status;
> +  UINT64 Attribute;
> +  EDKII_IOMMU_PPI*IoMmu;
> +
> +  IoMmu = GetIoMmu ();
> +
> +  if (IoMmu != NULL) {
> +Status = IoMmu->Map (
> + IoMmu,
> + Operation,
> + HostAddress,
> + NumberOfBytes,
> + DeviceAddress,
> + Mapping
> + );
>  if (EFI_ERROR (Status)) {
>return EFI_OUT_OF_RESOURCES;
>  }
> @@ -78,11 +107,11 @@ IoMmuMap (
>ASSERT(FALSE);
>return EFI_INVALID_PARAMETER;
>  }
> -Status = mIoMmu->SetAttribute (
> -   mIoMmu,
> -   *Mapping,
> -   Attribute
> -   );
> +Status = IoMmu->SetAttribute (
> +  IoMmu,
> +  *Mapping,
> +  Attribute
> +  );
>  if (EFI_ERROR (Status)) {
>return Status;
>  }
> @@ -108,11 +137,14 @@ IoMmuUnmap (
>IN VOID  *Mapping
>)
>  {
> -  EFI_STATUS  Status;
> +  EFI_STATUS Status;
> +  

Re: [edk2] [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc info is invalid

2019-01-30 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Bi, Dandan
> Sent: Thursday, January 31, 2019 8:27 AM
> To: Hsueh, Hong-chihX ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming 
> ; Laszlo Ersek 
> Subject: RE: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc 
> info is invalid
> 
> Reviewed-by: Bi Dandan 
> 
> Thanks,
> Dandan
> > -Original Message-
> > From: Hsueh, Hong-chihX
> > Sent: Wednesday, January 30, 2019 9:20 AM
> > To: edk2-devel@lists.01.org
> > Cc: Kinney, Michael D ; Gao, Liming
> > ; Bi, Dandan ; Laszlo Ersek
> > 
> > Subject: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc info
> > is invalid
> >
> > Skip runtime relocation for PE images that provide invalid relocation
> > infomation (ex: RelocDir->Size = 0) to fix a hang observed while booting
> > Windows.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Neo Hsueh 
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Dandan Bi 
> > Cc: Laszlo Ersek 
> > ---
> >  MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 30
> > --
> >  1 file changed, 20 insertions(+), 10 deletions(-)
> >
> > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > index 1bd079ad6a..e2c62e1932 100644
> > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > @@ -1002,7 +1002,7 @@ PeCoffLoaderRelocateImage (
> > 
> >  RelocDir->VirtualAddress + RelocDir-
> > >Size - 1,
> > 
> >  TeStrippedOffset
> > 
> >  );
> > -if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd <
> > RelocBase) {
> > +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN)
> > + RelocBaseEnd < (UINTN) RelocBase) {
> >ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
> >return RETURN_LOAD_ERROR;
> >  }
> > @@ -1022,7 +1022,7 @@ PeCoffLoaderRelocateImage (
> >  // Run the relocation information and apply the fixups
> >  //
> >  FixupData = ImageContext->FixupData;
> > -while (RelocBase < RelocBaseEnd) {
> > +while ((UINTN) RelocBase < (UINTN) RelocBaseEnd) {
> >
> >Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof
> > (EFI_IMAGE_BASE_RELOCATION));
> >//
> > @@ -1051,7 +1051,7 @@ PeCoffLoaderRelocateImage (
> >//
> >// Run this relocation record
> >//
> > -  while (Reloc < RelocEnd) {
> > +  while ((UINTN) Reloc < (UINTN) RelocEnd) {
> >  Fixup = PeCoffLoaderImageAddress (ImageContext, RelocBase-
> > >VirtualAddress + (*Reloc & 0xFFF), TeStrippedOffset);
> >  if (Fixup == NULL) {
> >ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
> > @@ -1739,13 +1739,23 @@ PeCoffLoaderRelocateImageForRuntime (
> >// is present in the image. You have to check the NumberOfRvaAndSizes in
> >// the optional header to verify a desired directory entry is there.
> >//
> > +  RelocBase = NULL;
> > +  RelocBaseEnd = NULL;
> >if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
> >  RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
> > -RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
> > PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
> > -RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
> > PeCoffLoaderImageAddress (,
> > -   
> >  RelocDir->VirtualAddress + RelocDir-
> > >Size - 1,
> > -   
> >  0
> > -   
> >  );
> > +if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
> > +  RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
> > PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
> > +  RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
> > PeCoffLoaderImageAddress (,
> > +   
> >RelocDir->VirtualAddress + RelocDir-
> > >Size - 1,
> > +   
> >0
> > +   
> >);
> > +}
> > +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN) RelocBaseEnd
> > < (UINTN) RelocBase) {
> > +  //
> > +  // relocation block is not valid, just return
> > +  //
> > +  return;
> > +}
> >} else {
> >  //
> >  // Cannot find relocations, cannot continue to relocate the image, 
> > ASSERT
> > for this invalid image.
> > @@ -1769,7 +1779,7 @@ PeCoffLoaderRelocateImageForRuntime (
> >  //
> >  FixupData = 

Re: [edk2] [PATCH v2 03/12] MdeModulePkg: Add definitions for Storage Security Command PPI

2019-01-30 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray ; Dong, Eric 
> Subject: [PATCH v2 03/12] MdeModulePkg: Add definitions for Storage
> Security Command PPI
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> 
> This commit will add the definitions for Storage Security Command (SSC) PPI.
> This PPI will be be used to abstract mass storage devices to allow code
> running in the PEI phase to send security protocol commands to mass storage
> devices without specific knowledge of the type of device or controller that
> manages the device.
> 
> More specifically, the PPI will provide services to:
> 
> * Get the number of mass storage devices managed by a instance of the SSC
>   PPI (by service 'GetNumberofDevices');
> * Get the identification information (DevicePath) of a managing mass
>   storage devices (by service 'GetDevicePath');
> * Send security protocol commands to mass storage devices (by services
>   'ReceiveData' and 'SendData').
> 
> Cc: Jian J Wang 
> Cc: Ray Ni 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/MdeModulePkg.dec |   3 +
>  MdeModulePkg/Include/Ppi/StorageSecurityCommand.h | 283
> 
>  2 files changed, 286 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 8efb19e626..7f646d7702
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -483,6 +483,9 @@
>## Include/Ppi/AtaAhciController.h
>gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0,
> { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
> 
> +  ## Include/Ppi/StorageSecurityCommand.h
> +  gEdkiiPeiStorageSecurityCommandPpiGuid= { 0x35de0b4e, 0x30fb,
> 0x46c3, { 0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58, 0xbb, 0x56 } }
> +
>## Include/Ppi/AtaPassThru.h
>gEdkiiPeiAtaPassThruPpiGuid   = { 0xa16473fd, 0xd474, 0x4c89, 
> { 0xae,
> 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
> 
> diff --git a/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h
> b/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h
> new file mode 100644
> index 00..cc1688dabb
> --- /dev/null
> +++ b/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h
> @@ -0,0 +1,283 @@
> +/** @file
> +
> +  Copyright (c) 2019, Intel Corporation. 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 _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_
> +#define _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_
> +
> +#include 
> +
> +///
> +/// Global ID for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI.
> +///
> +#define EDKII_PEI_STORAGE_SECURITY_CMD_PPI_GUID \
> +  { \
> +0x35de0b4e, 0x30fb, 0x46c3, { 0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58,
> +0xbb, 0x56 } \
> +  }
> +
> +//
> +// Forward declaration for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI.
> +//
> +typedef struct _EDKII_PEI_STORAGE_SECURITY_CMD_PPI
> +EDKII_PEI_STORAGE_SECURITY_CMD_PPI;
> +
> +//
> +// Revision The revision to which the Storage Security Command interface
> adheres.
> +//  All future revisions must be backwards compatible.
> +//  If a future version is not back wards compatible it is not the 
> same
> GUID.
> +//
> +#define EDKII_STORAGE_SECURITY_PPI_REVISION  0x0001
> +
> +
> +/**
> +  Gets the count of storage security devices that one specific driver 
> detects.
> +
> +  @param[in]  This   The PPI instance pointer.
> +  @param[out] NumberofDevicesThe number of storage security devices
> discovered.
> +
> +  @retval EFI_SUCCESS  The operation performed successfully.
> +  @retval EFI_INVALID_PARAMETERThe parameters are invalid.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_PEI_STORAGE_SECURITY_GET_NUMBER_DEVICES) (
> +  IN  EDKII_PEI_STORAGE_SECURITY_CMD_PPI*This,
> +  OUT UINTN *NumberofDevices
> +  );
> +
> +/**
> +  Gets the device path of a specific storage security device.
> +
> +  @param[in]  This The PPI instance pointer.
> +  @param[in]  DeviceIndex  Specifies the storage security device to
> which
> +   the function wants to talk. Because the 
> driver
> +   that implements Storage Security Command 
> PPIs
> +   will manage multiple storage devices, the 
> PPIs
> +   that 

Re: [edk2] [PATCH v2 04/12] MdeModulePkg: Add GUID for LockBox to save storage dev to init in S3

2019-01-30 Thread Ni, Ray



> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray ; Dong, Eric 
> Subject: [PATCH v2 04/12] MdeModulePkg: Add GUID for LockBox to save
> storage dev to init in S3
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> 
> This commit will add the GUID definitions for LockBox which is used to save a
> list of storage devices that need to get initialized during the S3 resume.
> 
> The content of the LockBox will be a DevicePath structure that contains zero
> or more DevicePath instances. Each instance denotes a storage device that
> needs to get initialized during the S3 resume.
> 
> The producers of the content of this LockBox will be drivers like
> OpalPassword DXE driver. This kind of drivers requires some specific storage
> devices to be initialized during the PEI phase of in S3 resume.
> (For the OpalPasword case, it requires the managing devices to be
> automatically unlocked during the S3 resume).
> 
> The attribute of the LockBox should be set to
> LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY.
> 
> The consumers of the content of this LockBox will be PEI storage device
> controller/bus drivers (e.g. NvmExpressPei) during S3 resume. This kind of
> drivers can use the DevicePath instances stored in the LockBox to get a list 
> of
> devices that need to get initialized. In such way, an on-demand
> (partial) device enumeration/initialization can be performed to benefit the S3
> resume performance.
> 
> Cc: Jian J Wang 
> Cc: Ray Ni 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/MdeModulePkg.dec   |  3 ++
>  MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h | 36
> 
>  2 files changed, 39 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 7f646d7702..a2130bc439
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -422,6 +422,9 @@
>## Include/Guid/S3SmmInitDone.h
>gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71,
> 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } }
> 
> +  ## Include/Guid/S3StorageDeviceInitList.h
> +  gS3StorageDeviceInitListGuid = { 0x310e9b8c, 0xcf90, 0x421e, { 0x8e,
> + 0x9b, 0x9e, 0xef, 0xb6, 0x17, 0xc8, 0xef } }
> +
>  [Ppis]
>## Include/Ppi/AtaController.h
>gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 
> 0x7a,
> 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
> diff --git a/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
> b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
> new file mode 100644
> index 00..cfbd2a78e7
> --- /dev/null
> +++ b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
> @@ -0,0 +1,36 @@
> +/** @file
> +  Define the LockBox GUID for list of storage devices need to be
> +initialized in
> +  S3.
> +
> +  Copyright (c) 2019, Intel Corporation. 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 __S3_STORAGE_DEVICE_INIT_LIST_H__ #define
> +__S3_STORAGE_DEVICE_INIT_LIST_H__
> +
> +#define S3_STORAGE_DEVICE_INIT_LIST \
> +  { \
> +0x310e9b8c, 0xcf90, 0x421e, { 0x8e, 0x9b, 0x9e, 0xef, 0xb6, 0x17,
> +0xc8, 0xef } \
> +  }
> +
> +//
> +// The LockBox will store a DevicePath structure that contains zero or
> +more // DevicePath instances. Each instance denotes a storage device
> +that needs to // get initialized during the S3 resume.

Can you have some pseudo code to describe the structure?

> +//
> +// The attribute of the LockBox should be set to //
> +'LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY'.
> +//
> +extern EFI_GUID  gS3StorageDeviceInitListGuid;
> +
> +#endif  // __S3_STORAGE_DEVICE_INIT_LIST_H__
> --
> 2.12.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 01/12] MdeModulePkg: Add definitions for ATA AHCI host controller PPI

2019-01-30 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray ; Dong, Eric 
> Subject: [PATCH v2 01/12] MdeModulePkg: Add definitions for ATA AHCI
> host controller PPI
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> 
> This commit will add the definitions for ATA AHCI host controller PPI. The
> purpose of the PPI in to provide:
> 
> * MMIO base address
> * Controller identification information (DevicePath)
> 
> for ATA host controllers working under AHCI mode.
> 
> Cc: Jian J Wang 
> Cc: Ray Ni 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/MdeModulePkg.dec|  3 +
>  MdeModulePkg/Include/Ppi/AtaAhciController.h | 89
> 
>  2 files changed, 92 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index e5c32d15ed..4411185073
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -480,6 +480,9 @@
>## Include/Ppi/NvmExpressHostController.h
>gEdkiiPeiNvmExpressHostControllerPpiGuid  = { 0xcae3aa63, 0x676f, 0x4da3,
> { 0xbd, 0x50, 0x6c, 0xc5, 0xed, 0xde, 0x9a, 0xad } }
> 
> +  ## Include/Ppi/AtaAhciController.h
> +  gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0,
> { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
> +
>  [Protocols]
>## Load File protocol provides capability to load and unload EFI image into
> memory and execute it.
>#  Include/Protocol/LoadPe32Image.h
> diff --git a/MdeModulePkg/Include/Ppi/AtaAhciController.h
> b/MdeModulePkg/Include/Ppi/AtaAhciController.h
> new file mode 100644
> index 00..2bdd53ff36
> --- /dev/null
> +++ b/MdeModulePkg/Include/Ppi/AtaAhciController.h
> @@ -0,0 +1,89 @@
> +/** @file
> +
> +  Copyright (c) 2019, Intel Corporation. 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 _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_H_
> +#define _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_H_
> +
> +#include 
> +
> +///
> +/// Global ID for the EDKII_ATA_AHCI_HOST_CONTROLLER_PPI.
> +///
> +#define EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_GUID \
> +  { \
> +0x61dd33ea, 0x421f, 0x4cc0, { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1,
> +0xa2, 0x61 } \
> +  }
> +
> +//
> +// Forward declaration for the EDKII_ATA_AHCI_HOST_CONTROLLER_PPI.
> +//
> +typedef struct _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI
> +EDKII_ATA_AHCI_HOST_CONTROLLER_PPI;
> +
> +/**
> +  Get the MMIO base address of ATA AHCI host controller.
> +
> +  @param[in]  This The PPI instance pointer.
> +  @param[in]  ControllerId The ID of the ATA AHCI host controller.
> +  @param[out] MmioBar  The MMIO base address of the controller.
> +
> +  @retval EFI_SUCCESS  The operation succeeds.
> +  @retval EFI_INVALID_PARAMETERThe parameters are invalid.
> +  @retval EFI_NOT_FOUNDThe specified ATA AHCI host controller not
> found.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_ATA_AHCI_HC_GET_MMIO_BAR) (
> +  IN  EDKII_ATA_AHCI_HOST_CONTROLLER_PPI*This,
> +  IN  UINT8 ControllerId,
> +  OUT UINTN *MmioBar
> +  );
> +
> +/**
> +  Get the device path of ATA AHCI host controller.
> +
> +  @param[in]  This The PPI instance pointer.
> +  @param[in]  ControllerId The ID of the ATA AHCI host controller.
> +  @param[out] DevicePathLength The length of the device path in bytes
> specified
> +   by DevicePath.
> +  @param[out] DevicePath   The device path of ATA AHCI host 
> controller.
> +   This field re-uses EFI Device Path 
> Protocol as
> +   defined by Section 10.2 EFI Device Path 
> Protocol
> +   of UEFI 2.7 Specification.
> +
> +  @retval EFI_SUCCESS  The operation succeeds.
> +  @retval EFI_INVALID_PARAMETERThe parameters are invalid.
> +  @retval EFI_NOT_FOUNDThe specified ATA AHCI host controller not
> found.
> +  @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of
> resources.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_ATA_AHCI_HC_GET_DEVICE_PATH) (
> +  IN  EDKII_ATA_AHCI_HOST_CONTROLLER_PPI*This,
> +  IN  UINT8 ControllerId,
> +  OUT UINTN 

Re: [edk2] [PATCH v2 02/12] MdeModulePkg: Add definitions for EDKII PEI ATA PassThru PPI

2019-01-30 Thread Ni, Ray
Hao,
You could re-use the structure definition in AtaPassThru protocol.
For example: EFI_ATA_PASS_THRU_MODE v.s. EDKII_PEI_ATA_PASS_THRU_MODE
I see more duplicated structure definitions. We can avoid them.

Thanks,
Ray

> -Original Message-
> From: Wu, Hao A 
> Sent: Thursday, January 31, 2019 10:49 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Wang, Jian J ;
> Ni, Ray ; Dong, Eric 
> Subject: [PATCH v2 02/12] MdeModulePkg: Add definitions for EDKII PEI ATA
> PassThru PPI
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409
> 
> This commit will add the definitions for EDKII PEI ATA PassThru PPI. This PPI
> will provide services that allow ATA commands to be sent to ATA devices
> attached to an ATA controller in the PEI phase.
> 
> More specifically, the PPI will provide services to:
> 
> * Send ATA commands to an ATA device (by service 'PassThru');
> * Get the list of the attached ATA device on a controller (by services
>   'GetNextPort' and 'GetNextDevice');
> * Get the identification information (DevicePath) of the underlying ATA
>   host controller (by service 'GetDevicePath').
> 
> Cc: Jian J Wang 
> Cc: Ruiyu Ni 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/MdeModulePkg.dec  |   3 +
>  MdeModulePkg/Include/Ppi/AtaPassThru.h | 359 
>  2 files changed, 362 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 4411185073..8efb19e626
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -483,6 +483,9 @@
>## Include/Ppi/AtaAhciController.h
>gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0,
> { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
> 
> +  ## Include/Ppi/AtaPassThru.h
> +  gEdkiiPeiAtaPassThruPpiGuid   = { 0xa16473fd, 0xd474, 0x4c89, 
> { 0xae,
> 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
> +
>  [Protocols]
>## Load File protocol provides capability to load and unload EFI image into
> memory and execute it.
>#  Include/Protocol/LoadPe32Image.h
> diff --git a/MdeModulePkg/Include/Ppi/AtaPassThru.h
> b/MdeModulePkg/Include/Ppi/AtaPassThru.h
> new file mode 100644
> index 00..9281f0b833
> --- /dev/null
> +++ b/MdeModulePkg/Include/Ppi/AtaPassThru.h
> @@ -0,0 +1,359 @@
> +/** @file
> +
> +  Copyright (c) 2019, Intel Corporation. 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 _EDKII_ATA_PASS_THRU_PPI_H_
> +#define _EDKII_ATA_PASS_THRU_PPI_H_
> +
> +#include 
> +
> +///
> +/// Global ID for the EDKII_PEI_ATA_PASS_THRU_PPI.
> +///
> +#define EDKII_PEI_ATA_PASS_THRU_PPI_GUID \
> +  { \
> +0xa16473fd, 0xd474, 0x4c89, { 0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73,
> +0x86, 0x9 } \
> +  }
> +
> +//
> +// Forward declaration for the EDKII_PEI_ATA_PASS_THRU_PPI.
> +//
> +typedef struct _EDKII_PEI_ATA_PASS_THRU_PPI
> +EDKII_PEI_ATA_PASS_THRU_PPI;
> +
> +//
> +// Revision The revision to which the ATA Pass Thru PPI interface adheres.
> +//  All future revisions must be backwards compatible.
> +//  If a future version is not back wards compatible it is not the 
> same
> GUID.
> +//
> +#define EDKII_PEI_ATA_PASS_THRU_PPI_REVISION 0x0001
> +
> +typedef struct {
> +  UINT32Attributes;
> +  UINT32IoAlign;
> +} EDKII_PEI_ATA_PASS_THRU_MODE;
> +
> +///
> +/// If this bit is set, then the EDKII_PEI_ATA_PASS_THRU_PPI interface
> +is for /// physical devices on the ATA controller.
> +///
> +#define EDKII_PEI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL  0x0001
> +///
> +/// If this bit is set, then the EDKII_PEI_ATA_PASS_THRU_PPI interface
> +is for /// logical devices on the ATA controller.
> +///
> +#define EDKII_PEI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL   0x0002
> +
> +typedef struct {
> +  UINT8Reserved1[2];
> +  UINT8AtaStatus;
> +  UINT8AtaError;
> +  UINT8AtaSectorNumber;
> +  UINT8AtaCylinderLow;
> +  UINT8AtaCylinderHigh;
> +  UINT8AtaDeviceHead;
> +  UINT8AtaSectorNumberExp;
> +  UINT8AtaCylinderLowExp;
> +  UINT8AtaCylinderHighExp;
> +  UINT8Reserved2;
> +  UINT8AtaSectorCount;
> +  UINT8AtaSectorCountExp;
> +  UINT8Reserved3[6];
> +} EDKII_PEI_ATA_STATUS_BLOCK;
> +
> +typedef struct {
> +  UINT8Reserved1[2];
> +  UINT8AtaCommand;
> +  UINT8AtaFeatures;
> +  UINT8AtaSectorNumber;
> +  UINT8AtaCylinderLow;
> +  UINT8AtaCylinderHigh;
> +  UINT8AtaDeviceHead;
> +  UINT8

Re: [edk2] [PATCH v2 0/3] FatPkg/GPT: Introduce GPT patch v3

2019-01-30 Thread Wu, Hao A
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chen
> A Chen
> Sent: Tuesday, January 29, 2019 1:28 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH v2 0/3] FatPkg/GPT: Introduce GPT patch v3
> 
> No function change, fix code style issue.

Thanks for the contribution.
Series has been pushed @8a9301cdd7..0d18f5db32.

Best Regards,
Hao Wu

> 
> Chen A Chen (3):
>   FatPkg: Break down Part.c file.
>   MdePkg/UefiGpt.h: Add new definition for enable GPT support
>   FatPkg: Add GPT check in FatPei to support Capsule-on-Disk feature.
> 
>  FatPkg/FatPei/Eltorito.c  | 239 ++
>  FatPkg/FatPei/FatLitePeim.h   |   3 +-
>  FatPkg/FatPei/FatPei.inf  |   7 +-
>  FatPkg/FatPei/Gpt.c   | 548
> ++
>  FatPkg/FatPei/Mbr.c   | 181 ++
>  FatPkg/FatPei/Part.c  | 434 +++--
>  MdePkg/Include/Uefi/UefiGpt.h |   6 +-
>  7 files changed, 1020 insertions(+), 398 deletions(-)
>  create mode 100644 FatPkg/FatPei/Eltorito.c
>  create mode 100644 FatPkg/FatPei/Gpt.c
>  create mode 100644 FatPkg/FatPei/Mbr.c
> 
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [RFC][PATCH v1] MdeModulePkg/NvmExpressDxe: Report StatusCode for device init failure

2019-01-30 Thread Hao Wu
From: Sean Brogan 

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1408

According to the information of the above BZ-1408 and other platform
owners, NVM Express devices are becoming more likely to be a critical
part during the boot process.

This commit will add the calls to 'REPORT_STATUS_CODE' when there is a
failure happens during the NVM Express controller/device initialization
process.

Cc: Sean Brogan 
Cc: Bret Barkelew 
Cc: Jian J Wang 
Cc: Ray Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf |  3 ++-
 MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h  |  3 ++-
 MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c   | 10 +-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf 
b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
index 38d793645b..4f888c49fb 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
@@ -4,7 +4,7 @@
 #  NvmExpressDxe driver is used to manage non-volatile memory subsystem which 
follows
 #  NVM Express specification.
 #
-#  Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -59,6 +59,7 @@
   UefiBootServicesTableLib
   UefiLib
   PrintLib
+  ReportStatusCodeLib
 
 [Protocols]
   gEfiPciIoProtocolGuid   ## TO_START
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h 
b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
index fe7d37c118..dcc848e930 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
@@ -3,7 +3,7 @@
   NVM Express specification.
 
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-  Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2013 - 2019, Intel Corporation. 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
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 typedef struct _NVME_CONTROLLER_PRIVATE_DATA NVME_CONTROLLER_PRIVATE_DATA;
 typedef struct _NVME_DEVICE_PRIVATE_DATA NVME_DEVICE_PRIVATE_DATA;
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c 
b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
index 4a070f3f13..90ad22b539 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
@@ -2,7 +2,7 @@
   NvmExpressDxe driver is used to manage non-volatile memory subsystem which 
follows
   NVM Express specification.
 
-  Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2013 - 2019, Intel Corporation. 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
@@ -379,6 +379,10 @@ NvmeDisableController (
 
   if (Index == 0) {
 Status = EFI_DEVICE_ERROR;
+REPORT_STATUS_CODE (
+  (EFI_ERROR_CODE | EFI_ERROR_MAJOR),
+  (EFI_IO_BUS_SCSI | EFI_IOB_EC_INTERFACE_ERROR)
+  );
   }
 
   DEBUG ((EFI_D_INFO, "NVMe controller is disabled with status [%r].\n", 
Status));
@@ -449,6 +453,10 @@ NvmeEnableController (
 
   if (Index == 0) {
 Status = EFI_TIMEOUT;
+REPORT_STATUS_CODE (
+  (EFI_ERROR_CODE | EFI_ERROR_MAJOR),
+  (EFI_IO_BUS_SCSI | EFI_IOB_EC_INTERFACE_ERROR)
+  );
   }
 
   DEBUG ((EFI_D_INFO, "NVMe controller is enabled with status [%r].\n", 
Status));
-- 
2.12.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 1/4] MdePkg/UefiSpec.h: Add definition to support Capsule-on-Disk feature

2019-01-30 Thread Ni, Ruiyu

On 1/31/2019 10:34 AM, Chen A Chen wrote:

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

UEFI Spec define this definition to support Capsule-on-Disk.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
  MdePkg/Include/Uefi/UefiSpec.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 75af99de50..8e7b96f09a 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -2201,6 +2201,11 @@ typedef struct {
#error Unknown Processor Type
  #endif
  
+//

+// The directory within the active EFI System Partition defined for delivery 
of capsule to firmware
+//
+#define EFI_CAPSULE_FILE_DIRECTORYL"\\EFI\\UpdateCapsule\\"
+
  #include 
  #include 
  #include 


Reviewed-by: Ray Ni 

--
Thanks,
Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] SecurityPkg: Add a PCD to skip Opal password prompt

2019-01-30 Thread Dong, Eric
Hi Maggie,

Thanks for your contribution! 

Reviewed-by: Eric Dong 

And pushed: 8a9301cdd75439e781754014f514fa06d99140d1

Thanks,
Eric
> -Original Message-
> From: Chu, Maggie
> Sent: Wednesday, January 30, 2019 2:41 PM
> To: edk2-devel@lists.01.org
> Cc: Zhang, Chao B ; Yao, Jiewen
> ; Dong, Eric 
> Subject: [PATCH] SecurityPkg: Add a PCD to skip Opal password prompt
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=1484
> Add a PCD for skipping password prompt and device unlock flow so that
> other pre-OS applications are able to take over Opal devices unlock flow.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Maggie Chu 
> Cc: Chao Zhang 
> Cc: Jiewen Yao 
> Cc: Eric Dong 
> ---
>  SecurityPkg/SecurityPkg.dec   | 6 ++
>  SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c| 4 
>  SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf | 3 +++
>  3 files changed, 13 insertions(+)
> 
> diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index
> 2708e7953c..70c9ff28a8 100644
> --- a/SecurityPkg/SecurityPkg.dec
> +++ b/SecurityPkg/SecurityPkg.dec
> @@ -428,6 +428,12 @@
># @Prompt Possible TPM2 Interrupt Number buffer
>gEfiSecurityPkgTokenSpaceGuid.PcdTpm2PossibleIrqNumBuf|{0x00, 0x00,
> 0x00, 0x00}|VOID*|0x0001001D
> 
> +  ## Indicates if Opal DXE driver skip unlock device flow.
> +  #   TRUE  - Skip unlock device flow.
> +  #   FALSE - Does not skip unlock device flow.
> +  # @Prompt Skip Opal DXE driver unlock device flow.
> +
> +
> gEfiSecurityPkgTokenSpaceGuid.PcdSkipOpalDxeUnlock|FALSE|BOOLEAN|0
> x000
> + 10020
> +
>  [PcdsDynamic, PcdsDynamicEx]
> 
>## This PCD indicates Hash mask for TPM 2.0. Bit definition strictly 
> follows
> TCG Algorithm Registry. diff --git
> a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
> b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
> index 38268539fb..734c5f06ff 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
> +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
> @@ -988,6 +988,10 @@ OpalDriverRequestPassword (
> 
>  IsLocked = OpalDeviceLocked (>OpalDisk.SupportedAttributes,
> >OpalDisk.LockingFeature);
> 
> +if (IsLocked && PcdGetBool (PcdSkipOpalDxeUnlock)) {
> +  return;
> +}
> +
>  while (Count < MAX_PASSWORD_TRY_COUNT) {
>Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, NULL,
> );
>if (PressEsc) {
> diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
> b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
> index cfa55dded7..11e58b95cd 100644
> --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
> +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
> @@ -75,5 +75,8 @@
>  [Guids]
>gEfiEndOfDxeEventGroupGuid## CONSUMES ## 
> Event
> 
> +[Pcd]
> +  gEfiSecurityPkgTokenSpaceGuid.PcdSkipOpalDxeUnlock  ## CONSUMES
> +
>  [Depex]
>gEfiHiiStringProtocolGuid AND gEfiHiiDatabaseProtocolGuid
> --
> 2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 11/12] MdeModulePkg/SmmLockBoxLib: Support LockBox enlarge in UpdateLockBox()

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the support to enlarge a LockBox when using the
LockBoxLib API UpdateLockBox().

Please note that the new support will ONLY work for LockBox with attribute
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY set.

The functional uni-test for the commit is available at:
https://github.com/hwu25/edk2/tree/lockbox_unitest

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Include/Library/LockBoxLib.h |  7 ++-
 MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c  |  7 ++-
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c |  5 +-
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c |  5 +-
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 57 ++--
 5 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Include/Library/LockBoxLib.h 
b/MdeModulePkg/Include/Library/LockBoxLib.h
index 5921731419..addce3bd4a 100644
--- a/MdeModulePkg/Include/Library/LockBoxLib.h
+++ b/MdeModulePkg/Include/Library/LockBoxLib.h
@@ -2,7 +2,7 @@
   This library is only intended to be used by DXE modules that need save
   confidential information to LockBox and get it by PEI modules in S3 phase.
 
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -85,7 +85,10 @@ SetLockBoxAttributes (
   @retval RETURN_SUCCESSthe information is saved successfully.
   @retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
   @retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
+no enough resource to save the information.
   @retval RETURN_ACCESS_DENIED  it is too late to invoke this interface
   @retval RETURN_NOT_STARTEDit is too early to invoke this interface
   @retval RETURN_UNSUPPORTEDthe service is not supported by 
implementaion.
diff --git a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c 
b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
index c40dfea398..0adda1e2a9 100644
--- a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
+++ b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -76,7 +76,10 @@ SetLockBoxAttributes (
   @retval RETURN_SUCCESSthe information is saved successfully.
   @retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
   @retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
+no enough resource to save the information.
   @retval RETURN_ACCESS_DENIED  it is too late to invoke this interface
   @retval RETURN_NOT_STARTEDit is too early to invoke this interface
   @retval RETURN_UNSUPPORTEDthe service is not supported by 
implementaion.
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
index 0428decbac..5ee563b71f 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
@@ -300,7 +300,10 @@ SetLockBoxAttributes (
   @retval RETURN_SUCCESSthe information is saved successfully.
   @retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or 
Length is 0.
   @retval RETURN_NOT_FOUND  the requested GUID not found.
-  @retval RETURN_BUFFER_TOO_SMALL   the original buffer to too small to hold 
new information.
+  @retval RETURN_BUFFER_TOO_SMALL   for lockbox with attribute 
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE,
+the original buffer to too small to hold 
new information.
+  @retval RETURN_OUT_OF_RESOURCES   for lockbox with 

[edk2] [PATCH v2 07/12] MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

For the NvmExpressPei driver, this commit will update the driver to
consume the S3StorageDeviceInitList LockBox in S3 phase. The purpose is to
perform an on-demand (partial) NVM Express device
enumeration/initialization to benefit the S3 resume performance.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf |   8 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h   |  16 +++
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c   |  20 
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c | 106 
 4 files changed, 149 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
index 0666e5892b..22b703e971 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
@@ -40,6 +40,7 @@
   NvmExpressPeiHci.h
   NvmExpressPeiPassThru.c
   NvmExpressPeiPassThru.h
+  NvmExpressPeiS3.c
   NvmExpressPeiStorageSecurity.c
   NvmExpressPeiStorageSecurity.h
 
@@ -54,6 +55,7 @@
   BaseMemoryLib
   IoLib
   TimerLib
+  LockBoxLib
   PeimEntryPoint
 
 [Ppis]
@@ -64,9 +66,13 @@
   gEfiPeiVirtualBlockIo2PpiGuid  ## SOMETIMES_PRODUCES
   gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES
 
+[Guids]
+  gS3StorageDeviceInitListGuid   ## SOMETIMES_CONSUMES ## 
UNDEFINED
+
 [Depex]
   gEfiPeiMemoryDiscoveredPpiGuid AND
-  gEdkiiPeiNvmExpressHostControllerPpiGuid
+  gEdkiiPeiNvmExpressHostControllerPpiGuid AND
+  gEfiPeiMasterBootModePpiGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
   NvmExpressPeiExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
index 7047c4f3ff..6f01413e6d 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
@@ -332,4 +332,20 @@ NvmeBuildDevicePath (
   OUT EFI_DEVICE_PATH_PROTOCOL**DevicePath
   );
 
+/**
+  Determine if a specific NVM Express controller can be skipped for S3 phase.
+
+  @param[in]  HcDevicePath  Device path of the controller.
+  @param[in]  HcDevicePathLengthLength of the device path specified by
+HcDevicePath.
+
+  @retvalThe number of ports that need to be enumerated.
+
+**/
+BOOLEAN
+NvmeS3SkipThisController (
+  IN  EFI_DEVICE_PATH_PROTOCOL*HcDevicePath,
+  IN  UINTN   HcDevicePathLength
+  );
+
 #endif
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
index 96622e6fd5..43b2dfc3e7 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c
@@ -213,6 +213,7 @@ NvmExpressPeimEntry (
   )
 {
   EFI_STATUS   Status;
+  EFI_BOOT_MODEBootMode;
   EDKII_NVM_EXPRESS_HOST_CONTROLLER_PPI*NvmeHcPpi;
   UINT8Controller;
   UINTNMmioBase;
@@ -224,6 +225,15 @@ NvmExpressPeimEntry (
   DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__));
 
   //
+  // Get the current boot mode.
+  //
+  Status = PeiServicesGetBootMode ();
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "%a: Fail to get the current boot mode.\n", 
__FUNCTION__));
+return Status;
+  }
+
+  //
   // Locate the NVME host controller PPI
   //
   Status = PeiServicesLocatePpi (
@@ -279,6 +289,16 @@ NvmExpressPeimEntry (
   continue;
 }
 
+if ((BootMode == BOOT_ON_S3_RESUME) &&
+(NvmeS3SkipThisController (DevicePath, DevicePathLength))) {
+  DEBUG ((
+DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n",
+__FUNCTION__, Controller
+));
+  Controller++;
+  continue;
+}
+
 //
 // Memory allocation for controller private data
 //
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c
new file mode 100644
index 00..afcf5f6c0a
--- /dev/null
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c
@@ -0,0 +1,106 @@
+/** @file
+  The NvmExpressPei driver is used to manage non-volatile memory subsystem
+  which follows NVM Express specification at PEI phase.
+
+  Copyright (c) 2019, Intel Corporation. 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 

[edk2] [PATCH v2 02/12] MdeModulePkg: Add definitions for EDKII PEI ATA PassThru PPI

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the definitions for EDKII PEI ATA PassThru PPI. This
PPI will provide services that allow ATA commands to be sent to ATA
devices attached to an ATA controller in the PEI phase.

More specifically, the PPI will provide services to:

* Send ATA commands to an ATA device (by service 'PassThru');
* Get the list of the attached ATA device on a controller (by services
  'GetNextPort' and 'GetNextDevice');
* Get the identification information (DevicePath) of the underlying ATA
  host controller (by service 'GetDevicePath').

Cc: Jian J Wang 
Cc: Ruiyu Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/MdeModulePkg.dec  |   3 +
 MdeModulePkg/Include/Ppi/AtaPassThru.h | 359 
 2 files changed, 362 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 4411185073..8efb19e626 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -483,6 +483,9 @@
   ## Include/Ppi/AtaAhciController.h
   gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0, { 
0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
 
+  ## Include/Ppi/AtaPassThru.h
+  gEdkiiPeiAtaPassThruPpiGuid   = { 0xa16473fd, 0xd474, 0x4c89, { 
0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
+
 [Protocols]
   ## Load File protocol provides capability to load and unload EFI image into 
memory and execute it.
   #  Include/Protocol/LoadPe32Image.h
diff --git a/MdeModulePkg/Include/Ppi/AtaPassThru.h 
b/MdeModulePkg/Include/Ppi/AtaPassThru.h
new file mode 100644
index 00..9281f0b833
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/AtaPassThru.h
@@ -0,0 +1,359 @@
+/** @file
+
+  Copyright (c) 2019, Intel Corporation. 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 _EDKII_ATA_PASS_THRU_PPI_H_
+#define _EDKII_ATA_PASS_THRU_PPI_H_
+
+#include 
+
+///
+/// Global ID for the EDKII_PEI_ATA_PASS_THRU_PPI.
+///
+#define EDKII_PEI_ATA_PASS_THRU_PPI_GUID \
+  { \
+0xa16473fd, 0xd474, 0x4c89, { 0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 
0x9 } \
+  }
+
+//
+// Forward declaration for the EDKII_PEI_ATA_PASS_THRU_PPI.
+//
+typedef struct _EDKII_PEI_ATA_PASS_THRU_PPI  EDKII_PEI_ATA_PASS_THRU_PPI;
+
+//
+// Revision The revision to which the ATA Pass Thru PPI interface adheres.
+//  All future revisions must be backwards compatible.
+//  If a future version is not back wards compatible it is not the 
same GUID.
+//
+#define EDKII_PEI_ATA_PASS_THRU_PPI_REVISION 0x0001
+
+typedef struct {
+  UINT32Attributes;
+  UINT32IoAlign;
+} EDKII_PEI_ATA_PASS_THRU_MODE;
+
+///
+/// If this bit is set, then the EDKII_PEI_ATA_PASS_THRU_PPI interface is for
+/// physical devices on the ATA controller.
+///
+#define EDKII_PEI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL  0x0001
+///
+/// If this bit is set, then the EDKII_PEI_ATA_PASS_THRU_PPI interface is for
+/// logical devices on the ATA controller.
+///
+#define EDKII_PEI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL   0x0002
+
+typedef struct {
+  UINT8Reserved1[2];
+  UINT8AtaStatus;
+  UINT8AtaError;
+  UINT8AtaSectorNumber;
+  UINT8AtaCylinderLow;
+  UINT8AtaCylinderHigh;
+  UINT8AtaDeviceHead;
+  UINT8AtaSectorNumberExp;
+  UINT8AtaCylinderLowExp;
+  UINT8AtaCylinderHighExp;
+  UINT8Reserved2;
+  UINT8AtaSectorCount;
+  UINT8AtaSectorCountExp;
+  UINT8Reserved3[6];
+} EDKII_PEI_ATA_STATUS_BLOCK;
+
+typedef struct {
+  UINT8Reserved1[2];
+  UINT8AtaCommand;
+  UINT8AtaFeatures;
+  UINT8AtaSectorNumber;
+  UINT8AtaCylinderLow;
+  UINT8AtaCylinderHigh;
+  UINT8AtaDeviceHead;
+  UINT8AtaSectorNumberExp;
+  UINT8AtaCylinderLowExp;
+  UINT8AtaCylinderHighExp;
+  UINT8AtaFeaturesExp;
+  UINT8AtaSectorCount;
+  UINT8AtaSectorCountExp;
+  UINT8Reserved2[6];
+} EDKII_PEI_ATA_COMMAND_BLOCK;
+
+typedef UINT8 EDKII_PEI_ATA_PASS_THRU_CMD_PROTOCOL;
+
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_ATA_HARDWARE_RESET  0x00
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_ATA_SOFTWARE_RESET  0x01
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA0x02
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN 0x04
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT0x05
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_DMA 0x06
+#define EDKII_PEI_ATA_PASS_THRU_PROTOCOL_DMA_QUEUED  0x07
+#define 

[edk2] [PATCH v2 05/12] MdeModulePkg/NvmExpressPei: Avoid updating the module-level variable

2019-01-30 Thread Hao Wu
This commit is out of the scope for BZ-1409. The commit will remove the
call of RegisterForShadow() at the entry point of the driver. By doing so,
the driver is now possible to be executed without being re-loaded into
permanent memory.

Thus, this commit will update the NvmExpressPei driver to avoid updating
the content of a global variable.

Cc: Jian J Wang 
Cc: Ray Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h |  12 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c| 153 +++-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c |  11 +-
 3 files changed, 92 insertions(+), 84 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
index 0bd62c2459..0135eca6f0 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
@@ -2,7 +2,7 @@
   The NvmExpressPei driver is used to manage non-volatile memory subsystem
   which follows NVM Express specification at PEI phase.
 
-  Copyright (c) 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions
@@ -147,13 +147,9 @@ struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
   CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, EndOfPeiNotifyList, 
NVME_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
 
 
-/**
-  Initialize IOMMU.
-**/
-VOID
-IoMmuInit (
-  VOID
-  );
+//
+// Internal functions
+//
 
 /**
   Allocates pages that are suitable for an OperationBusMasterCommonBuffer or
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
index 51b48d38dd..cb629c16b0 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/DmaMem.c
@@ -1,7 +1,7 @@
 /** @file
   The DMA memory help function.
 
-  Copyright (c) 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions
@@ -16,7 +16,33 @@
 
 #include "NvmExpressPei.h"
 
-EDKII_IOMMU_PPI  *mIoMmu;
+/**
+  Get IOMMU PPI.
+
+  @return Pointer to IOMMU PPI.
+
+**/
+EDKII_IOMMU_PPI *
+GetIoMmu (
+  VOID
+  )
+{
+  EFI_STATUS Status;
+  EDKII_IOMMU_PPI*IoMmu;
+
+  IoMmu  = NULL;
+  Status = PeiServicesLocatePpi (
+ ,
+ 0,
+ NULL,
+ (VOID **) 
+ );
+  if (!EFI_ERROR (Status) && (IoMmu != NULL)) {
+return IoMmu;
+  }
+
+  return NULL;
+}
 
 /**
   Provides the controller-specific addresses required to access system memory 
from a
@@ -46,18 +72,21 @@ IoMmuMap (
   OUT VOID  **Mapping
   )
 {
-  EFI_STATUS  Status;
-  UINT64  Attribute;
-
-  if (mIoMmu != NULL) {
-Status = mIoMmu->Map (
-   mIoMmu,
-   Operation,
-   HostAddress,
-   NumberOfBytes,
-   DeviceAddress,
-   Mapping
-   );
+  EFI_STATUS Status;
+  UINT64 Attribute;
+  EDKII_IOMMU_PPI*IoMmu;
+
+  IoMmu = GetIoMmu ();
+
+  if (IoMmu != NULL) {
+Status = IoMmu->Map (
+ IoMmu,
+ Operation,
+ HostAddress,
+ NumberOfBytes,
+ DeviceAddress,
+ Mapping
+ );
 if (EFI_ERROR (Status)) {
   return EFI_OUT_OF_RESOURCES;
 }
@@ -78,11 +107,11 @@ IoMmuMap (
   ASSERT(FALSE);
   return EFI_INVALID_PARAMETER;
 }
-Status = mIoMmu->SetAttribute (
-   mIoMmu,
-   *Mapping,
-   Attribute
-   );
+Status = IoMmu->SetAttribute (
+  IoMmu,
+  *Mapping,
+  Attribute
+  );
 if (EFI_ERROR (Status)) {
   return Status;
 }
@@ -108,11 +137,14 @@ IoMmuUnmap (
   IN VOID  *Mapping
   )
 {
-  EFI_STATUS  Status;
+  EFI_STATUS Status;
+  EDKII_IOMMU_PPI*IoMmu;
+
+  IoMmu = GetIoMmu ();
 
-  if (mIoMmu != NULL) {
-Status = mIoMmu->SetAttribute (mIoMmu, Mapping, 0);
-Status = mIoMmu->Unmap (mIoMmu, Mapping);
+  if (IoMmu != NULL) {
+Status = IoMmu->SetAttribute (IoMmu, Mapping, 0);
+Status = IoMmu->Unmap (IoMmu, Mapping);
   } else {
 Status = EFI_SUCCESS;
   }
@@ -148,39 +180,42 @@ IoMmuAllocateBuffer (
   EFI_STATUSStatus;
   UINTN NumberOfBytes;
   EFI_PHYSICAL_ADDRESS  HostPhyAddress;
+  EDKII_IOMMU_PPI   *IoMmu;
 
   *HostAddress = NULL;
   *DeviceAddress = 0;
 
-  if (mIoMmu != 

[edk2] [PATCH v2 09/12] MdeModulePkg/SmmLockBoxLib: Use 'DEBUG_' prefix instead of 'EFI_D_'

2019-01-30 Thread Hao Wu
This commit is out of the scope for BZ-1409. It is a coding style
refinement for the SmmLockBoxLib.

More specifically, the commit will remove all the debug message display
level macros starting with 'EFI_D_' and replace them with macros starting
with 'DEBUG_'.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c | 22 +++---
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 26 +++
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c | 78 ++--
 3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
index ac8bcd2ff7..0428decbac 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -153,7 +153,7 @@ SaveLockBox (
   UINT8   *CommBuffer;
   UINTN   CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
 
   //
   // Basic check
@@ -199,7 +199,7 @@ SaveLockBox (
 
   Status = (EFI_STATUS)LockBoxParameterSave->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Exit (%r)\n", Status));
 
   //
   // Done
@@ -235,7 +235,7 @@ SetLockBoxAttributes (
   UINT8 *CommBuffer;
   UINTN CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));
 
   //
   // Basic check
@@ -281,7 +281,7 @@ SetLockBoxAttributes (
 
   Status = (EFI_STATUS)LockBoxParameterSetAttributes->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit (%r)\n", 
Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Exit (%r)\n", 
Status));
 
   //
   // Done
@@ -322,7 +322,7 @@ UpdateLockBox (
   UINT8 *CommBuffer;
   UINTN CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
 
   //
   // Basic check
@@ -369,7 +369,7 @@ UpdateLockBox (
 
   Status = (EFI_STATUS)LockBoxParameterUpdate->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Exit (%r)\n", Status));
 
   //
   // Done
@@ -411,7 +411,7 @@ RestoreLockBox (
   UINT8  *CommBuffer;
   UINTN  CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
 
   //
   // Basic check
@@ -467,7 +467,7 @@ RestoreLockBox (
 
   Status = (EFI_STATUS)LockBoxParameterRestore->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", 
Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Exit (%r)\n", 
Status));
 
   //
   // Done
@@ -496,7 +496,7 @@ RestoreAllLockBoxInPlace (
   UINT8   *CommBuffer;
   UINTN   CommSize;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));
 
   SmmCommunication = LockBoxGetSmmCommProtocol ();
   if (SmmCommunication == NULL) {
@@ -532,7 +532,7 @@ RestoreAllLockBoxInPlace (
 
   Status = (EFI_STATUS)LockBoxParameterRestoreAllInPlace->Header.ReturnStatus;
 
-  DEBUG ((EFI_D_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit 
(%r)\n", Status));
+  DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Exit 
(%r)\n", Status));
 
   //
   // Done
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
index 8a168663c4..9f73480070 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -542,7 +542,7 @@ RestoreLockBox (
   // } 

[edk2] [PATCH v2 10/12] MdeModulePkg/SmmLockBox(PEI): Remove an ASSERT in RestoreLockBox()

2019-01-30 Thread Hao Wu
This commit is out of the scope for BZ-1409. It is a refinement for the
PEI library instance within SmmLockBoxLib.

For the below ASSERT statement within function RestoreLockBox():
  Status = SmmCommunicationPpi->Communicate (
  SmmCommunicationPpi,
  [0],
  
  );
  if (Status == EFI_NOT_STARTED) {
//
// Pei SMM communication not ready yet, so we access SMRAM directly
//
DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib Communicate - (%r)\n", Status));
Status = InternalRestoreLockBoxFromSmram (Guid, Buffer, Length);
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
if (Length != NULL) {
  LockBoxParameterRestore->Length = (UINT64)*Length;
}
  }
  ASSERT_EFI_ERROR (Status);

It is possible for previous codes to return an error status that is
possible for happen. One example is that, when the 'if' statement
'if (Status == EFI_NOT_STARTED) {' is entered, function
InternalRestoreLockBoxFromSmram() is possible to return 'BUFFER_TOO_SMALL'
if the caller of RestoreLockBox() provides a buffer that is too small to
hold the content of LockBox.

Thus, this commit will remove the ASSERT here.

Please note that the current implementation of RestoreLockBox() is
handling the above-mentioned error case properly, so no additional error
handling codes are needed here.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c 
b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
index 9f73480070..9d7b4c3706 100644
--- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
+++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c
@@ -623,7 +623,7 @@ RestoreLockBox (
   LockBoxParameterRestore->Length = (UINT64)*Length;
 }
   }
-  ASSERT_EFI_ERROR (Status);
+  //ASSERT_EFI_ERROR (Status);
 
   if (Length != NULL) {
 *Length = (UINTN)LockBoxParameterRestore->Length;
-- 
2.12.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 03/12] MdeModulePkg: Add definitions for Storage Security Command PPI

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the definitions for Storage Security Command (SSC)
PPI. This PPI will be be used to abstract mass storage devices to allow
code running in the PEI phase to send security protocol commands to mass
storage devices without specific knowledge of the type of device or
controller that manages the device.

More specifically, the PPI will provide services to:

* Get the number of mass storage devices managed by a instance of the SSC
  PPI (by service 'GetNumberofDevices');
* Get the identification information (DevicePath) of a managing mass
  storage devices (by service 'GetDevicePath');
* Send security protocol commands to mass storage devices (by services
  'ReceiveData' and 'SendData').

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/MdeModulePkg.dec |   3 +
 MdeModulePkg/Include/Ppi/StorageSecurityCommand.h | 283 
 2 files changed, 286 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 8efb19e626..7f646d7702 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -483,6 +483,9 @@
   ## Include/Ppi/AtaAhciController.h
   gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0, { 
0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
 
+  ## Include/Ppi/StorageSecurityCommand.h
+  gEdkiiPeiStorageSecurityCommandPpiGuid= { 0x35de0b4e, 0x30fb, 0x46c3, { 
0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58, 0xbb, 0x56 } }
+
   ## Include/Ppi/AtaPassThru.h
   gEdkiiPeiAtaPassThruPpiGuid   = { 0xa16473fd, 0xd474, 0x4c89, { 
0xae, 0xc7, 0x90, 0xb8, 0x3c, 0x73, 0x86, 0x9  } }
 
diff --git a/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h 
b/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h
new file mode 100644
index 00..cc1688dabb
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/StorageSecurityCommand.h
@@ -0,0 +1,283 @@
+/** @file
+
+  Copyright (c) 2019, Intel Corporation. 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 _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_
+#define _EDKII_STORAGE_SECURITY_COMMAND_PPI_H_
+
+#include 
+
+///
+/// Global ID for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI.
+///
+#define EDKII_PEI_STORAGE_SECURITY_CMD_PPI_GUID \
+  { \
+0x35de0b4e, 0x30fb, 0x46c3, { 0xbd, 0x84, 0x1f, 0xdb, 0xa1, 0x58, 0xbb, 
0x56 } \
+  }
+
+//
+// Forward declaration for the EDKII_PEI_STORAGE_SECURITY_CMD_PPI.
+//
+typedef struct _EDKII_PEI_STORAGE_SECURITY_CMD_PPI  
EDKII_PEI_STORAGE_SECURITY_CMD_PPI;
+
+//
+// Revision The revision to which the Storage Security Command interface 
adheres.
+//  All future revisions must be backwards compatible.
+//  If a future version is not back wards compatible it is not the 
same GUID.
+//
+#define EDKII_STORAGE_SECURITY_PPI_REVISION  0x0001
+
+
+/**
+  Gets the count of storage security devices that one specific driver detects.
+
+  @param[in]  This   The PPI instance pointer.
+  @param[out] NumberofDevicesThe number of storage security devices 
discovered.
+
+  @retval EFI_SUCCESS  The operation performed successfully.
+  @retval EFI_INVALID_PARAMETERThe parameters are invalid.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_STORAGE_SECURITY_GET_NUMBER_DEVICES) (
+  IN  EDKII_PEI_STORAGE_SECURITY_CMD_PPI*This,
+  OUT UINTN *NumberofDevices
+  );
+
+/**
+  Gets the device path of a specific storage security device.
+
+  @param[in]  This The PPI instance pointer.
+  @param[in]  DeviceIndex  Specifies the storage security device to 
which
+   the function wants to talk. Because the 
driver
+   that implements Storage Security Command 
PPIs
+   will manage multiple storage devices, the 
PPIs
+   that want to talk to a single device must 
specify
+   the device index that was assigned during 
the
+   enumeration process. This index is a number 
from
+   one to NumberofDevices.
+  @param[out] DevicePathLength The length of the device path in bytes 
specified
+   by DevicePath.
+  @param[out] DevicePath   The device path of storage security device.
+   This field re-uses EFI 

[edk2] [PATCH v2 06/12] MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

For the NvmExpressPei driver, this commit will add codes to produce the
Storage Security Command PPI if the underlying NVM Express controller
supports the Security Send and Security Receive commands.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf  |  10 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h|  81 +++-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h |  20 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h | 247 

 MdeModulePkg/Bus/Pci/NvmExpressPei/DevicePath.c   | 317 
+++
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.c| 143 +--
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c |  32 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.c | 423 

 8 files changed, 1184 insertions(+), 89 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
index 9591572fec..0666e5892b 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf
@@ -2,7 +2,7 @@
 #  The NvmExpressPei driver is used to manage non-volatile memory subsystem
 #  which follows NVM Express specification at PEI phase.
 #
-#  Copyright (c) 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -30,6 +30,7 @@
 #
 
 [Sources]
+  DevicePath.c
   DmaMem.c
   NvmExpressPei.c
   NvmExpressPei.h
@@ -39,6 +40,8 @@
   NvmExpressPeiHci.h
   NvmExpressPeiPassThru.c
   NvmExpressPeiPassThru.h
+  NvmExpressPeiStorageSecurity.c
+  NvmExpressPeiStorageSecurity.h
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -54,11 +57,12 @@
   PeimEntryPoint
 
 [Ppis]
-  gEfiPeiVirtualBlockIoPpiGuid   ## PRODUCES
-  gEfiPeiVirtualBlockIo2PpiGuid  ## PRODUCES
   gEdkiiPeiNvmExpressHostControllerPpiGuid   ## CONSUMES
   gEdkiiIoMmuPpiGuid ## CONSUMES
   gEfiEndOfPeiSignalPpiGuid  ## CONSUMES
+  gEfiPeiVirtualBlockIoPpiGuid   ## SOMETIMES_PRODUCES
+  gEfiPeiVirtualBlockIo2PpiGuid  ## SOMETIMES_PRODUCES
+  gEdkiiPeiStorageSecurityCommandPpiGuid ## SOMETIMES_PRODUCES
 
 [Depex]
   gEfiPeiMemoryDiscoveredPpiGuid AND
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h 
b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
index 0135eca6f0..7047c4f3ff 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -44,6 +45,7 @@ typedef struct _PEI_NVME_CONTROLLER_PRIVATE_DATA  
PEI_NVME_CONTROLLER_PRIVATE_DA
 #include "NvmExpressPeiHci.h"
 #include "NvmExpressPeiPassThru.h"
 #include "NvmExpressPeiBlockIo.h"
+#include "NvmExpressPeiStorageSecurity.h"
 
 //
 // NVME PEI driver implementation related definitions
@@ -90,10 +92,15 @@ struct _PEI_NVME_NAMESPACE_INFO {
 struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
   UINT32Signature;
   UINTN MmioBase;
+  UINTN DevicePathLength;
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+
   EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
   EFI_PEI_RECOVERY_BLOCK_IO2_PPIBlkIo2Ppi;
+  EDKII_PEI_STORAGE_SECURITY_CMD_PPIStorageSecurityPpi;
   EFI_PEI_PPI_DESCRIPTORBlkIoPpiList;
   EFI_PEI_PPI_DESCRIPTORBlkIo2PpiList;
+  EFI_PEI_PPI_DESCRIPTORStorageSecurityPpiList;
   EFI_PEI_NOTIFY_DESCRIPTOR EndOfPeiNotifyList;
 
   //
@@ -139,11 +146,13 @@ struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
   PEI_NVME_NAMESPACE_INFO   *NamespaceInfo;
 };
 
-#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a) \
+#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a)   \
   CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, BlkIoPpi, 
NVME_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
-#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2(a)\
+#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2(a)  \
   CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, BlkIo2Ppi, 
NVME_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
-#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a)\
+#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY(a)\
+  CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, StorageSecurityPpi, 

[edk2] [PATCH v2 01/12] MdeModulePkg: Add definitions for ATA AHCI host controller PPI

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the definitions for ATA AHCI host controller PPI. The
purpose of the PPI in to provide:

* MMIO base address
* Controller identification information (DevicePath)

for ATA host controllers working under AHCI mode.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/MdeModulePkg.dec|  3 +
 MdeModulePkg/Include/Ppi/AtaAhciController.h | 89 
 2 files changed, 92 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index e5c32d15ed..4411185073 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -480,6 +480,9 @@
   ## Include/Ppi/NvmExpressHostController.h
   gEdkiiPeiNvmExpressHostControllerPpiGuid  = { 0xcae3aa63, 0x676f, 0x4da3, { 
0xbd, 0x50, 0x6c, 0xc5, 0xed, 0xde, 0x9a, 0xad } }
 
+  ## Include/Ppi/AtaAhciController.h
+  gEdkiiPeiAtaAhciHostControllerPpiGuid = { 0x61dd33ea, 0x421f, 0x4cc0, { 
0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 0x61 } }
+
 [Protocols]
   ## Load File protocol provides capability to load and unload EFI image into 
memory and execute it.
   #  Include/Protocol/LoadPe32Image.h
diff --git a/MdeModulePkg/Include/Ppi/AtaAhciController.h 
b/MdeModulePkg/Include/Ppi/AtaAhciController.h
new file mode 100644
index 00..2bdd53ff36
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/AtaAhciController.h
@@ -0,0 +1,89 @@
+/** @file
+
+  Copyright (c) 2019, Intel Corporation. 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 _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_H_
+#define _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_H_
+
+#include 
+
+///
+/// Global ID for the EDKII_ATA_AHCI_HOST_CONTROLLER_PPI.
+///
+#define EDKII_ATA_AHCI_HOST_CONTROLLER_PPI_GUID \
+  { \
+0x61dd33ea, 0x421f, 0x4cc0, { 0x89, 0x29, 0xff, 0xee, 0xa9, 0xa1, 0xa2, 
0x61 } \
+  }
+
+//
+// Forward declaration for the EDKII_ATA_AHCI_HOST_CONTROLLER_PPI.
+//
+typedef struct _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI  
EDKII_ATA_AHCI_HOST_CONTROLLER_PPI;
+
+/**
+  Get the MMIO base address of ATA AHCI host controller.
+
+  @param[in]  This The PPI instance pointer.
+  @param[in]  ControllerId The ID of the ATA AHCI host controller.
+  @param[out] MmioBar  The MMIO base address of the controller.
+
+  @retval EFI_SUCCESS  The operation succeeds.
+  @retval EFI_INVALID_PARAMETERThe parameters are invalid.
+  @retval EFI_NOT_FOUNDThe specified ATA AHCI host controller not 
found.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_ATA_AHCI_HC_GET_MMIO_BAR) (
+  IN  EDKII_ATA_AHCI_HOST_CONTROLLER_PPI*This,
+  IN  UINT8 ControllerId,
+  OUT UINTN *MmioBar
+  );
+
+/**
+  Get the device path of ATA AHCI host controller.
+
+  @param[in]  This The PPI instance pointer.
+  @param[in]  ControllerId The ID of the ATA AHCI host controller.
+  @param[out] DevicePathLength The length of the device path in bytes 
specified
+   by DevicePath.
+  @param[out] DevicePath   The device path of ATA AHCI host controller.
+   This field re-uses EFI Device Path Protocol 
as
+   defined by Section 10.2 EFI Device Path 
Protocol
+   of UEFI 2.7 Specification.
+
+  @retval EFI_SUCCESS  The operation succeeds.
+  @retval EFI_INVALID_PARAMETERThe parameters are invalid.
+  @retval EFI_NOT_FOUNDThe specified ATA AHCI host controller not 
found.
+  @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of 
resources.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_ATA_AHCI_HC_GET_DEVICE_PATH) (
+  IN  EDKII_ATA_AHCI_HOST_CONTROLLER_PPI*This,
+  IN  UINT8 ControllerId,
+  OUT UINTN *DevicePathLength,
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePath
+  );
+
+//
+// This PPI contains a set of services to interact with the ATA AHCI host 
controller.
+//
+struct _EDKII_ATA_AHCI_HOST_CONTROLLER_PPI {
+  EDKII_ATA_AHCI_HC_GET_MMIO_BAR   GetAhciHcMmioBar;
+  EDKII_ATA_AHCI_HC_GET_DEVICE_PATHGetAhciHcDevicePath;
+};
+
+extern EFI_GUID gEdkiiPeiAtaAhciHostControllerPpiGuid;
+
+#endif
-- 
2.12.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org

[edk2] [PATCH v2 00/12] Split the S3 PEI phase HW init codes from Opal driver

2019-01-30 Thread Hao Wu
The series is also available at:
https://github.com/hwu25/edk2/tree/opal_remodel_v2

V2 changes:

For patch 8, the new series removes the codes to produce the Block IO PPIs
from the AhciPei driver.

The task to produce the Block IO services is out of the scope of BZ-1409
(actually covered by BZ-1483). And we will later propose seperate patch(s)
to address this.


V1 history:

For the below 2 types of storage device:

1. NVM Express devices;
2. ATA hard disk devices working under AHCI mode.

the OpalPassword driver supports auto-unlocking those devices during S3
resume.

Current implementation of the OpalPassword driver is handling the device
initialization (using boot script to restore the host controller PCI
configuration space also counts) in the PEI phase during S3 resume by
itself.

Meanwhile, the NvmExpressPei driver in MdeModulePkg also handles the NVME
device initialization during the PEI phase in order to produce the Block
IO PPI.

Moreover, there is a Bugzilla request (BZ-1483) for adding the Block IO
PPI support for ATA device as well. So there is likely to be an PEI driver
for ATA device that will handle the ATA device initialization.

In order to remove code duplication, the series will split the S3 phase
device initialization related codes out from the OpalPassword driver. And
let the existing NvmExpressPei driver and the new AhciPei driver to handle
the task.

After this remodel, NvmExpressPei and AhciPei drivers will produce a PPI
called Storage Security Command PPI. And the OpalPassword driver will
consume this PPI to perform the device auto-unlock in S3 resume.


Patch   1~4: Add the definitions of PPIs and GUIDs;
Patch 5: Refinement for the NvmExpressPei driver;
Patch   6~7: Update the NvmExpressPei driver to produce the PPI needed by
 OpalPassword;
Patch 8: Add the Ahci mode ATA device support in the PEI phase, it
 will produce the PPI needed by OpalPassword;
Patch  9~10: Refinements for the SmmLockBoxLib;
Patch11: Support LockBox enlarge for LockBoxLib API UpdateLockBox();
Patch12: Remove the hardware initialization codes from the
 OpalPassword driver. And consume the SSC PPI to unlock device
 in S3 resume.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Cc: Star Zeng 
Cc: Chao Zhang 
Cc: Jiewen Yao 

Hao Wu (12):
  MdeModulePkg: Add definitions for ATA AHCI host controller PPI
  MdeModulePkg: Add definitions for EDKII PEI ATA PassThru PPI
  MdeModulePkg: Add definitions for Storage Security Command PPI
  MdeModulePkg: Add GUID for LockBox to save storage dev to init in S3
  MdeModulePkg/NvmExpressPei: Avoid updating the module-level variable
  MdeModulePkg/NvmExpressPei: Add logic to produce SSC PPI
  MdeModulePkg/NvmExpressPei: Consume S3StorageDeviceInitList LockBox
  MdeModulePkg/AhciPei: Add AHCI mode ATA device support in PEI
  MdeModulePkg/SmmLockBoxLib: Use 'DEBUG_' prefix instead of 'EFI_D_'
  MdeModulePkg/SmmLockBox(PEI): Remove an ASSERT in RestoreLockBox()
  MdeModulePkg/SmmLockBoxLib: Support LockBox enlarge in UpdateLockBox()
  SecurityPkg/OpalPassword: Remove HW init codes and consume SSC PPI

 MdeModulePkg/MdeModulePkg.dec |   12 +
 MdeModulePkg/MdeModulePkg.dsc |1 +
 MdeModulePkg/Bus/Ata/AhciPei/AhciPei.inf  |   74 +
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.inf  |   18 +-
 SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf |6 +-
 SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.inf |   12 +-
 MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h|  711 
+++
 MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.h|  184 ++
 MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.h |  247 +++
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPei.h|  109 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.h |   20 +-
 MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiStorageSecurity.h |  247 +++
 MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h   |   36 +
 MdeModulePkg/Include/Library/LockBoxLib.h |7 +-
 MdeModulePkg/Include/Ppi/AtaAhciController.h  |   89 +
 MdeModulePkg/Include/Ppi/AtaPassThru.h|  359 
 MdeModulePkg/Include/Ppi/StorageSecurityCommand.h |  283 +++
 SecurityPkg/Tcg/Opal/OpalPassword/OpalAhciMode.h  |  412 
 SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h|4 +-
 SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.h  |  327 
 SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeReg.h   |  815 

 SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordCommon.h|   45 +-
 SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.h   |  106 +-
 MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c  

[edk2] [PATCH v2 04/12] MdeModulePkg: Add GUID for LockBox to save storage dev to init in S3

2019-01-30 Thread Hao Wu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1409

This commit will add the GUID definitions for LockBox which is used to
save a list of storage devices that need to get initialized during the S3
resume.

The content of the LockBox will be a DevicePath structure that contains
zero or more DevicePath instances. Each instance denotes a storage device
that needs to get initialized during the S3 resume.

The producers of the content of this LockBox will be drivers like
OpalPassword DXE driver. This kind of drivers requires some specific
storage devices to be initialized during the PEI phase of in S3 resume.
(For the OpalPasword case, it requires the managing devices to be
automatically unlocked during the S3 resume).

The attribute of the LockBox should be set to
LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY.

The consumers of the content of this LockBox will be PEI storage device
controller/bus drivers (e.g. NvmExpressPei) during S3 resume. This kind of
drivers can use the DevicePath instances stored in the LockBox to get a
list of devices that need to get initialized. In such way, an on-demand
(partial) device enumeration/initialization can be performed to benefit
the S3 resume performance.

Cc: Jian J Wang 
Cc: Ray Ni 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/MdeModulePkg.dec   |  3 ++
 MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h | 36 
 2 files changed, 39 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 7f646d7702..a2130bc439 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -422,6 +422,9 @@
   ## Include/Guid/S3SmmInitDone.h
   gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71, 0x84, 
0x50, 0x25, 0x79, 0x2e, 0xf6 } }
 
+  ## Include/Guid/S3StorageDeviceInitList.h
+  gS3StorageDeviceInitListGuid = { 0x310e9b8c, 0xcf90, 0x421e, { 0x8e, 0x9b, 
0x9e, 0xef, 0xb6, 0x17, 0xc8, 0xef } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
diff --git a/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h 
b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
new file mode 100644
index 00..cfbd2a78e7
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/S3StorageDeviceInitList.h
@@ -0,0 +1,36 @@
+/** @file
+  Define the LockBox GUID for list of storage devices need to be initialized in
+  S3.
+
+  Copyright (c) 2019, Intel Corporation. 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 __S3_STORAGE_DEVICE_INIT_LIST_H__
+#define __S3_STORAGE_DEVICE_INIT_LIST_H__
+
+#define S3_STORAGE_DEVICE_INIT_LIST \
+  { \
+0x310e9b8c, 0xcf90, 0x421e, { 0x8e, 0x9b, 0x9e, 0xef, 0xb6, 0x17, 0xc8, 
0xef } \
+  }
+
+//
+// The LockBox will store a DevicePath structure that contains zero or more
+// DevicePath instances. Each instance denotes a storage device that needs to
+// get initialized during the S3 resume.
+//
+// The attribute of the LockBox should be set to
+// 'LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY'.
+//
+extern EFI_GUID  gS3StorageDeviceInitListGuid;
+
+#endif  // __S3_STORAGE_DEVICE_INIT_LIST_H__
-- 
2.12.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 0/4] Introduce CapsuleApp patch v4

2019-01-30 Thread Wang, Jian J
Chen,

I just noticed that there's another patch series in which a new interface 
CharToUpper()
is introduced in BaseLib which can be used to replace your local equivalent one
UpperCaseString(). I would suggest to hold your patch for a while and use the 
new 
interface instead once that patch series is pushed. Sorry for the late remind.

Regards,
Jian

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chen
> A Chen
> Sent: Thursday, January 31, 2019 10:34 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH v4 0/4] Introduce CapsuleApp patch v4
> 
> No functionality change.
> Fix ECC and code style issue.
> Already pass CR process.
> https://git-amr-7.devtools.intel.com/gerrit/#/c/39023/
> 
> Chen A Chen (4):
>   MdePkg/UefiSpec.h: Add definition to support Capsule-on-Disk feature
>   MdeModulePkg/CapsuleApp: Add a function used to get next DevicePath
>   MdeModulePkg/CapsuleApp: Add functions to support Capsule-on-Disk
>   MdeModulePkg/CapsuleApp: Enhance CapsuleApp to support Capsule-on-Disk
> 
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 160 +++-
>  MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   8 +
>  MdeModulePkg/Application/CapsuleApp/CapsuleDump.c  | 538
> +-
>  .../Application/CapsuleApp/CapsuleOnDisk.c | 808
> +
>  MdeModulePkg/Include/Library/UefiBootManagerLib.h  |  21 +-
>  MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |  24 +-
>  MdeModulePkg/MdeModulePkg.dsc  |   1 +
>  MdePkg/Include/Uefi/UefiSpec.h |   5 +
>  8 files changed, 1546 insertions(+), 19 deletions(-)
>  create mode 100644 MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
> 
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 1/4] MdePkg/UefiSpec.h: Add definition to support Capsule-on-Disk feature

2019-01-30 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

UEFI Spec define this definition to support Capsule-on-Disk.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
---
 MdePkg/Include/Uefi/UefiSpec.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index 75af99de50..8e7b96f09a 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -2201,6 +2201,11 @@ typedef struct {
   #error Unknown Processor Type
 #endif
 
+//
+// The directory within the active EFI System Partition defined for delivery 
of capsule to firmware
+//
+#define EFI_CAPSULE_FILE_DIRECTORYL"\\EFI\\UpdateCapsule\\"
+
 #include 
 #include 
 #include 
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 0/4] Introduce CapsuleApp patch v4

2019-01-30 Thread Chen A Chen
No functionality change.
Fix ECC and code style issue.
Already pass CR process.
https://git-amr-7.devtools.intel.com/gerrit/#/c/39023/

Chen A Chen (4):
  MdePkg/UefiSpec.h: Add definition to support Capsule-on-Disk feature
  MdeModulePkg/CapsuleApp: Add a function used to get next DevicePath
  MdeModulePkg/CapsuleApp: Add functions to support Capsule-on-Disk
  MdeModulePkg/CapsuleApp: Enhance CapsuleApp to support Capsule-on-Disk

 MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 160 +++-
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   8 +
 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c  | 538 +-
 .../Application/CapsuleApp/CapsuleOnDisk.c | 808 +
 MdeModulePkg/Include/Library/UefiBootManagerLib.h  |  21 +-
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c   |  24 +-
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 MdePkg/Include/Uefi/UefiSpec.h |   5 +
 8 files changed, 1546 insertions(+), 19 deletions(-)
 create mode 100644 MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c

-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 3/4] MdeModulePkg/CapsuleApp: Add functions to support Capsule-on-Disk

2019-01-30 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

This file provide some basic function to support Capsule-on-Disk.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
Reviewed-by: Jian J Wang 
---
 .../Application/CapsuleApp/CapsuleOnDisk.c | 808 +
 1 file changed, 808 insertions(+)
 create mode 100644 MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
new file mode 100644
index 00..393b7ae7db
--- /dev/null
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
@@ -0,0 +1,808 @@
+/** @file
+  Process Capsule On Disk.
+
+  Copyright (c) 2019, Intel Corporation. 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.
+
+**/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 
0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };
+
+/**
+  Get shell protocol.
+
+  @return Pointer to shell protocol.
+
+**/
+EFI_SHELL_PROTOCOL *
+GetShellProtocol (
+  VOID
+  );
+
+/**
+  Get file name from file path.
+
+  @param  FilePathFile path.
+
+  @return Pointer to file name.
+
+**/
+CHAR16 *
+GetFileNameFromPath (
+  CHAR16*FilePath
+  )
+{
+  EFI_STATUSStatus;
+  EFI_SHELL_PROTOCOL*ShellProtocol;
+  SHELL_FILE_HANDLE Handle;
+  EFI_FILE_INFO *FileInfo;
+
+  ShellProtocol = GetShellProtocol ();
+  if (ShellProtocol == NULL) {
+return NULL;
+  }
+
+  //
+  // Open file by FileName.
+  //
+  Status = ShellProtocol->OpenFileByName (
+FilePath,
+,
+EFI_FILE_MODE_READ
+);
+  if (EFI_ERROR (Status)) {
+return NULL;
+  }
+
+  //
+  // Get file name from EFI_FILE_INFO.
+  //
+  FileInfo = ShellProtocol->GetFileInfo (Handle);
+  ShellProtocol->CloseFile (Handle);
+  if (FileInfo == NULL) {
+return NULL;
+  }
+
+  return FileInfo->FileName;
+}
+
+/**
+  Check if the device path is EFI system Partition.
+
+  @param  DevicePathThe ESP device path.
+
+  @retval TRUEDevicePath is a device path for ESP.
+  @retval FALSE   DevicePath is not a device path for ESP.
+
+**/
+BOOLEAN
+IsEfiSysPartitionDevicePath (
+  EFI_DEVICE_PATH_PROTOCOL   *DevicePath
+  )
+{
+  EFI_STATUS Status;
+  EFI_DEVICE_PATH_PROTOCOL   *TempDevicePath;
+  HARDDRIVE_DEVICE_PATH  *Hd;
+  EFI_HANDLE Handle;
+
+  //
+  // Check if the device path contains GPT node
+  //
+  TempDevicePath = DevicePath;
+
+  while (!IsDevicePathEnd (TempDevicePath)) {
+if ((DevicePathType (TempDevicePath) == MEDIA_DEVICE_PATH) &&
+  (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP)) {
+  Hd = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
+  if (Hd->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER) {
+break;
+  }
+}
+TempDevicePath = NextDevicePathNode (TempDevicePath);
+  }
+
+  if (!IsDevicePathEnd (TempDevicePath)) {
+//
+// Search for EFI system partition protocol on full device path in Boot 
Option
+//
+Status = gBS->LocateDevicePath (, , 
);
+return EFI_ERROR (Status) ? FALSE : TRUE;
+  } else {
+return FALSE;
+  }
+}
+
+/**
+  Dump all EFI System Partition.
+
+**/
+VOID
+DumpAllEfiSysPartition (
+  VOID
+  )
+{
+  EFI_HANDLE *SimpleFileSystemHandles;
+  UINTN  NumberSimpleFileSystemHandles;
+  UINTN  Index;
+  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
+  UINTN  NumberEfiSystemPartitions;
+  EFI_SHELL_PROTOCOL *ShellProtocol;
+
+  ShellProtocol = GetShellProtocol ();
+  NumberEfiSystemPartitions = 0;
+
+  Print (L"EFI System Partition list:\n");
+
+  gBS->LocateHandleBuffer (
+ ByProtocol,
+ ,
+ NULL,
+ ,
+ 
+ );
+
+  for (Index = 0; Index < NumberSimpleFileSystemHandles; Index++) {
+DevicePath = DevicePathFromHandle (SimpleFileSystemHandles[Index]);
+if (IsEfiSysPartitionDevicePath (DevicePath)) {
+  NumberEfiSystemPartitions++;
+  Print(L"%s\n%s\n", ShellProtocol->GetMapFromDevicePath 
(), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
+}
+  }
+
+  if 

[edk2] [PATCH v4 2/4] MdeModulePkg/CapsuleApp: Add a function used to get next DevicePath

2019-01-30 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

Add a new function to support Capsule-on-Disk feature.
This function is used to get next full DevicePath from a load option.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
Reviewed-by: Jian J Wang 
---
 MdeModulePkg/Include/Library/UefiBootManagerLib.h | 21 +++-
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c  | 24 ++-
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h 
b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
index bfc0cb86f8..64347ff160 100644
--- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h
+++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h
@@ -1,7 +1,7 @@
 /** @file
   Provide Boot Manager related library APIs.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
@@ -445,6 +445,25 @@ EfiBootManagerGetBootManagerMenu (
   EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
   );
 
+/**
+  Get the next possible full path pointing to the load option.
+  The routine doesn't guarantee the returned full path points to an existing
+  file, and it also doesn't guarantee the existing file is a valid load option.
+  BmGetNextLoadOptionBuffer() guarantees.
+
+  @param FilePath  The device path pointing to a load option.
+   It could be a short-form device path.
+  @param FullPath  The full path returned by the routine in last call.
+   Set to NULL in first call.
+
+  @return The next possible full path pointing to the load option.
+  Caller is responsible to free the memory.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EfiBootManagerGetNextFullDevicePath (
+  IN  EFI_DEVICE_PATH_PROTOCOL  *FilePath,
+  IN  EFI_DEVICE_PATH_PROTOCOL  *FullPath
+  );
 
 /**
   Get the load option by its device path.
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 6a23477eb8..684d7b8b1b 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1,7 +1,7 @@
 /** @file
   Library functions which relates with booting.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
@@ -2461,3 +2461,25 @@ EfiBootManagerGetBootManagerMenu (
   }
 }
 
+/**
+  Get the next possible full path pointing to the load option.
+  The routine doesn't guarantee the returned full path points to an existing
+  file, and it also doesn't guarantee the existing file is a valid load option.
+  BmGetNextLoadOptionBuffer() guarantees.
+
+  @param FilePath  The device path pointing to a load option.
+   It could be a short-form device path.
+  @param FullPath  The full path returned by the routine in last call.
+   Set to NULL in first call.
+
+  @return The next possible full path pointing to the load option.
+  Caller is responsible to free the memory.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EfiBootManagerGetNextFullDevicePath (
+  IN  EFI_DEVICE_PATH_PROTOCOL  *FilePath,
+  IN  EFI_DEVICE_PATH_PROTOCOL  *FullPath
+  )
+{
+  return BmGetNextLoadOptionDevicePath(FilePath, FullPath);
+}
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v4 4/4] MdeModulePkg/CapsuleApp: Enhance CapsuleApp to support Capsule-on-Disk

2019-01-30 Thread Chen A Chen
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1482

CapsuleApp is used for trigger capsule update.
Add -OD option in CapsuleApp to support doing capsule update via storage.
Add -F and -L options to support dumping information feature.
Finish unit test for -F and -L options.
Already verify this feature on Denlow platform, success to update capsule
via hard disk with -OD option.

Cc: Jian J Wang 
Cc: Hao Wu 
Cc: Zhang Chao B 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
Reviewed-by: Jian J Wang 
---
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.c   | 160 +-
 MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf |   8 +
 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c  | 538 -
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 4 files changed, 690 insertions(+), 17 deletions(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 4d907242f3..896acd3304 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -1,7 +1,7 @@
 /** @file
   A shell application that triggers capsule update process.
 
-  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2019, Intel Corporation. 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
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -105,6 +106,46 @@ DumpEsrtData (
   VOID
   );
 
+/**
+  Dump Provisioned Capsule.
+
+  @param[in]  DumpCapsuleInfo  The flag to indicate whether to dump the 
capsule inforomation.
+**/
+VOID
+DumpProvisionedCapsule (
+  IN BOOLEAN  DumpCapsuleInfo
+  );
+
+/**
+  Dump all EFI System Partition.
+**/
+VOID
+DumpAllEfiSysPartition (
+  VOID
+  );
+
+/**
+  Process Capsule On Disk.
+
+  @param[in]  CapsuleBuffer   An array of pointer to capsule images
+  @param[in]  CapsuleBufferSize   An array of UINTN to capsule images size
+  @param[in]  FilePathAn array of capsule images file path
+  @param[in]  Map File system mapping string
+  @param[in]  CapsuleNum  The count of capsule images
+
+  @retval EFI_SUCCESS   Capsule on disk success.
+  @retval othersCapsule on disk fail.
+
+**/
+EFI_STATUS
+ProcessCapsuleOnDisk (
+  IN VOID  **CapsuleBuffer,
+  IN UINTN *CapsuleBufferSize,
+  IN CHAR16**FilePath,
+  IN CHAR16*Map,
+  IN UINTN CapsuleNum
+  );
+
 /**
   Read a file.
 
@@ -799,19 +840,22 @@ PrintUsage (
   )
 {
   Print(L"CapsuleApp:  usage\n");
-  Print(L"  CapsuleApp  [-NR]\n");
+  Print(L"  CapsuleApp  [-NR] [-OD [FSx]]\n");
   Print(L"  CapsuleApp -S\n");
   Print(L"  CapsuleApp -C\n");
   Print(L"  CapsuleApp -P\n");
   Print(L"  CapsuleApp -E\n");
+  Print(L"  CapsuleApp -L\n");
+  Print(L"  CapsuleApp -L INFO\n");
+  Print(L"  CapsuleApp -F\n");
   Print(L"  CapsuleApp -G  -O \n");
   Print(L"  CapsuleApp -N  -O \n");
   Print(L"  CapsuleApp -D \n");
   Print(L"  CapsuleApp -P GET   -O \n");
   Print(L"Parameter:\n");
-  Print(L"  -NR: No reset will be triggered for the capsule with\n");
-  Print(L"   CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without\n");
-  Print(L"   CAPSULE_FLAGS_INITIATE_RESET.\n");
+  Print(L"  -NR: No reset will be triggered for the capsule\n");
+  Print(L"   with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without 
CAPSULE_FLAGS_INITIATE_RESET.\n");
+  Print(L"  -OD: Delivery of Capsules via file on Mass Storage device.");
   Print(L"  -S:  Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
   Print(L"   which is defined in UEFI specification.\n");
   Print(L"  -C:  Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
@@ -820,6 +864,8 @@ PrintUsage (
   Print(L"   ImageTypeId and Index (decimal format) to a file if 'GET'\n");
   Print(L"   option is used.\n");
   Print(L"  -E:  Dump UEFI ESRT table info.\n");
+  Print(L"  -L:  Dump provisioned capsule image information.\n");
+  Print(L"  -F:  Dump all EFI System Partition.\n");
   Print(L"  -G:  Convert a BMP file to be an UX capsule,\n");
   Print(L"   according to Windows Firmware Update document\n");
   Print(L"  -N:  Append a Capsule Header to an existing FMP capsule image\n");
@@ -851,7 +897,7 @@ UefiMain (
 {
   EFI_STATUSStatus;
   RETURN_STATUS RStatus;
-  UINTN FileSize[MAX_CAPSULE_NUM];
+  UINTN CapsuleBufferSize[MAX_CAPSULE_NUM];
   VOID  *CapsuleBuffer[MAX_CAPSULE_NUM];
   EFI_CAPSULE_BLOCK_DESCRIPTOR  *BlockDescriptors;
   

Re: [edk2] [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc info is invalid

2019-01-30 Thread Bi, Dandan
Reviewed-by: Bi Dandan 

Thanks,
Dandan
> -Original Message-
> From: Hsueh, Hong-chihX
> Sent: Wednesday, January 30, 2019 9:20 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming
> ; Bi, Dandan ; Laszlo Ersek
> 
> Subject: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc info
> is invalid
> 
> Skip runtime relocation for PE images that provide invalid relocation
> infomation (ex: RelocDir->Size = 0) to fix a hang observed while booting
> Windows.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Neo Hsueh 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Dandan Bi 
> Cc: Laszlo Ersek 
> ---
>  MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 30
> --
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> index 1bd079ad6a..e2c62e1932 100644
> --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> @@ -1002,7 +1002,7 @@ PeCoffLoaderRelocateImage (
>  
> RelocDir->VirtualAddress + RelocDir-
> >Size - 1,
>  
> TeStrippedOffset
>  
> );
> -if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd <
> RelocBase) {
> +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN)
> + RelocBaseEnd < (UINTN) RelocBase) {
>ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
>return RETURN_LOAD_ERROR;
>  }
> @@ -1022,7 +1022,7 @@ PeCoffLoaderRelocateImage (
>  // Run the relocation information and apply the fixups
>  //
>  FixupData = ImageContext->FixupData;
> -while (RelocBase < RelocBaseEnd) {
> +while ((UINTN) RelocBase < (UINTN) RelocBaseEnd) {
> 
>Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof
> (EFI_IMAGE_BASE_RELOCATION));
>//
> @@ -1051,7 +1051,7 @@ PeCoffLoaderRelocateImage (
>//
>// Run this relocation record
>//
> -  while (Reloc < RelocEnd) {
> +  while ((UINTN) Reloc < (UINTN) RelocEnd) {
>  Fixup = PeCoffLoaderImageAddress (ImageContext, RelocBase-
> >VirtualAddress + (*Reloc & 0xFFF), TeStrippedOffset);
>  if (Fixup == NULL) {
>ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
> @@ -1739,13 +1739,23 @@ PeCoffLoaderRelocateImageForRuntime (
>// is present in the image. You have to check the NumberOfRvaAndSizes in
>// the optional header to verify a desired directory entry is there.
>//
> +  RelocBase = NULL;
> +  RelocBaseEnd = NULL;
>if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
>  RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
> -RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
> PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
> -RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
> PeCoffLoaderImageAddress (,
> -
> RelocDir->VirtualAddress + RelocDir-
> >Size - 1,
> -0
> -
> );
> +if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
> +  RelocBase = (EFI_IMAGE_BASE_RELOCATION *)
> PeCoffLoaderImageAddress (, RelocDir->VirtualAddress, 0);
> +  RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *)
> PeCoffLoaderImageAddress (,
> + 
>  RelocDir->VirtualAddress + RelocDir-
> >Size - 1,
> + 
>  0
> + 
>  );
> +}
> +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN) RelocBaseEnd
> < (UINTN) RelocBase) {
> +  //
> +  // relocation block is not valid, just return
> +  //
> +  return;
> +}
>} else {
>  //
>  // Cannot find relocations, cannot continue to relocate the image, ASSERT
> for this invalid image.
> @@ -1769,7 +1779,7 @@ PeCoffLoaderRelocateImageForRuntime (
>  //
>  FixupData = RelocationData;
>  RelocBaseOrig = RelocBase;
> -while (RelocBase < RelocBaseEnd) {
> +while ((UINTN) RelocBase < (UINTN) RelocBaseEnd) {
>//
>// Add check for RelocBase->SizeOfBlock field.
>//
> @@ -1794,7 +1804,7 @@ PeCoffLoaderRelocateImageForRuntime (
>//
>// Run this relocation record
>//
> -  while (Reloc < RelocEnd) {
> +  while ((UINTN) Reloc < (UINTN) RelocEnd) {
> 
>  Fixup = PeCoffLoaderImageAddress (, RelocBase-
> >VirtualAddress + (*Reloc & 0xFFF), 0);
>  

[edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths

2019-01-30 Thread Jeff Brasen
From: Edgar Handal 

Use 16-bit and 32-bit IO widths for SDMMC MMIO to prevent all register
accesses from being split up into 8-bit accesses.

The SDHCI specification states that the registers shall be accessable in
byte, word, and double word accesses.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jeff Brasen 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 25 
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
index 5aec8c6..82f4493 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
@@ -152,19 +152,36 @@ SdMmcHcRwMmio (
   )
 {
   EFI_STATUS   Status;
+  EFI_PCI_IO_PROTOCOL_WIDTHWidth;
 
   if ((PciIo == NULL) || (Data == NULL))  {
 return EFI_INVALID_PARAMETER;
   }
 
-  if ((Count != 1) && (Count != 2) && (Count != 4) && (Count != 8)) {
-return EFI_INVALID_PARAMETER;
+  switch (Count) {
+case 1:
+  Width = EfiPciIoWidthUint8;
+  break;
+case 2:
+  Width = EfiPciIoWidthUint16;
+  Count = 1;
+  break;
+case 4:
+  Width = EfiPciIoWidthUint32;
+  Count = 1;
+  break;
+case 8:
+  Width = EfiPciIoWidthUint32;
+  Count = 2;
+  break;
+default:
+  return EFI_INVALID_PARAMETER;
   }
 
   if (Read) {
 Status = PciIo->Mem.Read (
   PciIo,
-  EfiPciIoWidthUint8,
+  Width,
   BarIndex,
   (UINT64) Offset,
   Count,
@@ -173,7 +190,7 @@ SdMmcHcRwMmio (
   } else {
 Status = PciIo->Mem.Write (
   PciIo,
-  EfiPciIoWidthUint8,
+  Width,
   BarIndex,
   (UINT64) Offset,
   Count,
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 edk2-platforms 00/23] Platform/Raspberry: Add Raspberry Pi 3 support

2019-01-30 Thread Leif Lindholm
On Wed, Jan 30, 2019 at 09:59:34PM +, Leif Lindholm wrote:
> Hi Pete,
> 
> I have two annoying pieces of feedback that apply to the whole set.
> 
> Firstly, I would really appreciate if we could have some sort of
> commit messages rather than just subject lines.
> So, for ACPI, mention the provenance and limitations.
> For SMBIOS, version supported and any relevant omissions or surprising
> inclusions. And so on.
> 
> Secondly, we try to follow a //... pattern.
> Could you possibly find it in your heart to do a global move and
> search-and-replace of Platform/Raspberry to Platform/RaspberryPi?

Err, Ard has pointed out to me that I may want to be more explicit
here.
My request is to rename Platform/Raspberry to Platform/RaspberryPi,
such that we end up with Platform/RaspberryPi/Pi3/RPi3.dsc.

It would also look more consistent to me if we renamed the
subdirectory RPi3 instead of Pi3, but I don't actually _care_ :)

Best Regards,

Leif

> 
> Best Regards,
> 
> Leif
> 
> On Tue, Jan 29, 2019 at 04:26:32PM +, Pete Batard wrote:
> > Changes applied to v4:
> > 
> > * Silicon/Broadcom/Include has been moved to 
> > Silicon/Broadcom/Bcm283x/Include.
> >   The [Packages] and [Includes] directives were also updated accordingly.
> > * Move the GpioLib function declarations into their own separate header.
> > * Add NOOPT to BUILD_TARGETS.
> > * Remove the no longer needed '-mcmodel=small' workaround from AcpiTables.
> > 
> > Changes not applied to v4:
> > 
> > * Ensure that all the ACPI tables _CID names, and the rest of the tables, 
> > are
> >   ACPI specs compliant, since we are constrained with regards to their usage
> >   for Microsoft Windows.
> > 
> > 
> > Preamble:
> > 
> > Because of its price point, ease of use and availability, the Raspberry Pi 
> > is
> > undeniably one of the most successful ARM platform in existence today. Its
> > widespread adoption therefore makes it a perfect fit as an EDK2 platform.
> > 
> > However, up until now, the Raspberry Pi hasn't been supported as a bona fide
> > platform in our repository. This series of patches remedies that by 
> > introducing
> > the Raspberry Pi 3 Model B and Model B+ as a viable EDK2 platform.
> > 
> > Notes regarding non-OSI content:
> > 
> > * Even though the ARM Trusted Firmware binary blobs are subject to a
> >   BSD-3-Clause licence, which may be compatible with the EDK2 one, we chose
> >   to follow the lead of other platforms that provide ATF binaries in non 
> > OSI.
> >   Ultimately, once there is a new dot release of ATF, we plan to remove 
> > these
> >   binaries and point to a dot release build configuartion.
> > * The Device Tree binaries (and source descriptors) are subject to a GPLv2
> >   license, as per the ones published by the Raspberry Pi Foundation.
> > * The Logo source code is under an EDK2 license, but the logo itself, which
> >   we obtained authorisation to use from the Raspberry Pi Foundation itself
> >   after detailing our planned usage, is subject to the trademark licensing
> >   terms put forward by the Foundation.
> > 
> > Additional Notes:
> > 
> > * Detailed instructions on how to build and test the platform firmware are
> >   included in the Readme.md found at the root of the platform.
> > * As detailed in the Readme, the resulting platform firmware has been
> >   successfully used to install and run Linux OSes, such as Ubuntu 18.10, as
> >   well as Windows 10 1809 (*full* UI version, not IoT).
> > 
> > Regards,
> > 
> > /Pete
> > 
> > Pete Batard (23):
> >   Silicon/Broadcom/Bcm282x: Add interrupt driver
> >   Silicon/Broadcom/Bcm283x: Add GpioLib
> >   Platform/Raspberry/Pi3: Add ACPI tables
> >   Platform/Raspberry/Pi3: Add reset and memory init libraries
> >   Platform/Raspberry/Pi3: Add platform library
> >   Platform/Raspberry/Pi3: Add RTC library
> >   Platform/Raspberry/Pi3: Add firmware driver
> >   Platform/Raspberry/Pi3: Add platform config driver
> >   Platform/Raspberry/Pi3: Add SMBIOS driver
> >   Platform/Raspberry/Pi3: Add display driver
> >   Platform/Raspberry/Pi3: Add console driver
> >   Platform/Raspberry/Pi3: Add NV storage driver
> >   Platform/Raspberry/Pi3: Add Device Tree driver
> >   Platform/Raspberry/Pi3: Add base MMC driver
> >   Platform/Raspberry/Pi3: Add Arasan MMC driver
> >   Platform/Raspberry/Pi3: Platform/Raspberry/Pi3: Add SD Host driver
> >   Platform/Raspberry/Pi3: Add platform boot manager and helper libraries
> >   Platform/Raspberry/Pi3: Add USB host driver
> >   Platform/Raspberry/Pi3: Add platform
> >   Platform/Raspberry/Pi3: Add platform readme
> >   Platform/Raspberry/Pi3 *NON-OSI*: Add ATF binaries
> >   Platform/Raspberry/Pi3 *NON-OSI*: Add Device Tree binaries
> >   Platform/Raspberry/Pi3 *NON-OSI*: Add logo driver
> > 
> >  .../Raspberry/Pi3/AcpiTables/AcpiTables.h |   82 +
> >  .../Raspberry/Pi3/AcpiTables/AcpiTables.inf   |   46 +
> >  Platform/Raspberry/Pi3/AcpiTables/Csrt.aslc   |  332 +++
> >  Platform/Raspberry/Pi3/AcpiTables/Dbg2.aslc   |   34 

Re: [edk2] [PATCH v4 edk2-platforms 06/23] Platform/Raspberry/Pi3: Add RTC library

2019-01-30 Thread Leif Lindholm
First of all - this is something I would like to see contributed
directly to edk2 EmbeddedPkg. It's something me and Ard have discussed
adding at some point, but never getting around to.

I would also like to look into whether we could replace
PcdBootEpochSeconds with a -DBUILD_EPOCH=`date +%s` addition to the
CFLAGS in the .inf.

Regards,

Leif

On Tue, Jan 29, 2019 at 04:26:38PM +, Pete Batard wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Pete Batard 
> ---
>  
> Platform/Raspberry/Pi3/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
>| 221 
>  
> Platform/Raspberry/Pi3/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
>  |  43 
>  2 files changed, 264 insertions(+)
> 
> diff --git 
> a/Platform/Raspberry/Pi3/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
>  
> b/Platform/Raspberry/Pi3/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> new file mode 100644
> index ..dea621ff03ef
> --- /dev/null
> +++ 
> b/Platform/Raspberry/Pi3/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
> @@ -0,0 +1,221 @@
> +/** @file
> + *
> + *  Implement dummy EFI RealTimeClock runtime services.
> + *
> + *  Copyright (c) 2018, Andrei Warkentin 
> + *  Copyright (c) Microsoft Corporation. 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.
> + *
> + **/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> +   Returns the current time and date information, and the time-keeping 
> capabilities
> +   of the virtual RTC.
> +
> +   For simplicity, this LibGetTime does not report Years/Months, instead it 
> will only report current
> +   Day, Hours, Minutes and Seconds starting from the begining of CPU 
> up-time. Otherwise, a more
> +   complex logic will be required to account for leap years and days/month 
> differences.
> +
> +   @param  Time  A pointer to storage to receive a snapshot 
> of the current time.
> +   @param  Capabilities  An optional pointer to a buffer to receive 
> the real time clock
> +   device's capabilities.
> +
> +   @retval EFI_SUCCESS   The operation completed successfully.
> +   @retval EFI_INVALID_PARAMETER Time is NULL.
> +   @retval EFI_DEVICE_ERROR  The time could not be retrieved due to 
> hardware error.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +LibGetTime (
> +  OUT EFI_TIME   *Time,
> +  OUT EFI_TIME_CAPABILITIES  *Capabilities
> +  )
> +{
> +  UINTN DataSize;
> +  UINT64 Counter;
> +  EFI_STATUS Status;
> +  UINTN ElapsedSeconds;
> +  UINT32 Remainder;
> +  UINT32 Freq = ArmGenericTimerGetTimerFreq ();
> +
> +  if (Time == NULL) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  //
> +  // Depend on ARM generic timer to report date/time relative to the
> +  // start of CPU timer counting where date and time will always
> +  // be relative to the date/time 1/1/1900 00H:00M:00S
> +  //
> +
> +  ASSERT (Freq != 0);
> +  if (Freq == 0) {
> +return EFI_DEVICE_ERROR;
> +  }
> +
> +  if (Capabilities) {
> +Capabilities->Accuracy = 0;
> +Capabilities->Resolution = Freq;
> +Capabilities->SetsToZero = FALSE;
> +  }
> +
> +  DataSize = sizeof (UINTN);
> +  ElapsedSeconds = 0;
> +  Status = EfiGetVariable (L"RtcEpochSeconds",
> + ,
> + NULL,
> + ,
> + );
> +  if (EFI_ERROR (Status)) {
> +ElapsedSeconds = PcdGet64 (PcdBootEpochSeconds);
> +  }
> +  Counter = GetPerformanceCounter ();
> +  ElapsedSeconds += DivU64x32Remainder (Counter, Freq, );
> +  EpochToEfiTime (ElapsedSeconds, Time);
> +
> +  //
> +  // Frequency < 0x1, so Remainder < 0x1, then (Remainder * 
> 1,000,000,000)
> +  // will not overflow 64-bit.
> +  //
> +  Time->Nanosecond = DivU64x32 (MultU64x64 ((UINT64)Remainder, 10U), 
> Freq);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +
> +/**
> +   Sets the current local time and date information.
> +
> +   @param  Time  A pointer to the current time.
> +
> +   @retval EFI_SUCCESS   The operation completed successfully.
> +   @retval EFI_INVALID_PARAMETER A time field is out of range.
> +   @retval EFI_DEVICE_ERROR  The time could not be set due due to 
> hardware error.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +LibSetTime (
> +  IN EFI_TIME  *Time
> +  )
> +{
> +  UINTN Epoch;
> +
> +  if (!IsTimeValid (Time)) {
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Epoch = EfiTimeToEpoch (Time);
> +  return 

Re: [edk2] [PATCH v4 edk2-platforms 00/23] Platform/Raspberry: Add Raspberry Pi 3 support

2019-01-30 Thread Leif Lindholm
Hi Pete,

I have two annoying pieces of feedback that apply to the whole set.

Firstly, I would really appreciate if we could have some sort of
commit messages rather than just subject lines.
So, for ACPI, mention the provenance and limitations.
For SMBIOS, version supported and any relevant omissions or surprising
inclusions. And so on.

Secondly, we try to follow a //... pattern.
Could you possibly find it in your heart to do a global move and
search-and-replace of Platform/Raspberry to Platform/RaspberryPi?

Best Regards,

Leif

On Tue, Jan 29, 2019 at 04:26:32PM +, Pete Batard wrote:
> Changes applied to v4:
> 
> * Silicon/Broadcom/Include has been moved to Silicon/Broadcom/Bcm283x/Include.
>   The [Packages] and [Includes] directives were also updated accordingly.
> * Move the GpioLib function declarations into their own separate header.
> * Add NOOPT to BUILD_TARGETS.
> * Remove the no longer needed '-mcmodel=small' workaround from AcpiTables.
> 
> Changes not applied to v4:
> 
> * Ensure that all the ACPI tables _CID names, and the rest of the tables, are
>   ACPI specs compliant, since we are constrained with regards to their usage
>   for Microsoft Windows.
> 
> 
> Preamble:
> 
> Because of its price point, ease of use and availability, the Raspberry Pi is
> undeniably one of the most successful ARM platform in existence today. Its
> widespread adoption therefore makes it a perfect fit as an EDK2 platform.
> 
> However, up until now, the Raspberry Pi hasn't been supported as a bona fide
> platform in our repository. This series of patches remedies that by 
> introducing
> the Raspberry Pi 3 Model B and Model B+ as a viable EDK2 platform.
> 
> Notes regarding non-OSI content:
> 
> * Even though the ARM Trusted Firmware binary blobs are subject to a
>   BSD-3-Clause licence, which may be compatible with the EDK2 one, we chose
>   to follow the lead of other platforms that provide ATF binaries in non OSI.
>   Ultimately, once there is a new dot release of ATF, we plan to remove these
>   binaries and point to a dot release build configuartion.
> * The Device Tree binaries (and source descriptors) are subject to a GPLv2
>   license, as per the ones published by the Raspberry Pi Foundation.
> * The Logo source code is under an EDK2 license, but the logo itself, which
>   we obtained authorisation to use from the Raspberry Pi Foundation itself
>   after detailing our planned usage, is subject to the trademark licensing
>   terms put forward by the Foundation.
> 
> Additional Notes:
> 
> * Detailed instructions on how to build and test the platform firmware are
>   included in the Readme.md found at the root of the platform.
> * As detailed in the Readme, the resulting platform firmware has been
>   successfully used to install and run Linux OSes, such as Ubuntu 18.10, as
>   well as Windows 10 1809 (*full* UI version, not IoT).
> 
> Regards,
> 
> /Pete
> 
> Pete Batard (23):
>   Silicon/Broadcom/Bcm282x: Add interrupt driver
>   Silicon/Broadcom/Bcm283x: Add GpioLib
>   Platform/Raspberry/Pi3: Add ACPI tables
>   Platform/Raspberry/Pi3: Add reset and memory init libraries
>   Platform/Raspberry/Pi3: Add platform library
>   Platform/Raspberry/Pi3: Add RTC library
>   Platform/Raspberry/Pi3: Add firmware driver
>   Platform/Raspberry/Pi3: Add platform config driver
>   Platform/Raspberry/Pi3: Add SMBIOS driver
>   Platform/Raspberry/Pi3: Add display driver
>   Platform/Raspberry/Pi3: Add console driver
>   Platform/Raspberry/Pi3: Add NV storage driver
>   Platform/Raspberry/Pi3: Add Device Tree driver
>   Platform/Raspberry/Pi3: Add base MMC driver
>   Platform/Raspberry/Pi3: Add Arasan MMC driver
>   Platform/Raspberry/Pi3: Platform/Raspberry/Pi3: Add SD Host driver
>   Platform/Raspberry/Pi3: Add platform boot manager and helper libraries
>   Platform/Raspberry/Pi3: Add USB host driver
>   Platform/Raspberry/Pi3: Add platform
>   Platform/Raspberry/Pi3: Add platform readme
>   Platform/Raspberry/Pi3 *NON-OSI*: Add ATF binaries
>   Platform/Raspberry/Pi3 *NON-OSI*: Add Device Tree binaries
>   Platform/Raspberry/Pi3 *NON-OSI*: Add logo driver
> 
>  .../Raspberry/Pi3/AcpiTables/AcpiTables.h |   82 +
>  .../Raspberry/Pi3/AcpiTables/AcpiTables.inf   |   46 +
>  Platform/Raspberry/Pi3/AcpiTables/Csrt.aslc   |  332 +++
>  Platform/Raspberry/Pi3/AcpiTables/Dbg2.aslc   |   34 +
>  Platform/Raspberry/Pi3/AcpiTables/Dsdt.asl|  511 +
>  Platform/Raspberry/Pi3/AcpiTables/Fadt.aslc   |   52 +
>  Platform/Raspberry/Pi3/AcpiTables/Gtdt.aslc   |   33 +
>  Platform/Raspberry/Pi3/AcpiTables/Madt.aslc   |   62 +
>  Platform/Raspberry/Pi3/AcpiTables/Pep.asl |   95 +
>  Platform/Raspberry/Pi3/AcpiTables/Pep.c   |   84 +
>  Platform/Raspberry/Pi3/AcpiTables/Pep.h   |  126 ++
>  Platform/Raspberry/Pi3/AcpiTables/Rhpx.asl|  201 ++
>  Platform/Raspberry/Pi3/AcpiTables/Sdhc.asl|  105 +
>  Platform/Raspberry/Pi3/AcpiTables/Spcr.asl|   53 +
>  Platform/Raspberry/Pi3/AcpiTables/Uart.asl

Re: [edk2] [PATCH v4 edk2-platforms 20/23] Platform/Raspberry/Pi3: Add platform readme

2019-01-30 Thread Leif Lindholm
Hi Pete,

I will only have minor comments on this set, but I'll start with this
documentation.

On Tue, Jan 29, 2019 at 04:26:52PM +, Pete Batard wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Pete Batard 
> ---
>  Platform/Raspberry/Pi3/Readme.md | 259 
>  Readme.md|   3 +
>  2 files changed, 262 insertions(+)
> 
> diff --git a/Platform/Raspberry/Pi3/Readme.md 
> b/Platform/Raspberry/Pi3/Readme.md
> new file mode 100644
> index ..7fb59ccdc321
> --- /dev/null
> +++ b/Platform/Raspberry/Pi3/Readme.md
> @@ -0,0 +1,259 @@
> +Raspberry Pi 3 EDK2 Platform Support
> +
> +
> +# Summary
> +
> +This is a port of 64-bit Tiano Core UEFI firmware for the Raspberry Pi 3/3B+ 
> platforms,
> +based on [Ard Bisheuvel's 
> 64-bit](http://www.workofard.com/2017/02/uefi-on-the-pi/)
> +and [Microsoft's 
> 32-bit](https://github.com/ms-iot/RPi-UEFI/tree/ms-iot/Pi3BoardPkg)
> +implementations, as maintained by [Andrei 
> Warkentin](https://github.com/andreiw/RaspberryPiPkg).
> +
> +This is meant as a generally useful 64-bit ATF + UEFI implementation for the 
> Raspberry
> +Pi 3/3B+ which should be good enough for most kind of UEFI development, as 
> well as for
> +running consummer Operating Systems in such as Linux or Windows.
> +
> +Raspberry Pi is a trademark of the [Raspberry Pi 
> Foundation](http://www.raspberrypi.org).
> +
> +# Status
> +
> +This firmware, that has been validated to compile against the current
> +[edk2](https://github.com/tianocore/edk2)/[edk2-platforms](https://github.com/tianocore/edk2-platforms),
> +should be able to boot Linux (SUSE, Ubuntu), NetBSD, FreeBSD as well as 
> Windows 10 ARM64
> +(full GUI version).
> +
> +It also provides support for ATF ([Arm Trusted 
> Platform](https://github.com/ARM-software/arm-trusted-firmware)).
> +
> +HDMI and the mini-UART serial port can be used for output devices, with 
> mirrored output.
> +USB keyboards and the mini-UART serial port can be used as input.
> +
> +The boot order is currently hardcoded, first to the USB ports and then to 
> the uSD card.
> +If there no bootable media media is found, the UEFI Shell is launched.
> +Esc enters platform setup. F1 boots the UEFI Shell.
> +
> +# Building
> +
> +(These instructions were validated against the latest edk2 / edk2-platforms /
> +edk2-non-osi as of 2019.01.27, on a Debian 9.6 x64 system).
> +
> +You may need to install the relevant compilation tools. Especially you 
> should have the
> +ACPI Source Language (ASL) compiler, `nasm` as well as a native compiler 
> installed.

nasm? The x86 assembler?

> +On a Debian system, you can get these prerequisites installed with:
> +```
> +sudo apt-get install build-essential acpica-tools nasm uuid-dev
> +```
> +
> +**IMPORTANT:** We recommend the use of the Linaro GCC for compilation 
> instead of
> +your system's native ARM64 GCC cross compiler.

This sounds like something written in the days of GCC 4.8. I doubt it
has any relevance today.

Also, and this applies both above and below: I am trying very hard to
get rid of (mostly unnecessary) platform-specific build instructions.
The top-level Readme.md in this repository contains basic build
instructions. I would much prefer if you can refer to that instead and
drop everything after the # Building header above...

> +
> +You can then build the firmware as follows:
> +
> +* Standalone instructions
> +
> +```
> +mkdir ~/workspace
> +cd ~/workspace
> +git clone https://github.com/tianocore/edk2.git
> +# The following is only needed once, after you cloned edk2
> +make -C edk2/BaseTools
> +git clone https://github.com/tianocore/edk2-platforms.git
> +git clone https://github.com/tianocore/edk2-non-osi.git
> +wget 
> https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
> +tar -xJvf gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
> +# If you have multiple AARCH64 toolchains, make sure the above one comes 
> first in your path
> +export PATH=$PWD/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:$PATH
> +export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
> +export WORKSPACE=$PWD
> +export 
> PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi
> +. edk2/edksetup.sh

...down to here.
(I would certainly not object if you felt the need to improve on the
contents of the top-level Readme.md. For example with the explicit
prerequisite installation steps, rather than the brief list provided
under the Prerequisites section currently on that page.)

> +build -a AARCH64 -t GCC5 -p edk2-platforms/Platform/Raspberry/Pi3/RPi3.dsc 
> -DBUILD_EPOCH=`date +%s` -b RELEASE
> +```
> +

The below _is_ platform-specific, so clearly I have no issue with
it. Not sure that needed poinging out, but...
And the above line points out the location of the .dsc, so no
objection there.

> +# Booting the 

Re: [edk2] [PATCH edk2-staging 10/20] IntelUndiPkg/XGigUndiDxe: drop StdLibC library class reference

2019-01-30 Thread Kinney, Michael D
Hi Richard,

It is possible to update C code to prevent the use of compiler
intrinsic functions.  This is what we have done for EDK II modules
that are built for both IA32 and X64.

The one exception is the use of OpenSSL.  We prefer to use that
project "as is" as a git submodule, so modifying the OpenSSL
sources to prevent use of intrinsic functions was not practical.
The CryptoPkg has the minimum set of intrinsic functions required
For OpenSSL to build.

We do recognize that this issue is difficult for developers to
resolve because the techniques require generation of mixed C/asm
output files to track down the C statements that are generating
the intrinsic functions.

Similar to the ARM support for an intrinsic lib, it may be 
reasonable to add a small intrinsic lib for IA32 and X64 that
supports the intrinsic functions that are seen the most often.
May  require an intrinsic lib for each supported tool chain.

This would be a new feature that would take some effort to 
implement and validate.  Can you enter an Bugzilla for this
feature and list the specific intrinsic functions needed for
this driver?

Thanks,

Mike

> -Original Message-
> From: Ryszard Knop
> [mailto:ryszard.k...@linux.intel.com]
> Sent: Wednesday, January 30, 2019 9:27 AM
> To: Ard Biesheuvel ; edk2-
> de...@lists.01.org; Carsey, Jaben
> 
> Cc: Kacperski, Kamil ; Jin,
> Eric ; Orlowski, Pawel
> ; Kinney, Michael D
> ; Hsiung, Harry L
> 
> Subject: Re: [edk2] [PATCH edk2-staging 10/20]
> IntelUndiPkg/XGigUndiDxe: drop StdLibC library class
> reference
> 
> That's actually not quite correct - we need this
> package to build on
> IA32. It's named rather unfortunately, since it's not
> the EDK2 StdLibC,
> but rather a package in this repository - see
> IntelUndiPkg/LibC. It
> contains the bare minimum of functionality required to
> fix missing 64-
> bit math/shifts on IA32 and missing memcpy/memset
> intrinsics. We can't
> prevent MSVC from yielding memcpy/memset either, so
> this was the nasty
> solution for build issues. You have included
> CompilerIntrinsicsLib for
> the same reason, too :)
> 
> I'm not aware of any X64/IA32 equivalent of your
> CompilerIntrinsicsLib,
> but I'd be happy to be proven wrong here. I'm off for
> the rest of the
> week - I'll continue with reviews and merging early
> next week.
> 
> Thanks, Richard.
> 
> On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela
> wrote:
> > StdLibc should not be used in drivers (it has
> dependencies on Shell
> > protocols), but in fact, we don't appear to rely on
> it in the first
> > place, so just drop the reference.
> >
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> > Signed-off-by: Ard Biesheuvel  linaro.org>
> > ---
> >  IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> > b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> > index beee8aa8134e..b5747565fbea 100644
> > --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> > +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> > @@ -132,7 +132,6 @@ GCC:*_*_*_CC_FLAGS = -DEFI32
> >PrintLib
> >UefiLib
> >HiiLib
> > -  StdLibC
> >
> >  [LibraryClasses.X64]
> >

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 edk2-platforms 00/23] Platform/Raspberry: Add Raspberry Pi 3 support

2019-01-30 Thread Ard Biesheuvel
On Wed, 30 Jan 2019 at 20:42, Leif Lindholm  wrote:
>
> On Wed, Jan 30, 2019 at 08:38:19PM +0100, Ard Biesheuvel wrote:
> > On Tue, 29 Jan 2019 at 22:10, Pete Batard  wrote:
> > >
> > > On 2019.01.29 17:40, Ard Biesheuvel wrote:
> > > > I managed to build and run a RELEASE image, and I must say, I'm
> > > > impressed. It works really well, and looks really slick too. Thanks a
> > > > lot for taking the time to upstream this, it makes the RPI3 a lot more
> > > > usable for people that want to run a generic distro.
> > >
> > > I'm very happy to hear that.
> > >
> > > Indeed, our hope is that, once the firmware gets "officialized" into
> > > edk2-platforms, mainline Linux distros will switch to using its
> > > facilities and make the whole Linux boot process a friendlier/more
> > > familiar experience for Pi3 users.
> > >
> > > Of course, you have to thank Andrei Warkentin for this nice outcome,
> > > since he put a lot of effort into it, as well as all the people who
> > > contributed to the firmware (including Linaro & Microsoft).
> > >
> > > > Tested-by: Ard Biesheuvel 
> > >
> > > Many thanks for this.
> > >
> >
> > What happened to patch #20? I don't think I received it.
>
> I have it, both for my cc and from the list.
> It's also in the archive:
> https://lists.01.org/pipermail/edk2-devel/2019-January/035947.html
>

OK, found it in my spam folder :-)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 edk2-platforms 00/23] Platform/Raspberry: Add Raspberry Pi 3 support

2019-01-30 Thread Leif Lindholm
On Wed, Jan 30, 2019 at 08:38:19PM +0100, Ard Biesheuvel wrote:
> On Tue, 29 Jan 2019 at 22:10, Pete Batard  wrote:
> >
> > On 2019.01.29 17:40, Ard Biesheuvel wrote:
> > > I managed to build and run a RELEASE image, and I must say, I'm
> > > impressed. It works really well, and looks really slick too. Thanks a
> > > lot for taking the time to upstream this, it makes the RPI3 a lot more
> > > usable for people that want to run a generic distro.
> >
> > I'm very happy to hear that.
> >
> > Indeed, our hope is that, once the firmware gets "officialized" into
> > edk2-platforms, mainline Linux distros will switch to using its
> > facilities and make the whole Linux boot process a friendlier/more
> > familiar experience for Pi3 users.
> >
> > Of course, you have to thank Andrei Warkentin for this nice outcome,
> > since he put a lot of effort into it, as well as all the people who
> > contributed to the firmware (including Linaro & Microsoft).
> >
> > > Tested-by: Ard Biesheuvel 
> >
> > Many thanks for this.
> >
> 
> What happened to patch #20? I don't think I received it.

I have it, both for my cc and from the list.
It's also in the archive:
https://lists.01.org/pipermail/edk2-devel/2019-January/035947.html

/
Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms] Silicon/Bcm2836: add random number generator driver

2019-01-30 Thread Ard Biesheuvel
Expose the SoC's RNG peripheral via the EFI_RNG_PROTOCOL.
This is used by Linux to seed the KASLR routines.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c   | 204 

 Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.inf |  45 +
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836Rng.h |  26 +++
 3 files changed, 275 insertions(+)

diff --git a/Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c 
b/Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c
new file mode 100644
index ..b1bc93ce0381
--- /dev/null
+++ b/Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c
@@ -0,0 +1,204 @@
+/** @file
+
+  This driver produces an EFI_RNG_PROTOCOL instance for the Broadcom 2836 RNG
+
+  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.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#define RNG_WARMUP_COUNT0x4
+#define RNG_MAX_RETRIES 0x100 // arbitrary upper bound
+
+/**
+  Returns information about the random number generation implementation.
+
+  @param[in] This A pointer to the EFI_RNG_PROTOCOL
+  instance.
+  @param[in,out] RNGAlgorithmListSize On input, the size in bytes of
+  RNGAlgorithmList.
+  On output with a return code of
+  EFI_SUCCESS, the size in bytes of the
+  data returned in RNGAlgorithmList. On
+  output with a return code of
+  EFI_BUFFER_TOO_SMALL, the size of
+  RNGAlgorithmList required to obtain the
+  list.
+  @param[out] RNGAlgorithmListA caller-allocated memory buffer filled
+  by the driver with one EFI_RNG_ALGORITHM
+  element for each supported RNG algorithm.
+  The list must not change across multiple
+  calls to the same driver. The first
+  algorithm in the list is the default
+  algorithm for the driver.
+
+  @retval EFI_SUCCESS The RNG algorithm list was returned
+  successfully.
+  @retval EFI_UNSUPPORTED The services is not supported by this
+  driver.
+  @retval EFI_DEVICE_ERRORThe list of algorithms could not be
+  retrieved due to a hardware or firmware
+  error.
+  @retval EFI_INVALID_PARAMETER   One or more of the parameters are
+  incorrect.
+  @retval EFI_BUFFER_TOO_SMALLThe buffer RNGAlgorithmList is too small
+  to hold the result.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+Bcm2836RngGetInfo (
+  IN  EFI_RNG_PROTOCOL*This,
+  IN OUT  UINTN   *RNGAlgorithmListSize,
+  OUT EFI_RNG_ALGORITHM   *RNGAlgorithmList
+  )
+{
+  if (This == NULL || RNGAlgorithmListSize == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  if (*RNGAlgorithmListSize < sizeof (EFI_RNG_ALGORITHM)) {
+*RNGAlgorithmListSize = sizeof (EFI_RNG_ALGORITHM);
+return EFI_BUFFER_TOO_SMALL;
+  }
+
+  if (RNGAlgorithmList == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  *RNGAlgorithmListSize = sizeof (EFI_RNG_ALGORITHM);
+  CopyGuid (RNGAlgorithmList, );
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Produces and returns an RNG value using either the default or specified RNG
+  algorithm.
+
+  @param[in]  ThisA pointer to the EFI_RNG_PROTOCOL
+  instance.
+  @param[in]  RNGAlgorithmA pointer to the EFI_RNG_ALGORITHM that
+  identifies the RNG algorithm to use. May
+  be NULL in which case the function will
+  use its default RNG algorithm.
+  @param[in]  RNGValueLength  The length in bytes of the memory buffer
+  pointed to by RNGValue. The driver shall
+  

Re: [edk2] [PATCH v4 edk2-platforms 00/23] Platform/Raspberry: Add Raspberry Pi 3 support

2019-01-30 Thread Ard Biesheuvel
On Tue, 29 Jan 2019 at 22:10, Pete Batard  wrote:
>
> On 2019.01.29 17:40, Ard Biesheuvel wrote:
> > I managed to build and run a RELEASE image, and I must say, I'm
> > impressed. It works really well, and looks really slick too. Thanks a
> > lot for taking the time to upstream this, it makes the RPI3 a lot more
> > usable for people that want to run a generic distro.
>
> I'm very happy to hear that.
>
> Indeed, our hope is that, once the firmware gets "officialized" into
> edk2-platforms, mainline Linux distros will switch to using its
> facilities and make the whole Linux boot process a friendlier/more
> familiar experience for Pi3 users.
>
> Of course, you have to thank Andrei Warkentin for this nice outcome,
> since he put a lot of effort into it, as well as all the people who
> contributed to the firmware (including Linaro & Microsoft).
>
> > Tested-by: Ard Biesheuvel 
>
> Many thanks for this.
>

What happened to patch #20? I don't think I received it.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 10/20] IntelUndiPkg/XGigUndiDxe: drop StdLibC library class reference

2019-01-30 Thread Andrew Fish via edk2-devel
> On Jan 30, 2019, at 9:26 AM, Ryszard Knop  
> wrote:
> 
> That's actually not quite correct - we need this package to build on
> IA32. It's named rather unfortunately, since it's not the EDK2 StdLibC,
> but rather a package in this repository - see IntelUndiPkg/LibC. It
> contains the bare minimum of functionality required to fix missing 64-
> bit math/shifts on IA32 and missing memcpy/memset intrinsics. We can't
> prevent MSVC from yielding memcpy/memset either, so this was the nasty
> solution for build issues. You have included CompilerIntrinsicsLib for
> the same reason, too :)
> 

Ryszard,

For IA32/X64 we avoid the compiler intrinsic libs via the coding standard. 
1) If you don't assign something too large at execution time with an = the 
compiler will not inline memcpy()/memset()
2) BaseLib.h has all the math functions that generate intrinsics that your code 
can call explicitly: 
https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/BaseLib.h#L3533
 


UINT64 X=0x1;
UINT64 Y=2;

So:
Y = X*Y;
should be:
Y = MultU64x64 (X, Y);

When ARM got added much later and some versions of ARM did not even have a 
divide instruction we gave up on trying to add more functions into all the 
existing IA32 code, and add the intrinsic lib. 

If we are going to add an intrinsic lib for x86 then we should probably add it 
to the MdePkg and it needs to support MSVC and GCC (as far as I can tell clang 
should work with the GCC intrinsics). 

Thanks,

Andrew Fish


> I'm not aware of any X64/IA32 equivalent of your CompilerIntrinsicsLib,
> but I'd be happy to be proven wrong here. I'm off for the rest of the
> week - I'll continue with reviews and merging early next week.
> 
> Thanks, Richard.
> 
> On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
>> StdLibc should not be used in drivers (it has dependencies on Shell
>> protocols), but in fact, we don't appear to rely on it in the first
>> place, so just drop the reference.
>> 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel 
>> ---
>> IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf | 1 -
>> 1 file changed, 1 deletion(-)
>> 
>> diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
>> b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
>> index beee8aa8134e..b5747565fbea 100644
>> --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
>> +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
>> @@ -132,7 +132,6 @@ GCC:*_*_*_CC_FLAGS = -DEFI32
>>   PrintLib
>>   UefiLib
>>   HiiLib
>> -  StdLibC
>> 
>> [LibraryClasses.X64]
>> 
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.

2019-01-30 Thread Leif Lindholm
I updated the subject line to start with EmbeddedPkg: instead.

On Thu, Jan 24, 2019 at 07:35:18PM +0530, Meenakshi Aggarwal wrote:
> Issue : SD read failure for high capacity cards e.g. 64 GB
> i

And I dropped the above stray i.
Reviewed-by: Leif Lindholm 

Pushed as b566259c8a.

Thanks!

> Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
> and cant be fit into 32 bit wide SD host controller register.
> 
> Fix :
> AccessMode bits [29:30] of OCR is a valid definition to calculate
> data address for eMMC cards.
> 
> For SD cards, data address is calculated on the basis of
> card capacity status bit[30] of OCR.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  EmbeddedPkg/Universal/MmcDxe/Mmc.h|  2 ++
>  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 -
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h 
> b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> index a77ba41..62de2c8 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> @@ -70,6 +70,8 @@
>  #define SD_HIGH_SPEED   5000
>  #define SWITCH_CMD_SUCCESS_MASK 0x0f00
>  
> +#define SD_CARD_CAPACITY0x0002
> +
>  #define BUSWIDTH_4  4
>  
>  typedef enum {
> diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c 
> b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> index a2b9232..1dea7d3 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> @@ -148,12 +148,23 @@ MmcTransferBlock (
>MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
>MmcHost = MmcHostInstance->MmcHost;
>  
> -  //Set command argument based on the card access mode (Byte mode or Block 
> mode)
> -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
> -  MMC_OCR_ACCESS_SECTOR) {
> -CmdArg = Lba;
> +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> +//Set command argument based on the card capacity
> +//if 0 : SDSC card
> +//if 1 : SDXC/SDHC
> +if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) {
> +  CmdArg = Lba;
> +} else {
> +  CmdArg = Lba * This->Media->BlockSize;
> +}
>} else {
> -CmdArg = Lba * This->Media->BlockSize;
> +//Set command argument based on the card access mode (Byte mode or Block 
> mode)
> +if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) 
> ==
> +MMC_OCR_ACCESS_SECTOR) {
> +  CmdArg = Lba;
> +} else {
> +  CmdArg = Lba * This->Media->BlockSize;
> +}
>}
>  
>Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> -- 
> 1.9.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 10/20] IntelUndiPkg/XGigUndiDxe: drop StdLibC library class reference

2019-01-30 Thread Ryszard Knop
That's actually not quite correct - we need this package to build on
IA32. It's named rather unfortunately, since it's not the EDK2 StdLibC,
but rather a package in this repository - see IntelUndiPkg/LibC. It
contains the bare minimum of functionality required to fix missing 64-
bit math/shifts on IA32 and missing memcpy/memset intrinsics. We can't
prevent MSVC from yielding memcpy/memset either, so this was the nasty
solution for build issues. You have included CompilerIntrinsicsLib for
the same reason, too :)

I'm not aware of any X64/IA32 equivalent of your CompilerIntrinsicsLib,
but I'd be happy to be proven wrong here. I'm off for the rest of the
week - I'll continue with reviews and merging early next week.

Thanks, Richard.

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> StdLibc should not be used in drivers (it has dependencies on Shell
> protocols), but in fact, we don't appear to rely on it in the first
> place, so just drop the reference.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> index beee8aa8134e..b5747565fbea 100644
> --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> @@ -132,7 +132,6 @@ GCC:*_*_*_CC_FLAGS = -DEFI32
>PrintLib
>UefiLib
>HiiLib
> -  StdLibC
>  
>  [LibraryClasses.X64]
>

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 18/20] IntelUndiPkg/XGigUndiDxe: set MDEPKG_NDEBUG only for RELEASE builds

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Only define the CPP macro MDEPKG_NDEBUG for the RELEASE target so
> that debug features are functional otherwise.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> index b5747565fbea..e3201fb9881f 100644
> --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> @@ -44,7 +44,8 @@ UNLOAD_IMAGE = UnloadXGigUndiDriver
>  
>  [BuildOptions.common]
>  
> -MSFT:*_*_*_CC_FLAGS = /FAcs /D MDEPKG_NDEBUG /D UNDI_10G /wd4244
> /wd4206 /wd4189
> +MSFT:*_*_*_CC_FLAGS = /FAcs /D UNDI_10G /wd4244 /wd4206 /wd4189
> +MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
>  GCC:*_*_*_CC_FLAGS = -DUNDI_10G
>  GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>  

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [platforms: PATCH v3 0/5] Armada7k8k memory handling update

2019-01-30 Thread Leif Lindholm
Thanks for the rework.

(We should probably move that broken-out function to ArmPkg at some point.)

For the series:
Reviewed-by: Leif Lindholm 

Pushed as b0bb325f20..0a7d8e7d93.

On Mon, Jan 28, 2019 at 10:45:10AM +0100, Marcin Wojtas wrote:
> Hi,
> 
> The third version of the patchset moves the new common
> header for Marvell SMC ID's to the IndustryStandard directory.
> What is more important, now 3 regions (described by new PCDs)
> are reserved separately. For that purpose a preparation
> patch was added, which extract existing reservation code
> into a new subroutine. More details can be found in
> the changelog below and the commit messages.
> 
> Patches are available in the github:
> https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/dram-upstream-r20190128
> 
> I'm looking forward to the comments and remarks.
> 
> Best regards,
> Marcin
> 
> Changelog:
> v2 -> v3
> * 1/5
>   - New patch - extract memory reservation to a separate routine
> 
> * 2/2
>   - Add new PCDs and reserve 3 regions (ARM-TF, PEI stack, OP-TEE)
> separately
>   - Update commit message accordingly
> 
> * 3/5
>   - Move MvSmc.h to Include/IndustryStandard
> 
> * 4,5/5
>   - Add Leif's RB
> 
> v1 -> v2:
> * 1/4
>   - Improve commit log - mention single area size and new PEI stack base
> 
> * 2/4 (new patch)
>   - Add common header for Marvell SMC ID's
> 
> * 3/4
>   - Add function description comment
>   - Define and use ARMADA7K8K_AP806_INDEX
>   - Change function argument to EFI_PHYSICAL_ADDRESS
> 
> * 4/4
>   - Move new SMC ID to MvSmc.h
>   - Include ArmadaSoCDescLib.h directly (instead indirectly via BoardDesc.h)
>   - Remove ARMADA7K8K_AP806_INDEX macro
> 
> Grzegorz Jaszczyk (2):
>   Marvell/Library: ArmadaSoCDescLib: Add North Bridge description
>   Marvell/Armada7k8k: Read DRAM settings from ARM-TF
> 
> Marcin Wojtas (3):
>   Marvell/Armada7k8k: Refactor reserving memory regions
>   Marvell/Armada7k8k: Shift PEI stack base and extend memory reservation
>   Marvell/Library: Introduce common header for the SMC ID's
> 
>  Silicon/Marvell/Marvell.dec  
> |   8 +-
>  Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
> |  16 ++-
>  Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLib.inf   
> |   3 +
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kMemoryInitPeiLib/Armada7k8kMemoryInitPeiLib.inf
>  |   8 +-
>  Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLibMem.h  
> |  25 -
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
>|   6 ++
>  Silicon/Marvell/Include/IndustryStandard/MvSmc.h 
> |  24 +
>  Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h   
> |  28 +
>  Silicon/Marvell/Library/ComPhyLib/ComPhySipSvc.h 
> |   8 +-
>  Silicon/Marvell/Armada7k8k/Library/Armada7k8kLib/Armada7k8kLibMem.c  
> |  60 ---
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kMemoryInitPeiLib/Armada7k8kMemoryInitPeiLib.c
>| 107 +---
>  
> Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
>|  34 +++
>  Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c  
> |  14 +--
>  13 files changed, 220 insertions(+), 121 deletions(-)
>  create mode 100644 Silicon/Marvell/Include/IndustryStandard/MvSmc.h
> 
> -- 
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 07/20] IntelUndiPkg/XGigUndiDxe: drop definition of gImageHandle

2019-01-30 Thread Andrew Fish via edk2-devel



> On Jan 30, 2019, at 8:05 AM, Ryszard Knop  
> wrote:
> 
> Hmm, is there a list/something I can generate to see which globals
> build tools emit? There are some more variables I'd happily get rid
> of, eg if I could drop gSystemTable and others.
> 

Ryszard,

You need to use libs by including the include file, and listing the lib in the 
INF. The library constructor initializes the globals. 

https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/DxeServicesTableLib.h
 

https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/UefiBootServicesTableLib.h
 

https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/UefiRuntimeServicesTableLib.h

For edk2 the library constructors get called prior calling your drivers entry 
point. 

Thanks,

Andrew Fish


> Reviewed-by: Ryszard Knop 
> 
> On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
>> Remove duplicate definition of gImageHandle, which is emitted by
>> the build tools as well.
>> 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel 
>> ---
>> IntelUndiPkg/XGigUndiDxe/Init.c | 2 --
>> 1 file changed, 2 deletions(-)
>> 
>> diff --git a/IntelUndiPkg/XGigUndiDxe/Init.c
>> b/IntelUndiPkg/XGigUndiDxe/Init.c
>> index 84e06ea071c5..03e3942a1944 100644
>> --- a/IntelUndiPkg/XGigUndiDxe/Init.c
>> +++ b/IntelUndiPkg/XGigUndiDxe/Init.c
>> @@ -47,7 +47,6 @@ UINT16 mActiveChildren= 0;
>> EFI_EVENT  gEventNotifyExitBs;
>> EFI_EVENT  gEventNotifyVirtual;
>> 
>> -EFI_HANDLEgImageHandle;
>> EFI_SYSTEM_TABLE *gSystemTable;
>> 
>> EFI_GUID gEfiNiiPointerGuid = EFI_NII_POINTER_PROTOCOL_GUID;
>> @@ -502,7 +501,6 @@ InitializeXGigUndiDriver (
>> {
>>   EFI_STATUS Status;
>> 
>> -  gImageHandle  = ImageHandle;
>>   gSystemTable  = SystemTable;
>> 
>>   Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable,
>> , ImageHandle);
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 17/20] IntelUndiPkg/XGigUndiDxe: drop unused variables

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Drop some variables that are defined, assigned but never referenced.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Decode.c | 3 ---
>  IntelUndiPkg/XGigUndiDxe/HiiInternalLib.c | 4 
>  IntelUndiPkg/XGigUndiDxe/Xgbe.c   | 2 --
>  3 files changed, 9 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Decode.c
> b/IntelUndiPkg/XGigUndiDxe/Decode.c
> index 5f37ce254872..c8dc3f4eb659 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Decode.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Decode.c
> @@ -1454,14 +1454,11 @@ UndiStatus (
>)
>  {
>PXE_DB_GET_STATUS *  DbPtr;
> -  UINT16   i;
>UINT32   IntStatus;
>UINT16   NumEntries;
>struct ixgbe_legacy_rx_desc *RxPtr;
>bool LinkUp;
>  
> -  i = 0;
> -
>if (XgbeAdapter->DriverBusy) {
>
>  //DEBUGPRINT (CRITICAL, ("ERROR: UndiStatus called when driver
> busy\n"));
> diff --git a/IntelUndiPkg/XGigUndiDxe/HiiInternalLib.c
> b/IntelUndiPkg/XGigUndiDxe/HiiInternalLib.c
> index 2aacb63ca158..df5238a3b55a 100644
> --- a/IntelUndiPkg/XGigUndiDxe/HiiInternalLib.c
> +++ b/IntelUndiPkg/XGigUndiDxe/HiiInternalLib.c
> @@ -197,7 +197,6 @@ GetNextRequestElement (
>)
>  {
>EFI_STRING StringPtr;
> -  EFI_STRING TmpPtr;
>EFI_STATUS Status;
>UINTN  Length;
>UINT8 *TmpBuffer;
> @@ -226,9 +225,6 @@ GetNextRequestElement (
>  return NULL;
>}
>  
> -  // Back up the header of one 
> -  TmpPtr = StringPtr;
> -
>StringPtr += StrLen (L"OFFSET=");
>  
>// Get Offset
> diff --git a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> index 6769f2dc72ab..b3dbbd2b1d08 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> @@ -1399,12 +1399,10 @@ XgbeInitialize (
>XGBE_DRIVER_DATA *XgbeAdapter
>)
>  {
> -  UINT32 * TempBar;
>PXE_STATCODE PxeStatcode;
>EFI_STATUS   Status;
>  
>PxeStatcode = PXE_STATCODE_SUCCESS;
> -  TempBar = NULL;
>  
>ZeroMem (
>  (VOID *)(UINTN)XgbeAdapter->RxRing.UnmappedAddress,

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 16/20] IntelUndiPkg/XGigUndiDxe: add missing EFIAPI modifiers

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> When building for the X64 target using GCC, correct use of the
> EFIAPI modifiers is essential to ensure that the correct calling
> convention is used. So add the missing ones where appropriate.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/AdapterInformation.c | 3 +++
>  IntelUndiPkg/XGigUndiDxe/ComponentName.c  | 2 ++
>  IntelUndiPkg/XGigUndiDxe/ComponentName.h  | 1 +
>  IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c  | 1 +
>  IntelUndiPkg/XGigUndiDxe/DriverHealth.c   | 2 ++
>  IntelUndiPkg/XGigUndiDxe/StartStop.c  | 2 ++
>  6 files changed, 11 insertions(+)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/AdapterInformation.c
> b/IntelUndiPkg/XGigUndiDxe/AdapterInformation.c
> index 26556e284381..b25ed7c4f022 100644
> --- a/IntelUndiPkg/XGigUndiDxe/AdapterInformation.c
> +++ b/IntelUndiPkg/XGigUndiDxe/AdapterInformation.c
> @@ -123,6 +123,7 @@ GetIpv6SupportInformationBlock (
>  **/
>  STATIC
>  EFI_STATUS
> +EFIAPI
>  GetInformation (
>IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
>IN  EFI_GUID *InformationType,
> @@ -188,6 +189,7 @@ GetInformation (
>  **/
>  STATIC
>  EFI_STATUS
> +EFIAPI
>  SetInformation (
>IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
>IN  EFI_GUID *InformationType,
> @@ -234,6 +236,7 @@ SetInformation (
>  **/
>  STATIC
>  EFI_STATUS
> +EFIAPI
>  GetSupportedTypes (
>IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
>OUT EFI_GUID **   InfoTypesBuffer,
> diff --git a/IntelUndiPkg/XGigUndiDxe/ComponentName.c
> b/IntelUndiPkg/XGigUndiDxe/ComponentName.c
> index 2972c28bda4e..eee59d7c14f4 100644
> --- a/IntelUndiPkg/XGigUndiDxe/ComponentName.c
> +++ b/IntelUndiPkg/XGigUndiDxe/ComponentName.c
> @@ -116,6 +116,7 @@ ComponentNameInitializeControllerName (
>  language specified by Language.
>  **/
>  EFI_STATUS
> +EFIAPI
>  ComponentNameGetDriverName (
>IN  EFI_COMPONENT_NAME_PROTOCOL *This,
>IN  CHAR8 *  Language,
> @@ -186,6 +187,7 @@ ComponentNameGetDriverName (
>  language specified by Language.
>  **/
>  EFI_STATUS
> +EFIAPI
>  ComponentNameGetControllerName (
>IN  EFI_COMPONENT_NAME_PROTOCOL
> *   This,
>IN  EFI_HANDLE  Co
> ntrollerHandle,
> diff --git a/IntelUndiPkg/XGigUndiDxe/ComponentName.h
> b/IntelUndiPkg/XGigUndiDxe/ComponentName.h
> index f63d58b8a18c..4f62e48379ed 100644
> --- a/IntelUndiPkg/XGigUndiDxe/ComponentName.h
> +++ b/IntelUndiPkg/XGigUndiDxe/ComponentName.h
> @@ -67,6 +67,7 @@ ComponentNameInitializeControllerName (
>  language specified by Language.
>  **/
>  EFI_STATUS
> +EFIAPI
>  ComponentNameGetDriverName (
>IN  EFI_COMPONENT_NAME_PROTOCOL *This,
>IN  CHAR8 *  Language,
> diff --git a/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> b/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> index 2f9c66771910..77b7a954698b 100644
> --- a/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> +++ b/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> @@ -370,6 +370,7 @@ XgbeUndiPhyLoopback (
>   ChildHandle did not pass
> the diagnostic.
>  **/
>  EFI_STATUS
> +EFIAPI
>  XgbeUndiDriverDiagnosticsRunDiagnostics (
>IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL
> *   This,
>IN
> EFI_HANDLE  C
> ontrollerHandle,
> diff --git a/IntelUndiPkg/XGigUndiDxe/DriverHealth.c
> b/IntelUndiPkg/XGigUndiDxe/DriverHealth.c
> index df6cfdf8a123..4b173bc8d8a9 100644
> --- a/IntelUndiPkg/XGigUndiDxe/DriverHealth.c
> +++ b/IntelUndiPkg/XGigUndiDxe/DriverHealth.c
> @@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
> @retval  !EFI_SUCCESS  Failure to retrieve health status
>  **/
>  EFI_STATUS
> +EFIAPI
>  GetHealthStatus (
>IN  EFI_DRIVER_HEALTH_PROTOCOL * This,
>IN  EFI_HANDLE   ControllerHandle, OPTIONAL
> @@ -145,6 +146,7 @@ GetHealthStatus (
> @retval   EFI_UNSUPPORTED   This function is unsupported
>  **/
>  EFI_STATUS
> +EFIAPI
>  Repair (
>IN  EFI_DRIVER_HEALTH_PROTOCOL*This,
>IN  EFI_HANDLEControllerHandle,
> diff --git a/IntelUndiPkg/XGigUndiDxe/StartStop.c
> b/IntelUndiPkg/XGigUndiDxe/StartStop.c
> index 156e927a35c6..c881c811aefb 100644
> --- a/IntelUndiPkg/XGigUndiDxe/StartStop.c
> +++ b/IntelUndiPkg/XGigUndiDxe/StartStop.c
> @@ -38,6 +38,7 @@ EFI_GUID gEfiStartStopProtocolGuid =
> EFI_DRIVER_STOP_PROTOCOL_GUID;
> @retval   EFI_SUCCESS   Driver is stopped successfully
>  **/
>  EFI_STATUS
> +EFIAPI
>  StopDriver (
>IN 

Re: [edk2] [PATCH edk2-staging 15/20] IntelUndiPkg/XGigUndiDxe: use intermediate UINTN casts for pointers

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Use intermediate (UINTN) casts when casting pointers to UINT64.
> This is needed to be able to build this code for 32-bit architectures
> such as ARM or IA32.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Dma.c   | 8 
>  IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c | 4 ++--
>  IntelUndiPkg/XGigUndiDxe/Init.c  | 6 +++---
>  IntelUndiPkg/XGigUndiDxe/Xgbe.c  | 8 
>  IntelUndiPkg/XGigUndiDxe/Xgbe.h  | 4 ++--
>  5 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Dma.c
> b/IntelUndiPkg/XGigUndiDxe/Dma.c
> index c8588df96ef5..79a5cefe9f41 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Dma.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Dma.c
> @@ -127,7 +127,7 @@ FREE_BUF_ON_ERROR:
>PciIo->FreeBuffer (
> PciIo,
> BytesToPages (DmaMapping->Size),
> -   (VOID *) DmaMapping->UnmappedAddress
> +   (VOID *)(UINTN)DmaMapping->UnmappedAddress
> );
>DmaMapping->Size = 0;
>DmaMapping->UnmappedAddress = 0;
> @@ -173,7 +173,7 @@ UndiDmaFreeCommonBuffer (
>PciIo->FreeBuffer (
> PciIo,
> BytesToPages (DmaMapping->Size),
> -   (VOID *) DmaMapping->UnmappedAddress
> +   (VOID *)(UINTN)DmaMapping->UnmappedAddress
> );
>  
>DmaMapping->UnmappedAddress = 0;
> @@ -209,7 +209,7 @@ UndiDmaMapCommonBuffer (
>return PciIo->Map (
>PciIo,
>EfiPciIoOperationBusMasterCommonBuffer,
> -  (VOID *) DmaMapping->UnmappedAddress,
> +  (VOID *)(UINTN)DmaMapping->UnmappedAddress,
>>Size,
>>PhysicalAddress,
>>Mapping
> @@ -243,7 +243,7 @@ UndiDmaMapMemoryRead (
>return PciIo->Map (
>PciIo,
>EfiPciIoOperationBusMasterRead,
> -  (VOID *) DmaMapping->UnmappedAddress,
> +  (VOID *)(UINTN)DmaMapping->UnmappedAddress,
>>Size,
>>PhysicalAddress,
>>Mapping
> diff --git a/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> b/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> index 66dc67a5400e..2f9c66771910 100644
> --- a/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> +++ b/IntelUndiPkg/XGigUndiDxe/DriverDiagnostics.c
> @@ -119,11 +119,11 @@ XgbeUndiRunPhyLoopback (
>DEBUGPRINT (DIAG, ("CpbReceive.BufferAddr allocated at %x\n",
> (UINTN) CpbReceive.BufferAddr));
>  
>while (j < PHY_LOOPBACK_ITERATIONS) {
> -ZeroMem ((VOID *) CpbReceive.BufferAddr, RX_BUFFER_SIZE);
> +ZeroMem ((VOID *)(UINTN)CpbReceive.BufferAddr, RX_BUFFER_SIZE);
>  
>  Status = XgbeTransmit (
> XgbeAdapter,
> -   (UINT64) ,
> +   (UINT64)(UINTN),
> PXE_OPFLAGS_TRANSMIT_WHOLE
>   );
>  
> diff --git a/IntelUndiPkg/XGigUndiDxe/Init.c
> b/IntelUndiPkg/XGigUndiDxe/Init.c
> index 03e3942a1944..c112db667148 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Init.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Init.c
> @@ -260,7 +260,7 @@ InitUndiPxeStructInit (
> PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED |
> PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED;
>  
> -  PxePtr->EntryPoint= (UINT64) UndiApiEntry;
> +  PxePtr->EntryPoint= (UINT64)(UINTN)UndiApiEntry;
>PxePtr->MinorVer  = PXE_ROMID_MINORVER_31;
>  
>PxePtr->reserved2[0]  = 0;
> @@ -1099,7 +1099,7 @@ InitUndiCallbackFunctions (
>NicInfo->MapMem  = (VOID *) 0;
>NicInfo->UnMapMem= (VOID *) 0;
>NicInfo->SyncMem = (VOID *) 0;
> -  NicInfo->UniqueId   = (UINT64) NicInfo;
> +  NicInfo->UniqueId   = (UINT64)(UINTN)NicInfo;
>NicInfo->VersionFlag = 0x31;
>  }
>  
> @@ -1284,7 +1284,7 @@ InitNiiProtocol (
>EFI_STATUS Status;
>  
>  
> -  NiiProtocol31->Id= (UINT64) (mIxgbePxe31);
> +  NiiProtocol31->Id= (UINT64)(UINTN)(mIxgbePxe31);
>  
>// IFcnt should be equal to the total number of physical ports - 1
>NiiProtocol31->IfNum = mIxgbePxe31->IFcnt;
> diff --git a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> index 003c3b9065ec..6769f2dc72ab 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> @@ -1237,7 +1237,7 @@ XgbeTxRxConfigure (
>  
>ZeroMem (XgbeAdapter->TxBufferMappings, sizeof (XgbeAdapter-
> >TxBufferMappings));
>  
> -  RxBuffer = (LOCAL_RX_BUFFER *) XgbeAdapter-
> >RxBufferMapping.PhysicalAddress;
> +  RxBuffer = (LOCAL_RX_BUFFER *)(UINTN)XgbeAdapter-
> >RxBufferMapping.PhysicalAddress;
>  
>DEBUGPRINT (
>  XGBE, ("Local Rx Buffer %X size %X\n",
> @@ -1407,17 +1407,17 @@ XgbeInitialize (
>TempBar = NULL;
>  
>ZeroMem (
> -

Re: [edk2] [PATCH edk2-staging 14/20] IntelUndiPkg/XGigUndiDxe: redefine UNREFERENCED_nPARAMETER macros for GCC

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Use (VOID) casts to silence unreferenced parameter warnings on GCC.
> The
> existing macros generate 'statement with no effect' warnings instead,
> which does not really help.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/ixgbe_type.h | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/ixgbe_type.h
> b/IntelUndiPkg/XGigUndiDxe/ixgbe_type.h
> index e3bb1a8a313e..f67bfbfc2a9f 100644
> --- a/IntelUndiPkg/XGigUndiDxe/ixgbe_type.h
> +++ b/IntelUndiPkg/XGigUndiDxe/ixgbe_type.h
> @@ -4411,11 +4411,19 @@ struct ixgbe_hw {
>  #define IXGBE_NOT_IMPLEMENTED0x7FFF
>  
>  #ifndef UNREFERENCED_XPARAMETER
> +#ifdef _MSC_VER
>  #define UNREFERENCED_XPARAMETER
>  #define UNREFERENCED_1PARAMETER(_p) (_p);
>  #define UNREFERENCED_2PARAMETER(_p, _q) (_p); (_q);
>  #define UNREFERENCED_3PARAMETER(_p, _q, _r) (_p); (_q); (_r);
>  #define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) (_p); (_q); (_r);
> (_s);
> +#else
> +#define UNREFERENCED_1PARAMETER(_p) (VOID)(_p)
> +#define UNREFERENCED_2PARAMETER(_p, _q) (VOID)(_p); (VOID)(_q);
> +#define UNREFERENCED_3PARAMETER(_p, _q, _r) (VOID)(_p); (VOID)(_q);
> (VOID)(_r);
> +#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) (VOID)(_p);
> (VOID)(_q); (VOID)(_r); (VOID)(_s);
> +#define UNREFERENCED_5PARAMETER(_p, _q, _r, _s, _t) (VOID)(_p);
> (VOID)(_q); (VOID)(_r); (VOID)(_s); (VOID)(_t);
> +#endif
>  #endif
>  #define IXGBE_FUSES0_GROUP(_i)   (0x11158 + ((_i) * 4))
>  #define IXGBE_FUSES0_300MHZ  (1 << 5)

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 11/20] IntelUndiPkg/XGigUndiDxe: cast XgbeMemCopy () args to correct pointer type

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> XgbeMemCopy () takes UINT8 pointers not INT8 pointers, so cast the
> arguments to the correct type.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Xgbe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> index 9e3ee862fb4e..0c823efe8963 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> @@ -542,8 +542,8 @@ XgbeReceive (
>  
>// Copy the packet from our list to the EFI buffer.
>XgbeMemCopy (
> -(INT8 *) (UINTN) CpbReceive->BufferAddr,
> -(INT8 *) (UINTN) ReceiveDescriptor->buffer_addr,
> +(UINT8 *) (UINTN) CpbReceive->BufferAddr,
> +(UINT8 *) (UINTN) ReceiveDescriptor->buffer_addr,
>  TempLen
>);
>  

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 12/20] IntelUndiPkg/XGigUndiDxe: don't take address of cast expression

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Taking the address of a cast expression is not permitted in C.
> Instead,
> take the address of the variable, and cast the pointer to the desired
> pointer type.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Xgbe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> index 0c823efe8963..003c3b9065ec 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
> @@ -1264,7 +1264,7 @@ XgbeTxRxConfigure (
>IXGBE_WRITE_REG (>Hw, IXGBE_RDBAL (0), (UINT32)
> (UINTN) (XgbeAdapter->RxRing.PhysicalAddress));
>  
>MemAddr = (UINT64) (UINTN) XgbeAdapter->RxRing.PhysicalAddress;
> -  MemPtr  = &((UINT32) MemAddr);
> +  MemPtr  = (UINT32 *) 
>MemPtr++;
>IXGBE_WRITE_REG (>Hw, IXGBE_RDBAH (0), *MemPtr);
>DEBUGPRINT (XGBE, ("Rdbal0 %X\n", (UINT32) IXGBE_READ_REG
> (>Hw, IXGBE_RDBAL (0;
> @@ -1337,7 +1337,7 @@ XgbeTxRxConfigure (
>XgbeAdapter->XmitDoneHead = 0;  // the last cleaned buffer
>IXGBE_WRITE_REG (>Hw, IXGBE_TDBAL (0), (UINT32)
> (XgbeAdapter->TxRing.PhysicalAddress));
>MemAddr = (UINT64) XgbeAdapter->TxRing.PhysicalAddress;
> -  MemPtr  = &((UINT32) MemAddr);
> +  MemPtr  = (UINT32 *) 
>MemPtr++;
>IXGBE_WRITE_REG (>Hw, IXGBE_TDBAH (0), *MemPtr);
>DEBUGPRINT (XGBE, ("TdBah0 %X\n", *MemPtr));

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 07/20] IntelUndiPkg/XGigUndiDxe: drop definition of gImageHandle

2019-01-30 Thread Ryszard Knop
Ah, thanks!

On Wed, 2019-01-30 at 17:06 +0100, Ard Biesheuvel wrote:
> On Wed, 30 Jan 2019 at 17:05, Ryszard Knop <
> ryszard.k...@linux.intel.com> wrote:
> > Hmm, is there a list/something I can generate to see which globals
> > build tools emit? There are some more variables I'd happily get rid
> > of, eg if I could drop gSystemTable and others.
> > 
> 
> You can look at the contents of the various AutoGen.h files in the
> Build/ folder
> 
> 
> > Reviewed-by: Ryszard Knop 
> > 
> > On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> > > Remove duplicate definition of gImageHandle, which is emitted by
> > > the build tools as well.
> > > 
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel 
> > > ---
> > >  IntelUndiPkg/XGigUndiDxe/Init.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > > 
> > > diff --git a/IntelUndiPkg/XGigUndiDxe/Init.c
> > > b/IntelUndiPkg/XGigUndiDxe/Init.c
> > > index 84e06ea071c5..03e3942a1944 100644
> > > --- a/IntelUndiPkg/XGigUndiDxe/Init.c
> > > +++ b/IntelUndiPkg/XGigUndiDxe/Init.c
> > > @@ -47,7 +47,6 @@ UINT16 mActiveChildren= 0;
> > >  EFI_EVENT  gEventNotifyExitBs;
> > >  EFI_EVENT  gEventNotifyVirtual;
> > > 
> > > -EFI_HANDLEgImageHandle;
> > >  EFI_SYSTEM_TABLE *gSystemTable;
> > > 
> > >  EFI_GUID gEfiNiiPointerGuid = EFI_NII_POINTER_PROTOCOL_GUID;
> > > @@ -502,7 +501,6 @@ InitializeXGigUndiDriver (
> > >  {
> > >EFI_STATUS Status;
> > > 
> > > -  gImageHandle  = ImageHandle;
> > >gSystemTable  = SystemTable;
> > > 
> > >Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable,
> > > , ImageHandle);

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v5 7/7] ShellPkg/UefiShellLib: Use BaseLib api CharToUpper

2019-01-30 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Zhang, Shenglei
> Sent: Tuesday, January 29, 2019 10:34 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ray ; Carsey, Jaben 
> Subject: [PATCH v5 7/7] ShellPkg/UefiShellLib: Use BaseLib api CharToUpper
> Importance: High
> 
> Substitute InternalShellCharToUpper with CharToUpper which is a public
> function with the same effect.
> Remove the implement of InternalShellCharToUpper.
> https://bugzilla.tianocore.org/show_bug.cgi?id=1369
> 
> Cc: Ruiyu Ni 
> Cc: Jaben Carsey 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang 
> Reviewed-by: Jaben Carsey 
> Reviewed-by: Liming Gao 
> ---
>  ShellPkg/Library/UefiShellLib/UefiShellLib.c | 31 ++--
>  1 file changed, 2 insertions(+), 29 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> index b17266d623..aff933dcdf 100644
> --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> @@ -3740,33 +3740,6 @@ ShellFileExists(
>return (EFI_SUCCESS);
>  }
> 
> -/**
> -  Convert a Unicode character to upper case only if
> -  it maps to a valid small-case ASCII character.
> -
> -  This internal function only deal with Unicode character
> -  which maps to a valid small-case ASCII character, i.e.
> -  L'a' to L'z'. For other Unicode character, the input character
> -  is returned directly.
> -
> -  @param  Char  The character to convert.
> -
> -  @retval LowerCharacter   If the Char is with range L'a' to L'z'.
> -  @retval UnchangedOtherwise.
> -
> -**/
> -CHAR16
> -InternalShellCharToUpper (
> -  IN  CHAR16Char
> -  )
> -{
> -  if (Char >= L'a' && Char <= L'z') {
> -return (CHAR16) (Char - (L'a' - L'A'));
> -  }
> -
> -  return Char;
> -}
> -
>  /**
>Convert a Unicode character to numerical value.
> 
> @@ -3789,7 +3762,7 @@ InternalShellHexCharToUintn (
>  return Char - L'0';
>}
> 
> -  return (10 + InternalShellCharToUpper (Char) - L'A');
> +  return (10 + CharToUpper (Char) - L'A');
>  }
> 
>  /**
> @@ -3849,7 +3822,7 @@ InternalShellStrHexToUint64 (
>  String++;
>}
> 
> -  if (InternalShellCharToUpper (*String) == L'X') {
> +  if (CharToUpper (*String) == L'X') {
>  if (*(String - 1) != L'0') {
>return 0;
>  }
> --
> 2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v5 6/7] ShellPkg/Shell: Use BaseLib api CharToUpper

2019-01-30 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Zhang, Shenglei
> Sent: Tuesday, January 29, 2019 10:34 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ray ; Carsey, Jaben 
> Subject: [PATCH v5 6/7] ShellPkg/Shell: Use BaseLib api CharToUpper
> Importance: High
> 
> Substitute InternalShellCharToUpper with a public function
> CharToUpper which has the same function.
> Remove the implement of InternalShellCharToUpper.
> 
> Cc: Ruiyu Ni 
> Cc: Jaben Carsey 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang 
> Reviewed-by: Jaben Carsey 
> Reviewed-by: Liming Gao 
> ---
>  ShellPkg/Application/Shell/ShellManParser.c | 23 +
>  1 file changed, 1 insertion(+), 22 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/ShellManParser.c
> b/ShellPkg/Application/Shell/ShellManParser.c
> index b180c6c8f7..2c044dbe4a 100644
> --- a/ShellPkg/Application/Shell/ShellManParser.c
> +++ b/ShellPkg/Application/Shell/ShellManParser.c
> @@ -46,27 +46,6 @@ SHELL_MAN_HII_VENDOR_DEVICE_PATH
> mShellManHiiDevicePath = {
>}
>  };
> 
> -
> -/**
> -  Convert a Unicode character to upper case only if
> -  it maps to a valid small-case ASCII character.
> -
> -  This internal function only deal with Unicode character
> -  which maps to a valid small-case ASCII character, i.e.
> -  L'a' to L'z'. For other Unicode character, the input character
> -  is returned directly.
> -
> -  @param  Char  The character to convert.
> -
> -  @retval LowerCharacter   If the Char is with range L'a' to L'z'.
> -  @retval UnchangedOtherwise.
> -
> -**/
> -CHAR16
> -InternalShellCharToUpper (
> -  IN CHAR16  Char
> -  );
> -
>  /**
>Verifies that the filename has .EFI on the end.
> 
> @@ -416,7 +395,7 @@ IsTitleHeader(
>ReturnFound = TRUE;  // This is the desired command's title header 
> line.
>State = (BriefDesc == NULL) ? Final : GetBriefDescription;
>  }
> -else if (InternalShellCharToUpper (*Line) != InternalShellCharToUpper
> (*(Command + CommandIndex++))) {
> +else if (CharToUpper (*Line) != CharToUpper (*(Command +
> CommandIndex++))) {
>State = Final;
>  }
>  Line++;
> --
> 2.18.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 09/20] IntelUndiPkg/XGigUndiDxe: fix incorrect use of CPP token pasting

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> The ## CPP token pasting operator is used to paste *tokens*, which
> is not the same thing as pasting arbitrary macro arguments. Since a
> token cannot contain . or ) characters in the first place, using
> the ## operator here is wrong and unnecessary, so just remove it.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/NVDataStruc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> b/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> index 63dd841277ab..c78d26da7869 100644
> --- a/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> +++ b/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> @@ -113,7 +113,7 @@ typedef struct {
>  
> @return   Width of given field is returned
>  **/
> -#define UNDI_CONFIG_WIDTH(Field) sizeof (UndiPrivateData-
> >Configuration. ## Field ## )
> +#define UNDI_CONFIG_WIDTH(Field) sizeof (UndiPrivateData-
> >Configuration.Field)
>  
>  // General parameters
>  #define QUESTION_ID_EFI_DRIVER_VER  0x11
> 00

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 08/20] IntelUndiPkg/XGigUndiDxe: add missing braces to GUID literals

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> The Data4 member of the GUID/EFI_GUID struct type is an array of
> UINT8, so literals require two sets of { } braces. Add them where
> missing.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/NVDataStruc.h | 4 ++--
>  IntelUndiPkg/XGigUndiDxe/StartStop.h   | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> b/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> index e5e669681b07..63dd841277ab 100644
> --- a/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> +++ b/IntelUndiPkg/XGigUndiDxe/NVDataStruc.h
> @@ -34,12 +34,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  
>  #define XGBE_HII_FORM_GUID \
>{ \
> -0x25fd9f0b, 0xa3ef, 0x4788, 0xa4, 0x0c, 0x81, 0x84, 0x9d, 0x17,
> 0x8a, 0x6c \
> +0x25fd9f0b, 0xa3ef, 0x4788, { 0xa4, 0x0c, 0x81, 0x84, 0x9d,
> 0x17, 0x8a, 0x6c } \
>}
>  
>  #define XGBE_HII_DATA_GUID \
>{ \
> -0xe2c85968, 0x6906, 0x4b27, 0x9d, 0x09, 0x33, 0x43, 0xaf, 0x06,
> 0x46, 0x76 \
> +0xe2c85968, 0x6906, 0x4b27, { 0x9d, 0x09, 0x33, 0x43, 0xaf,
> 0x06, 0x46, 0x76 } \
>}
>  
>  
> diff --git a/IntelUndiPkg/XGigUndiDxe/StartStop.h
> b/IntelUndiPkg/XGigUndiDxe/StartStop.h
> index 03ad3dc9cecc..5dfc45c7de6a 100644
> --- a/IntelUndiPkg/XGigUndiDxe/StartStop.h
> +++ b/IntelUndiPkg/XGigUndiDxe/StartStop.h
> @@ -32,8 +32,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  #include "Xgbe.h"
>  
>  #define EFI_DRIVER_STOP_PROTOCOL_GUID \
> -  { 0x34d59603, 0x1428, 0x4429, 0xa4, 0x14, 0xe6, 0xb3, \
> -0xb5, 0xfd, 0x7d, 0xc1 }
> +  { 0x34d59603, 0x1428, 0x4429, { 0xa4, 0x14, 0xe6, 0xb3, \
> +0xb5, 0xfd, 0x7d, 0xc1 } }
>  
>  typedef struct EFI_DRIVER_STOP_PROTOCOL_S  EFI_DRIVER_STOP_PROTOCOL;
>  

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 07/20] IntelUndiPkg/XGigUndiDxe: drop definition of gImageHandle

2019-01-30 Thread Ard Biesheuvel
On Wed, 30 Jan 2019 at 17:05, Ryszard Knop  wrote:
>
> Hmm, is there a list/something I can generate to see which globals
> build tools emit? There are some more variables I'd happily get rid
> of, eg if I could drop gSystemTable and others.
>

You can look at the contents of the various AutoGen.h files in the Build/ folder


> Reviewed-by: Ryszard Knop 
>
> On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> > Remove duplicate definition of gImageHandle, which is emitted by
> > the build tools as well.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  IntelUndiPkg/XGigUndiDxe/Init.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/IntelUndiPkg/XGigUndiDxe/Init.c
> > b/IntelUndiPkg/XGigUndiDxe/Init.c
> > index 84e06ea071c5..03e3942a1944 100644
> > --- a/IntelUndiPkg/XGigUndiDxe/Init.c
> > +++ b/IntelUndiPkg/XGigUndiDxe/Init.c
> > @@ -47,7 +47,6 @@ UINT16 mActiveChildren= 0;
> >  EFI_EVENT  gEventNotifyExitBs;
> >  EFI_EVENT  gEventNotifyVirtual;
> >
> > -EFI_HANDLEgImageHandle;
> >  EFI_SYSTEM_TABLE *gSystemTable;
> >
> >  EFI_GUID gEfiNiiPointerGuid = EFI_NII_POINTER_PROTOCOL_GUID;
> > @@ -502,7 +501,6 @@ InitializeXGigUndiDriver (
> >  {
> >EFI_STATUS Status;
> >
> > -  gImageHandle  = ImageHandle;
> >gSystemTable  = SystemTable;
> >
> >Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable,
> > , ImageHandle);
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 07/20] IntelUndiPkg/XGigUndiDxe: drop definition of gImageHandle

2019-01-30 Thread Ryszard Knop
Hmm, is there a list/something I can generate to see which globals
build tools emit? There are some more variables I'd happily get rid
of, eg if I could drop gSystemTable and others.

Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Remove duplicate definition of gImageHandle, which is emitted by
> the build tools as well.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Init.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Init.c
> b/IntelUndiPkg/XGigUndiDxe/Init.c
> index 84e06ea071c5..03e3942a1944 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Init.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Init.c
> @@ -47,7 +47,6 @@ UINT16 mActiveChildren= 0;
>  EFI_EVENT  gEventNotifyExitBs;
>  EFI_EVENT  gEventNotifyVirtual;
>  
> -EFI_HANDLEgImageHandle;
>  EFI_SYSTEM_TABLE *gSystemTable;
>  
>  EFI_GUID gEfiNiiPointerGuid = EFI_NII_POINTER_PROTOCOL_GUID;
> @@ -502,7 +501,6 @@ InitializeXGigUndiDriver (
>  {
>EFI_STATUS Status;
>  
> -  gImageHandle  = ImageHandle;
>gSystemTable  = SystemTable;
>  
>Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable,
> , ImageHandle);

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 06/20] IntelUndiPkg/XGigUndiDxe: add missing UINT8* cast

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> UINT8 and CHAR8 are not the same underlying type on all
> architectures,
> so add an explicit cast where necessary.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Hii.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Hii.c
> b/IntelUndiPkg/XGigUndiDxe/Hii.c
> index 3ad7d61e493d..3170580487d5 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Hii.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Hii.c
> @@ -782,7 +782,7 @@ HiiSetMenuStrings (
>  
>Status = ReadPbaString (
>   >NicInfo,
> - PBAString8,
> + (UINT8 *)PBAString8,
>   MAX_PBA_STR_LENGTH
> );
>if (Status == EFI_SUCCESS) {

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 05/20] IntelUndiPkg/XGigUndiDxe: add missing VOID** cast

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Unlike Visual Studio, GCC does not permit implicit conversion between
> a pointer-to-void-pointer and pointer to a typed pointer. So add the
> explicit casts where necessary.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Hii.c  | 8 
>  IntelUndiPkg/XGigUndiDxe/Init.c | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Hii.c
> b/IntelUndiPkg/XGigUndiDxe/Hii.c
> index 857a475622f7..3ad7d61e493d 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Hii.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Hii.c
> @@ -459,7 +459,7 @@ HiiOpenProtocol (
>Status = gBS->LocateProtocol (
>,
>NULL,
> -  >HiiDatabase
> +  (VOID **)>HiiDatabase
>  );
>if (EFI_ERROR (Status)) {
>  DEBUGPRINT (CRITICAL, ("Error finding HII protocol: %r\n",
> Status));
> @@ -472,7 +472,7 @@ HiiOpenProtocol (
>Status = gBS->LocateProtocol (
>,
>NULL,
> -  >HiiString
> +  (VOID **)>HiiString
>  );
>if (EFI_ERROR (Status)) {
>  DEBUGPRINT (CRITICAL, ("Error finding HII String protocol:
> %r\n", Status));
> @@ -485,7 +485,7 @@ HiiOpenProtocol (
>Status = gBS->LocateProtocol (
>,
>NULL,
> -  >FormBrowser2
> +  (VOID **)>FormBrowser2
>  );
>if (EFI_ERROR (Status)) {
>  DEBUGPRINT (CRITICAL, ("Error finding HII form browser protocol:
> %r\n", Status));
> @@ -498,7 +498,7 @@ HiiOpenProtocol (
>Status = gBS->LocateProtocol (
>,
>NULL,
> -  >HiiConfigRouting
> +  (VOID **)>HiiConfigRouting
>  );
>if (EFI_ERROR (Status)) {
>  DEBUGPRINT (CRITICAL, ("Error finding HII ConfigRouting
> protocol: %r\n", Status));
> diff --git a/IntelUndiPkg/XGigUndiDxe/Init.c
> b/IntelUndiPkg/XGigUndiDxe/Init.c
> index bffe3c165866..84e06ea071c5 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Init.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Init.c
> @@ -179,7 +179,7 @@ InitAppendMac2DevPath (
>Status = gBS->AllocatePool (
>EfiBootServicesData,  // EfiRuntimeServicesData,
>TotalPathLen,
> -  
> +  (VOID **)
>  );
>  
>if (Status != EFI_SUCCESS) {

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 04/20] IntelUndiPkg/XGigUndiDxe: move BRAND_STRUCT declaration after type definition

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Move the extern declaration of mBrandingTable[] after the definition
> of
> the type. This solves a build issue with GCC.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/DeviceSupport.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/DeviceSupport.h
> b/IntelUndiPkg/XGigUndiDxe/DeviceSupport.h
> index e997983ba3e7..d501d9bb1371 100644
> --- a/IntelUndiPkg/XGigUndiDxe/DeviceSupport.h
> +++ b/IntelUndiPkg/XGigUndiDxe/DeviceSupport.h
> @@ -33,9 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  
>  typedef struct BRAND_STRUCT_S BRAND_STRUCT;
>  
> -extern BRAND_STRUCT mBrandingTable[];
> -extern UINTNmBrandingTableSize;
> -
>  /* Defines */
>  #define INVALID_VENDOR_ID 0x
>  #define INVALID_SUBVENDOR_ID  0x
> @@ -53,6 +50,9 @@ struct BRAND_STRUCT_S {
>CHAR16 *BrandString;
>  };
>  
> +extern BRAND_STRUCT mBrandingTable[];
> +extern UINTNmBrandingTableSize;
> +
>  /* Function declarations */
>  
>  /** Returns pointer to current device's branding string (looks for
> best match)

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 03/20] IntelUndiPkg/XGigUndiDxe: consistently use forward slashes as path separators

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Replace backslashes in paths with forward slashes to be compatible
> with
> non-Windows OSes.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/Decode.c|  2 +-
>  IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf | 14 +++---
>  IntelUndiPkg/XGigUndiDxe/Xgbe.h  |  2 +-
>  IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h   |  4 ++--
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/Decode.c
> b/IntelUndiPkg/XGigUndiDxe/Decode.c
> index 70fbce64c64f..5f37ce254872 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Decode.c
> +++ b/IntelUndiPkg/XGigUndiDxe/Decode.c
> @@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  
> ***/
>  
>  #include "Xgbe.h"
> -#include 
> +#include 
>  
>  // Forward declarations for UNDI function table
>  /** This routine determines the operational state of the UNDI.  It
> updates the state flags in the
> diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> index 7ccc52bc9869..beee8aa8134e 100644
> --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> @@ -110,13 +110,13 @@ GCC:*_*_*_CC_FLAGS = -DEFI32
>   Version.h
>   HiiInternalLib.c
>   HiiInternalLib.h
> -  wol\wol.c
> -  wol\wol.h
> -  wol\wolfamily.c
> -  wol\wolimpl.c
> -  wol\wolimpl.h
> -  wol\wolinfo.c
> -  wol\wol_10G.c
> +  wol/wol.c
> +  wol/wol.h
> +  wol/wolfamily.c
> +  wol/wolimpl.c
> +  wol/wolimpl.h
> +  wol/wolinfo.c
> +  wol/wol_10G.c
>  
>  [Packages]
>MdePkg/MdePkg.dec
> diff --git a/IntelUndiPkg/XGigUndiDxe/Xgbe.h
> b/IntelUndiPkg/XGigUndiDxe/Xgbe.h
> index 5ab088362f90..4472cfb4fa31 100644
> --- a/IntelUndiPkg/XGigUndiDxe/Xgbe.h
> +++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.h
> @@ -69,7 +69,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  
>  #include 
>  
> diff --git a/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> b/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> index 368f40811904..e324b0539782 100644
> --- a/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> +++ b/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> @@ -39,8 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  
>  #include 
>  #include 
> -#include 
> -#include 
> +#include 
> +#include 
>  #include 
>  
>  #define CHARCHAR8

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 02/20] IntelUndiPkg/XGigUndiDxe: move MSFT warning overrides to INF file

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> GCC chokes on the unknown MSVC specific #pragmas used for suppressing
> warnings, so remove them and use the INF BuildOptions section
> instead.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf |  4 ++--
>  IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h   | 10 --
>  2 files changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> index ab9c64dac7e8..7ccc52bc9869 100644
> --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> @@ -44,7 +44,7 @@ UNLOAD_IMAGE = UnloadXGigUndiDriver
>  
>  [BuildOptions.common]
>  
> -MSFT:*_*_*_CC_FLAGS = /FAcs /D MDEPKG_NDEBUG /D UNDI_10G
> +MSFT:*_*_*_CC_FLAGS = /FAcs /D MDEPKG_NDEBUG /D UNDI_10G /wd4244
> /wd4206 /wd4189
>  GCC:*_*_*_CC_FLAGS = -DUNDI_10G
>  GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>  
> @@ -60,7 +60,7 @@ GCC:*_*_*_CC_FLAGS = -DEFI64
>  
>  [BuildOptions.IA32]
>  
> -MSFT:*_*_*_CC_FLAGS = /D EFI32
> +MSFT:*_*_*_CC_FLAGS = /D EFI32 /wd4305
>  GCC:*_*_*_CC_FLAGS = -DEFI32
>  
>  [sources.common]
> diff --git a/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> b/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> index 6fa0d1605c7c..368f40811904 100644
> --- a/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> +++ b/IntelUndiPkg/XGigUndiDxe/ixgbe_osdep.h
> @@ -29,16 +29,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> POSSIBILITY OF SUCH DAMAGE.
>  #ifndef IXGBE_OSDEP_H_
>  #define IXGBE_OSDEP_H_
>  
> -#pragma warning(disable : 4244)
> -#pragma warning(disable : 4206)
> -#pragma warning(disable : 4189)
> -
> -#ifdef EFI32
> -
> -// Remove truncation warning in type cast when some 64 bit variables
> are converted to 32-bit pointers
> -#pragma warning(disable : 4305)
> -#endif /* EFI32 */
> -
>  #ifndef EFI_SPECIFICATION_VERSION
>  #define EFI_SPECIFICATION_VERSION 0x0002
>  #endif /* EFI_SPECIFICATION_VERSION */

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 01/20] IntelUndiPkg/XGigUndiDxe: create GCC alternatives for MSFT build options

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Wed, 2018-11-14 at 18:33 -0800, ard.biesheuvela wrote:
> Prefix the existing MSFT-only build option overrides with MSFT: and
> create the GCC: counterparts so we can build this code with GCC as
> well.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf | 13 +
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> index 9e0e4aff0885..ab9c64dac7e8 100644
> --- a/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> +++ b/IntelUndiPkg/XGigUndiDxe/XGigUndiDxe.inf
> @@ -44,19 +44,24 @@ UNLOAD_IMAGE = UnloadXGigUndiDriver
>  
>  [BuildOptions.common]
>  
> -*_*_*_CC_FLAGS = /FAcs /D MDEPKG_NDEBUG /D UNDI_10G
> +MSFT:*_*_*_CC_FLAGS = /FAcs /D MDEPKG_NDEBUG /D UNDI_10G
> +GCC:*_*_*_CC_FLAGS = -DUNDI_10G
> +GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
>  
>  [BuildOptions.X64]
>  
> -*_*_*_CC_FLAGS = /D EFIX64 
> +MSFT:*_*_*_CC_FLAGS = /D EFIX64
> +GCC:*_*_*_CC_FLAGS = -DEFIX64
>  
>  [BuildOptions.IPF]
>  
> -*_*_*_CC_FLAGS = /D EFI64
> +MSFT:*_*_*_CC_FLAGS = /D EFI64
> +GCC:*_*_*_CC_FLAGS = -DEFI64
>  
>  [BuildOptions.IA32]
>  
> -*_*_*_CC_FLAGS = /D EFI32
> +MSFT:*_*_*_CC_FLAGS = /D EFI32
> +GCC:*_*_*_CC_FLAGS = -DEFI32
>  
>  [sources.common]
>   InventoryStrings.uni

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 18/19] IntelUndiPkg/GigUndiDxe: add missing EFIAPI modifiers

2019-01-30 Thread Ard Biesheuvel
On Wed, 30 Jan 2019 at 16:31, Ryszard Knop  wrote:
>
> Builds were fine, the result didn't work. Adding proper EFIAPIs fixed
> that, so should be okay everywhere.
>

Right. No I didn't spot that - I did build tests of all architectures,
and boot tests on 64-bit ARM. (I don't have x86 hardware with PCIe
slots)

> On Wed, 2019-01-30 at 16:20 +0100, Ard Biesheuvel wrote:
> > On Wed, 30 Jan 2019 at 16:15, Ryszard Knop <
> > ryszard.k...@linux.intel.com> wrote:
> > > I'm going through all the protocols we have defined/used and in
> > > Decode.c/h there's [E1000]UndiApiEntry for PXE/UNDI callbacks. I've
> > > tested an X64 GCC build under OVMF and these calls were broken due
> > > to
> > > mismatched calling conventions. Did this work correctly for your
> > > builds
> > > on your platforms?
> > >
> >
> > Do you mean the builds were broken? Or the resulting builds didn't
> > work?
> >
> > In any case, that issue only exists on X64, since there are different
> > SysV and MS calling conventions. and GCC uses the former by default.
> > On ARM, there is no such difference.
> >
> > > Reviewed-by: Ryszard Knop 
> > >
> > > On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> > > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > > Signed-off-by: Ard Biesheuvel 
> > > > ---
> > > >  IntelUndiPkg/GigUndiDxe/AdapterInformation.c  | 3 +++
> > > >  IntelUndiPkg/GigUndiDxe/ComponentName.c   | 2 ++
> > > >  IntelUndiPkg/GigUndiDxe/ComponentName.h   | 1 +
> > > >  IntelUndiPkg/GigUndiDxe/DriverConfiguration.c | 3 +++
> > > >  IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c   | 1 +
> > > >  IntelUndiPkg/GigUndiDxe/DriverHealth.c| 2 ++
> > > >  IntelUndiPkg/GigUndiDxe/StartStop.c   | 2 ++
> > > >  7 files changed, 14 insertions(+)
> > > >
> > > > diff --git a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > > b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > > index 8918c538e447..1cece79911b1 100644
> > > > --- a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > > +++ b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > > @@ -123,6 +123,7 @@ GetIpv6SupportInformationBlock (
> > > >  **/
> > > >  STATIC
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  GetInformation (
> > > >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> > > >IN  EFI_GUID *InformationType,
> > > > @@ -188,6 +189,7 @@ GetInformation (
> > > >  **/
> > > >  STATIC
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  SetInformation (
> > > >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> > > >IN  EFI_GUID *InformationType,
> > > > @@ -234,6 +236,7 @@ SetInformation (
> > > >  **/
> > > >  STATIC
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  GetSupportedTypes (
> > > >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> > > >OUT EFI_GUID **   InfoTypesBuffer,
> > > > diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > > b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > > index 70baf00f4a5d..2bf9bbfbe0e4 100644
> > > > --- a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > > +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > > @@ -112,6 +112,7 @@ ComponentNameInitializeControllerName (
> > > >  language specified by
> > > > Language.
> > > >  **/
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  ComponentNameGetDriverName (
> > > >IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> > > >IN  CHAR8 *  Language,
> > > > @@ -182,6 +183,7 @@ ComponentNameGetDriverName (
> > > >  language specified by
> > > > Language.
> > > >  **/
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  ComponentNameGetControllerName (
> > > >IN  EFI_COMPONENT_NAME_PROTOCOL
> > > > *   This,
> > > >IN  EFI_HANDLE
> > > >   Co
> > > > ntrollerHandle,
> > > > diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > > b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > > index 5a3d414c6970..0b93a5410fc0 100644
> > > > --- a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > > +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > > @@ -65,6 +65,7 @@ ComponentNameInitializeControllerName (
> > > >  language specified by
> > > > Language.
> > > >  **/
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  ComponentNameGetDriverName (
> > > >IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> > > >IN  CHAR8 *  Language,
> > > > diff --git a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > > b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > > index 20d40ab672ef..99e086d81044 100644
> > > > --- a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > > +++ b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > > @@ -310,6 +310,7 @@ GigUndiDriverConfigurationDisplayMenu (
> > > > @retval   EFI_SUCCESS   Configuration was successful
> > > >  **/
> > > >  EFI_STATUS
> > > > +EFIAPI
> > > >  GigUndiDriverConfigurationSetOptions (
> > > 

Re: [edk2] [PATCH edk2-staging 18/19] IntelUndiPkg/GigUndiDxe: add missing EFIAPI modifiers

2019-01-30 Thread Ryszard Knop
Builds were fine, the result didn't work. Adding proper EFIAPIs fixed
that, so should be okay everywhere.

On Wed, 2019-01-30 at 16:20 +0100, Ard Biesheuvel wrote:
> On Wed, 30 Jan 2019 at 16:15, Ryszard Knop <
> ryszard.k...@linux.intel.com> wrote:
> > I'm going through all the protocols we have defined/used and in
> > Decode.c/h there's [E1000]UndiApiEntry for PXE/UNDI callbacks. I've
> > tested an X64 GCC build under OVMF and these calls were broken due
> > to
> > mismatched calling conventions. Did this work correctly for your
> > builds
> > on your platforms?
> > 
> 
> Do you mean the builds were broken? Or the resulting builds didn't
> work?
> 
> In any case, that issue only exists on X64, since there are different
> SysV and MS calling conventions. and GCC uses the former by default.
> On ARM, there is no such difference.
> 
> > Reviewed-by: Ryszard Knop 
> > 
> > On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel 
> > > ---
> > >  IntelUndiPkg/GigUndiDxe/AdapterInformation.c  | 3 +++
> > >  IntelUndiPkg/GigUndiDxe/ComponentName.c   | 2 ++
> > >  IntelUndiPkg/GigUndiDxe/ComponentName.h   | 1 +
> > >  IntelUndiPkg/GigUndiDxe/DriverConfiguration.c | 3 +++
> > >  IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c   | 1 +
> > >  IntelUndiPkg/GigUndiDxe/DriverHealth.c| 2 ++
> > >  IntelUndiPkg/GigUndiDxe/StartStop.c   | 2 ++
> > >  7 files changed, 14 insertions(+)
> > > 
> > > diff --git a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > index 8918c538e447..1cece79911b1 100644
> > > --- a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > +++ b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > > @@ -123,6 +123,7 @@ GetIpv6SupportInformationBlock (
> > >  **/
> > >  STATIC
> > >  EFI_STATUS
> > > +EFIAPI
> > >  GetInformation (
> > >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> > >IN  EFI_GUID *InformationType,
> > > @@ -188,6 +189,7 @@ GetInformation (
> > >  **/
> > >  STATIC
> > >  EFI_STATUS
> > > +EFIAPI
> > >  SetInformation (
> > >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> > >IN  EFI_GUID *InformationType,
> > > @@ -234,6 +236,7 @@ SetInformation (
> > >  **/
> > >  STATIC
> > >  EFI_STATUS
> > > +EFIAPI
> > >  GetSupportedTypes (
> > >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> > >OUT EFI_GUID **   InfoTypesBuffer,
> > > diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > index 70baf00f4a5d..2bf9bbfbe0e4 100644
> > > --- a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > > @@ -112,6 +112,7 @@ ComponentNameInitializeControllerName (
> > >  language specified by
> > > Language.
> > >  **/
> > >  EFI_STATUS
> > > +EFIAPI
> > >  ComponentNameGetDriverName (
> > >IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> > >IN  CHAR8 *  Language,
> > > @@ -182,6 +183,7 @@ ComponentNameGetDriverName (
> > >  language specified by
> > > Language.
> > >  **/
> > >  EFI_STATUS
> > > +EFIAPI
> > >  ComponentNameGetControllerName (
> > >IN  EFI_COMPONENT_NAME_PROTOCOL
> > > *   This,
> > >IN  EFI_HANDLE
> > >   Co
> > > ntrollerHandle,
> > > diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > index 5a3d414c6970..0b93a5410fc0 100644
> > > --- a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > > @@ -65,6 +65,7 @@ ComponentNameInitializeControllerName (
> > >  language specified by
> > > Language.
> > >  **/
> > >  EFI_STATUS
> > > +EFIAPI
> > >  ComponentNameGetDriverName (
> > >IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> > >IN  CHAR8 *  Language,
> > > diff --git a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > index 20d40ab672ef..99e086d81044 100644
> > > --- a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > +++ b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > > @@ -310,6 +310,7 @@ GigUndiDriverConfigurationDisplayMenu (
> > > @retval   EFI_SUCCESS   Configuration was successful
> > >  **/
> > >  EFI_STATUS
> > > +EFIAPI
> > >  GigUndiDriverConfigurationSetOptions (
> > >IN EFI_DRIVER_CONFIGURATION_PROTOCOL *  This,
> > >IN
> > > EFI_HANDLE   ControllerHandle,
> > > @@ -418,6 +419,7 @@ GigUndiDriverConfigurationSetOptions (
> > > @retval   EFI_SUCCESS   Always returned
> > >  **/
> > >  EFI_STATUS
> > > +EFIAPI
> > >  GigUndiDriverConfigurationOptionsValid (
> > >IN 

Re: [edk2] [PATCH edk2-staging 15/19] IntelUndiPkg/GigUndiDxe: remove forward declaration of non-existent function

2019-01-30 Thread Ryszard Knop
Reviewed-by: Ryszard Knop 

On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> Remove the forward declaration of e1000_disable_ulp_lpt_lp (), which
> is never defined anywhere in the code.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/GigUndiDxe/e1000_ich8lan.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/IntelUndiPkg/GigUndiDxe/e1000_ich8lan.c
> b/IntelUndiPkg/GigUndiDxe/e1000_ich8lan.c
> index 7669630a5c03..e9fc5394ab28 100644
> --- a/IntelUndiPkg/GigUndiDxe/e1000_ich8lan.c
> +++ b/IntelUndiPkg/GigUndiDxe/e1000_ich8lan.c
> @@ -103,9 +103,6 @@ STATIC s32  e1000_reset_hw_ich8lan(struct
> e1000_hw *hw);
>  STATIC s32  e1000_init_hw_ich8lan(struct e1000_hw *hw);
>  STATIC s32  e1000_setup_link_ich8lan(struct e1000_hw *hw);
>  STATIC s32  e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
> -#if !defined(NO_ULP_IN_S5_SUPPORT) 
> -STATIC s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool
> force);
> -#endif /* !NO_ULP_IN_S5_SUPPORT && !ULP_IN_D0_SUPPORT */
>  STATIC s32  e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
>  STATIC s32  e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
>  u16 *speed, u16 *duplex);

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-staging 18/19] IntelUndiPkg/GigUndiDxe: add missing EFIAPI modifiers

2019-01-30 Thread Ryszard Knop
I'm going through all the protocols we have defined/used and in
Decode.c/h there's [E1000]UndiApiEntry for PXE/UNDI callbacks. I've
tested an X64 GCC build under OVMF and these calls were broken due to
mismatched calling conventions. Did this work correctly for your builds
on your platforms?

Reviewed-by: Ryszard Knop 

On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  IntelUndiPkg/GigUndiDxe/AdapterInformation.c  | 3 +++
>  IntelUndiPkg/GigUndiDxe/ComponentName.c   | 2 ++
>  IntelUndiPkg/GigUndiDxe/ComponentName.h   | 1 +
>  IntelUndiPkg/GigUndiDxe/DriverConfiguration.c | 3 +++
>  IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c   | 1 +
>  IntelUndiPkg/GigUndiDxe/DriverHealth.c| 2 ++
>  IntelUndiPkg/GigUndiDxe/StartStop.c   | 2 ++
>  7 files changed, 14 insertions(+)
> 
> diff --git a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> index 8918c538e447..1cece79911b1 100644
> --- a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> +++ b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> @@ -123,6 +123,7 @@ GetIpv6SupportInformationBlock (
>  **/
>  STATIC
>  EFI_STATUS
> +EFIAPI
>  GetInformation (
>IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
>IN  EFI_GUID *InformationType,
> @@ -188,6 +189,7 @@ GetInformation (
>  **/
>  STATIC
>  EFI_STATUS
> +EFIAPI
>  SetInformation (
>IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
>IN  EFI_GUID *InformationType,
> @@ -234,6 +236,7 @@ SetInformation (
>  **/
>  STATIC
>  EFI_STATUS
> +EFIAPI
>  GetSupportedTypes (
>IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
>OUT EFI_GUID **   InfoTypesBuffer,
> diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> index 70baf00f4a5d..2bf9bbfbe0e4 100644
> --- a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> @@ -112,6 +112,7 @@ ComponentNameInitializeControllerName (
>  language specified by Language.
>  **/
>  EFI_STATUS
> +EFIAPI
>  ComponentNameGetDriverName (
>IN  EFI_COMPONENT_NAME_PROTOCOL *This,
>IN  CHAR8 *  Language,
> @@ -182,6 +183,7 @@ ComponentNameGetDriverName (
>  language specified by Language.
>  **/
>  EFI_STATUS
> +EFIAPI
>  ComponentNameGetControllerName (
>IN  EFI_COMPONENT_NAME_PROTOCOL
> *   This,
>IN  EFI_HANDLE  Co
> ntrollerHandle,
> diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> index 5a3d414c6970..0b93a5410fc0 100644
> --- a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> @@ -65,6 +65,7 @@ ComponentNameInitializeControllerName (
>  language specified by Language.
>  **/
>  EFI_STATUS
> +EFIAPI
>  ComponentNameGetDriverName (
>IN  EFI_COMPONENT_NAME_PROTOCOL *This,
>IN  CHAR8 *  Language,
> diff --git a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> index 20d40ab672ef..99e086d81044 100644
> --- a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> +++ b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> @@ -310,6 +310,7 @@ GigUndiDriverConfigurationDisplayMenu (
> @retval   EFI_SUCCESS   Configuration was successful
>  **/
>  EFI_STATUS
> +EFIAPI
>  GigUndiDriverConfigurationSetOptions (
>IN EFI_DRIVER_CONFIGURATION_PROTOCOL *  This,
>IN EFI_HANDLE   ControllerHandle,
> @@ -418,6 +419,7 @@ GigUndiDriverConfigurationSetOptions (
> @retval   EFI_SUCCESS   Always returned
>  **/
>  EFI_STATUS
> +EFIAPI
>  GigUndiDriverConfigurationOptionsValid (
>IN EFI_DRIVER_CONFIGURATION_PROTOCOL *   This,
>IN EFI_HANDLEControllerHandle,
> @@ -442,6 +444,7 @@ GigUndiDriverConfigurationOptionsValid (
> @retval   EFI_SUCCESS   Configuration was successful
>  **/
>  EFI_STATUS
> +EFIAPI
>  GigUndiDriverConfigurationForceDefaults (
>IN EFI_DRIVER_CONFIGURATION_PROTOCOL *   This,
>IN
> EFI_HANDLEControllerHandl
> e,
> diff --git a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> index aceb015e480f..f6152cd24c59 100644
> --- a/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> +++ b/IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c
> @@ -1394,6 +1394,7 @@ Error:
>  ChildHandle did not pass the
> diagnostic.
>  **/
>  EFI_STATUS
> +EFIAPI
>  GigUndiDriverDiagnosticsRunDiagnostics (
>IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *   This,
>IN EFI_HANDLE

Re: [edk2] [PATCH edk2-staging 18/19] IntelUndiPkg/GigUndiDxe: add missing EFIAPI modifiers

2019-01-30 Thread Ard Biesheuvel
On Wed, 30 Jan 2019 at 16:15, Ryszard Knop  wrote:
>
> I'm going through all the protocols we have defined/used and in
> Decode.c/h there's [E1000]UndiApiEntry for PXE/UNDI callbacks. I've
> tested an X64 GCC build under OVMF and these calls were broken due to
> mismatched calling conventions. Did this work correctly for your builds
> on your platforms?
>

Do you mean the builds were broken? Or the resulting builds didn't work?

In any case, that issue only exists on X64, since there are different
SysV and MS calling conventions. and GCC uses the former by default.
On ARM, there is no such difference.

> Reviewed-by: Ryszard Knop 
>
> On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  IntelUndiPkg/GigUndiDxe/AdapterInformation.c  | 3 +++
> >  IntelUndiPkg/GigUndiDxe/ComponentName.c   | 2 ++
> >  IntelUndiPkg/GigUndiDxe/ComponentName.h   | 1 +
> >  IntelUndiPkg/GigUndiDxe/DriverConfiguration.c | 3 +++
> >  IntelUndiPkg/GigUndiDxe/DriverDiagnostics.c   | 1 +
> >  IntelUndiPkg/GigUndiDxe/DriverHealth.c| 2 ++
> >  IntelUndiPkg/GigUndiDxe/StartStop.c   | 2 ++
> >  7 files changed, 14 insertions(+)
> >
> > diff --git a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > index 8918c538e447..1cece79911b1 100644
> > --- a/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > +++ b/IntelUndiPkg/GigUndiDxe/AdapterInformation.c
> > @@ -123,6 +123,7 @@ GetIpv6SupportInformationBlock (
> >  **/
> >  STATIC
> >  EFI_STATUS
> > +EFIAPI
> >  GetInformation (
> >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> >IN  EFI_GUID *InformationType,
> > @@ -188,6 +189,7 @@ GetInformation (
> >  **/
> >  STATIC
> >  EFI_STATUS
> > +EFIAPI
> >  SetInformation (
> >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> >IN  EFI_GUID *InformationType,
> > @@ -234,6 +236,7 @@ SetInformation (
> >  **/
> >  STATIC
> >  EFI_STATUS
> > +EFIAPI
> >  GetSupportedTypes (
> >IN  EFI_ADAPTER_INFORMATION_PROTOCOL *This,
> >OUT EFI_GUID **   InfoTypesBuffer,
> > diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > index 70baf00f4a5d..2bf9bbfbe0e4 100644
> > --- a/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.c
> > @@ -112,6 +112,7 @@ ComponentNameInitializeControllerName (
> >  language specified by Language.
> >  **/
> >  EFI_STATUS
> > +EFIAPI
> >  ComponentNameGetDriverName (
> >IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> >IN  CHAR8 *  Language,
> > @@ -182,6 +183,7 @@ ComponentNameGetDriverName (
> >  language specified by Language.
> >  **/
> >  EFI_STATUS
> > +EFIAPI
> >  ComponentNameGetControllerName (
> >IN  EFI_COMPONENT_NAME_PROTOCOL
> > *   This,
> >IN  EFI_HANDLE  Co
> > ntrollerHandle,
> > diff --git a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > index 5a3d414c6970..0b93a5410fc0 100644
> > --- a/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > +++ b/IntelUndiPkg/GigUndiDxe/ComponentName.h
> > @@ -65,6 +65,7 @@ ComponentNameInitializeControllerName (
> >  language specified by Language.
> >  **/
> >  EFI_STATUS
> > +EFIAPI
> >  ComponentNameGetDriverName (
> >IN  EFI_COMPONENT_NAME_PROTOCOL *This,
> >IN  CHAR8 *  Language,
> > diff --git a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > index 20d40ab672ef..99e086d81044 100644
> > --- a/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > +++ b/IntelUndiPkg/GigUndiDxe/DriverConfiguration.c
> > @@ -310,6 +310,7 @@ GigUndiDriverConfigurationDisplayMenu (
> > @retval   EFI_SUCCESS   Configuration was successful
> >  **/
> >  EFI_STATUS
> > +EFIAPI
> >  GigUndiDriverConfigurationSetOptions (
> >IN EFI_DRIVER_CONFIGURATION_PROTOCOL *  This,
> >IN EFI_HANDLE   ControllerHandle,
> > @@ -418,6 +419,7 @@ GigUndiDriverConfigurationSetOptions (
> > @retval   EFI_SUCCESS   Always returned
> >  **/
> >  EFI_STATUS
> > +EFIAPI
> >  GigUndiDriverConfigurationOptionsValid (
> >IN EFI_DRIVER_CONFIGURATION_PROTOCOL *   This,
> >IN EFI_HANDLEControllerHandle,
> > @@ -442,6 +444,7 @@ GigUndiDriverConfigurationOptionsValid (
> > @retval   EFI_SUCCESS   Configuration was successful
> >  **/
> >  EFI_STATUS
> > +EFIAPI
> >  GigUndiDriverConfigurationForceDefaults (
> >IN EFI_DRIVER_CONFIGURATION_PROTOCOL *   This,
> >IN
> > EFI_HANDLEControllerHandl
> > e,
> > 

Re: [edk2] [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if reloc info is invalid

2019-01-30 Thread Laszlo Ersek
Hi,

I think this is maybe the 3rd or 4th iteration of the patch. That's OK,
but if you don't add v2, v3, v4 identifies to the subject prefix, such
as [PATCH v2], [PATCH v3] etc, then it's too difficult to follow what
one should review vs. what is obsolete.

Anyway, I think this version is good:

On 01/30/19 02:19, Neo Hsueh wrote:
> Skip runtime relocation for PE images that provide invalid relocation
> infomation (ex: RelocDir->Size = 0) to fix a hang observed while booting
> Windows.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Neo Hsueh 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Dandan Bi 
> Cc: Laszlo Ersek 
> ---
>  MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 30 --
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
> b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> index 1bd079ad6a..e2c62e1932 100644
> --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> @@ -1002,7 +1002,7 @@ PeCoffLoaderRelocateImage (
>  
> RelocDir->VirtualAddress + RelocDir->Size - 1,
>  
> TeStrippedOffset
>  
> );
> -if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd < 
> RelocBase) {
> +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN) RelocBaseEnd < 
> (UINTN) RelocBase) {
>ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
>return RETURN_LOAD_ERROR;
>  }
> @@ -1022,7 +1022,7 @@ PeCoffLoaderRelocateImage (
>  // Run the relocation information and apply the fixups
>  //
>  FixupData = ImageContext->FixupData;
> -while (RelocBase < RelocBaseEnd) {
> +while ((UINTN) RelocBase < (UINTN) RelocBaseEnd) {
>  
>Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof 
> (EFI_IMAGE_BASE_RELOCATION));
>//
> @@ -1051,7 +1051,7 @@ PeCoffLoaderRelocateImage (
>//
>// Run this relocation record
>//
> -  while (Reloc < RelocEnd) {
> +  while ((UINTN) Reloc < (UINTN) RelocEnd) {
>  Fixup = PeCoffLoaderImageAddress (ImageContext, 
> RelocBase->VirtualAddress + (*Reloc & 0xFFF), TeStrippedOffset);
>  if (Fixup == NULL) {
>ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
> @@ -1739,13 +1739,23 @@ PeCoffLoaderRelocateImageForRuntime (
>// is present in the image. You have to check the NumberOfRvaAndSizes in
>// the optional header to verify a desired directory entry is there.
>//
> +  RelocBase = NULL;
> +  RelocBaseEnd = NULL;
>if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
>  RelocDir  = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
> -RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
> (, RelocDir->VirtualAddress, 0);
> -RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
> (,
> -
> RelocDir->VirtualAddress + RelocDir->Size - 1,
> -0
> -
> );
> +if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
> +  RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
> (, RelocDir->VirtualAddress, 0);
> +  RelocBaseEnd  = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress 
> (,
> + 
>  RelocDir->VirtualAddress + RelocDir->Size - 1,
> + 
>  0
> + 
>  );
> +}
> +if (RelocBase == NULL || RelocBaseEnd == NULL || (UINTN) RelocBaseEnd < 
> (UINTN) RelocBase) {
> +  //
> +  // relocation block is not valid, just return
> +  //
> +  return;
> +}
>} else {
>  //
>  // Cannot find relocations, cannot continue to relocate the image, 
> ASSERT for this invalid image.
> @@ -1769,7 +1779,7 @@ PeCoffLoaderRelocateImageForRuntime (
>  //
>  FixupData = RelocationData;
>  RelocBaseOrig = RelocBase;
> -while (RelocBase < RelocBaseEnd) {
> +while ((UINTN) RelocBase < (UINTN) RelocBaseEnd) {
>//
>// Add check for RelocBase->SizeOfBlock field.
>//
> @@ -1794,7 +1804,7 @@ PeCoffLoaderRelocateImageForRuntime (
>//
>// Run this relocation record
>//
> -  while (Reloc < RelocEnd) {
> +  while ((UINTN) Reloc < (UINTN) RelocEnd) {
>  
>  Fixup = PeCoffLoaderImageAddress (, 
> RelocBase->VirtualAddress + (*Reloc & 0xFFF), 0);
>  if 

  1   2   >