[edk2] [PATCH v2] MdeModulePkg: Remove redundant library classes, protocols and GUIDs

2018-08-01 Thread shenglei
v2:
1.Correct some typos.
2.Remove two library classse and a protocal in .c and .h files

Some redundant library classes, protocols and GUIDs
have been removed in inf, .c and .h files.
https://bugzilla.tianocore.org/show_bug.cgi?id=1017
https://bugzilla.tianocore.org/show_bug.cgi?id=1035
https://bugzilla.tianocore.org/show_bug.cgi?id=1033
https://bugzilla.tianocore.org/show_bug.cgi?id=1012
https://bugzilla.tianocore.org/show_bug.cgi?id=1011

Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei 
---
 MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf  | 1 -
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h   | 1 -
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf  | 1 -
 MdeModulePkg/Core/Dxe/DxeMain.inf | 1 -
 MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 1 -
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 -
 MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c   | 1 -
 MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf | 1 -
 8 files changed, 8 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf 
b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
index 4aab75bab7..d067df0400 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
@@ -60,7 +60,6 @@
   ReportStatusCodeLib
 
 [Guids]
-  gEfiDiskInfoIdeInterfaceGuid  ## SOMETIMES_PRODUCES ## 
UNDEFINED
   gEfiDiskInfoAhciInterfaceGuid ## SOMETIMES_PRODUCES ## 
UNDEFINED
 
 [Protocols]
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
index 55eb3a5a80..f9eebdd5a8 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h
@@ -44,7 +44,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index a21dd2b5ed..faf68c7d90 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -78,7 +78,6 @@
   BaseLib
   UefiDriverEntryPoint
   DebugLib
-  PeCoffLib
 
 [Protocols]
   gEfiPciHotPlugRequestProtocolGuid   ## SOMETIMES_PRODUCES
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf 
b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 68fa0a01d9..fc8af3d293 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -163,7 +163,6 @@
   gEfiHiiPackageListProtocolGuid## SOMETIMES_PRODUCES
   gEfiEbcProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiSmmBase2ProtocolGuid  ## SOMETIMES_CONSUMES
-  gEfiBlockIoProtocolGuid   ## SOMETIMES_CONSUMES
 
   # Arch Protocols
   gEfiBdsArchProtocolGuid   ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c 
b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
index 2f7e490af1..4cd219c88e 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
@@ -44,7 +44,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 
 #include 
-#include 
 #include 
 
 #include "DxeMain.h"
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf 
b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
index a2ff773a74..f11ccb0e07 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
@@ -66,7 +66,6 @@
   TimerLib
   HobLib
   SmmMemLib
-  DxeServicesLib
 
 [Protocols]
   gEfiDxeSmmReadyToLockProtocolGuid ## UNDEFINED # 
SmiHandlerRegister
diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c 
b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
index f41353a6b8..f1db65fc29 100644
--- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
+++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
@@ -23,7 +23,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf 
b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
index a4184212bb..36ed80cc79 100644
--- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
@@ -42,7 +42,6 @@
 
 [LibraryClasses]
   UefiBootServicesTableLib
-  MemoryAllocationLib
   UefiDriverEntryPoint
   BaseMemoryLib
   BaseLib
-- 
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 1/6] MdePkg/UefiLib: introduce EfiOpenFileByDevicePath()

2018-08-01 Thread Gao, Liming
Laszlo:
  I have no other comments. IntelFrameworkPkg has another UefiLib library 
instance FrameworkUefiLib. Could you help update it also?

  For MdePkg, you can add Reviewed-by: Liming Gao 

Thanks
Liming
>-Original Message-
>From: Laszlo Ersek [mailto:ler...@redhat.com]
>Sent: Monday, July 30, 2018 10:14 PM
>To: Ni, Ruiyu ; edk2-devel-01 
>Cc: Zhang, Chao B ; Dong, Eric
>; Carsey, Jaben ; Wu, Jiaxin
>; Yao, Jiewen ; Gao, Liming
>; Kinney, Michael D ;
>Roman Bacik ; Fu, Siyuan
>; Zeng, Star 
>Subject: Re: [PATCH 1/6] MdePkg/UefiLib: introduce
>EfiOpenFileByDevicePath()
>
>On 07/30/18 03:54, Ni, Ruiyu wrote:
>> On 7/27/2018 8:06 PM, Laszlo Ersek wrote:
>>> On 07/27/18 11:28, Ni, Ruiyu wrote:
 On 7/19/2018 4:50 AM, Laszlo Ersek wrote:

> +  //
> +  // Traverse the device path nodes relative to the filesystem.
> +  //
> +  while (!IsDevicePathEnd (*FilePath)) {
> +    //
> +    // Keep local variables that relate to the current device path
> node tightly
> +    // scoped.
> +    //
> +    FILEPATH_DEVICE_PATH *FilePathNode;
> +    CHAR16   *AlignedPathName;
> +    CHAR16   *PathName;
> +    EFI_FILE_PROTOCOL    *NextFile;
 1. Not sure if it follows the coding style. I would prefer to move the
 definition to the beginning of the function.
>>>
>>> OK, will do.
>>
>> Thanks!
>>
>>>

> +
> +    if (DevicePathType (*FilePath) != MEDIA_DEVICE_PATH ||
> +    DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP) {
> +  Status = EFI_INVALID_PARAMETER;
> +  goto CloseLastFile;
> +    }
> +    FilePathNode = (FILEPATH_DEVICE_PATH *)*FilePath;
> +
> +    //
> +    // FilePathNode->PathName may be unaligned, and the UEFI
> specification
> +    // requires pointers that are passed to protocol member functions
> to be
> +    // aligned. Create an aligned copy of the pathname if necessary.
> +    //
> +    if ((UINTN)FilePathNode->PathName % sizeof
> *FilePathNode->PathName == 0) {
> +  AlignedPathName = NULL;
> +  PathName = FilePathNode->PathName;
> +    } else {
> +  AlignedPathName = AllocateCopyPool (
> +  (DevicePathNodeLength (FilePathNode) -
> +   SIZE_OF_FILEPATH_DEVICE_PATH),
> +  FilePathNode->PathName
> +  );
> +  if (AlignedPathName == NULL) {
> +    Status = EFI_OUT_OF_RESOURCES;
> +    goto CloseLastFile;
> +  }
> +  PathName = AlignedPathName;
> +    }
> +
> +    //
> +    // Open the next pathname fragment with EFI_FILE_MODE_CREATE
> masked out and
> +    // with Attributes set to 0.
> +    //
> +    Status = LastFile->Open (
> + LastFile,
> + ,
> + PathName,
> + OpenMode & ~(UINT64)EFI_FILE_MODE_CREATE,
> + 0
> + );
 2. As I said in previous mail, is it really needed?
 Per spec it's not required. Per FAT driver implementation, it's also not
 required.
>>>
>>> I can do that, but it's out of scope for this series. The behavior that
>>> you point out is not a functionality bug (it is not observably erroneous
>>> behavior), just sub-optimal implementation. This series is about
>>> unifying the implementation and fixing those issues that are actual
>>> bugs. I suggest that we report a separate BZ about this question,
>>> discuss it separately, and then I can send a separate patch (which will
>>> benefit all client code at once).
>>>
>>> Does that sound acceptable?
>>
>> I agree.
>>
>>>

> +
> +    //
> +    // Retry with EFI_FILE_MODE_CREATE and the original Attributes if
> the first
> +    // attempt failed, and the caller specified EFI_FILE_MODE_CREATE.
> +    //
> +    if (EFI_ERROR (Status) && (OpenMode &
>EFI_FILE_MODE_CREATE) !=
> 0) {
> +  Status = LastFile->Open (
> +   LastFile,
> +   ,
> +   PathName,
> +   OpenMode,
> +   Attributes
> +   );
> +    }
> +
> +    //
> +    // Release any AlignedPathName on both error and success paths;
> PathName is
> +    // no longer needed.
> +    //
> +    if (AlignedPathName != NULL) {
> +  FreePool (AlignedPathName);
> +    }
> +    if (EFI_ERROR (Status)) {
> +  goto CloseLastFile;
> +    }
> +
> +    //
> +    // Advance to the next device path node.
> +    //
> +    LastFile->Close (LastFile);
> +    LastFile = NextFile;
> +    *FilePath = NextDevicePathNode (FilePathNode);
> +  }
> +
> + 

[edk2] 答复: [PATCH edk2-platforms v1 00/38] Upload for D06 platform

2018-08-01 Thread Guoheyi
Yes, it seems to us that different IORT versions require different acpica 
versions; acpica does not keep backward compatibility for IORT, i.e. newer 
acpica is not able to compile older IORT. That's really awkward :(


Heyi


-邮件原件-
发件人: Ming [mailto:ming.hu...@linaro.org] 
发送时间: 2018年8月2日 9:46
收件人: Leif Lindholm 
抄送: linaro-u...@lists.linaro.org; edk2-devel@lists.01.org; 
graeme.greg...@linaro.org; ard.biesheu...@linaro.org; Guoheyi 
; wanghuiqiang ; Huangming (Mark) 
; zhangjinsong (A) ; 
huangdaode ; John Garry ; 
xinliang@linaro.org
主题: Re: [PATCH edk2-platforms v1 00/38] Upload for D06 platform



在 8/2/2018 5:56 AM, Leif Lindholm 写道:
> On Tue, Jul 24, 2018 at 03:08:44PM +0800, Ming Huang wrote:
>> The major features of this patchset include:
>> 1 D06 source code;
>> 2 Unify some D0x modules;
>>
>> This patch set is base on pcihostbridage-v2.
>> For compiling D06, add below hunk to edk2-platforms.config [d06] 
>> LONGNAME=HiSilicon D06 DSC=Platform/Hisilicon/D06/D06.dsc
>> ARCH=AARCH64
> 
> Very helpful, thank you.
> 
>>
>> Code can also be found in github: 
>> https://github.com/hisilicon/OpenPlatformPkg.git
>> branch: d06-platform-v1
> 
> Now, I started by trying to compile this, but I run into two issues.
> 
> First, the platform fails to build without FIRMWARE_VER specified on 
> the command line, since there is an extra '"' in the definition of 
> PcdFirmwareVersionString.
> 
> Then there is a build fault when generating ACPI tables. I tried to 
> update to a newer version of acpica-tools, but I still get:
> ---
> "aarch64-linux-gnu-gcc" -x c -E -include AutoGen.h 
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/D
> sdt 
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> -I/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/H
> i1620/Hi1620AcpiTables/AcpiTablesHi1620/DEBUG
> -I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include 
> -I/work/git/edk2/ArmPlatformPkg 
> -I/work/git/edk2/ArmPlatformPkg/Include -I/work/git/edk2/EmbeddedPkg 
> -I/work/git/edk2/EmbeddedPkg/Include -I/work/git/edk2/MdeModulePkg 
> -I/work/git/edk2/MdeModulePkg/Include -I/work/git/edk2/MdePkg 
> -I/work/git/edk2/MdePkg/Include
> -I/work/git/edk2/MdePkg/Include/AArch64
> -I/work/git/edk2-platforms/Silicon/Hisilicon
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Include
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1
> 620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.i
>> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi
>> 1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.iii
> Trim --source-code -l -o
> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort."aarch64-linux-gnu-gcc"
> -x c -E -include AutoGen.h
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/D
> sdt 
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> -I/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon
> /Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/DEBUG
> -I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include 
> -I/work/git/edk2/ArmPlatformPkg 
> -I/work/git/edk2/ArmPlatformPkg/Include -I/work/git/edk2/EmbeddedPkg 
> -I/work/git/edk2/EmbeddedPkg/Include -I/work/git/edk2/MdeModulePkg 
> -I/work/git/edk2/MdeModulePkg/Include -I/work/git/edk2/MdePkg 
> -I/work/git/edk2/MdePkg/Include
> -I/work/git/edk2/MdePkg/Include/AArch64
> -I/work/git/edk2-platforms/Silicon/Hisilicon
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Include
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/H
> i1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.i
>> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/
>> Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.iii
> Trim --source-code -l -o
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/H
> i1620/Hi1620AcpiTables/AcpiTablesHi16Copyright
> (c) 2000 - 2018 Intel Corporation
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/H
> i1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.
> 71: [0004] ID Count : 0100
> Error6303 -
> Integer too large for target ^  (0100 - max 1 bytes)
> 
> Table Input:
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/H
> i1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.
> - 1991 lines, 59818 bytes, 68 fields
> 
> Compilation complete. 2 Errors, 0 Warnings, 0 Remarks
> ---
> 
> Any ideas what may be causing this?
> 
> /
> Leif
> 

I am sorry for the first issue, the modify FIRMWARE_VER patch is add alone just 
befor send out 

Re: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7 with OVMF

2018-08-01 Thread Zhang, Chao B
Hi Laszlo & Ricardo
The patch was intended to reduce the time to read TPM interface ID register. 
The interface type should not change within boot cycle according to PTP spec.
I agree to add some ASSERT after PCDSetxxsS.
But It is a core solution without platform change as PCD has been configured as 
DYN, DYNEx in DEC.  I don’t know why you meet Set Failure
In OVMF. Here, I include PCD expert to explain this.


From: Laszlo Ersek [mailto:ler...@redhat.com]
Sent: Thursday, August 2, 2018 5:49 AM
To: Ricardo Araújo ; Zhang, Chao B 
; Marc-André Lureau 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7 with 
OVMF

On 08/01/18 19:50, Ricardo Araújo wrote:
> The commit I was referring to is:
> https://github.com/tianocore/edk2/commit/f15cb995bb3880b77e15afe6facd3da05e599a17
>
> Regards,
>
> Ricardo Araujo -
> www.lsd.ufcg.edu.br/~ricardo
>
> - Mensagem original -
> De: "Ricardo Araújo" mailto:rica...@lsd.ufcg.edu.br>>
> Para: edk2-devel@lists.01.org
> Enviadas: Quarta-feira, 1 de agosto de 2018 14:33:45
> Assunto: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7
> with OVMF
>
> Hi everyone,
>
> I'm using OVMF with a simulated TPM 2.0 (from
> https://github.com/stefanberger/swtpm) and I noticed lately that PCRs
> 0-7 are zeroed after booting the vm (ubuntu 18.04) and the only
> message related to this in dmesg is:
>
> [ 2.286690] tpm_tis 00:06: 2.0 TPM (device-id 0x1, rev-id 1)
> [ 2.303753] tpm tpm0: A TPM error (256) occurred continue selftest
> [ 2.314199] tpm tpm0: starting up the TPM manually
>
> I found this started to happen after this commit , previous commits to
> that are showing boot time measurements on PCR 0-7 normally and the
> error message is gone. Has anyone experienced the same behavior? I
> followed the instructions here for building OVMF but I added the
> parameters -D TPM2_ENABLE=TRUE -D SECURE_BOOT_ENABLE=TRUE -D
> HTTP_BOOT_ENABLE=TRUE. Is there anything else I need to add to enable
> these measurements?
>
> Regards,
>
> Ricardo Araujo
> www.lsd.ufcg.edu.br/~ricardo

Thank you for the bug report. It looks like a regression to me, but the
details aren't immediately clear.

Adding Marc-André who contributed the TPM enablement for OVMF, and Chao
Zhang who authored the commit in question.

If I recall correctly, in OVMF we decided to never cache the TPM type
but always detect it. I could be remembering wrong though. See commit
6cf1880fb5b6 ("OvmfPkg: add customized Tcg2ConfigPei clone",
2018-03-09).

Chao Zhang: can you please explain what additional requirements are
presented for a platform by commit f15cb995bb38? In OVMF we use a
customized Tcg2ConfigPei module (see the commit above).


Oh wait, I suspect what's wrong. I believe there are two bugs in commit
f15cb995bb38 ("SecurityPkg: Cache TPM interface type info", 2018-06-25):

* Bug#1:

Commit f15cb995bb38  introduces a new PCD, called
"PcdActiveTpmInterfaceType", in section [PcdsDynamic, PcdsDynamicEx] of
"SecurityPkg.dec", and makes core modules from SecurityPkg dependent on
it.

Obviously this means that platforms are required to provide a Dynamic
Default for the new PCD in their DSC files, if they include those core
modules from SecurityPkg, otherwise the PCD won't actually behave
dynamically -- "set" operations will fail, and "get" operations will
just return the central default from the SecurityPkg.dec file. As a
result, the cached TPM type will always be wrong (it will look like
"undetected", 0xFF).

This could have been avoided by grepping all "*dsc*" files in the edk2
tree for references to the SecurityPkg module INF files that were about
to receive a dependency on the PCD. Such as:

  git grep -l -F \
-e SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf \
--or -e SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf \
--or -e SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf \
--or -e SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf \
'*dsc*'

This would have listed all platforms in-tree that were going to depend
on the new dynamic PCD via inclusion of the affected SecurityPkg
modules.

Running this command now, I get the following output:

  OvmfPkg/OvmfPkgIa32.dsc
  OvmfPkg/OvmfPkgIa32X64.dsc
  OvmfPkg/OvmfPkgX64.dsc
  SecurityPkg/SecurityPkg.dsc

Open source hygiene dictates that modifications to infrastructure code
or otherwise central code be accompanied by necessary updates to *ALL*
in-tree subsystems that depend on said core code. (Out-of-tree
subsystems are a different matter.) It's OK if a single contributor
cannot test every single platform -- but we can still use the mailing
list and the bug tracker for raising the issue and expose the new
dependency for platforms that we can't test, but see as affected.

Ricardo, Marc-André: does the following patch work for you guys
(build-tested only):

> diff --git 

Re: [edk2] [PATCH edk2-platforms v1 00/38] Upload for D06 platform

2018-08-01 Thread Ming


在 8/2/2018 5:56 AM, Leif Lindholm 写道:
> On Tue, Jul 24, 2018 at 03:08:44PM +0800, Ming Huang wrote:
>> The major features of this patchset include:
>> 1 D06 source code;
>> 2 Unify some D0x modules;
>>
>> This patch set is base on pcihostbridage-v2.
>> For compiling D06, add below hunk to edk2-platforms.config
>> [d06]
>> LONGNAME=HiSilicon D06
>> DSC=Platform/Hisilicon/D06/D06.dsc
>> ARCH=AARCH64
> 
> Very helpful, thank you.
> 
>>
>> Code can also be found in github: 
>> https://github.com/hisilicon/OpenPlatformPkg.git
>> branch: d06-platform-v1
> 
> Now, I started by trying to compile this, but I run into two issues.
> 
> First, the platform fails to build without FIRMWARE_VER specified on
> the command line, since there is an extra '"' in the definition of
> PcdFirmwareVersionString.
> 
> Then there is a build fault when generating ACPI tables. I tried to
> update to a newer version of acpica-tools, but I still get:
> ---
> "aarch64-linux-gnu-gcc" -x c -E -include AutoGen.h
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> -I/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/DEBUG
> -I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include
> -I/work/git/edk2/ArmPlatformPkg
> -I/work/git/edk2/ArmPlatformPkg/Include -I/work/git/edk2/EmbeddedPkg
> -I/work/git/edk2/EmbeddedPkg/Include -I/work/git/edk2/MdeModulePkg
> -I/work/git/edk2/MdeModulePkg/Include -I/work/git/edk2/MdePkg
> -I/work/git/edk2/MdePkg/Include
> -I/work/git/edk2/MdePkg/Include/AArch64
> -I/work/git/edk2-platforms/Silicon/Hisilicon
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Include
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.i
>> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.iii
> Trim --source-code -l -o
> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort."aarch64-linux-gnu-gcc"
> -x c -E -include AutoGen.h
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> -I/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/DEBUG
> -I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include
> -I/work/git/edk2/ArmPlatformPkg
> -I/work/git/edk2/ArmPlatformPkg/Include -I/work/git/edk2/EmbeddedPkg
> -I/work/git/edk2/EmbeddedPkg/Include -I/work/git/edk2/MdeModulePkg
> -I/work/git/edk2/MdeModulePkg/Include -I/work/git/edk2/MdePkg
> -I/work/git/edk2/MdePkg/Include
> -I/work/git/edk2/MdePkg/Include/AArch64
> -I/work/git/edk2-platforms/Silicon/Hisilicon
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Include
> -I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.i
>> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.iii
> Trim --source-code -l -o
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi16Copyright
> (c) 2000 - 2018 Intel Corporation
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.
> 71: [0004] ID Count : 0100
> Error6303 -
> Integer too large for target ^  (0100 - max 1 bytes)
> 
> Table Input:
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.
> - 1991 lines, 59818 bytes, 68 fields
> 
> Compilation complete. 2 Errors, 0 Warnings, 0 Remarks
> ---
> 
> Any ideas what may be causing this?
> 
> /
> Leif
> 

I am sorry for the first issue, the modify FIRMWARE_VER patch is add
alone just befor send out the patchset.

For generating acpi table, I use acpica-tools 20180508 version and it works.
I think acpica-tools are not backward compatibility and confused about 
acpica-tools.

Thanks.

>>
>> Heyi Guo (2):
>>   Hisilicon/Hi1620: Add ACPI PPTT table
>>   Platform/Hisilicon/D06: Enable ACPI PPTT
>>
>> Luqi Jiang (1):
>>   Hisilicon/D06: add apei driver
>>
>> Ming Huang (18):
>>   Silicon/Hisilicon: Modify the MRC interface for other module
>>   Silicon/Hisilicon: Separate PlatformArch.h
>>   Hisilicon/D06: Add several basal file for D06
>>   Platform/Hisilicon/D06: Add M41T83RealTimeClockLib
>>   Platform/Hisilicon/D06: Add binary file for D06
>>   

Re: [edk2] [PATCH edk2-platforms 3/3] Platform/Microsoft: Add Lauterbach debug library

2018-08-01 Thread Chris Co



> -Original Message-
> From: Leif Lindholm 
> Sent: Wednesday, August 1, 2018 2:39 AM
> To: Ard Biesheuvel 
> Cc: Chris Co ; edk2-devel@lists.01.org;
> Michael D Kinney 
> Subject: Re: [PATCH edk2-platforms 3/3] Platform/Microsoft: Add
> Lauterbach debug library
> 
> On Tue, Jul 31, 2018 at 10:59:22PM +0200, Ard Biesheuvel wrote:
> > On 31 July 2018 at 22:56, Leif Lindholm  wrote:
> > > On Tue, Jul 17, 2018 at 02:05:45AM +, Chris Co wrote:
> > >> This debug library provides support for importing symbols to debug
> > >> using Lauterbach.
> > >>
> > >> Derived from: ArmPkg\Library\DebugPeCoffExtraActionLib
> > >
> > > I'm not seeing any difference between this one and the original
> > > other than the addition of the Microsoft copyright statement and
> > > updating of the debug printouts to modern style.
> > >
> > > I would be happy to take this as a patch to the original, but I
> > > don't see what benefit this copy brings. What prevents you from
> > > using the original?
> >
> > The 'data.load.elf' statement in
> > PeCoffLoaderRelocateImageExtraAction() is particular to Lauterbach
> 
> Oh, right.
> 
> That (original) code badly needs reformatting.
> 
> Still, if that's the only difference - and in a debug printout, why fork the
> module?
> 
> If there is a way to identify which debugger is being used, use that.
> If not, dump all the possible strings.
> 

Currently I didn't find a way to identify the debugger being used.  Default 
behavior of the original code assumes ARM platforms use DS5 debugger.  I could 
introduce a PCD or compile flag so the developer can indicate DS5 vs Lauterbach 
debugger and key the debug print off of that.
Regarding dumping all possible strings, I am not sure exactly how the DS5 
output string is being used.  i.e. does the DS5 software receive the serial 
info directly?  If so, does it expect to see a specific format?  Is the 
software resilient enough that it can handle the Lauterbach spew on the same 
channel?

> We really don't want a situation where you need to hard-code which
> debugger you are using for a specific platform. And even if that is
> unavoidable, it needs to live in the main edk2 repository.
> 

Agreed

> /
> Leif


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


Re: [edk2] [Patch] NetworkPkg/HttpDxe: Stripped square brackets in IPv6 expressed HostName.

2018-08-01 Thread Wu, Jiaxin
Thanks Laszlo, I have refined the patch to v2 with your "Reviewed-by" tag.



> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Wednesday, August 1, 2018 5:49 PM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan 
> Subject: Re: [Patch] NetworkPkg/HttpDxe: Stripped square brackets in IPv6
> expressed HostName.
> 
> On 08/01/18 03:54, Jiaxin Wu wrote:
> > In URI, the colon (:) is used to terminate the HostName path before
> > a port number. However, if HostName is expressed as IPv6 format, colon
> > characters in IPv6 addresses will conflict with the colon before port
> > number. To alleviate this conflict in URI, the IPv6 expressed HostName
> > are enclosed in square brackets ([]). To record the real IPv6 HostName,
> > square brackets should be stripped.
> >
> > Cc: Ye Ting 
> > Cc: Fu Siyuan 
> > Cc: Laszlo Ersek 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Wu Jiaxin 
> > ---
> >  NetworkPkg/HttpDxe/HttpImpl.c | 17 ++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/NetworkPkg/HttpDxe/HttpImpl.c
> b/NetworkPkg/HttpDxe/HttpImpl.c
> > index 17deceb395..e05ee9344b 100644
> > --- a/NetworkPkg/HttpDxe/HttpImpl.c
> > +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> > @@ -403,14 +403,25 @@ EfiHttpRequest (
> >  Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, 
> > );
> >  if (EFI_ERROR (Status)) {
> >goto Error1;
> >  }
> >
> > -HostName   = NULL;
> > -Status = HttpUrlGetHostName (Url, UrlParser, );
> > +Status = HttpUrlGetHostName (Url, UrlParser, );
> >  if (EFI_ERROR (Status)) {
> > - goto Error1;
> > +  goto Error1;
> > +}
> > +
> > +if (HttpInstance->LocalAddressIsIPv6 && AsciiStrSize (HostName) > 2
> &&
> > +HostName[0] == '[' && *(HostName + (AsciiStrSize (HostName) - 2))
> == ']') {
> > +  //
> > +  // HostName format is expressed as IPv6, so, remove '[' and ']'.
> > +  //
> > +  HostNameSize = AsciiStrSize (HostName) - 2;
> > +
> > +  CopyMem (HostName, HostName + 1, HostNameSize - 1);
> > +
> > +  *(HostName + HostNameSize - 1) = '\0';
> >  }
> >
> >  Status = HttpUrlGetPort (Url, UrlParser, );
> >  if (EFI_ERROR (Status)) {
> >if (HttpInstance->UseHttps) {
> >
> 
> There are a number of expressions of the form
> 
>   *(HostName + Offset)
> 
> which could be rewritten more idiomatically as
> 
>   HostName[Offset]
> 
> In addition, I think the code could be optimized by calculating
> AsciiStrSize() only once:
> 
>   if (HttpInstance->LocalAddressIsIPv6) {
> HostNameSize = AsciiStrSize (HostName);
> 
> if (HostNameSize > 2 &&
> HostName[0] == '[' &&
> HostName[HostNameSize - 2] == ']') {
>   //
>   // HostName format is expressed as IPv6, so, remove '[' and ']'.
>   //
>   HostNameSize -= 2;
>   CopyMem (HostName, HostName + 1, HostNameSize - 1);
>   HostName[HostNameSize - 1] = '\0';
> }
>   }
> 
> Under my proposal, if the inner condition fails, then "HostNameSize"
> will be set as a "side effect", but I don't think that's a problem.
> 
> 
> Anyway, the patch seems technically correct; if you don't want to submit
> a v2, I'm fine with this variant too:
> 
> Reviewed-by: Laszlo Ersek 
> 
> I have just one request for the subject line, before you push the patch:
> please replace "stripped" with "strip".
> 
> Thanks!
> Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg DxeCapsuleLibFmp: Add NULL check to the return buffers

2018-08-01 Thread Wu, Hao A
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu


> -Original Message-
> From: Zeng, Star
> Sent: Thursday, August 02, 2018 9:16 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Yao, Jiewen; Wu, Hao A
> Subject: [PATCH] MdeModulePkg DxeCapsuleLibFmp: Add NULL check to the
> return buffers
> 
> Add NULL check to the return buffers from GetFmpHandleBufferByType().
> 
> Cc: Jiewen Yao 
> Cc: Hao A Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> index 85848279d44c..91c6849a4658 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> @@ -1225,7 +1225,9 @@ ProcessFmpCapsuleImage (
> ,
> 
> );
> -if (EFI_ERROR(Status)) {
> +if (EFI_ERROR(Status) ||
> +(HandleBuffer == NULL) ||
> +(ResetRequiredBuffer == NULL)) {
>NotReady = TRUE;
>RecordFmpCapsuleStatus (
>  NULL,
> --
> 2.7.0.windows.1

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


[edk2] [PATCH v2] NetworkPkg/HttpDxe: Strip square brackets in IPv6 expressed HostName.

2018-08-01 Thread Jiaxin Wu
*v2: Optimize the patch by calculating AsciiStrSize() only once.

In URI, the colon (:) is used to terminate the HostName path before
a port number. However, if HostName is expressed as IPv6 format, colon
characters in IPv6 addresses will conflict with the colon before port
number. To alleviate this conflict in URI, the IPv6 expressed HostName
are enclosed in square brackets ([]). To record the real IPv6 HostName,
square brackets should be stripped.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Laszlo Ersek 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
Reviewed-by: Fu Siyuan 
Reviewed-by: Laszlo Ersek 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 17deceb395..de48243982 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -403,14 +403,26 @@ EfiHttpRequest (
 Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, );
 if (EFI_ERROR (Status)) {
   goto Error1;
 }
 
-HostName   = NULL;
-Status = HttpUrlGetHostName (Url, UrlParser, );
+Status = HttpUrlGetHostName (Url, UrlParser, );
 if (EFI_ERROR (Status)) {
- goto Error1;
+  goto Error1;
+}
+
+if (HttpInstance->LocalAddressIsIPv6) {
+  HostNameSize = AsciiStrSize (HostName);
+
+  if (HostNameSize > 2 && HostName[0] == '[' && HostName[HostNameSize - 2] 
== ']') {
+//
+// HostName format is expressed as IPv6, so, remove '[' and ']'.
+//
+HostNameSize -= 2;
+CopyMem (HostName, HostName + 1, HostNameSize - 1);
+HostName[HostNameSize - 1] = '\0';
+  }
 }
 
 Status = HttpUrlGetPort (Url, UrlParser, );
 if (EFI_ERROR (Status)) {
   if (HttpInstance->UseHttps) {
-- 
2.17.1.windows.2

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


[edk2] [PATCH] MdeModulePkg DxeCapsuleLibFmp: Add NULL check to the return buffers

2018-08-01 Thread Star Zeng
Add NULL check to the return buffers from GetFmpHandleBufferByType().

Cc: Jiewen Yao 
Cc: Hao A Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c 
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 85848279d44c..91c6849a4658 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -1225,7 +1225,9 @@ ProcessFmpCapsuleImage (
,

);
-if (EFI_ERROR(Status)) {
+if (EFI_ERROR(Status) ||
+(HandleBuffer == NULL) ||
+(ResetRequiredBuffer == NULL)) {
   NotReady = TRUE;
   RecordFmpCapsuleStatus (
 NULL,
-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH edk2-platforms 1/3] Platform/Microsoft: Add SdMmc Dxe Driver

2018-08-01 Thread Chris Co
Hi Leif,

> -Original Message-
> From: Leif Lindholm 
> Sent: Tuesday, July 31, 2018 1:33 PM
> To: Chris Co 
> Cc: edk2-devel@lists.01.org; Ard Biesheuvel ;
> Michael D Kinney 
> Subject: Re: [PATCH edk2-platforms 1/3] Platform/Microsoft: Add SdMmc
> Dxe Driver
> 
> Hi Chris,
> 
> On Tue, Jul 17, 2018 at 02:05:42AM +, Chris Co wrote:
> > This SdMmc driver adds support to boot Windows from SD and eMMC.
> > It implements RPMB protocol support for eMMC, unique device path
> > creation for each slot on the SD bus, high speed modes, eMMC bus width
> > auto-detection, and support for high capacity SDXC cards.
> >
> > Derived from: EmbeddedPkg\Universal\MmcDxe
> 
> Hmm, I'm already slightly unhappy that we have duplication between
> EmbeddedPkg and MdeModulePkg (not to mention the extra fork for
> Marvell's XenonDxe).
> 
> I'm obviously keen for the added functionality to be available to more
> platforms. Is there any way for this support to be added into either the
> EmbeddedPkg or the MdeModulePkg driver?
> 

Understood - from talking with the other developers, we duplicated since we 
didn't know if these changes would be desired in edk2 core.  As part of the 
review, do let me know if changes would be better placed in edk2 core instead 
of platform.  I will be happy to refactor and submit patches to edk2 core.

Chris

> (Deferring comments on specific content.)
> 
> /
> Leif
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 1/7] Silicon/NXP: Add support for iMX SDHC

2018-08-01 Thread Chris Co
Hi Leif,

Thank you for the initial feedback.  I will address the items on all the 
patches and resubmit as one set.

Chris

> -Original Message-
> From: Leif Lindholm 
> Sent: Wednesday, August 1, 2018 9:15 AM
> To: Chris Co 
> Cc: edk2-devel@lists.01.org; Ard Biesheuvel ;
> Michael D Kinney 
> Subject: Re: [PATCH edk2-platforms 1/7] Silicon/NXP: Add support for iMX
> SDHC
> 
> On Thu, Jul 19, 2018 at 04:11:18AM +, Chris Co wrote:
> > This adds support for using the SD host controller on
> > NXP i.MX platforms.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Christopher Co 
> > Cc: Ard Biesheuvel 
> > Cc: Leif Lindholm 
> > Cc: Michael D Kinney 
> 
> Trying to build the code[1] in this patch throws up issues due to
> (initially) a missing dependency on a iMXIoMuxLib mapping. Which is
> not introduced in this set at all.
> 
> Could you bring these sets together into a single (huge) one,
> ensuring that code is introduced in dependency order?
> 
> It will be no more unwieldy (I can push patches from the front as they
> merit it), and will make my life a _lot_ easier.
> 
> If you can also address the items I point out as "address throughout"
> below, for all the patches, that will reduce churn.
> 
> [1] By hacking the .inf into EmbeddedPkg/EmbeddedPkg.dsc, since the
> i.MX one is also not included in this set.
> 
> > ---
> >  Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c   | 1356
> 
> >  Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.inf |   67 +
> >  Silicon/NXP/iMXPlatformPkg/Include/iMXGpio.h   |  101 ++
> >  Silicon/NXP/iMXPlatformPkg/Include/iMXuSdhc.h  |  277 
> >  4 files changed, 1801 insertions(+)
> >
> > diff --git a/Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c
> b/Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c
> > new file mode 100644
> > index ..5f087f8a28b9
> > --- /dev/null
> > +++ b/Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c
> > @@ -0,0 +1,1356 @@
> > +/** @file
> > +*
> > +*  Copyright (c) Microsoft Corporation. All rights reserved.
> 
> Please add copyright year throughout all patches.
> 
> > +*
> > +*  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
> > +*
> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopenso
> urce.org%2Flicenses%2Fbsd-
> license.phpdata=02%7C01%7CChristopher.Co%40microsoft.com%7Cc0
> f078beab2c4534017c08d5f7c9f5f5%7C72f988bf86f141af91ab2d7cd011db47%7
> C1%7C0%7C636687369157661520sdata=noPZDlLAGlOgwhpiKbfxZk%2B
> OPT6KNdeBtEi8VELsugQ%3Dreserved=0
> > +*
> > +*  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 
> 
> Please sort includes alphabetically.
> 
> > +
> > +#include 
> > +#include 
> > +
> > +typedef struct {
> > +UINT32 IoNumber;
> > +IMX_GPIO_BANK Bank;
> > +} IMX_GPIO_PIN;
> > +
> > +#define PCD_GPIO_PIN_IO_NUMBER(X)   ((X) & 0xFF)
> > +#define PCD_GPIO_PIN_BANK(X)(((X) >> 8) & 0xFF)
> > +
> > +//
> > +// A special value to indicate that GPIO is not the signal source for 
> > either
> > +// CardDetect or WriteProtect
> > +//
> > +typedef enum {
> > +USDHC_SIGNAL_GPIO_START = 0x000,
> > +USDHC_SIGNAL_GPIO_END = 0xFF00,
> > +USDHC_SIGNAL_OVERRIDE_PIN_LOW = 0xFF00,
> 
> Are the above two lines intentionally assigning the same value?
> 
> > +USDHC_SIGNAL_OVERRIDE_PIN_HIGH = 0xFF01,
> > +USDHC_SIGNAL_INTERNAL_PIN = 0x
> > +} USDHC_SIGNAL_SOURCE;
> > +
> > +#define USDHC_IS_GPIO_SIGNAL_SOURCE(X)  \
> > +(((X) >= USDHC_SIGNAL_GPIO_START) && ((X) <
> USDHC_SIGNAL_GPIO_END))
> > +
> > +typedef struct {
> > +UINT32 SdhcId;
> > +EFI_HANDLE SdhcProtocolHandle;
> > +USDHC_REGISTERS *RegistersBase;
> > +USDHC_SIGNAL_SOURCE CardDetectSignal;
> > +USDHC_SIGNAL_SOURCE WriteProtectSignal;
> > +IMX_GPIO_PIN CardDetectGpioPin;
> > +IMX_GPIO_PIN WriteProtectGpioPin;
> > +} USDHC_PRIVATE_CONTEXT;
> > +
> > +#define LOG_FMT_HELPER(FMT, ...) \
> > +"SDHC%d:" FMT "%a\n", ((SdhcCtx != NULL) ? SdhcCtx->SdhcId : -1),
> __VA_ARGS__
> > +
> > +#define LOG_INFO(...) \
> > +DEBUG((DEBUG_INFO | DEBUG_BLKIO,
> LOG_FMT_HELPER(__VA_ARGS__, "")))
> > +
> > +#define LOG_TRACE(...) \
> > +DEBUG((DEBUG_VERBOSE | DEBUG_BLKIO,
> LOG_FMT_HELPER(__VA_ARGS__, "")))
> > +
> > +#define LOG_ERROR(...) \
> > +DEBUG((DEBUG_ERROR | DEBUG_BLKIO,
> LOG_FMT_HELPER(__VA_ARGS__, "")))
> > +
> > +#define LOG_ASSERT(TXT) \
> > +

Re: [edk2] Undefined types referenced in MdePkg

2018-08-01 Thread edk2-lists
Laszlo,

Thank you for the pointers to the dependent header files.

I agree that main API header files should include any headers that they depend 
upon and not require the developer to search out the dependencies.  Most modern 
pre-processors and compilers have optimizations to mitigate reading the same 
header file multiple times.  This invalidates the old rationale for policies 
that don't allow header files to include other header files.

Now, I need to find out why my search tool didn't find those headers.  ☹

In gratitude,
Daryl McDaniel
The Year of the Justifiably Defensive Lobster.
The Season of the fraternizing CEOs.

-Original Message-
From: edk2-devel  On Behalf Of Laszlo Ersek
Sent: Wednesday, August 1, 2018 2:56 PM
To: edk2-li...@mc2research.org; edk2-devel@lists.01.org
Subject: Re: [edk2] Undefined types referenced in MdePkg

On 08/01/18 19:49, edk2-li...@mc2research.org wrote:
> When including MdePkg/Include/Library/HobLib.h in my project I get 
> errors indicating that the following types are undefined:
> 
> * EFI_RESOURCE_TYPE, lines 206 and 231
> * EFI_RESOURCE_ATTRIBUTE_TYPE, lines 207 and 232
> 
>  
> 
> A similar thing is happening with MdePkg/Include/Protocol/FirmwareVolume2.h.
> 
> * EFI_FV_FILE_ATTRIBUTES, lines 309, 443, 612
> 
>  
> 
> I updated my EDK II tree then searched the entire tree for these 
> types.  They only show up in the locations mentioned above; never defined.
> 
>  
> 
> Am I missing something or are these really undefined?
> 
>  
> 
> I don't want to just disable these errors since that could hide a 
> bigger problem.

IMO, the header files you mention should include the following files,
respectively:

- MdePkg/Include/Library/HobLib.h
  --> MdePkg/Include/Pi/PiHob.h

- MdePkg/Include/Protocol/FirmwareVolume2.h
  --> MdePkg/Include/Pi/PiFirmwareVolume.h

I'm firmly in the camp that believes that developers should not have to hunt 
down themselves the dependencies of the main API header file that they are 
actually interested in.

Thanks
Laszlo
___
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 v6 21/23] FmpDevicePkg/FmpDxe: Fix XCODE build failure

2018-08-01 Thread Kinney, Michael D
From: "Zeng, Star" 

FmpDxe.c:517:18: error: equality comparison with extraneous
parentheses [-Werror,-Wparentheses-equality]

NOTE: This patch is based on thread
https://lists.01.org/pipermail/edk2-devel/2018-July/027810.html.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 0f3396c2ef..eb3a9b0e32 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -514,7 +514,7 @@ GetTheImage (
 goto cleanup;
   }
 
-  if ((ImageSize == NULL)) {
+  if (ImageSize == NULL) {
 DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is 
NULL.\n"));
 Status = EFI_INVALID_PARAMETER;
 goto cleanup;
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 17/23] FmpDevicePkg FmpDxe: Return UNSUPPORTED if device has been locked

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Instead of EFI_ACCESS_DENIED which is not defined in retval by
UEFI spec, return UNSUPPORTED if device has been locked in
SetTheImage().

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index fb02e34f70..b25a1511c7 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -928,7 +928,7 @@ SetTheImage (
   //
   if (mFmpDeviceLocked) {
 DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Device is already locked.  
Can't update.\n"));
-Status = EFI_ACCESS_DENIED;
+Status = EFI_UNSUPPORTED;
 goto cleanup;
   }
 
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 23/23] MdeModulePkg/BdsDxe: Move display of test key usage into BDS module

2018-08-01 Thread Kinney, Michael D
Cc: Ruiyu Ni 
Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Star Zeng 
---
 MdeModulePkg/Universal/BdsDxe/BdsDxe.inf |  1 +
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf 
b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index 7e644aa995..7030d67907 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -100,6 +100,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable  ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed   ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index a25663ea43..8946d79ab2 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -884,6 +884,18 @@ BdsEntry (
   PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole");
   PlatformBootManagerAfterConsole ();
   PERF_INMODULE_END("PlatformBootManagerAfterConsole");
+
+  //
+  // If any component set PcdTestKeyUsed to TRUE because use of a test key
+  // was detected, then display a warning message on the debug log and the 
console
+  //
+  if (PcdGetBool (PcdTestKeyUsed)) {
+DEBUG ((DEBUG_ERROR, "**\n"));
+DEBUG ((DEBUG_ERROR, "**  WARNING: Test Key is used.  **\n"));
+DEBUG ((DEBUG_ERROR, "**\n"));
+Print (L"**  WARNING: Test Key is used.  **\n");
+  }
+
   //
   // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. 
Skip HotkeyBoot
   //
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 22/23] FmpDevicePkg: Remove useless lib mapping in dsc

2018-08-01 Thread Kinney, Michael D
From: "Zeng, Star" 

NOTE: This patch is based on thread
https://lists.01.org/pipermail/edk2-devel/2018-July/027810.html.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index 8d2436627d..444cd1ffa7 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -48,43 +48,24 @@ [Defines]
 
 [LibraryClasses]
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
-  
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
-  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
-  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
-  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
-  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
-  PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
-
-  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
-  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
-  
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
-  
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
-  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
   
FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
-
   
CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
   
FmpPayloadHeaderLib|FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
   FmpDeviceLib|FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
-  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
-  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   #
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 12/23] FmpDevicePkg: Remove DisplayUpdateProgressLib mapping for FmpDxe

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

FmpDxe does not consume DisplayUpdateProgressLib, so remove the
mapping in FmpDevicePkg.dsc.
Also rename the ESRT GUIDs.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index 525640de2e..8d2436627d 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -43,8 +43,8 @@ [Defines]
   #
   # Define ESRT GUIDs for Firmware Management Protocol instances
   #
-  DEFINE FMP_GRAPHICS_ESRT_GUID  = B461B3BD-E62A-4A71-841C-50BA4E500267
-  DEFINE FMP_TEXT_ESRT_GUID  = 226034C4-8B67-4536-8653-D6EE7CE5A316
+  DEFINE SYSTEM_FMP_ESRT_GUID   = B461B3BD-E62A-4A71-841C-50BA4E500267
+  DEFINE DEVICE_FMP_ESRT_GUID   = 226034C4-8B67-4536-8653-D6EE7CE5A316
 
 [LibraryClasses]
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
@@ -116,11 +116,9 @@ [Components]
   FmpDevicePkg/FmpDxe/FmpDxe.inf {
 
   #
-  # FILE_GUID is FMP ESRT GUID
+  # FILE_GUID is used as ESRT GUID
   #
-  FILE_GUID = $(FMP_GRAPHICS_ESRT_GUID)
-
-  
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
+  FILE_GUID = $(SYSTEM_FMP_ESRT_GUID)
   }
 
   FmpDevicePkg/FmpDxe/FmpDxe.inf {
@@ -128,9 +126,7 @@ [Components]
   #
   # FILE_GUID is used as ESRT GUID
   #
-  FILE_GUID = $(FMP_TEXT_ESRT_GUID)
-
-  
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
+  FILE_GUID = $(DEVICE_FMP_ESRT_GUID)
   }
 
 [BuildOptions]
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 20/23] FmpDevicePkg FmpDxe: Use local variable to store test key digest size

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Some static tool reports "the condition in 'if' statement is constant".

This patch updates the code to use local variable to store test key
digest size. It can pass the static tool's check.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/DetectTestKey.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c 
b/FmpDevicePkg/FmpDxe/DetectTestKey.c
index 6dedbdfaee..f9b983bb75 100644
--- a/FmpDevicePkg/FmpDxe/DetectTestKey.c
+++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c
@@ -53,12 +53,14 @@ DetectTestKey (
   UINT8*PublicKeyDataXdrEnd;
   VOID *HashContext;
   UINT8Digest[SHA256_DIGEST_SIZE];
+  UINTNTestKeyDigestSize;
 
   //
   // If PcdFmpDeviceTestKeySha256Digest is not exacty SHA256_DIGEST_SIZE bytes,
   // then skip the test key detection.
   //
-  if (PcdGetSize (PcdFmpDeviceTestKeySha256Digest) != SHA256_DIGEST_SIZE) {
+  TestKeyDigestSize = PcdGetSize (PcdFmpDeviceTestKeySha256Digest);
+  if (TestKeyDigestSize != SHA256_DIGEST_SIZE) {
 return;
   }
 
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 18/23] FmpDevicePkg FmpDxe: Initialize DeviceLibLowestSupportedVersion

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Some static tool reports "DeviceLibLowestSupportedVersion" is used,
but is uninitialized. It is false positive reporting based because
DeviceLibLowestSupportedVersion will have assigned value after
FmpDeviceGetLowestSupportedVersion() returns SUCCESS.

This patch updates the code to initialize
DeviceLibLowestSupportedVersion
to DEFAULT_LOWESTSUPPORTEDVERSION before calling
FmpDeviceGetLowestSupportedVersion().
It can pass the static tool's check.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index b25a1511c7..095cebaa75 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -229,6 +229,7 @@ GetLowestSupportedVersion (
   //
   // Check the FmpDeviceLib
   //
+  DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
   Status = FmpDeviceGetLowestSupportedVersion 
();
   if (EFI_ERROR (Status)) {
 DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 10/23] FmpDevicePkg FmpDxe: Add EFI_ABORTED in retval of CheckTheImage()

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index f0e8b0da82..69b6cb7d4c 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -626,6 +626,7 @@ GetAllHeaderSize (
  if available, additional information if the 
image is invalid.
 
   @retval EFI_SUCCESSThe image was successfully checked.
+  @retval EFI_ABORTEDThe operation is aborted.
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
   @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 19/23] FmpDevicePkg: Fix code style issue

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.uni  | 22 ++--
 FmpDevicePkg/FmpDxe/DetectTestKey.c|  2 +-
 FmpDevicePkg/FmpDxe/FmpDxe.c   | 42 +++---
 FmpDevicePkg/FmpDxe/VariableSupport.c  |  6 ++--
 FmpDevicePkg/FmpDxe/VariableSupport.h  |  6 ++--
 .../Include/Library/CapsuleUpdatePolicyLib.h   |  6 ++--
 FmpDevicePkg/Include/Library/FmpDeviceLib.h| 20 +--
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h |  8 ++---
 .../CapsuleUpdatePolicyLibNull.c   |  6 ++--
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c| 22 ++--
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c|  8 ++---
 11 files changed, 75 insertions(+), 73 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni
index fed1da4802..a922ff44e4 100644
--- a/FmpDevicePkg/FmpDevicePkg.uni
+++ b/FmpDevicePkg/FmpDevicePkg.uni
@@ -59,17 +59,17 @@

   "value of 0 disables the watchdog timer.  The 
default value is 0 (watchdog"

   "disabled)."
 
-#string 
STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT  
#language en-US "One or more XDR encoded PKCS7 certificates used to verify 
firmware device capsule update images"
-#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP  
  #language en-US "Provides one or more PKCS7 certificates used to verify a 
firmware device"
-   
  "capsule update image.  This PCD is encoded using the 
Variable-Length Opaque"
-   
  "Data format of RFC 4506 External Data Representation 
Standard (XDR)."
-   
  "The default value is empty with 0 certificates."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT  
#language en-US "One or more XDR encoded PKCS7 certificates used to verify 
firmware device capsule update images"
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP
#language en-US "Provides one or more PKCS7 certificates used to verify a 
firmware device"
+   
"capsule update image.  This PCD is encoded using the 
Variable-Length Opaque"
+   
"Data format of RFC 4506 External Data Representation Standard 
(XDR)."
+   
"The default value is empty with 0 certificates."
 
-#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_PROMPT  
#language en-US "Firmware Device Lock Event GUID."
-#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_HELP
#language en-US "An event GUID that locks the firmware device when the event is 
signaled."
-   
 "If this PCD is not a valid GUID value, then the firmware device 
is locked"
-   
 "when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  
The"
-   
 "default value is empty, so by default the firmware device is 
locked at the"
-   
 "end of the DXE phase."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_PROMPT  
#language en-US "Firmware Device Lock Event GUID."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_HELP
#language en-US "An event GUID that locks the firmware device when the event is 
signaled."
+   
   "If this PCD is not a valid GUID value, then the firmware device is 
locked"
+   
   "when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  
The"
+   
   "default value is empty, so by default the firmware device is locked 
at the"
+   
   

[edk2] [Patch v6 16/23] FmpDevicePkg FmpDxe: Add comment in mFmpDeviceLocked's declaration

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Add comment in mFmpDeviceLocked's declaration to make it more clear.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 3544afd3de..fb02e34f70 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -89,6 +89,13 @@ UINT64  mImageId  = 0x1;
 CHAR16  *mVersionName = NULL;
 
 EFI_EVENT  mFmpDeviceLockEvent;
+//
+// Indicates if an attempt has been made to lock a 
+// FLASH storage device by calling FmpDeviceLock().
+// A FLASH storage device may not support being locked,
+// so this variable is set to TRUE even if FmpDeviceLock()
+// returns an error.
+//
 BOOLEANmFmpDeviceLocked = FALSE;
 
 /**
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 15/23] FmpDevicePkg FmpDxe: Use Attributes to know whether reset is required

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

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

Use Attributes to know whether reset is required and remove
PcdFmpDeviceSystemResetRequired.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dec |  7 ---
 FmpDevicePkg/FmpDevicePkg.uni |  5 -
 FmpDevicePkg/FmpDxe/FmpDxe.c  | 13 ++---
 FmpDevicePkg/FmpDxe/FmpDxe.inf|  1 -
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf |  1 -
 5 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dec b/FmpDevicePkg/FmpDevicePkg.dec
index 9ea0d73359..ad0730a532 100644
--- a/FmpDevicePkg/FmpDevicePkg.dec
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -62,13 +62,6 @@ [Guids]
   gFmpDevicePkgTokenSpaceGuid = { 0x40b2d964, 0xfe11, 0x40dc, { 0x82, 0x83, 
0x2e, 0xfb, 0xda, 0x29, 0x53, 0x56 } }
 
 [PcdsFixedAtBuild]
-  ## Indicates if a full system reset is required before a firmware update to a
-  #  firmware devices takes effect.
-  #   TRUE  - System reset is required.
-  #   FALSE - System reset is not required.
-  # @Prompt FMP Device System Reset Required.
-  
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired|TRUE|BOOLEAN|0x4008
-
   ## The SHA-256 hash of a PKCS7 test key that is used to detect if a test key
   #  is being used to authenticate capsules.  Test key detection is disabled by
   #  setting the value to {0}.
diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni
index da31d0ac81..fed1da4802 100644
--- a/FmpDevicePkg/FmpDevicePkg.uni
+++ b/FmpDevicePkg/FmpDevicePkg.uni
@@ -22,11 +22,6 @@
 
 #string STR_PACKAGE_DESCRIPTION  #language en-US  "This package provides 
libraries that support the implementation of a module that produces the 
Firmware Management Protocol to support the update of a system firmware 
component."
 
-#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_PROMPT 
 #language en-US "FMP Device System Reset Required."
-#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_HELP   
 #language en-US "Indicates if a full system reset is required before a 
firmware update to a firmware device takes effect.\n"
-   
 "TRUE  - System reset is required.\n"
-   
 "FALSE - System reset is not required."
-
 #string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceTestKeySha256Digest_PROMPT 
 #language en-US "SHA-256 hash of PKCS7 test key."
 #string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceTestKeySha256Digest_HELP   
 #language en-US "The SHA-256 hash of a PKCS7 test key that is used to detect 
if a test key"

 "is being used to authenticate capsules.  Test key detection 
can be disabled"
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 94fdf56085..3544afd3de 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -898,6 +898,9 @@ SetTheImage (
   UINT32  AllHeaderSize;
   UINT32  IncommingFwVersion;
   UINT32  LastAttemptStatus;
+  EFI_STATUS  GetAttributesStatus;
+  UINT64  AttributesSupported;
+  UINT64  AttributesSetting;
 
   Status = EFI_SUCCESS;
   Updateable = 0;
@@ -1110,10 +1113,14 @@ SetTheImage (
 
   //
   // Set flag so the descriptor is repopulated
-  // This only applied to devices that do not require system reboot
+  // This is only applied to devices that do not require reset
   //
-  if (!PcdGetBool (PcdFmpDeviceSystemResetRequired)) {
-mDescriptorPopulated = FALSE;
+  GetAttributesStatus = FmpDeviceGetAttributes (, 
);
+  if (!EFI_ERROR (GetAttributesStatus)) {
+if (((AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0) ||
+((AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0)) {
+  mDescriptorPopulated = FALSE;
+}
   }
 
 cleanup:
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index ec2bb2d052..228e53658a 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -76,7 +76,6 @@ [Protocols]
   gEdkiiFirmwareManagementProgressProtocolGuid  ## PRODUCES
 
 [Pcd]
-  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired  ## 
CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName  ## 
CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion  ## 
CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid## 
CONSUMES
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf 
b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
index 41acf45fcf..5484531155 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -76,7 +76,6 @@ 

[edk2] [Patch v6 13/23] FmpDevicePkg FmpDxe: Add NULL check to return Value from GetVariable2

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/VariableSupport.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c 
b/FmpDevicePkg/FmpDxe/VariableSupport.c
index c15178d099..6a4330ad6a 100644
--- a/FmpDevicePkg/FmpDxe/VariableSupport.c
+++ b/FmpDevicePkg/FmpDxe/VariableSupport.c
@@ -72,7 +72,7 @@ GetVersionFromVariable (
   Version = DEFAULT_VERSION;
 
   Status = GetVariable2 (VARNAME_VERSION, , (VOID **), 
);
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_ERROR, "Failed to get the Version from variable.  Status = 
%r\n", Status));
 return Version;
   }
@@ -125,7 +125,7 @@ GetLowestSupportedVersionFromVariable (
   Version = DEFAULT_LOWESTSUPPORTEDVERSION;
 
   Status = GetVariable2 (VARNAME_LSV, , (VOID **), 
);
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_WARN, "Warning: Failed to get the Lowest Supported Version 
from variable.  Status = %r\n", Status));
 return Version;
   }
@@ -177,7 +177,7 @@ GetLastAttemptStatusFromVariable (
   LastAttemptStatus = DEFAULT_LASTATTEMPT;
 
   Status = GetVariable2 (VARNAME_LASTATTEMPTSTATUS, , (VOID 
**), );
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_WARN, "Warning: Failed to get the Last Attempt Status from 
variable.  Status = %r\n", Status));
 return LastAttemptStatus;
   }
@@ -233,7 +233,7 @@ GetLastAttemptVersionFromVariable (
   Version = DEFAULT_LASTATTEMPT;
 
   Status = GetVariable2 (VARNAME_LASTATTEMPTVERSION, , (VOID 
**), );
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_WARN, "Warning: Failed to get the Last Attempt Version from 
variable.  Status = %r\n", Status));
 return Version;
   }
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 14/23] FmpDevicePkg FmpDxe: Check ImageIndex first before Image/ImageSize

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

It does not make sense to check the Image/ImageSize if ImageIndex
has been invalid.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index eb45273754..94fdf56085 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -497,6 +497,15 @@ GetTheImage (
 
   Status = EFI_SUCCESS;
 
+  //
+  // Check to make sure index is 1 (only 1 image for this device)
+  //
+  if (ImageIndex != 1) {
+DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));
+Status = EFI_INVALID_PARAMETER;
+goto cleanup;
+  }
+
   if ((ImageSize == NULL)) {
 DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is 
NULL.\n"));
 Status = EFI_INVALID_PARAMETER;
@@ -523,16 +532,6 @@ GetTheImage (
 goto cleanup;
   }
 
-  //
-  // Check to make sure index is 1 (only 1 image for this device)
-  //
-  if (ImageIndex != 1) {
-DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));
-Status = EFI_INVALID_PARAMETER;
-goto cleanup;
-  }
-
-
   Status = FmpDeviceGetImage (Image, ImageSize);
 cleanup:
 
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 11/23] FmpDevicePkg FmpDxe: Fix typo "EFI_SECURITY_VIOLATIO"

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Fix typo "EFI_SECURITY_VIOLATIO" to "EFI_SECURITY_VIOLATION".

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 69b6cb7d4c..eb45273754 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -480,7 +480,7 @@ cleanup:
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_NOT_FOUND  The current image is not copied to the buffer.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
@@ -629,7 +629,7 @@ GetAllHeaderSize (
   @retval EFI_ABORTEDThe operation is aborted.
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
@@ -875,7 +875,7 @@ cleanup:
   @retval EFI_ABORTEDThe operation is aborted.
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
@@ -1206,7 +1206,7 @@ GetPackageInfo (
   @retval EFI_INVALID_PARAMETER  The PackageVersionName length is longer than 
the value
  returned in PackageVersionNameMaxLen.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 09/23] FmpDevicePkg FmpDxe: Check Progress!= NULL before calling Progress(100)

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 091f950b95..f0e8b0da82 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -1121,10 +1121,12 @@ cleanup:
   mProgressSupported = FALSE;
   SetLastAttemptStatusInVariable (LastAttemptStatus);
 
-  //
-  // Set progress to 100 after everything is done including recording Status.
-  //
-  Progress (100);
+  if (Progress != NULL) {
+//
+// Set progress to 100 after everything is done including recording Status.
+//
+Progress (100);
+  }
 
   return Status;
 }
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 08/23] FmpDevicePkg: Add DISABLE_NEW_DEPRECATED_INTERFACES build options

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Add DISABLE_NEW_DEPRECATED_INTERFACES build options to make sure
no deprecated interface used in this package.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index a4eac1e60d..525640de2e 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -132,3 +132,6 @@ [Components]
 
   
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
   }
+
+[BuildOptions]
+  *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 07/23] FmpDevicePkg: Remove IPF

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc   | 2 +-
 FmpDevicePkg/FmpDxe/FmpDxe.inf  | 2 +-
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf   | 2 +-
 .../Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf   | 2 +-
 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  | 2 +-
 FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf| 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index 4d08a2cf9e..a4eac1e60d 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -36,7 +36,7 @@ [Defines]
   PLATFORM_VERSION   = 0.1
   DSC_SPECIFICATION  = 0x00010005
   OUTPUT_DIRECTORY   = Build/FmpDevicePkg
-  SUPPORTED_ARCHITECTURES= IA32|IPF|X64|ARM|AARCH64
+  SUPPORTED_ARCHITECTURES= IA32|X64|ARM|AARCH64
   BUILD_TARGETS  = DEBUG|RELEASE
   SKUID_IDENTIFIER   = DEFAULT
 
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index 256c50bf03..ec2bb2d052 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -38,7 +38,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf 
b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
index c8fe49e0c0..41acf45fcf 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -39,7 +39,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
index c7c669e3e0..f92d88a7c1 100644
--- 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
+++ 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
@@ -34,7 +34,7 @@ [Defines]
   LIBRARY_CLASS   = CapsuleUpdatePolicyLib
 
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf 
b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
index d51f69d0b9..0383b250f6 100644
--- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
@@ -37,7 +37,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git 
a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf 
b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
index 41ed6e2aca..324b7cc781 100644
--- a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
+++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
@@ -37,7 +37,7 @@ [Defines]
   LIBRARY_CLASS  = FmpPayloadHeaderLib|DXE_DRIVER 
UEFI_APPLICATION
 
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 05/23] FmpDevicePkg FmpDxe: Update function comment for FmpDxeEntryPoint

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

FmpDxeEntryPoint is used by both FmpDxe and FmpDxeLib.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index b709bc282a..c0c1383723 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -1360,7 +1360,7 @@ cleanup:
 }
 
 /**
-  Main entry for this library.
+  Main entry for this driver/library.
 
   @param[in] ImageHandle  Image handle this driver.
   @param[in] SystemTable  Pointer to SystemTable.
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 06/23] FmpDevicePkg FmpDxe: Return 0 when LSV check is not required

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Current code return 1 when LSV check is not required,
but 1 LSV will make 0 Version capsule image update failed.

0 LSV is valid, this patch updates the code to return 0 when
LSV check is not required
We can see even the DEFAULT_LOWESTSUPPORTEDVERSION is 0.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index c0c1383723..091f950b95 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -210,12 +210,15 @@ GetLowestSupportedVersion (
   // Get the LowestSupportedVersion.
   //
 
-  DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
-  ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
   if (!IsLowestSupportedVersionCheckRequired ()) {
-return 1;
+//
+// Any Version can pass the 0 LowestSupportedVersion check.
+//
+return 0;
   }
 
+  ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
+
   //
   // Check the FmpDeviceLib
   //
-- 
2.14.2.windows.3

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


[edk2] [Patch v6 04/23] FmpDevicePkg: Add DSC file to build all package components

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Adds a DSC file that is used to verify that all of the
FmpDevicePkg libraries and modules build without error.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Star Zeng 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 134 ++
 1 file changed, 134 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
new file mode 100644
index 00..4d08a2cf9e
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -0,0 +1,134 @@
+## @file
+# Firmware Management Protocol Device Package
+#
+# This package provides an implementation of a Firmware Management Protocol
+# instance that supports the update of firmware storage devices using UEFI
+# Capsules.  The behavior of the Firmware Management Protocol instance is
+# customized using libraries and PCDs.
+#
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+# Copyright (c) 2018, Intel Corporation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+##
+
+[Defines]
+  PLATFORM_NAME  = FmpDevicePkg
+  PLATFORM_GUID  = 0af3d540-27c6-11e8-828b-f8597177a00a
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x00010005
+  OUTPUT_DIRECTORY   = Build/FmpDevicePkg
+  SUPPORTED_ARCHITECTURES= IA32|IPF|X64|ARM|AARCH64
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+
+  #
+  # Define ESRT GUIDs for Firmware Management Protocol instances
+  #
+  DEFINE FMP_GRAPHICS_ESRT_GUID  = B461B3BD-E62A-4A71-841C-50BA4E500267
+  DEFINE FMP_TEXT_ESRT_GUID  = 226034C4-8B67-4536-8653-D6EE7CE5A316
+
+[LibraryClasses]
+  
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+  
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+  
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+
+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+  

[edk2] [Patch v6 02/23] FmpDevicePkg: Add library instances

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Add library instances for FmpDeviceLib, CapsuleUpdatePolicyLib,
and FmpPayloadHeaderLib.

Library Classes
===
* FmpDeviceLibNull - Non-functional template of the FmpDeviceLib
  that can be used as a starting point for an FmpDeviceLib for
  a specific firmware storage device.
* CapsuleUpdatePolicyLibNull - Functional template of the
  CapsuleUpdatePolicyLib that can be used as a starting point
  of a platform specific implementation.
* FmpPayloadHeaderLibV1 - Version 1 of the FmpPayloadHeaderLib.
  This library is indented to be used "as is" with no need for
  any device specific or platform specific changes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Star Zeng 
---
 .../CapsuleUpdatePolicyLibNull.c   | 136 +++
 .../CapsuleUpdatePolicyLibNull.inf |  45 +++
 .../CapsuleUpdatePolicyLibNull.uni |  17 +
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c| 427 +
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |  48 +++
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |  18 +
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c| 188 +
 .../FmpPayloadHeaderLibV1.inf  |  48 +++
 .../FmpPayloadHeaderLibV1.uni  |  21 +
 9 files changed, 948 insertions(+)
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.uni
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.uni

diff --git 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
new file mode 100644
index 00..d86d6ba612
--- /dev/null
+++ 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
@@ -0,0 +1,136 @@
+/**  @file
+  Provides platform policy services used during a capsule update.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+
+/**
+  Determine if the system power state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system power state supports a capsule
+update.  Returns FALSE if system power state does not
+support a capsule update.  Return value is only valid if
+return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESSGood parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR   System power state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemPower (
+  OUT BOOLEAN  *Good
+  )
+{
+  *Good = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  Determines if the system thermal state supports a capsule 

[edk2] [Patch v6 00/23] Add FmpDevicePkg

2018-08-01 Thread Kinney, Michael D
Changes in V6
=
* Remove Bool PCD comparison against TRUE in BDS
* Remove useless lib mapping in FmpDevicePkg DSC file
* Fix XCODE build failure due to extra parenthesis

Changes in V4/V5
=
* Return 0 when LSV check is not required
* Remove IPF
* Add DISABLE_NEW_DEPRECATED_INTERFACES build options
* Check Progress!= NULL before calling Progress(100)
* Add EFI_ABORTED in retval of CheckTheImage()
* Fix typo "EFI_SECURITY_VIOLATIO"
* Add NULL check to return Value from GetVariable2
* Check ImageIndex first before Image/ImageSize
* Use Attributes to know whether reset is required
* Add comment in mFmpDeviceLocked's declaration
* Return UNSUPPORTED if device has been locked
* Initialize DeviceLibLowestSupportedVersion
* Fix code style issue
* Use local variable to store test key digest size

Changes in V3
=
* Change CheckLowestSupportedVersion() to LowestSupportedVersionCheckRequired()
* Change LockFmpDeviceAtLockEventGuid() to 
LockFmpDeviceAtLockEventGuidRequired()
* Set EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL Version field to 1
* Fix description of return values in LowestSupportedVersionCheckRequired()
* Fix description of return values in LockFmpDeviceAtLockEventGuidRequired()

Changes in V2
=
* FmpDevicePkg DEC file
  + Change PcdFmpDeviceSystemResetRequired from FeatureFlag
to FixedAtBuild
  + Add PcdFmpDeviceTestKeySha256Digest for test key detection.
Set to {0} to disable test key detection.
* FmpDevicePkg DSC file
  + Fix ARM and AARCH64 build issues
  + Update DisplayUpdateProgressLib mappings to match patches in
Bug_801_DisplayUpdateProgressLib_V2
* FmpDeviceLib Class and Instance
  + Update FmpDeviceGetSize() to return EFI_STATUS
  + Update FmpDeviceGetAttributes() to return EFI_STATUS
  + Update FmpDeviceGetVersionString() to return EFI_STATUS
* FmpDxe
  + Set depex to Variable Arch Write Protocol and Variable Lock Protocol
  + Break out test key detection in FmpDxe into DetectTestKey.c
  + Change LockAllVars() to LockAllFmpVariables()
  + Update LockAllFmpVariables() to lock each of the UEFI variables used.
  + Always lock UEFI variables when PcdFmpDeviceLockEventGuid is signaled
  + Remove ComputeVersionName().  FmpDeviceLib must provide version string

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Further development and testing of FmpDevicePkg was performed at:
  https://github.com/tianocore/edk2-staging/tree/FmpDevicePkg-master
  https://github.com/tianocore/edk2-staging/tree/FmpDevicePkg-UDK2018

This package provides an implementation of a Firmware Management Protocol
instance that supports the update of firmware storage devices using UEFI
Capsules.  The behavior of the Firmware Management Protocol instance is
customized using libraries and PCDs.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 

Kinney, Michael D (5):
  FmpDevicePkg: Add package, library classes, and PCDs
  FmpDevicePkg: Add library instances
  FmpDevicePkg: Add FmpDxe module
  FmpDevicePkg: Add DSC file to build all package components
  MdeModulePkg/BdsDxe: Move display of test key usage into BDS module

Star Zeng (16):
  FmpDevicePkg FmpDxe: Update function comment for FmpDxeEntryPoint
  FmpDevicePkg FmpDxe: Return 0 when LSV check is not required
  FmpDevicePkg: Remove IPF
  FmpDevicePkg: Add DISABLE_NEW_DEPRECATED_INTERFACES build options
  FmpDevicePkg FmpDxe: Check Progress!= NULL before calling
Progress(100)
  FmpDevicePkg FmpDxe: Add EFI_ABORTED in retval of CheckTheImage()
  FmpDevicePkg FmpDxe: Fix typo "EFI_SECURITY_VIOLATIO"
  FmpDevicePkg: Remove DisplayUpdateProgressLib mapping for FmpDxe
  FmpDevicePkg FmpDxe: Add NULL check to return Value from GetVariable2
  FmpDevicePkg FmpDxe: Check ImageIndex first before Image/ImageSize
  FmpDevicePkg FmpDxe: Use Attributes to know whether reset is required
  FmpDevicePkg FmpDxe: Add comment in mFmpDeviceLocked's declaration
  FmpDevicePkg FmpDxe: Return UNSUPPORTED if device has been locked
  FmpDevicePkg FmpDxe: Initialize DeviceLibLowestSupportedVersion
  FmpDevicePkg: Fix code style issue
  FmpDevicePkg FmpDxe: Use local variable to store test key digest size

Zeng, Star (2):
  FmpDevicePkg/FmpDxe: Fix XCODE build failure
  FmpDevicePkg: Remove useless lib mapping in dsc

 FmpDevicePkg/FmpDevicePkg.dec  |  125 ++
 FmpDevicePkg/FmpDevicePkg.dsc  |  114 ++
 FmpDevicePkg/FmpDevicePkg.uni  |   75 +
 FmpDevicePkg/FmpDevicePkgExtra.uni |   18 +
 FmpDevicePkg/FmpDxe/DetectTestKey.c|  168 +++
 FmpDevicePkg/FmpDxe/FmpDxe.c   | 1474 
 FmpDevicePkg/FmpDxe/FmpDxe.inf |   92 ++
 FmpDevicePkg/FmpDxe/FmpDxe.uni |   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni

[edk2] [Patch v6 03/23] FmpDevicePkg: Add FmpDxe module

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

The FmpDxe directory contains 2 INF files.  FmpDxe.inf
is a DXE driver that is used in a platform to add a
Firmware Management Protocol for firmware device that
supports firmware updates.

FmpDxeLib.inf is a NULL library instance with the exact
same functionality as FmpDxe.inf, but allows the the
Firmware Management Protocol feature to be added to
an existing device driver.

The FmpDxe component is intended to be used "as is"
with no need for any device specific or platform specific
changes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Star Zeng 
---
 FmpDevicePkg/FmpDxe/DetectTestKey.c   |  166 
 FmpDevicePkg/FmpDxe/FmpDxe.c  | 1452 +
 FmpDevicePkg/FmpDxe/FmpDxe.inf|   93 +++
 FmpDevicePkg/FmpDxe/FmpDxe.uni|   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni   |   18 +
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf |   90 ++
 FmpDevicePkg/FmpDxe/VariableSupport.c |  461 +++
 FmpDevicePkg/FmpDxe/VariableSupport.h |  180 
 8 files changed, 2480 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDxe/DetectTestKey.c
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.c
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.inf
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.uni
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxeLib.inf
 create mode 100644 FmpDevicePkg/FmpDxe/VariableSupport.c
 create mode 100644 FmpDevicePkg/FmpDxe/VariableSupport.h

diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c 
b/FmpDevicePkg/FmpDxe/DetectTestKey.c
new file mode 100644
index 00..0a6e37eded
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c
@@ -0,0 +1,166 @@
+/**  @file
+  Detects if PcdFmpDevicePkcs7CertBufferXdr contains a test key.
+
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Check to see if any of the keys in PcdFmpDevicePkcs7CertBufferXdr matches
+  the test key.  PcdFmpDeviceTestKeySha256Digest contains the SHA256 hash of
+  the test key.  For each key in PcdFmpDevicePkcs7CertBufferXdr, compute the
+  SHA256 hash and compare it to PcdFmpDeviceTestKeySha256Digest.  If the
+  SHA256 hash matches or there is then error computing the SHA256 hash, then
+  set PcdTestKeyUsed to TRUE.  Skip this check if PcdTestKeyUsed is already
+  TRUE or PcdFmpDeviceTestKeySha256Digest is not exactly SHA256_DIGEST_SIZE
+  bytes.
+**/
+VOID
+DetectTestKey (
+  VOID
+  )
+{
+  BOOLEAN  TestKeyUsed;
+  UINTNPublicKeyDataLength;
+  UINT8*PublicKeyDataXdr;
+  UINT8*PublicKeyDataXdrEnd;
+  VOID *HashContext;
+  UINT8Digest[SHA256_DIGEST_SIZE];
+
+  //
+  // If PcdFmpDeviceTestKeySha256Digest is not exacty SHA256_DIGEST_SIZE bytes,
+  // then skip the test key detection.
+  //
+  if (PcdGetSize (PcdFmpDeviceTestKeySha256Digest) != SHA256_DIGEST_SIZE) {
+return;
+  }
+
+  //
+  // If PcdTestKeyUsed is already TRUE, then skip test key detection
+  //
+  TestKeyUsed = PcdGetBool (PcdTestKeyUsed);
+  if (TestKeyUsed) {
+return;
+  }
+
+  //
+  // If PcdFmpDevicePkcs7CertBufferXdr is invalid, then skip test key detection
+  //
+  PublicKeyDataXdr= PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
+  PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize 
(PcdFmpDevicePkcs7CertBufferXdr);
+  if (PublicKeyDataXdr == NULL || PublicKeyDataXdr == PublicKeyDataXdrEnd) {
+

[edk2] [Patch v6 01/23] FmpDevicePkg: Add package, library classes, and PCDs

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Create FmpDevicePkg with library classes and PCDs used to
customize the behavior of a Firmware Management Protocol
instance.

Library Classes
===
* FmpDeviceLib - Provides firmware device specific services
  to support updates of a firmware image stored in a firmware
  device.
* CapsuleUpdatePolicyLib - Provides platform policy services
  used during a capsule update.
* FmpPayloadHeaderLib - Provides services to retrieve values
  from a capsule's FMP Payload Header.  The structure is not
  included in the library class.  Instead, services are
  provided to retrieve information from the FMP Payload Header.
  If information is added to the FMP Payload Header, then new
  services may be added to this library class to retrieve the
  new information.

PCDs set per module

* PcdFmpDeviceSystemResetRequired - Indicates if a full
  system reset is required before a firmware update to a
  firmware devices takes effect
* PcdFmpDeviceTestKeySha256Digest - The SHA-256 hash of a
  PKCS7 test key that is used to detect if a test key is
  being used to authenticate capsules.  Test key detection
  is disabled by setting the value to {0}.
* PcdFmpDeviceProgressColor - The color of the progress bar
  during a firmware update.
* PcdFmpDeviceImageIdName - The Null-terminated Unicode
  string used to fill in the ImageIdName field of the
  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned
  by the GetImageInfo() service of the Firmware Management
  Protocol for the firmware device.
* PcdFmpDeviceBuildTimeLowestSupportedVersion - The build
  time value used to fill in the LowestSupportedVersion field
  of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is
  returned by the GetImageInfo() service of the Firmware
  Management Protocol.
* PcdFmpDeviceProgressWatchdogTimeInSeconds - The time in
  seconds to arm a watchdog timer during the update of a
  firmware device.

PCDs set per module or for entire platform
==
* PcdFmpDevicePkcs7CertBufferXdr - One or more PKCS7
  certificates used to verify a firmware device capsule
  update image.
* PcdFmpDeviceLockEventGuid - An event GUID that locks
  the firmware device when the event is signaled.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Star Zeng 
---
 FmpDevicePkg/FmpDevicePkg.dec  | 132 +++
 FmpDevicePkg/FmpDevicePkg.uni  |  80 
 FmpDevicePkg/FmpDevicePkgExtra.uni |  18 +
 .../Include/Library/CapsuleUpdatePolicyLib.h   | 120 ++
 FmpDevicePkg/Include/Library/FmpDeviceLib.h| 405 +
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h | 100 +
 6 files changed, 855 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dec
 create mode 100644 FmpDevicePkg/FmpDevicePkg.uni
 create mode 100644 FmpDevicePkg/FmpDevicePkgExtra.uni
 create mode 100644 FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpDeviceLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h

diff --git a/FmpDevicePkg/FmpDevicePkg.dec b/FmpDevicePkg/FmpDevicePkg.dec
new file mode 100644
index 00..9ea0d73359
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -0,0 +1,132 @@
+## @file
+# Firmware Management Protocol Device Package
+#
+# This package provides an implementation of a Firmware Management Protocol
+# instance that supports the update of firmware storage devices using UEFI
+# Capsules.  The behavior of the Firmware Management Protocol instance is
+# customized using libraries and PCDs.
+#
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+# Copyright (c) 2018, Intel Corporation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 

Re: [edk2] [PATCH] FmpDevicePkg: Remove useless lib mapping in dsc

2018-08-01 Thread Kinney, Michael D
Star,

I have verified that removing the rest of the lib
mappings still builds, so those changes look good.

I have integrated these changes except the ARM/AARCH64
changes into a V6 version of the patch series.

Thanks,

Mike

> -Original Message-
> From: Kinney, Michael D
> Sent: Wednesday, August 1, 2018 7:15 AM
> To: Zeng, Star ; edk2-
> de...@lists.01.org; Kinney, Michael D
> 
> Subject: RE: [PATCH] FmpDevicePkg: Remove useless lib
> mapping in dsc
> 
> Star,
> 
> The ARM and AARCH64 specific lib mappings should not be
> removed.
> That will break the FmpDevicePkg build for ARM and
> AARCH64.
> 
> Mike
> 
> > -Original Message-
> > From: Zeng, Star
> > Sent: Wednesday, August 1, 2018 3:30 AM
> > To: edk2-devel@lists.01.org
> > Cc: Zeng, Star ; Kinney, Michael
> D
> > 
> > Subject: [PATCH] FmpDevicePkg: Remove useless lib
> > mapping in dsc
> >
> > Cc: Michael D Kinney 
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> > Signed-off-by: Star Zeng 
> >
> > NOTE: This patch is based on thread
> > https://lists.01.org/pipermail/edk2-devel/2018-
> > July/027810.html.
> >
> > ---
> >  FmpDevicePkg/FmpDevicePkg.dsc | 34 -
> --
> > ---
> >  1 file changed, 34 deletions(-)
> >
> > diff --git a/FmpDevicePkg/FmpDevicePkg.dsc
> > b/FmpDevicePkg/FmpDevicePkg.dsc
> > index 8d2436627dae..c04cb0efe86e 100644
> > --- a/FmpDevicePkg/FmpDevicePkg.dsc
> > +++ b/FmpDevicePkg/FmpDevicePkg.dsc
> > @@ -48,58 +48,24 @@ [Defines]
> >
> >  [LibraryClasses]
> >
> >
> UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoin
> > t/UefiDriverEntryPoint.inf
> > -
> >
> UefiApplicationEntryPoint|MdePkg/Library/UefiApplicatio
> > nEntryPoint/UefiApplicationEntryPoint.inf
> >
> >
> UefiBootServicesTableLib|MdePkg/Library/UefiBootService
> > sTableLib/UefiBootServicesTableLib.inf
> >UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
> >
> >
> UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeS
> > ervicesTableLib/UefiRuntimeServicesTableLib.inf
> > -
> >
> UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntim
> > eLib.inf
> >
> >
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocation
> > Lib/UefiMemoryAllocationLib.inf
> >
> >
> DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevi
> > cePathLib.inf
> > -
> UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
> > -
> >
> UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
> >BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> >
> >
> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLi
> > b.inf
> > -
> >
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLi
> > b/BaseSynchronizationLib.inf
> >
> > PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> >
> >
> DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLib
> > StdErr.inf
> >
> >
> DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintEr
> > rorLevelLib/BaseDebugPrintErrorLevelLib.inf
> > -
> >
> PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePo
> > stCodeLibPort80.inf
> >
> >
> PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> > -
> >
> DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeService
> > sLib.inf
> > -
> > -
> >
> UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeS
> > ervicesTableLib/UefiRuntimeServicesTableLib.inf
> > -  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
> > -
> >
> DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevi
> > cePathLib.inf
> > -
> >
> UefiBootManagerLib|MdeModulePkg/Library/UefiBootManager
> > Lib/UefiBootManagerLib.inf
> > -
> >
> DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/
> > DxeServicesTableLib.inf
> > -
> >
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocation
> > Lib/UefiMemoryAllocationLib.inf
> > -  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >
> >
> OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
> >
> >
> IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLi
> > b.inf
> >
> >
> BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLi
> > b.inf
> >
> >
> FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticat
> > ionLibPkcs7/FmpAuthenticationLibPkcs7.inf
> > -
> >
> >
> CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpda
> > tePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
> >
> >
> FmpPayloadHeaderLib|FmpDevicePkg/Library/FmpPayloadHead
> > erLibV1/FmpPayloadHeaderLibV1.inf
> >
> >
> FmpDeviceLib|FmpDevicePkg/Library/FmpDeviceLibNull/FmpD
> > eviceLibNull.inf
> > -
> >
> BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/Ba
> > seBmpSupportLib.inf
> > -
> >
> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib
> > .inf
> > -
> >
> CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCap
> > suleLib.inf
> > -
> > -[LibraryClasses.ARM, LibraryClasses.AARCH64]
> > -  #
> > -  # It is not possible to prevent the ARM compiler
> for
> > generic intrinsic functions.
> > -  # This library provides the instrinsic functions
> > generate by a given compiler.
> > -  # [LibraryClasses.ARM, LibraryClasses.AARCH64] and
> > NULL mean link this library
> > -  # into all ARM and 

Re: [edk2] [PATCH] FmpDevicePkg FmpDxe: Fix XCODE build failure

2018-08-01 Thread Kinney, Michael D
Star,

Reviewed-by: Michael D Kinney 

I have integrated this patch into a V6 patch series.

Mike

> -Original Message-
> From: Zeng, Star
> Sent: Wednesday, August 1, 2018 3:31 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Kinney, Michael D
> 
> Subject: [PATCH] FmpDevicePkg FmpDxe: Fix XCODE build
> failure
> 
> FmpDxe.c:517:18: error: equality comparison with
> extraneous
> parentheses [-Werror,-Wparentheses-equality]
> 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> 
> NOTE: This patch is based on thread
> https://lists.01.org/pipermail/edk2-devel/2018-
> July/027810.html.
> 
> ---
>  FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c
> b/FmpDevicePkg/FmpDxe/FmpDxe.c
> index 0f3396c2ef83..eb3a9b0e32c2 100644
> --- a/FmpDevicePkg/FmpDxe/FmpDxe.c
> +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
> @@ -514,7 +514,7 @@ GetTheImage (
>  goto cleanup;
>}
> 
> -  if ((ImageSize == NULL)) {
> +  if (ImageSize == NULL) {
>  DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() -
> ImageSize Pointer Parameter is NULL.\n"));
>  Status = EFI_INVALID_PARAMETER;
>  goto cleanup;
> --
> 2.7.0.windows.1

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


Re: [edk2] [Patch v5 21/21] MdeModulePkg/BdsDxe: Move display of test key usage into BDS module

2018-08-01 Thread Kinney, Michael D
Star,

I agree.  I will integrate into a V6 patch series.

Thanks,

Mike

> -Original Message-
> From: Zeng, Star
> Sent: Wednesday, August 1, 2018 12:53 AM
> To: Kinney, Michael D ;
> edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Dong, Eric
> ; Zeng, Star 
> Subject: RE: [Patch v5 21/21] MdeModulePkg/BdsDxe: Move
> display of test key usage into BDS module
> 
> A very minor comment.
> 
> if (PcdGetBool (PcdTestKeyUsed))
> can be used directly instead of
> if (PcdGetBool (PcdTestKeyUsed) == TRUE)
> 
> With update, Reviewed-by: Star Zeng
> .
> 
> 
> Thanks,
> Star
> -Original Message-
> From: Kinney, Michael D
> Sent: Wednesday, August 1, 2018 2:55 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Zeng, Star
> ; Dong, Eric
> ; Kinney, Michael D
> 
> Subject: [Patch v5 21/21] MdeModulePkg/BdsDxe: Move
> display of test key usage into BDS module
> 
> Cc: Ruiyu Ni 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney
> 
> ---
>  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf |  1 +
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 12
> 
>  2 files changed, 13 insertions(+)
> 
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> index 7e644aa995..7030d67907 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
> @@ -100,6 +100,7 @@ [Pcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision
> ## CONSUMES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
> ## CONSUMES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable
> ## SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed
> ## CONSUMES
> 
>  [Depex]
>TRUE
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> index a25663ea43..b9ca31741e 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> @@ -884,6 +884,18 @@ BdsEntry (
> 
> PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole");
>PlatformBootManagerAfterConsole ();
> 
> PERF_INMODULE_END("PlatformBootManagerAfterConsole");
> +
> +  //
> +  // If any component set PcdTestKeyUsed to TRUE
> because use of a test key
> +  // was detected, then display a warning message on
> the debug log and the console
> +  //
> +  if (PcdGetBool (PcdTestKeyUsed) == TRUE) {
> +DEBUG ((DEBUG_ERROR,
> "**\n"));
> +DEBUG ((DEBUG_ERROR, "**  WARNING: Test Key is
> used.  **\n"));
> +DEBUG ((DEBUG_ERROR,
> "**\n"));
> +Print (L"**  WARNING: Test Key is used.  **\n");
> +  }
> +
>//
>// Boot to Boot Manager Menu when
> EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip
> HotkeyBoot
>//
> --
> 2.14.2.windows.3

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


Re: [edk2] [PATCH edk2-platforms v1 00/38] Upload for D06 platform

2018-08-01 Thread Leif Lindholm
On Tue, Jul 24, 2018 at 03:08:44PM +0800, Ming Huang wrote:
> The major features of this patchset include:
> 1 D06 source code;
> 2 Unify some D0x modules;
> 
> This patch set is base on pcihostbridage-v2.
> For compiling D06, add below hunk to edk2-platforms.config
> [d06]
> LONGNAME=HiSilicon D06
> DSC=Platform/Hisilicon/D06/D06.dsc
> ARCH=AARCH64

Very helpful, thank you.

> 
> Code can also be found in github: 
> https://github.com/hisilicon/OpenPlatformPkg.git
> branch: d06-platform-v1

Now, I started by trying to compile this, but I run into two issues.

First, the platform fails to build without FIRMWARE_VER specified on
the command line, since there is an extra '"' in the definition of
PcdFirmwareVersionString.

Then there is a build fault when generating ACPI tables. I tried to
update to a newer version of acpica-tools, but I still get:
---
"aarch64-linux-gnu-gcc" -x c -E -include AutoGen.h
-I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt
-I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
-I/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/DEBUG
-I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include
-I/work/git/edk2/ArmPlatformPkg
-I/work/git/edk2/ArmPlatformPkg/Include -I/work/git/edk2/EmbeddedPkg
-I/work/git/edk2/EmbeddedPkg/Include -I/work/git/edk2/MdeModulePkg
-I/work/git/edk2/MdeModulePkg/Include -I/work/git/edk2/MdePkg
-I/work/git/edk2/MdePkg/Include
-I/work/git/edk2/MdePkg/Include/AArch64
-I/work/git/edk2-platforms/Silicon/Hisilicon
-I/work/git/edk2-platforms/Silicon/Hisilicon/Include
-I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.i
> /work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.iii
Trim --source-code -l -o
/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/work/git/tianocore/Build/D06/DEBUG_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort."aarch64-linux-gnu-gcc"
-x c -E -include AutoGen.h
-I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt
-I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
-I/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/DEBUG
-I/work/git/edk2/ArmPkg -I/work/git/edk2/ArmPkg/Include
-I/work/git/edk2/ArmPlatformPkg
-I/work/git/edk2/ArmPlatformPkg/Include -I/work/git/edk2/EmbeddedPkg
-I/work/git/edk2/EmbeddedPkg/Include -I/work/git/edk2/MdeModulePkg
-I/work/git/edk2/MdeModulePkg/Include -I/work/git/edk2/MdePkg
-I/work/git/edk2/MdePkg/Include
-I/work/git/edk2/MdePkg/Include/AArch64
-I/work/git/edk2-platforms/Silicon/Hisilicon
-I/work/git/edk2-platforms/Silicon/Hisilicon/Include
-I/work/git/edk2-platforms/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables
/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.i
> /work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.iii
Trim --source-code -l -o
/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi16Copyright
(c) 2000 - 2018 Intel Corporation
/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.
71: [0004] ID Count : 0100
Error6303 -
Integer too large for target ^  (0100 - max 1 bytes)

Table Input:
/work/git/tianocore/Build/D06/RELEASE_GCC5/AARCH64/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/AcpiTablesHi1620/OUTPUT/./Hi1620Iort.
- 1991 lines, 59818 bytes, 68 fields

Compilation complete. 2 Errors, 0 Warnings, 0 Remarks
---

Any ideas what may be causing this?

/
Leif

> 
> Heyi Guo (2):
>   Hisilicon/Hi1620: Add ACPI PPTT table
>   Platform/Hisilicon/D06: Enable ACPI PPTT
> 
> Luqi Jiang (1):
>   Hisilicon/D06: add apei driver
> 
> Ming Huang (18):
>   Silicon/Hisilicon: Modify the MRC interface for other module
>   Silicon/Hisilicon: Separate PlatformArch.h
>   Hisilicon/D06: Add several basal file for D06
>   Platform/Hisilicon/D06: Add M41T83RealTimeClockLib
>   Platform/Hisilicon/D06: Add binary file for D06
>   Hisilicon/D06: Add OemMiscLibD06
>   Silicon/Hisilicon/D06: Wait for all disk ready
>   Silicon/Hisilicon/Acpi: Unify HisiAcipPlatformDxe
>   Silicon/Hisilicon/I2C: Optimize I2C library
>   Platform/Hisilicon/D06: Add OemNicLib
>   Hisilicon/D0X: Rename the global variable gDS3231RtcDevice
>   Platform/Hisilicon/D06: Add EarlyConfigPeim peim
>   Platform/Hisilicon/D06: Add PciHostBridgeLib
>   Silicon/Hisilicon/D06: Add some Lpc macro to LpcLib.h
>   Silicon/Hisilicon/Setup: Support SPCR 

Re: [edk2] Undefined types referenced in MdePkg

2018-08-01 Thread Laszlo Ersek
On 08/01/18 19:49, edk2-li...@mc2research.org wrote:
> When including MdePkg/Include/Library/HobLib.h in my project I get errors
> indicating that the following types are undefined:
> 
> * EFI_RESOURCE_TYPE, lines 206 and 231
> * EFI_RESOURCE_ATTRIBUTE_TYPE, lines 207 and 232
> 
>  
> 
> A similar thing is happening with MdePkg/Include/Protocol/FirmwareVolume2.h.
> 
> * EFI_FV_FILE_ATTRIBUTES, lines 309, 443, 612
> 
>  
> 
> I updated my EDK II tree then searched the entire tree for these types.  They
> only show up in the locations mentioned above; never defined.
> 
>  
> 
> Am I missing something or are these really undefined?
> 
>  
> 
> I don't want to just disable these errors since that could hide a bigger
> problem.

IMO, the header files you mention should include the following files,
respectively:

- MdePkg/Include/Library/HobLib.h
  --> MdePkg/Include/Pi/PiHob.h

- MdePkg/Include/Protocol/FirmwareVolume2.h
  --> MdePkg/Include/Pi/PiFirmwareVolume.h

I'm firmly in the camp that believes that developers should not have to
hunt down themselves the dependencies of the main API header file that
they are actually interested in.

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


Re: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7 with OVMF

2018-08-01 Thread Laszlo Ersek
On 08/01/18 19:50, Ricardo Araújo wrote:
> The commit I was referring to is:
> https://github.com/tianocore/edk2/commit/f15cb995bb3880b77e15afe6facd3da05e599a17
>
> Regards,
>
> Ricardo Araujo -
> www.lsd.ufcg.edu.br/~ricardo
>
> - Mensagem original -
> De: "Ricardo Araújo" 
> Para: edk2-devel@lists.01.org
> Enviadas: Quarta-feira, 1 de agosto de 2018 14:33:45
> Assunto: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7
> with OVMF
>
> Hi everyone,
>
> I'm using OVMF with a simulated TPM 2.0 (from
> https://github.com/stefanberger/swtpm) and I noticed lately that PCRs
> 0-7 are zeroed after booting the vm (ubuntu 18.04) and the only
> message related to this in dmesg is:
>
> [ 2.286690] tpm_tis 00:06: 2.0 TPM (device-id 0x1, rev-id 1)
> [ 2.303753] tpm tpm0: A TPM error (256) occurred continue selftest
> [ 2.314199] tpm tpm0: starting up the TPM manually
>
> I found this started to happen after this commit , previous commits to
> that are showing boot time measurements on PCR 0-7 normally and the
> error message is gone. Has anyone experienced the same behavior? I
> followed the instructions here for building OVMF but I added the
> parameters -D TPM2_ENABLE=TRUE -D SECURE_BOOT_ENABLE=TRUE -D
> HTTP_BOOT_ENABLE=TRUE. Is there anything else I need to add to enable
> these measurements?
>
> Regards,
>
> Ricardo Araujo
> www.lsd.ufcg.edu.br/~ricardo

Thank you for the bug report. It looks like a regression to me, but the
details aren't immediately clear.

Adding Marc-André who contributed the TPM enablement for OVMF, and Chao
Zhang who authored the commit in question.

If I recall correctly, in OVMF we decided to never cache the TPM type
but always detect it. I could be remembering wrong though. See commit
6cf1880fb5b6 ("OvmfPkg: add customized Tcg2ConfigPei clone",
2018-03-09).

Chao Zhang: can you please explain what additional requirements are
presented for a platform by commit f15cb995bb38? In OVMF we use a
customized Tcg2ConfigPei module (see the commit above).


Oh wait, I suspect what's wrong. I believe there are two bugs in commit
f15cb995bb38 ("SecurityPkg: Cache TPM interface type info", 2018-06-25):

* Bug#1:

Commit f15cb995bb38  introduces a new PCD, called
"PcdActiveTpmInterfaceType", in section [PcdsDynamic, PcdsDynamicEx] of
"SecurityPkg.dec", and makes core modules from SecurityPkg dependent on
it.

Obviously this means that platforms are required to provide a Dynamic
Default for the new PCD in their DSC files, if they include those core
modules from SecurityPkg, otherwise the PCD won't actually behave
dynamically -- "set" operations will fail, and "get" operations will
just return the central default from the SecurityPkg.dec file. As a
result, the cached TPM type will always be wrong (it will look like
"undetected", 0xFF).

This could have been avoided by grepping all "*dsc*" files in the edk2
tree for references to the SecurityPkg module INF files that were about
to receive a dependency on the PCD. Such as:

  git grep -l -F \
-e SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf \
--or -e SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf \
--or -e SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf \
--or -e SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf \
'*dsc*'

This would have listed all platforms in-tree that were going to depend
on the new dynamic PCD via inclusion of the affected SecurityPkg
modules.

Running this command now, I get the following output:

  OvmfPkg/OvmfPkgIa32.dsc
  OvmfPkg/OvmfPkgIa32X64.dsc
  OvmfPkg/OvmfPkgX64.dsc
  SecurityPkg/SecurityPkg.dsc

Open source hygiene dictates that modifications to infrastructure code
or otherwise central code be accompanied by necessary updates to *ALL*
in-tree subsystems that depend on said core code. (Out-of-tree
subsystems are a different matter.) It's OK if a single contributor
cannot test every single platform -- but we can still use the mailing
list and the bug tracker for raising the issue and expose the new
dependency for platforms that we can't test, but see as affected.

Ricardo, Marc-André: does the following patch work for you guys
(build-tested only):

> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index a28b511d5c2f..b0153f66b710 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -579,6 +579,7 @@ [PcdsDynamicDefault]
>
>  !if $(TPM2_ENABLE) == TRUE
>gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0x00, 0x00, 0x00, 0x00, 
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
> +  gEfiSecurityPkgTokenSpaceGuid.PcdActiveTpmInterfaceType|0xFF
>  !endif
>
>  
> 
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 115d0c01ff5c..fcce846ab9a5 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -587,6 +587,7 @@ [PcdsDynamicDefault]
>
>  !if $(TPM2_ENABLE) == TRUE
>

Re: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7 with OVMF

2018-08-01 Thread Ricardo Araújo
The commit I was referring to is: 
https://github.com/tianocore/edk2/commit/f15cb995bb3880b77e15afe6facd3da05e599a17

Regards,

Ricardo Araujo - 
www.lsd.ufcg.edu.br/~ricardo 

- Mensagem original -
De: "Ricardo Araújo" 
Para: edk2-devel@lists.01.org
Enviadas: Quarta-feira, 1 de agosto de 2018 14:33:45
Assunto: [edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7 with OVMF

Hi everyone, 

I'm using OVMF with a simulated TPM 2.0 (from 
https://github.com/stefanberger/swtpm) and I noticed lately that PCRs 0-7 are 
zeroed after booting the vm (ubuntu 18.04) and the only message related to this 
in dmesg is: 

[ 2.286690] tpm_tis 00:06: 2.0 TPM (device-id 0x1, rev-id 1) 
[ 2.303753] tpm tpm0: A TPM error (256) occurred continue selftest 
[ 2.314199] tpm tpm0: starting up the TPM manually 

I found this started to happen after this commit , previous commits to that are 
showing boot time measurements on PCR 0-7 normally and the error message is 
gone. Has anyone experienced the same behavior? I followed the instructions 
here for building OVMF but I added the parameters -D TPM2_ENABLE=TRUE -D 
SECURE_BOOT_ENABLE=TRUE -D HTTP_BOOT_ENABLE=TRUE. Is there anything else I need 
to add to enable these measurements? 

Regards, 

Ricardo Araujo 
www.lsd.ufcg.edu.br/~ricardo 

___
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] Undefined types referenced in MdePkg

2018-08-01 Thread edk2-lists
When including MdePkg/Include/Library/HobLib.h in my project I get errors
indicating that the following types are undefined:

*   EFI_RESOURCE_TYPE, lines 206 and 231
*   EFI_RESOURCE_ATTRIBUTE_TYPE, lines 207 and 232

 

A similar thing is happening with MdePkg/Include/Protocol/FirmwareVolume2.h.

*   EFI_FV_FILE_ATTRIBUTES, lines 309, 443, 612

 

I updated my EDK II tree then searched the entire tree for these types.  They
only show up in the locations mentioned above; never defined.

 

Am I missing something or are these really undefined?

 

I don't want to just disable these errors since that could hide a bigger
problem.

 

Thanks,

Daryl McDaniel

The Year of the Justifiably Defensive Lobster.

The Season of the fraternizing CEOs.

 

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


[edk2] Missing boot related measurements at TPM 2.0 PCRs 0-7 with OVMF

2018-08-01 Thread Ricardo Araújo
Hi everyone, 

I'm using OVMF with a simulated TPM 2.0 (from 
https://github.com/stefanberger/swtpm) and I noticed lately that PCRs 0-7 are 
zeroed after booting the vm (ubuntu 18.04) and the only message related to this 
in dmesg is: 

[ 2.286690] tpm_tis 00:06: 2.0 TPM (device-id 0x1, rev-id 1) 
[ 2.303753] tpm tpm0: A TPM error (256) occurred continue selftest 
[ 2.314199] tpm tpm0: starting up the TPM manually 

I found this started to happen after this commit , previous commits to that are 
showing boot time measurements on PCR 0-7 normally and the error message is 
gone. Has anyone experienced the same behavior? I followed the instructions 
here for building OVMF but I added the parameters -D TPM2_ENABLE=TRUE -D 
SECURE_BOOT_ENABLE=TRUE -D HTTP_BOOT_ENABLE=TRUE. Is there anything else I need 
to add to enable these measurements? 

Regards, 

Ricardo Araujo 
www.lsd.ufcg.edu.br/~ricardo 

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


Re: [edk2] [PATCH edk2-platforms 1/7] Silicon/NXP: Add support for iMX SDHC

2018-08-01 Thread Leif Lindholm
On Thu, Jul 19, 2018 at 04:11:18AM +, Chris Co wrote:
> This adds support for using the SD host controller on
> NXP i.MX platforms.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Christopher Co 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Michael D Kinney 

Trying to build the code[1] in this patch throws up issues due to
(initially) a missing dependency on a iMXIoMuxLib mapping. Which is
not introduced in this set at all.

Could you bring these sets together into a single (huge) one,
ensuring that code is introduced in dependency order?

It will be no more unwieldy (I can push patches from the front as they
merit it), and will make my life a _lot_ easier.

If you can also address the items I point out as "address throughout"
below, for all the patches, that will reduce churn.

[1] By hacking the .inf into EmbeddedPkg/EmbeddedPkg.dsc, since the
i.MX one is also not included in this set.

> ---
>  Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c   | 1356 
> 
>  Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.inf |   67 +
>  Silicon/NXP/iMXPlatformPkg/Include/iMXGpio.h   |  101 ++
>  Silicon/NXP/iMXPlatformPkg/Include/iMXuSdhc.h  |  277 
>  4 files changed, 1801 insertions(+)
> 
> diff --git a/Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c 
> b/Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c
> new file mode 100644
> index ..5f087f8a28b9
> --- /dev/null
> +++ b/Silicon/NXP/iMXPlatformPkg/Drivers/SdhcDxe/SdhcDxe.c
> @@ -0,0 +1,1356 @@
> +/** @file
> +*
> +*  Copyright (c) Microsoft Corporation. All rights reserved.

Please add copyright year throughout all patches.

> +*
> +*  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 

Please sort includes alphabetically.

> +
> +#include 
> +#include 
> +
> +typedef struct {
> +UINT32 IoNumber;
> +IMX_GPIO_BANK Bank;
> +} IMX_GPIO_PIN;
> +
> +#define PCD_GPIO_PIN_IO_NUMBER(X)   ((X) & 0xFF)
> +#define PCD_GPIO_PIN_BANK(X)(((X) >> 8) & 0xFF)
> +
> +//
> +// A special value to indicate that GPIO is not the signal source for either
> +// CardDetect or WriteProtect
> +//
> +typedef enum {
> +USDHC_SIGNAL_GPIO_START = 0x000,
> +USDHC_SIGNAL_GPIO_END = 0xFF00,
> +USDHC_SIGNAL_OVERRIDE_PIN_LOW = 0xFF00,

Are the above two lines intentionally assigning the same value?

> +USDHC_SIGNAL_OVERRIDE_PIN_HIGH = 0xFF01,
> +USDHC_SIGNAL_INTERNAL_PIN = 0x
> +} USDHC_SIGNAL_SOURCE;
> +
> +#define USDHC_IS_GPIO_SIGNAL_SOURCE(X)  \
> +(((X) >= USDHC_SIGNAL_GPIO_START) && ((X) < USDHC_SIGNAL_GPIO_END))
> +
> +typedef struct {
> +UINT32 SdhcId;
> +EFI_HANDLE SdhcProtocolHandle;
> +USDHC_REGISTERS *RegistersBase;
> +USDHC_SIGNAL_SOURCE CardDetectSignal;
> +USDHC_SIGNAL_SOURCE WriteProtectSignal;
> +IMX_GPIO_PIN CardDetectGpioPin;
> +IMX_GPIO_PIN WriteProtectGpioPin;
> +} USDHC_PRIVATE_CONTEXT;
> +
> +#define LOG_FMT_HELPER(FMT, ...) \
> +"SDHC%d:" FMT "%a\n", ((SdhcCtx != NULL) ? SdhcCtx->SdhcId : -1), 
> __VA_ARGS__
> +
> +#define LOG_INFO(...) \
> +DEBUG((DEBUG_INFO | DEBUG_BLKIO, LOG_FMT_HELPER(__VA_ARGS__, "")))
> +
> +#define LOG_TRACE(...) \
> +DEBUG((DEBUG_VERBOSE | DEBUG_BLKIO, LOG_FMT_HELPER(__VA_ARGS__, "")))
> +
> +#define LOG_ERROR(...) \
> +DEBUG((DEBUG_ERROR | DEBUG_BLKIO, LOG_FMT_HELPER(__VA_ARGS__, "")))
> +
> +#define LOG_ASSERT(TXT) \
> +ASSERT(!"Sdhc: " TXT "\n")
> +
> +#ifdef MIN
> +#undef MIN
> +#define MIN(x,y) ((x) > (y) ? (y) : (x))
> +#endif // MIN

Please remove - the MIN macro has existed in Base.h since at least
2007. It does not need local redefinition.

> +
> +//
> +// uSDHC read/write FIFO is 128x32-bit
> +//
> +#define USDHC_FIFO_MAX_WORD_COUNT   128
> +
> +//
> +// Max block count allowed in a single transfer
> +//
> +#define USDHC_MAX_BLOCK_COUNT   0x
> +
> +//
> +// Number of register maximum polls
> +//
> +#define USDHC_POLL_RETRY_COUNT  10
> +
> +//
> +// Waits between each registry poll
> +//
> +#define USDHC_POLL_WAIT_US  20
> +
> +//
> +// uSDHC input clock. Ideally, should query it from clock manager
> +//
> +#define USDHC_BASE_CLOCK_FREQ_HZ19800
> +
> +#define USDHC_BLOCK_LENGTH_BYTES   512
> +

Can all of the above #defines, enums and structs be moved to a local
"SdhcDxe.h"?

> 

Re: [edk2] [PATCH] FmpDevicePkg: Remove useless lib mapping in dsc

2018-08-01 Thread Kinney, Michael D
Star,

The ARM and AARCH64 specific lib mappings should not be removed.
That will break the FmpDevicePkg build for ARM and AARCH64.

Mike

> -Original Message-
> From: Zeng, Star
> Sent: Wednesday, August 1, 2018 3:30 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Kinney, Michael D
> 
> Subject: [PATCH] FmpDevicePkg: Remove useless lib
> mapping in dsc
> 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> 
> NOTE: This patch is based on thread
> https://lists.01.org/pipermail/edk2-devel/2018-
> July/027810.html.
> 
> ---
>  FmpDevicePkg/FmpDevicePkg.dsc | 34 ---
> ---
>  1 file changed, 34 deletions(-)
> 
> diff --git a/FmpDevicePkg/FmpDevicePkg.dsc
> b/FmpDevicePkg/FmpDevicePkg.dsc
> index 8d2436627dae..c04cb0efe86e 100644
> --- a/FmpDevicePkg/FmpDevicePkg.dsc
> +++ b/FmpDevicePkg/FmpDevicePkg.dsc
> @@ -48,58 +48,24 @@ [Defines]
> 
>  [LibraryClasses]
> 
> UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoin
> t/UefiDriverEntryPoint.inf
> -
> UefiApplicationEntryPoint|MdePkg/Library/UefiApplicatio
> nEntryPoint/UefiApplicationEntryPoint.inf
> 
> UefiBootServicesTableLib|MdePkg/Library/UefiBootService
> sTableLib/UefiBootServicesTableLib.inf
>UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
> 
> UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeS
> ervicesTableLib/UefiRuntimeServicesTableLib.inf
> -
> UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntim
> eLib.inf
> 
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocation
> Lib/UefiMemoryAllocationLib.inf
> 
> DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevi
> cePathLib.inf
> -  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
> -
> UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> 
> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLi
> b.inf
> -
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLi
> b/BaseSynchronizationLib.inf
> 
> PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> 
> DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLib
> StdErr.inf
> 
> DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintEr
> rorLevelLib/BaseDebugPrintErrorLevelLib.inf
> -
> PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePo
> stCodeLibPort80.inf
> 
> PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> -
> DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeService
> sLib.inf
> -
> -
> UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeS
> ervicesTableLib/UefiRuntimeServicesTableLib.inf
> -  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
> -
> DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevi
> cePathLib.inf
> -
> UefiBootManagerLib|MdeModulePkg/Library/UefiBootManager
> Lib/UefiBootManagerLib.inf
> -
> DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/
> DxeServicesTableLib.inf
> -
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocation
> Lib/UefiMemoryAllocationLib.inf
> -  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> 
> OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
> 
> IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLi
> b.inf
> 
> BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLi
> b.inf
> 
> FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticat
> ionLibPkcs7/FmpAuthenticationLibPkcs7.inf
> -
> 
> CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpda
> tePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
> 
> FmpPayloadHeaderLib|FmpDevicePkg/Library/FmpPayloadHead
> erLibV1/FmpPayloadHeaderLibV1.inf
> 
> FmpDeviceLib|FmpDevicePkg/Library/FmpDeviceLibNull/FmpD
> eviceLibNull.inf
> -
> BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/Ba
> seBmpSupportLib.inf
> -
> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib
> .inf
> -
> CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCap
> suleLib.inf
> -
> -[LibraryClasses.ARM, LibraryClasses.AARCH64]
> -  #
> -  # It is not possible to prevent the ARM compiler for
> generic intrinsic functions.
> -  # This library provides the instrinsic functions
> generate by a given compiler.
> -  # [LibraryClasses.ARM, LibraryClasses.AARCH64] and
> NULL mean link this library
> -  # into all ARM and AARCH64 images.
> -  #
> -
> NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntri
> nsicsLib.inf
> -
> -  # Add support for stack protector
> -
> NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib
> .inf
> -
> -[LibraryClasses.ARM]
> -
> ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftF
> loatLib.inf
> 
>  [Components]
>#
> --
> 2.7.0.windows.1

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


[edk2] [PATCH] FmpDevicePkg FmpDxe: Fix XCODE build failure

2018-08-01 Thread Star Zeng
FmpDxe.c:517:18: error: equality comparison with extraneous
parentheses [-Werror,-Wparentheses-equality]

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 

NOTE: This patch is based on thread
https://lists.01.org/pipermail/edk2-devel/2018-July/027810.html.

---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 0f3396c2ef83..eb3a9b0e32c2 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -514,7 +514,7 @@ GetTheImage (
 goto cleanup;
   }
 
-  if ((ImageSize == NULL)) {
+  if (ImageSize == NULL) {
 DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is 
NULL.\n"));
 Status = EFI_INVALID_PARAMETER;
 goto cleanup;
-- 
2.7.0.windows.1

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


[edk2] [PATCH] FmpDevicePkg: Remove useless lib mapping in dsc

2018-08-01 Thread Star Zeng
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 

NOTE: This patch is based on thread
https://lists.01.org/pipermail/edk2-devel/2018-July/027810.html.

---
 FmpDevicePkg/FmpDevicePkg.dsc | 34 --
 1 file changed, 34 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index 8d2436627dae..c04cb0efe86e 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -48,58 +48,24 @@ [Defines]
 
 [LibraryClasses]
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
-  
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
-  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
-  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
-  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
-  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
-  PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
-
-  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
-  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
-  
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
-  
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
-  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
   
FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
-
   
CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
   
FmpPayloadHeaderLib|FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
   FmpDeviceLib|FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
-  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
-  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
-
-[LibraryClasses.ARM, LibraryClasses.AARCH64]
-  #
-  # It is not possible to prevent the ARM compiler for generic intrinsic 
functions.
-  # This library provides the instrinsic functions generate by a given 
compiler.
-  # [LibraryClasses.ARM, LibraryClasses.AARCH64] and NULL mean link this 
library
-  # into all ARM and AARCH64 images.
-  #
-  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
-
-  # Add support for stack protector
-  NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
-
-[LibraryClasses.ARM]
-  ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
 
 [Components]
   #
-- 
2.7.0.windows.1

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


Re: [edk2] [Patch] NetworkPkg/HttpDxe: Stripped square brackets in IPv6 expressed HostName.

2018-08-01 Thread Laszlo Ersek
On 08/01/18 03:54, Jiaxin Wu wrote:
> In URI, the colon (:) is used to terminate the HostName path before
> a port number. However, if HostName is expressed as IPv6 format, colon
> characters in IPv6 addresses will conflict with the colon before port
> number. To alleviate this conflict in URI, the IPv6 expressed HostName
> are enclosed in square brackets ([]). To record the real IPv6 HostName,
> square brackets should be stripped.
> 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  NetworkPkg/HttpDxe/HttpImpl.c | 17 ++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
> index 17deceb395..e05ee9344b 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -403,14 +403,25 @@ EfiHttpRequest (
>  Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, 
> );
>  if (EFI_ERROR (Status)) {
>goto Error1;
>  }
>  
> -HostName   = NULL;
> -Status = HttpUrlGetHostName (Url, UrlParser, );
> +Status = HttpUrlGetHostName (Url, UrlParser, );
>  if (EFI_ERROR (Status)) {
> - goto Error1;
> +  goto Error1;
> +}
> +
> +if (HttpInstance->LocalAddressIsIPv6 && AsciiStrSize (HostName) > 2 &&
> +HostName[0] == '[' && *(HostName + (AsciiStrSize (HostName) - 2)) == 
> ']') {
> +  //
> +  // HostName format is expressed as IPv6, so, remove '[' and ']'.
> +  //
> +  HostNameSize = AsciiStrSize (HostName) - 2;
> +
> +  CopyMem (HostName, HostName + 1, HostNameSize - 1);
> +
> +  *(HostName + HostNameSize - 1) = '\0';
>  }
>  
>  Status = HttpUrlGetPort (Url, UrlParser, );
>  if (EFI_ERROR (Status)) {
>if (HttpInstance->UseHttps) {
> 

There are a number of expressions of the form

  *(HostName + Offset)

which could be rewritten more idiomatically as

  HostName[Offset]

In addition, I think the code could be optimized by calculating
AsciiStrSize() only once:

  if (HttpInstance->LocalAddressIsIPv6) {
HostNameSize = AsciiStrSize (HostName);

if (HostNameSize > 2 &&
HostName[0] == '[' &&
HostName[HostNameSize - 2] == ']') {
  //
  // HostName format is expressed as IPv6, so, remove '[' and ']'.
  //
  HostNameSize -= 2;
  CopyMem (HostName, HostName + 1, HostNameSize - 1);
  HostName[HostNameSize - 1] = '\0';
}
  }

Under my proposal, if the inner condition fails, then "HostNameSize"
will be set as a "side effect", but I don't think that's a problem.


Anyway, the patch seems technically correct; if you don't want to submit
a v2, I'm fine with this variant too:

Reviewed-by: Laszlo Ersek 

I have just one request for the subject line, before you push the patch:
please replace "stripped" with "strip".

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


Re: [edk2] [PATCH edk2-platforms 3/3] Platform/Microsoft: Add Lauterbach debug library

2018-08-01 Thread Leif Lindholm
On Tue, Jul 31, 2018 at 10:59:22PM +0200, Ard Biesheuvel wrote:
> On 31 July 2018 at 22:56, Leif Lindholm  wrote:
> > On Tue, Jul 17, 2018 at 02:05:45AM +, Chris Co wrote:
> >> This debug library provides support for importing symbols to
> >> debug using Lauterbach.
> >>
> >> Derived from: ArmPkg\Library\DebugPeCoffExtraActionLib
> >
> > I'm not seeing any difference between this one and the original other
> > than the addition of the Microsoft copyright statement and updating of
> > the debug printouts to modern style.
> >
> > I would be happy to take this as a patch to the original, but I don't
> > see what benefit this copy brings. What prevents you from using the
> > original?
> 
> The 'data.load.elf' statement in
> PeCoffLoaderRelocateImageExtraAction() is particular to Lauterbach

Oh, right.

That (original) code badly needs reformatting.

Still, if that's the only difference - and in a debug printout, why
fork the module?

If there is a way to identify which debugger is being used, use that.
If not, dump all the possible strings.

We really don't want a situation where you need to hard-code which
debugger you are using for a specific platform. And even if that is
unavoidable, it needs to live in the main edk2 repository.

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


Re: [edk2] [Patch v5 21/21] MdeModulePkg/BdsDxe: Move display of test key usage into BDS module

2018-08-01 Thread Zeng, Star
A very minor comment.

if (PcdGetBool (PcdTestKeyUsed))
can be used directly instead of
if (PcdGetBool (PcdTestKeyUsed) == TRUE)

With update, Reviewed-by: Star Zeng .


Thanks,
Star
-Original Message-
From: Kinney, Michael D 
Sent: Wednesday, August 1, 2018 2:55 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Zeng, Star ; Dong, 
Eric ; Kinney, Michael D 
Subject: [Patch v5 21/21] MdeModulePkg/BdsDxe: Move display of test key usage 
into BDS module

Cc: Ruiyu Ni 
Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Universal/BdsDxe/BdsDxe.inf |  1 +
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf 
b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index 7e644aa995..7030d67907 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -100,6 +100,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable  ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed   ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index a25663ea43..b9ca31741e 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -884,6 +884,18 @@ BdsEntry (
   PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole");
   PlatformBootManagerAfterConsole ();
   PERF_INMODULE_END("PlatformBootManagerAfterConsole");
+
+  //
+  // If any component set PcdTestKeyUsed to TRUE because use of a test key
+  // was detected, then display a warning message on the debug log and the 
console
+  //
+  if (PcdGetBool (PcdTestKeyUsed) == TRUE) {
+DEBUG ((DEBUG_ERROR, "**\n"));
+DEBUG ((DEBUG_ERROR, "**  WARNING: Test Key is used.  **\n"));
+DEBUG ((DEBUG_ERROR, "**\n"));
+Print (L"**  WARNING: Test Key is used.  **\n");
+  }
+
   //
   // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. 
Skip HotkeyBoot
   //
-- 
2.14.2.windows.3

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


Re: [edk2] [Patch v5 04/21] FmpDevicePkg: Add DSC file to build all package components

2018-08-01 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Kinney, 
Michael D
Sent: Wednesday, August 1, 2018 2:55 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Yao, Jiewen 

Subject: [edk2] [Patch v5 04/21] FmpDevicePkg: Add DSC file to build all 
package components

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

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Adds a DSC file that is used to verify that all of the FmpDevicePkg libraries 
and modules build without error.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 134 ++
 1 file changed, 134 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc new 
file mode 100644 index 00..4d08a2cf9e
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -0,0 +1,134 @@
+## @file
+# Firmware Management Protocol Device Package # # This package provides 
+an implementation of a Firmware Management Protocol # instance that 
+supports the update of firmware storage devices using UEFI # Capsules.  
+The behavior of the Firmware Management Protocol instance is # 
+customized using libraries and PCDs.
+#
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved. # 
+Copyright (c) 2018, Intel Corporation. All rights reserved. # # 
+Redistribution and use in source and binary forms, with or without # 
+modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright 
+notice, # this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright 
+notice, # this list of conditions and the following disclaimer in the 
+documentation # and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
+ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF 
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR 
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, 
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE # 
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # 
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+##
+
+[Defines]
+  PLATFORM_NAME  = FmpDevicePkg
+  PLATFORM_GUID  = 0af3d540-27c6-11e8-828b-f8597177a00a
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x00010005
+  OUTPUT_DIRECTORY   = Build/FmpDevicePkg
+  SUPPORTED_ARCHITECTURES= IA32|IPF|X64|ARM|AARCH64
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+
+  #
+  # Define ESRT GUIDs for Firmware Management Protocol instances  #  
+ DEFINE FMP_GRAPHICS_ESRT_GUID  = B461B3BD-E62A-4A71-841C-50BA4E500267
+  DEFINE FMP_TEXT_ESRT_GUID  = 226034C4-8B67-4536-8653-D6EE7CE5A316
+
+[LibraryClasses]
+  
+UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntr
+yPoint.inf
+  
+UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/Uefi
+ApplicationEntryPoint.inf
+  
+UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBo
+otServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  
+UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/
+UefiRuntimeServicesTableLib.inf
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  
+MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAl
+locationLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  
+SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniz
+ationLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
+  
+DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Base
+DebugPrintErrorLevelLib.inf
+  
+PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.
+inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  

Re: [edk2] [Patch v5 02/21] FmpDevicePkg: Add library instances

2018-08-01 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Kinney, 
Michael D
Sent: Wednesday, August 1, 2018 2:55 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Yao, Jiewen 

Subject: [edk2] [Patch v5 02/21] FmpDevicePkg: Add library instances

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

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Add library instances for FmpDeviceLib, CapsuleUpdatePolicyLib, and 
FmpPayloadHeaderLib.

Library Classes
===
* FmpDeviceLibNull - Non-functional template of the FmpDeviceLib
  that can be used as a starting point for an FmpDeviceLib for
  a specific firmware storage device.
* CapsuleUpdatePolicyLibNull - Functional template of the
  CapsuleUpdatePolicyLib that can be used as a starting point
  of a platform specific implementation.
* FmpPayloadHeaderLibV1 - Version 1 of the FmpPayloadHeaderLib.
  This library is indented to be used "as is" with no need for
  any device specific or platform specific changes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../CapsuleUpdatePolicyLibNull.c   | 136 +++
 .../CapsuleUpdatePolicyLibNull.inf |  45 +++
 .../CapsuleUpdatePolicyLibNull.uni |  17 +
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c| 427 +
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |  48 +++  
.../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |  18 +
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c| 188 +
 .../FmpPayloadHeaderLibV1.inf  |  48 +++
 .../FmpPayloadHeaderLibV1.uni  |  21 +
 9 files changed, 948 insertions(+)
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.uni
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.uni

diff --git 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
new file mode 100644
index 00..d86d6ba612
--- /dev/null
+++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolic
+++ yLibNull.c
@@ -0,0 +1,136 @@
+/**  @file
+  Provides platform policy services used during a capsule update.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.  
+ Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without  
+ modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright 
+ notice,  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright 
+ notice,  this list of conditions and the following disclaimer in the 
+ documentation  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ "AS IS" AND  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ LIMITED TO, THE IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
+ ANY DIRECT,  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ CONSEQUENTIAL DAMAGES (INCLUDING,  BUT NOT LIMITED TO, PROCUREMENT OF 
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS; OR 
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  LIABILITY, 
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF  
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+
+/**
+  Determine if the system power state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system power state supports a capsule
+update.  Returns FALSE if system power state does not
+support a capsule update.  Return value is only valid if
+return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESSGood parameter has been updated with result.
+  

Re: [edk2] [Patch v5 01/21] FmpDevicePkg: Add package, library classes, and PCDs

2018-08-01 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Kinney, 
Michael D
Sent: Wednesday, August 1, 2018 2:55 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Yao, Jiewen 

Subject: [edk2] [Patch v5 01/21] FmpDevicePkg: Add package, library classes, 
and PCDs

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

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Create FmpDevicePkg with library classes and PCDs used to customize the 
behavior of a Firmware Management Protocol instance.

Library Classes
===
* FmpDeviceLib - Provides firmware device specific services
  to support updates of a firmware image stored in a firmware
  device.
* CapsuleUpdatePolicyLib - Provides platform policy services
  used during a capsule update.
* FmpPayloadHeaderLib - Provides services to retrieve values
  from a capsule's FMP Payload Header.  The structure is not
  included in the library class.  Instead, services are
  provided to retrieve information from the FMP Payload Header.
  If information is added to the FMP Payload Header, then new
  services may be added to this library class to retrieve the
  new information.

PCDs set per module

* PcdFmpDeviceSystemResetRequired - Indicates if a full
  system reset is required before a firmware update to a
  firmware devices takes effect
* PcdFmpDeviceTestKeySha256Digest - The SHA-256 hash of a
  PKCS7 test key that is used to detect if a test key is
  being used to authenticate capsules.  Test key detection
  is disabled by setting the value to {0}.
* PcdFmpDeviceProgressColor - The color of the progress bar
  during a firmware update.
* PcdFmpDeviceImageIdName - The Null-terminated Unicode
  string used to fill in the ImageIdName field of the
  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned
  by the GetImageInfo() service of the Firmware Management
  Protocol for the firmware device.
* PcdFmpDeviceBuildTimeLowestSupportedVersion - The build
  time value used to fill in the LowestSupportedVersion field
  of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is
  returned by the GetImageInfo() service of the Firmware
  Management Protocol.
* PcdFmpDeviceProgressWatchdogTimeInSeconds - The time in
  seconds to arm a watchdog timer during the update of a
  firmware device.

PCDs set per module or for entire platform 
==
* PcdFmpDevicePkcs7CertBufferXdr - One or more PKCS7
  certificates used to verify a firmware device capsule
  update image.
* PcdFmpDeviceLockEventGuid - An event GUID that locks
  the firmware device when the event is signaled.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dec  | 132 +++
 FmpDevicePkg/FmpDevicePkg.uni  |  80 
 FmpDevicePkg/FmpDevicePkgExtra.uni |  18 +
 .../Include/Library/CapsuleUpdatePolicyLib.h   | 120 ++
 FmpDevicePkg/Include/Library/FmpDeviceLib.h| 405 +
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h | 100 +
 6 files changed, 855 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dec  create mode 100644 
FmpDevicePkg/FmpDevicePkg.uni  create mode 100644 
FmpDevicePkg/FmpDevicePkgExtra.uni
 create mode 100644 FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpDeviceLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h

diff --git a/FmpDevicePkg/FmpDevicePkg.dec b/FmpDevicePkg/FmpDevicePkg.dec new 
file mode 100644 index 00..9ea0d73359
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -0,0 +1,132 @@
+## @file
+# Firmware Management Protocol Device Package # # This package provides 
+an implementation of a Firmware Management Protocol # instance that 
+supports the update of firmware storage devices using UEFI # Capsules.  
+The behavior of the Firmware Management Protocol instance is # 
+customized using libraries and PCDs.
+#
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved. # 
+Copyright (c) 2018, Intel Corporation. All rights reserved. # # 
+Redistribution and use in source and binary forms, with or without # 
+modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright 
+notice, # this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright 
+notice, # this list of conditions and the following disclaimer in the 
+documentation # and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED 

Re: [edk2] [Patch v5 03/21] FmpDevicePkg: Add FmpDxe module

2018-08-01 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Kinney, 
Michael D
Sent: Wednesday, August 1, 2018 2:55 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Yao, Jiewen 

Subject: [edk2] [Patch v5 03/21] FmpDevicePkg: Add FmpDxe module

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

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

The FmpDxe directory contains 2 INF files.  FmpDxe.inf
is a DXE driver that is used in a platform to add a
Firmware Management Protocol for firmware device that
supports firmware updates.

FmpDxeLib.inf is a NULL library instance with the exact
same functionality as FmpDxe.inf, but allows the the
Firmware Management Protocol feature to be added to
an existing device driver.

The FmpDxe component is intended to be used "as is"
with no need for any device specific or platform specific
changes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/DetectTestKey.c   |  166 
 FmpDevicePkg/FmpDxe/FmpDxe.c  | 1452 +
 FmpDevicePkg/FmpDxe/FmpDxe.inf|   93 +++
 FmpDevicePkg/FmpDxe/FmpDxe.uni|   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni   |   18 +
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf |   90 ++
 FmpDevicePkg/FmpDxe/VariableSupport.c |  461 +++
 FmpDevicePkg/FmpDxe/VariableSupport.h |  180 
 8 files changed, 2480 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDxe/DetectTestKey.c
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.c
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.inf
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.uni
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxeLib.inf
 create mode 100644 FmpDevicePkg/FmpDxe/VariableSupport.c
 create mode 100644 FmpDevicePkg/FmpDxe/VariableSupport.h

diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c 
b/FmpDevicePkg/FmpDxe/DetectTestKey.c
new file mode 100644
index 00..0a6e37eded
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c
@@ -0,0 +1,166 @@
+/**  @file
+  Detects if PcdFmpDevicePkcs7CertBufferXdr contains a test key.
+
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Check to see if any of the keys in PcdFmpDevicePkcs7CertBufferXdr matches
+  the test key.  PcdFmpDeviceTestKeySha256Digest contains the SHA256 hash of
+  the test key.  For each key in PcdFmpDevicePkcs7CertBufferXdr, compute the
+  SHA256 hash and compare it to PcdFmpDeviceTestKeySha256Digest.  If the
+  SHA256 hash matches or there is then error computing the SHA256 hash, then
+  set PcdTestKeyUsed to TRUE.  Skip this check if PcdTestKeyUsed is already
+  TRUE or PcdFmpDeviceTestKeySha256Digest is not exactly SHA256_DIGEST_SIZE
+  bytes.
+**/
+VOID
+DetectTestKey (
+  VOID
+  )
+{
+  BOOLEAN  TestKeyUsed;
+  UINTNPublicKeyDataLength;
+  UINT8*PublicKeyDataXdr;
+  UINT8*PublicKeyDataXdrEnd;
+  VOID *HashContext;
+  UINT8Digest[SHA256_DIGEST_SIZE];
+
+  //
+  // If PcdFmpDeviceTestKeySha256Digest is not exacty SHA256_DIGEST_SIZE bytes,
+  // then skip the test key detection.
+  //
+  if (PcdGetSize (PcdFmpDeviceTestKeySha256Digest) != SHA256_DIGEST_SIZE) {
+return;
+  }
+
+  //
+  // If PcdTestKeyUsed is already TRUE, then skip test key detection
+  //
+  TestKeyUsed = PcdGetBool (PcdTestKeyUsed);
+  if (TestKeyUsed) {
+return;
+  }
+
+  //
+  // If PcdFmpDevicePkcs7CertBufferXdr 

Re: [edk2] [Patch] BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue

2018-08-01 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: Kinney, Michael D 
Sent: Wednesday, August 01, 2018 12:29 AM
To: edk2-devel@lists.01.org
Cc: Sun, Yanyan ; Zhu, Yonghong ; 
Gao, Liming ; Kinney, Michael D 

Subject: [Patch] BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue

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

Convert Buffer to type bytearray before converting to a string of hex byte 
values so the type of items in Buffer is consistent for both Python 2.7.x and 
Python 3.x.

Cc: YanYan Sun 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 BaseTools/Scripts/BinToPcd.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py 
index c42e37bd11..25b74f6004 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -66,7 +66,7 @@ if __name__ == '__main__':
 #
 # If Xdr flag is not set, then concatenate all the data
 #
-Buffer = b''.join (Buffer)
+Buffer = bytearray (b''.join (Buffer))
 #
 # Return a PCD value of the form '{0x01, 0x02, ...}' along with the 
PCD length in bytes
 #
--
2.14.2.windows.3

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


[edk2] [Patch v5 21/21] MdeModulePkg/BdsDxe: Move display of test key usage into BDS module

2018-08-01 Thread Kinney, Michael D
Cc: Ruiyu Ni 
Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Universal/BdsDxe/BdsDxe.inf |  1 +
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf 
b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
index 7e644aa995..7030d67907 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -100,6 +100,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable  ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed   ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index a25663ea43..b9ca31741e 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -884,6 +884,18 @@ BdsEntry (
   PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole");
   PlatformBootManagerAfterConsole ();
   PERF_INMODULE_END("PlatformBootManagerAfterConsole");
+
+  //
+  // If any component set PcdTestKeyUsed to TRUE because use of a test key
+  // was detected, then display a warning message on the debug log and the 
console
+  //
+  if (PcdGetBool (PcdTestKeyUsed) == TRUE) {
+DEBUG ((DEBUG_ERROR, "**\n"));
+DEBUG ((DEBUG_ERROR, "**  WARNING: Test Key is used.  **\n"));
+DEBUG ((DEBUG_ERROR, "**\n"));
+Print (L"**  WARNING: Test Key is used.  **\n");
+  }
+
   //
   // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. 
Skip HotkeyBoot
   //
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 13/21] FmpDevicePkg FmpDxe: Add NULL check to return Value from GetVariable2

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/VariableSupport.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c 
b/FmpDevicePkg/FmpDxe/VariableSupport.c
index c15178d099..6a4330ad6a 100644
--- a/FmpDevicePkg/FmpDxe/VariableSupport.c
+++ b/FmpDevicePkg/FmpDxe/VariableSupport.c
@@ -72,7 +72,7 @@ GetVersionFromVariable (
   Version = DEFAULT_VERSION;
 
   Status = GetVariable2 (VARNAME_VERSION, , (VOID **), 
);
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_ERROR, "Failed to get the Version from variable.  Status = 
%r\n", Status));
 return Version;
   }
@@ -125,7 +125,7 @@ GetLowestSupportedVersionFromVariable (
   Version = DEFAULT_LOWESTSUPPORTEDVERSION;
 
   Status = GetVariable2 (VARNAME_LSV, , (VOID **), 
);
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_WARN, "Warning: Failed to get the Lowest Supported Version 
from variable.  Status = %r\n", Status));
 return Version;
   }
@@ -177,7 +177,7 @@ GetLastAttemptStatusFromVariable (
   LastAttemptStatus = DEFAULT_LASTATTEMPT;
 
   Status = GetVariable2 (VARNAME_LASTATTEMPTSTATUS, , (VOID 
**), );
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_WARN, "Warning: Failed to get the Last Attempt Status from 
variable.  Status = %r\n", Status));
 return LastAttemptStatus;
   }
@@ -233,7 +233,7 @@ GetLastAttemptVersionFromVariable (
   Version = DEFAULT_LASTATTEMPT;
 
   Status = GetVariable2 (VARNAME_LASTATTEMPTVERSION, , (VOID 
**), );
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (Value == NULL)) {
 DEBUG ((DEBUG_WARN, "Warning: Failed to get the Last Attempt Version from 
variable.  Status = %r\n", Status));
 return Version;
   }
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 16/21] FmpDevicePkg FmpDxe: Add comment in mFmpDeviceLocked's declaration

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Add comment in mFmpDeviceLocked's declaration to make it more clear.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 3544afd3de..fb02e34f70 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -89,6 +89,13 @@ UINT64  mImageId  = 0x1;
 CHAR16  *mVersionName = NULL;
 
 EFI_EVENT  mFmpDeviceLockEvent;
+//
+// Indicates if an attempt has been made to lock a 
+// FLASH storage device by calling FmpDeviceLock().
+// A FLASH storage device may not support being locked,
+// so this variable is set to TRUE even if FmpDeviceLock()
+// returns an error.
+//
 BOOLEANmFmpDeviceLocked = FALSE;
 
 /**
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 18/21] FmpDevicePkg FmpDxe: Initialize DeviceLibLowestSupportedVersion

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Some static tool reports "DeviceLibLowestSupportedVersion" is used,
but is uninitialized. It is false positive reporting based because
DeviceLibLowestSupportedVersion will have assigned value after
FmpDeviceGetLowestSupportedVersion() returns SUCCESS.

This patch updates the code to initialize
DeviceLibLowestSupportedVersion
to DEFAULT_LOWESTSUPPORTEDVERSION before calling
FmpDeviceGetLowestSupportedVersion().
It can pass the static tool's check.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index b25a1511c7..095cebaa75 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -229,6 +229,7 @@ GetLowestSupportedVersion (
   //
   // Check the FmpDeviceLib
   //
+  DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
   Status = FmpDeviceGetLowestSupportedVersion 
();
   if (EFI_ERROR (Status)) {
 DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 19/21] FmpDevicePkg: Fix code style issue

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.uni  | 22 ++--
 FmpDevicePkg/FmpDxe/DetectTestKey.c|  2 +-
 FmpDevicePkg/FmpDxe/FmpDxe.c   | 42 +++---
 FmpDevicePkg/FmpDxe/VariableSupport.c  |  6 ++--
 FmpDevicePkg/FmpDxe/VariableSupport.h  |  6 ++--
 .../Include/Library/CapsuleUpdatePolicyLib.h   |  6 ++--
 FmpDevicePkg/Include/Library/FmpDeviceLib.h| 20 +--
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h |  8 ++---
 .../CapsuleUpdatePolicyLibNull.c   |  6 ++--
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c| 22 ++--
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c|  8 ++---
 11 files changed, 75 insertions(+), 73 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni
index fed1da4802..a922ff44e4 100644
--- a/FmpDevicePkg/FmpDevicePkg.uni
+++ b/FmpDevicePkg/FmpDevicePkg.uni
@@ -59,17 +59,17 @@

   "value of 0 disables the watchdog timer.  The 
default value is 0 (watchdog"

   "disabled)."
 
-#string 
STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT  
#language en-US "One or more XDR encoded PKCS7 certificates used to verify 
firmware device capsule update images"
-#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP  
  #language en-US "Provides one or more PKCS7 certificates used to verify a 
firmware device"
-   
  "capsule update image.  This PCD is encoded using the 
Variable-Length Opaque"
-   
  "Data format of RFC 4506 External Data Representation 
Standard (XDR)."
-   
  "The default value is empty with 0 certificates."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT  
#language en-US "One or more XDR encoded PKCS7 certificates used to verify 
firmware device capsule update images"
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP
#language en-US "Provides one or more PKCS7 certificates used to verify a 
firmware device"
+   
"capsule update image.  This PCD is encoded using the 
Variable-Length Opaque"
+   
"Data format of RFC 4506 External Data Representation Standard 
(XDR)."
+   
"The default value is empty with 0 certificates."
 
-#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_PROMPT  
#language en-US "Firmware Device Lock Event GUID."
-#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_HELP
#language en-US "An event GUID that locks the firmware device when the event is 
signaled."
-   
 "If this PCD is not a valid GUID value, then the firmware device 
is locked"
-   
 "when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  
The"
-   
 "default value is empty, so by default the firmware device is 
locked at the"
-   
 "end of the DXE phase."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_PROMPT  
#language en-US "Firmware Device Lock Event GUID."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_HELP
#language en-US "An event GUID that locks the firmware device when the event is 
signaled."
+   
   "If this PCD is not a valid GUID value, then the firmware device is 
locked"
+   
   "when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  
The"
+   
   "default value is empty, so by default the firmware device is locked 
at the"
+   
   

[edk2] [Patch v5 04/21] FmpDevicePkg: Add DSC file to build all package components

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Adds a DSC file that is used to verify that all of the
FmpDevicePkg libraries and modules build without error.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 134 ++
 1 file changed, 134 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
new file mode 100644
index 00..4d08a2cf9e
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -0,0 +1,134 @@
+## @file
+# Firmware Management Protocol Device Package
+#
+# This package provides an implementation of a Firmware Management Protocol
+# instance that supports the update of firmware storage devices using UEFI
+# Capsules.  The behavior of the Firmware Management Protocol instance is
+# customized using libraries and PCDs.
+#
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+# Copyright (c) 2018, Intel Corporation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+##
+
+[Defines]
+  PLATFORM_NAME  = FmpDevicePkg
+  PLATFORM_GUID  = 0af3d540-27c6-11e8-828b-f8597177a00a
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x00010005
+  OUTPUT_DIRECTORY   = Build/FmpDevicePkg
+  SUPPORTED_ARCHITECTURES= IA32|IPF|X64|ARM|AARCH64
+  BUILD_TARGETS  = DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+
+  #
+  # Define ESRT GUIDs for Firmware Management Protocol instances
+  #
+  DEFINE FMP_GRAPHICS_ESRT_GUID  = B461B3BD-E62A-4A71-841C-50BA4E500267
+  DEFINE FMP_TEXT_ESRT_GUID  = 226034C4-8B67-4536-8653-D6EE7CE5A316
+
+[LibraryClasses]
+  
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+  
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+  
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+
+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+  

[edk2] [Patch v5 14/21] FmpDevicePkg FmpDxe: Check ImageIndex first before Image/ImageSize

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

It does not make sense to check the Image/ImageSize if ImageIndex
has been invalid.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index eb45273754..94fdf56085 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -497,6 +497,15 @@ GetTheImage (
 
   Status = EFI_SUCCESS;
 
+  //
+  // Check to make sure index is 1 (only 1 image for this device)
+  //
+  if (ImageIndex != 1) {
+DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));
+Status = EFI_INVALID_PARAMETER;
+goto cleanup;
+  }
+
   if ((ImageSize == NULL)) {
 DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is 
NULL.\n"));
 Status = EFI_INVALID_PARAMETER;
@@ -523,16 +532,6 @@ GetTheImage (
 goto cleanup;
   }
 
-  //
-  // Check to make sure index is 1 (only 1 image for this device)
-  //
-  if (ImageIndex != 1) {
-DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));
-Status = EFI_INVALID_PARAMETER;
-goto cleanup;
-  }
-
-
   Status = FmpDeviceGetImage (Image, ImageSize);
 cleanup:
 
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 00/21] Add FmpDevicePkg

2018-08-01 Thread Kinney, Michael D
Changes in V4/V5
=
* Return 0 when LSV check is not required
* Remove IPF
* Add DISABLE_NEW_DEPRECATED_INTERFACES build options
* Check Progress!= NULL before calling Progress(100)
* Add EFI_ABORTED in retval of CheckTheImage()
* Fix typo "EFI_SECURITY_VIOLATIO"
* Add NULL check to return Value from GetVariable2
* Check ImageIndex first before Image/ImageSize
* Use Attributes to know whether reset is required
* Add comment in mFmpDeviceLocked's declaration
* Return UNSUPPORTED if device has been locked
* Initialize DeviceLibLowestSupportedVersion
* Fix code style issue
* Use local variable to store test key digest size

Changes in V3
=
* Change CheckLowestSupportedVersion() to LowestSupportedVersionCheckRequired()
* Change LockFmpDeviceAtLockEventGuid() to 
LockFmpDeviceAtLockEventGuidRequired()
* Set EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL Version field to 1
* Fix description of return values in LowestSupportedVersionCheckRequired()
* Fix description of return values in LockFmpDeviceAtLockEventGuidRequired()

Changes in V2
=
* FmpDevicePkg DEC file
  + Change PcdFmpDeviceSystemResetRequired from FeatureFlag
to FixedAtBuild
  + Add PcdFmpDeviceTestKeySha256Digest for test key detection.
Set to {0} to disable test key detection.
* FmpDevicePkg DSC file
  + Fix ARM and AARCH64 build issues
  + Update DisplayUpdateProgressLib mappings to match patches in
Bug_801_DisplayUpdateProgressLib_V2
* FmpDeviceLib Class and Instance
  + Update FmpDeviceGetSize() to return EFI_STATUS
  + Update FmpDeviceGetAttributes() to return EFI_STATUS
  + Update FmpDeviceGetVersionString() to return EFI_STATUS
* FmpDxe
  + Set depex to Variable Arch Write Protocol and Variable Lock Protocol
  + Break out test key detection in FmpDxe into DetectTestKey.c
  + Change LockAllVars() to LockAllFmpVariables()
  + Update LockAllFmpVariables() to lock each of the UEFI variables used.
  + Always lock UEFI variables when PcdFmpDeviceLockEventGuid is signaled
  + Remove ComputeVersionName().  FmpDeviceLib must provide version string

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Further development and testing of FmpDevicePkg was performed at:
  https://github.com/tianocore/edk2-staging/tree/FmpDevicePkg-master
  https://github.com/tianocore/edk2-staging/tree/FmpDevicePkg-UDK2018

This package provides an implementation of a Firmware Management Protocol
instance that supports the update of firmware storage devices using UEFI
Capsules.  The behavior of the Firmware Management Protocol instance is
customized using libraries and PCDs.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 

Kinney, Michael D (5):
  FmpDevicePkg: Add package, library classes, and PCDs
  FmpDevicePkg: Add library instances
  FmpDevicePkg: Add FmpDxe module
  FmpDevicePkg: Add DSC file to build all package components
  MdeModulePkg/BdsDxe: Move display of test key usage into BDS module

Star Zeng (16):
  FmpDevicePkg FmpDxe: Update function comment for FmpDxeEntryPoint
  FmpDevicePkg FmpDxe: Return 0 when LSV check is not required
  FmpDevicePkg: Remove IPF
  FmpDevicePkg: Add DISABLE_NEW_DEPRECATED_INTERFACES build options
  FmpDevicePkg FmpDxe: Check Progress!= NULL before calling
Progress(100)
  FmpDevicePkg FmpDxe: Add EFI_ABORTED in retval of CheckTheImage()
  FmpDevicePkg FmpDxe: Fix typo "EFI_SECURITY_VIOLATIO"
  FmpDevicePkg: Remove DisplayUpdateProgressLib mapping for FmpDxe
  FmpDevicePkg FmpDxe: Add NULL check to return Value from GetVariable2
  FmpDevicePkg FmpDxe: Check ImageIndex first before Image/ImageSize
  FmpDevicePkg FmpDxe: Use Attributes to know whether reset is required
  FmpDevicePkg FmpDxe: Add comment in mFmpDeviceLocked's declaration
  FmpDevicePkg FmpDxe: Return UNSUPPORTED if device has been locked
  FmpDevicePkg FmpDxe: Initialize DeviceLibLowestSupportedVersion
  FmpDevicePkg: Fix code style issue
  FmpDevicePkg FmpDxe: Use local variable to store test key digest size

 FmpDevicePkg/FmpDevicePkg.dec  |  125 ++
 FmpDevicePkg/FmpDevicePkg.dsc  |  133 ++
 FmpDevicePkg/FmpDevicePkg.uni  |   75 +
 FmpDevicePkg/FmpDevicePkgExtra.uni |   18 +
 FmpDevicePkg/FmpDxe/DetectTestKey.c|  168 +++
 FmpDevicePkg/FmpDxe/FmpDxe.c   | 1474 
 FmpDevicePkg/FmpDxe/FmpDxe.inf |   92 ++
 FmpDevicePkg/FmpDxe/FmpDxe.uni |   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni|   18 +
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf  |   89 ++
 FmpDevicePkg/FmpDxe/VariableSupport.c  |  461 ++
 FmpDevicePkg/FmpDxe/VariableSupport.h  |  180 +++
 .../Include/Library/CapsuleUpdatePolicyLib.h   |  120 ++
 

[edk2] [Patch v5 10/21] FmpDevicePkg FmpDxe: Add EFI_ABORTED in retval of CheckTheImage()

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index f0e8b0da82..69b6cb7d4c 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -626,6 +626,7 @@ GetAllHeaderSize (
  if available, additional information if the 
image is invalid.
 
   @retval EFI_SUCCESSThe image was successfully checked.
+  @retval EFI_ABORTEDThe operation is aborted.
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
   @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 11/21] FmpDevicePkg FmpDxe: Fix typo "EFI_SECURITY_VIOLATIO"

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Fix typo "EFI_SECURITY_VIOLATIO" to "EFI_SECURITY_VIOLATION".

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 69b6cb7d4c..eb45273754 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -480,7 +480,7 @@ cleanup:
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_NOT_FOUND  The current image is not copied to the buffer.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
@@ -629,7 +629,7 @@ GetAllHeaderSize (
   @retval EFI_ABORTEDThe operation is aborted.
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
@@ -875,7 +875,7 @@ cleanup:
   @retval EFI_ABORTEDThe operation is aborted.
   @retval EFI_INVALID_PARAMETER  The Image was NULL.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
@@ -1206,7 +1206,7 @@ GetPackageInfo (
   @retval EFI_INVALID_PARAMETER  The PackageVersionName length is longer than 
the value
  returned in PackageVersionNameMaxLen.
   @retval EFI_UNSUPPORTEDThe operation is not supported.
-  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to 
an authentication failure.
+  @retval EFI_SECURITY_VIOLATION The operation could not be performed due to 
an authentication failure.
 
 **/
 EFI_STATUS
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 07/21] FmpDevicePkg: Remove IPF

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc   | 2 +-
 FmpDevicePkg/FmpDxe/FmpDxe.inf  | 2 +-
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf   | 2 +-
 .../Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf   | 2 +-
 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  | 2 +-
 FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf| 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index 4d08a2cf9e..a4eac1e60d 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -36,7 +36,7 @@ [Defines]
   PLATFORM_VERSION   = 0.1
   DSC_SPECIFICATION  = 0x00010005
   OUTPUT_DIRECTORY   = Build/FmpDevicePkg
-  SUPPORTED_ARCHITECTURES= IA32|IPF|X64|ARM|AARCH64
+  SUPPORTED_ARCHITECTURES= IA32|X64|ARM|AARCH64
   BUILD_TARGETS  = DEBUG|RELEASE
   SKUID_IDENTIFIER   = DEFAULT
 
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index 256c50bf03..ec2bb2d052 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -38,7 +38,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf 
b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
index c8fe49e0c0..41acf45fcf 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -39,7 +39,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
index c7c669e3e0..f92d88a7c1 100644
--- 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
+++ 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
@@ -34,7 +34,7 @@ [Defines]
   LIBRARY_CLASS   = CapsuleUpdatePolicyLib
 
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf 
b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
index d51f69d0b9..0383b250f6 100644
--- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
@@ -37,7 +37,7 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
diff --git 
a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf 
b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
index 41ed6e2aca..324b7cc781 100644
--- a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
+++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
@@ -37,7 +37,7 @@ [Defines]
   LIBRARY_CLASS  = FmpPayloadHeaderLib|DXE_DRIVER 
UEFI_APPLICATION
 
 #
-#  VALID_ARCHITECTURES   = IA32 X64 IPF ARM AARCH64
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
 #
 
 [Sources]
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 05/21] FmpDevicePkg FmpDxe: Update function comment for FmpDxeEntryPoint

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

FmpDxeEntryPoint is used by both FmpDxe and FmpDxeLib.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index b709bc282a..c0c1383723 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -1360,7 +1360,7 @@ cleanup:
 }
 
 /**
-  Main entry for this library.
+  Main entry for this driver/library.
 
   @param[in] ImageHandle  Image handle this driver.
   @param[in] SystemTable  Pointer to SystemTable.
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 06/21] FmpDevicePkg FmpDxe: Return 0 when LSV check is not required

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Current code return 1 when LSV check is not required,
but 1 LSV will make 0 Version capsule image update failed.

0 LSV is valid, this patch updates the code to return 0 when
LSV check is not required
We can see even the DEFAULT_LOWESTSUPPORTEDVERSION is 0.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index c0c1383723..091f950b95 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -210,12 +210,15 @@ GetLowestSupportedVersion (
   // Get the LowestSupportedVersion.
   //
 
-  DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
-  ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
   if (!IsLowestSupportedVersionCheckRequired ()) {
-return 1;
+//
+// Any Version can pass the 0 LowestSupportedVersion check.
+//
+return 0;
   }
 
+  ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
+
   //
   // Check the FmpDeviceLib
   //
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 17/21] FmpDevicePkg FmpDxe: Return UNSUPPORTED if device has been locked

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Instead of EFI_ACCESS_DENIED which is not defined in retval by
UEFI spec, return UNSUPPORTED if device has been locked in
SetTheImage().

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index fb02e34f70..b25a1511c7 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -928,7 +928,7 @@ SetTheImage (
   //
   if (mFmpDeviceLocked) {
 DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Device is already locked.  
Can't update.\n"));
-Status = EFI_ACCESS_DENIED;
+Status = EFI_UNSUPPORTED;
 goto cleanup;
   }
 
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 09/21] FmpDevicePkg FmpDxe: Check Progress!= NULL before calling Progress(100)

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/FmpDxe.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 091f950b95..f0e8b0da82 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -1121,10 +1121,12 @@ cleanup:
   mProgressSupported = FALSE;
   SetLastAttemptStatusInVariable (LastAttemptStatus);
 
-  //
-  // Set progress to 100 after everything is done including recording Status.
-  //
-  Progress (100);
+  if (Progress != NULL) {
+//
+// Set progress to 100 after everything is done including recording Status.
+//
+Progress (100);
+  }
 
   return Status;
 }
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 08/21] FmpDevicePkg: Add DISABLE_NEW_DEPRECATED_INTERFACES build options

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Add DISABLE_NEW_DEPRECATED_INTERFACES build options to make sure
no deprecated interface used in this package.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index a4eac1e60d..525640de2e 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -132,3 +132,6 @@ [Components]
 
   
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
   }
+
+[BuildOptions]
+  *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 20/21] FmpDevicePkg FmpDxe: Use local variable to store test key digest size

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Some static tool reports "the condition in 'if' statement is constant".

This patch updates the code to use local variable to store test key
digest size. It can pass the static tool's check.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/DetectTestKey.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c 
b/FmpDevicePkg/FmpDxe/DetectTestKey.c
index 6dedbdfaee..f9b983bb75 100644
--- a/FmpDevicePkg/FmpDxe/DetectTestKey.c
+++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c
@@ -53,12 +53,14 @@ DetectTestKey (
   UINT8*PublicKeyDataXdrEnd;
   VOID *HashContext;
   UINT8Digest[SHA256_DIGEST_SIZE];
+  UINTNTestKeyDigestSize;
 
   //
   // If PcdFmpDeviceTestKeySha256Digest is not exacty SHA256_DIGEST_SIZE bytes,
   // then skip the test key detection.
   //
-  if (PcdGetSize (PcdFmpDeviceTestKeySha256Digest) != SHA256_DIGEST_SIZE) {
+  TestKeyDigestSize = PcdGetSize (PcdFmpDeviceTestKeySha256Digest);
+  if (TestKeyDigestSize != SHA256_DIGEST_SIZE) {
 return;
   }
 
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 12/21] FmpDevicePkg: Remove DisplayUpdateProgressLib mapping for FmpDxe

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

FmpDxe does not consume DisplayUpdateProgressLib, so remove the
mapping in FmpDevicePkg.dsc.
Also rename the ESRT GUIDs.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dsc | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
index 525640de2e..8d2436627d 100644
--- a/FmpDevicePkg/FmpDevicePkg.dsc
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -43,8 +43,8 @@ [Defines]
   #
   # Define ESRT GUIDs for Firmware Management Protocol instances
   #
-  DEFINE FMP_GRAPHICS_ESRT_GUID  = B461B3BD-E62A-4A71-841C-50BA4E500267
-  DEFINE FMP_TEXT_ESRT_GUID  = 226034C4-8B67-4536-8653-D6EE7CE5A316
+  DEFINE SYSTEM_FMP_ESRT_GUID   = B461B3BD-E62A-4A71-841C-50BA4E500267
+  DEFINE DEVICE_FMP_ESRT_GUID   = 226034C4-8B67-4536-8653-D6EE7CE5A316
 
 [LibraryClasses]
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
@@ -116,11 +116,9 @@ [Components]
   FmpDevicePkg/FmpDxe/FmpDxe.inf {
 
   #
-  # FILE_GUID is FMP ESRT GUID
+  # FILE_GUID is used as ESRT GUID
   #
-  FILE_GUID = $(FMP_GRAPHICS_ESRT_GUID)
-
-  
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
+  FILE_GUID = $(SYSTEM_FMP_ESRT_GUID)
   }
 
   FmpDevicePkg/FmpDxe/FmpDxe.inf {
@@ -128,9 +126,7 @@ [Components]
   #
   # FILE_GUID is used as ESRT GUID
   #
-  FILE_GUID = $(FMP_TEXT_ESRT_GUID)
-
-  
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
+  FILE_GUID = $(DEVICE_FMP_ESRT_GUID)
   }
 
 [BuildOptions]
-- 
2.14.2.windows.3

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


[edk2] [Patch v5 03/21] FmpDevicePkg: Add FmpDxe module

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

The FmpDxe directory contains 2 INF files.  FmpDxe.inf
is a DXE driver that is used in a platform to add a
Firmware Management Protocol for firmware device that
supports firmware updates.

FmpDxeLib.inf is a NULL library instance with the exact
same functionality as FmpDxe.inf, but allows the the
Firmware Management Protocol feature to be added to
an existing device driver.

The FmpDxe component is intended to be used "as is"
with no need for any device specific or platform specific
changes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDxe/DetectTestKey.c   |  166 
 FmpDevicePkg/FmpDxe/FmpDxe.c  | 1452 +
 FmpDevicePkg/FmpDxe/FmpDxe.inf|   93 +++
 FmpDevicePkg/FmpDxe/FmpDxe.uni|   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni   |   18 +
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf |   90 ++
 FmpDevicePkg/FmpDxe/VariableSupport.c |  461 +++
 FmpDevicePkg/FmpDxe/VariableSupport.h |  180 
 8 files changed, 2480 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDxe/DetectTestKey.c
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.c
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.inf
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxe.uni
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni
 create mode 100644 FmpDevicePkg/FmpDxe/FmpDxeLib.inf
 create mode 100644 FmpDevicePkg/FmpDxe/VariableSupport.c
 create mode 100644 FmpDevicePkg/FmpDxe/VariableSupport.h

diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c 
b/FmpDevicePkg/FmpDxe/DetectTestKey.c
new file mode 100644
index 00..0a6e37eded
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c
@@ -0,0 +1,166 @@
+/**  @file
+  Detects if PcdFmpDevicePkcs7CertBufferXdr contains a test key.
+
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Check to see if any of the keys in PcdFmpDevicePkcs7CertBufferXdr matches
+  the test key.  PcdFmpDeviceTestKeySha256Digest contains the SHA256 hash of
+  the test key.  For each key in PcdFmpDevicePkcs7CertBufferXdr, compute the
+  SHA256 hash and compare it to PcdFmpDeviceTestKeySha256Digest.  If the
+  SHA256 hash matches or there is then error computing the SHA256 hash, then
+  set PcdTestKeyUsed to TRUE.  Skip this check if PcdTestKeyUsed is already
+  TRUE or PcdFmpDeviceTestKeySha256Digest is not exactly SHA256_DIGEST_SIZE
+  bytes.
+**/
+VOID
+DetectTestKey (
+  VOID
+  )
+{
+  BOOLEAN  TestKeyUsed;
+  UINTNPublicKeyDataLength;
+  UINT8*PublicKeyDataXdr;
+  UINT8*PublicKeyDataXdrEnd;
+  VOID *HashContext;
+  UINT8Digest[SHA256_DIGEST_SIZE];
+
+  //
+  // If PcdFmpDeviceTestKeySha256Digest is not exacty SHA256_DIGEST_SIZE bytes,
+  // then skip the test key detection.
+  //
+  if (PcdGetSize (PcdFmpDeviceTestKeySha256Digest) != SHA256_DIGEST_SIZE) {
+return;
+  }
+
+  //
+  // If PcdTestKeyUsed is already TRUE, then skip test key detection
+  //
+  TestKeyUsed = PcdGetBool (PcdTestKeyUsed);
+  if (TestKeyUsed) {
+return;
+  }
+
+  //
+  // If PcdFmpDevicePkcs7CertBufferXdr is invalid, then skip test key detection
+  //
+  PublicKeyDataXdr= PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
+  PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize 
(PcdFmpDevicePkcs7CertBufferXdr);
+  if (PublicKeyDataXdr == NULL || PublicKeyDataXdr == PublicKeyDataXdrEnd) {
+return;
+  }
+
+  //
+  

[edk2] [Patch v5 15/21] FmpDevicePkg FmpDxe: Use Attributes to know whether reset is required

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

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

Use Attributes to know whether reset is required and remove
PcdFmpDeviceSystemResetRequired.

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dec |  7 ---
 FmpDevicePkg/FmpDevicePkg.uni |  5 -
 FmpDevicePkg/FmpDxe/FmpDxe.c  | 13 ++---
 FmpDevicePkg/FmpDxe/FmpDxe.inf|  1 -
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf |  1 -
 5 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/FmpDevicePkg/FmpDevicePkg.dec b/FmpDevicePkg/FmpDevicePkg.dec
index 9ea0d73359..ad0730a532 100644
--- a/FmpDevicePkg/FmpDevicePkg.dec
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -62,13 +62,6 @@ [Guids]
   gFmpDevicePkgTokenSpaceGuid = { 0x40b2d964, 0xfe11, 0x40dc, { 0x82, 0x83, 
0x2e, 0xfb, 0xda, 0x29, 0x53, 0x56 } }
 
 [PcdsFixedAtBuild]
-  ## Indicates if a full system reset is required before a firmware update to a
-  #  firmware devices takes effect.
-  #   TRUE  - System reset is required.
-  #   FALSE - System reset is not required.
-  # @Prompt FMP Device System Reset Required.
-  
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired|TRUE|BOOLEAN|0x4008
-
   ## The SHA-256 hash of a PKCS7 test key that is used to detect if a test key
   #  is being used to authenticate capsules.  Test key detection is disabled by
   #  setting the value to {0}.
diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni
index da31d0ac81..fed1da4802 100644
--- a/FmpDevicePkg/FmpDevicePkg.uni
+++ b/FmpDevicePkg/FmpDevicePkg.uni
@@ -22,11 +22,6 @@
 
 #string STR_PACKAGE_DESCRIPTION  #language en-US  "This package provides 
libraries that support the implementation of a module that produces the 
Firmware Management Protocol to support the update of a system firmware 
component."
 
-#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_PROMPT 
 #language en-US "FMP Device System Reset Required."
-#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_HELP   
 #language en-US "Indicates if a full system reset is required before a 
firmware update to a firmware device takes effect.\n"
-   
 "TRUE  - System reset is required.\n"
-   
 "FALSE - System reset is not required."
-
 #string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceTestKeySha256Digest_PROMPT 
 #language en-US "SHA-256 hash of PKCS7 test key."
 #string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceTestKeySha256Digest_HELP   
 #language en-US "The SHA-256 hash of a PKCS7 test key that is used to detect 
if a test key"

 "is being used to authenticate capsules.  Test key detection 
can be disabled"
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 94fdf56085..3544afd3de 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -898,6 +898,9 @@ SetTheImage (
   UINT32  AllHeaderSize;
   UINT32  IncommingFwVersion;
   UINT32  LastAttemptStatus;
+  EFI_STATUS  GetAttributesStatus;
+  UINT64  AttributesSupported;
+  UINT64  AttributesSetting;
 
   Status = EFI_SUCCESS;
   Updateable = 0;
@@ -1110,10 +1113,14 @@ SetTheImage (
 
   //
   // Set flag so the descriptor is repopulated
-  // This only applied to devices that do not require system reboot
+  // This is only applied to devices that do not require reset
   //
-  if (!PcdGetBool (PcdFmpDeviceSystemResetRequired)) {
-mDescriptorPopulated = FALSE;
+  GetAttributesStatus = FmpDeviceGetAttributes (, 
);
+  if (!EFI_ERROR (GetAttributesStatus)) {
+if (((AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0) ||
+((AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0)) {
+  mDescriptorPopulated = FALSE;
+}
   }
 
 cleanup:
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index ec2bb2d052..228e53658a 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -76,7 +76,6 @@ [Protocols]
   gEdkiiFirmwareManagementProgressProtocolGuid  ## PRODUCES
 
 [Pcd]
-  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired  ## 
CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName  ## 
CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion  ## 
CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid## 
CONSUMES
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf 
b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
index 41acf45fcf..5484531155 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -76,7 +76,6 @@ 

[edk2] [Patch v5 01/21] FmpDevicePkg: Add package, library classes, and PCDs

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Create FmpDevicePkg with library classes and PCDs used to
customize the behavior of a Firmware Management Protocol
instance.

Library Classes
===
* FmpDeviceLib - Provides firmware device specific services
  to support updates of a firmware image stored in a firmware
  device.
* CapsuleUpdatePolicyLib - Provides platform policy services
  used during a capsule update.
* FmpPayloadHeaderLib - Provides services to retrieve values
  from a capsule's FMP Payload Header.  The structure is not
  included in the library class.  Instead, services are
  provided to retrieve information from the FMP Payload Header.
  If information is added to the FMP Payload Header, then new
  services may be added to this library class to retrieve the
  new information.

PCDs set per module

* PcdFmpDeviceSystemResetRequired - Indicates if a full
  system reset is required before a firmware update to a
  firmware devices takes effect
* PcdFmpDeviceTestKeySha256Digest - The SHA-256 hash of a
  PKCS7 test key that is used to detect if a test key is
  being used to authenticate capsules.  Test key detection
  is disabled by setting the value to {0}.
* PcdFmpDeviceProgressColor - The color of the progress bar
  during a firmware update.
* PcdFmpDeviceImageIdName - The Null-terminated Unicode
  string used to fill in the ImageIdName field of the
  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned
  by the GetImageInfo() service of the Firmware Management
  Protocol for the firmware device.
* PcdFmpDeviceBuildTimeLowestSupportedVersion - The build
  time value used to fill in the LowestSupportedVersion field
  of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is
  returned by the GetImageInfo() service of the Firmware
  Management Protocol.
* PcdFmpDeviceProgressWatchdogTimeInSeconds - The time in
  seconds to arm a watchdog timer during the update of a
  firmware device.

PCDs set per module or for entire platform
==
* PcdFmpDevicePkcs7CertBufferXdr - One or more PKCS7
  certificates used to verify a firmware device capsule
  update image.
* PcdFmpDeviceLockEventGuid - An event GUID that locks
  the firmware device when the event is signaled.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 FmpDevicePkg/FmpDevicePkg.dec  | 132 +++
 FmpDevicePkg/FmpDevicePkg.uni  |  80 
 FmpDevicePkg/FmpDevicePkgExtra.uni |  18 +
 .../Include/Library/CapsuleUpdatePolicyLib.h   | 120 ++
 FmpDevicePkg/Include/Library/FmpDeviceLib.h| 405 +
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h | 100 +
 6 files changed, 855 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dec
 create mode 100644 FmpDevicePkg/FmpDevicePkg.uni
 create mode 100644 FmpDevicePkg/FmpDevicePkgExtra.uni
 create mode 100644 FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpDeviceLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h

diff --git a/FmpDevicePkg/FmpDevicePkg.dec b/FmpDevicePkg/FmpDevicePkg.dec
new file mode 100644
index 00..9ea0d73359
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -0,0 +1,132 @@
+## @file
+# Firmware Management Protocol Device Package
+#
+# This package provides an implementation of a Firmware Management Protocol
+# instance that supports the update of firmware storage devices using UEFI
+# Capsules.  The behavior of the Firmware Management Protocol instance is
+# customized using libraries and PCDs.
+#
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+# Copyright (c) 2018, Intel Corporation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

[edk2] [Patch v5 02/21] FmpDevicePkg: Add library instances

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=922

Based on content from the following branch:

https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg

Add library instances for FmpDeviceLib, CapsuleUpdatePolicyLib,
and FmpPayloadHeaderLib.

Library Classes
===
* FmpDeviceLibNull - Non-functional template of the FmpDeviceLib
  that can be used as a starting point for an FmpDeviceLib for
  a specific firmware storage device.
* CapsuleUpdatePolicyLibNull - Functional template of the
  CapsuleUpdatePolicyLib that can be used as a starting point
  of a platform specific implementation.
* FmpPayloadHeaderLibV1 - Version 1 of the FmpPayloadHeaderLib.
  This library is indented to be used "as is" with no need for
  any device specific or platform specific changes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../CapsuleUpdatePolicyLibNull.c   | 136 +++
 .../CapsuleUpdatePolicyLibNull.inf |  45 +++
 .../CapsuleUpdatePolicyLibNull.uni |  17 +
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c| 427 +
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |  48 +++
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |  18 +
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c| 188 +
 .../FmpPayloadHeaderLibV1.inf  |  48 +++
 .../FmpPayloadHeaderLibV1.uni  |  21 +
 9 files changed, 948 insertions(+)
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
 create mode 100644 
FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.uni
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
 create mode 100644 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
 create mode 100644 
FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.uni

diff --git 
a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
new file mode 100644
index 00..d86d6ba612
--- /dev/null
+++ 
b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
@@ -0,0 +1,136 @@
+/**  @file
+  Provides platform policy services used during a capsule update.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+
+/**
+  Determine if the system power state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system power state supports a capsule
+update.  Returns FALSE if system power state does not
+support a capsule update.  Return value is only valid if
+return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESSGood parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR   System power state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemPower (
+  OUT BOOLEAN  *Good
+  )
+{
+  *Good = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  Determines if the system thermal state supports a capsule update.
+
+  @param[out] Good 

[edk2] [Patch v3 08/10] BaseTools/Capsule: Update file header with tool limitations

2018-08-01 Thread Kinney, Michael D
Update file header to state that the tool does not support:
* Multiple payloads
* Drivers
* Vendor code bytes

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

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 76426dcf66..d829000849 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -1,6 +1,17 @@
 ## @file
 # Generate a capsule.
 #
+# This tool generates a UEFI Capsule around an FMP Capsule.  The capsule 
payload
+# be signed using signtool or OpenSSL and if it is signed the signed content
+# includes an FMP Payload Header.
+#
+# This tool is intended to be used to generate UEFI Capsules to update the
+# system firmware or device firmware for integrated devices.  In order to
+# keep the tool as simple as possible, it has the following limitations:
+#   * Do not support multiple payloads in a capsule.
+#   * Do not support optional drivers in a capsule.
+#   * Do not support vendor code bytes in a capsule.
+#
 # Copyright (c) 2018, 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
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 04/10] BaseTools/Capsule: Remove support for PopulateSystemTable

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=1030

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 5398c12a9c..34337b2710 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -239,8 +239,8 @@ if __name__ == '__main__':
 # Add optional arguments for this command
 #
 parser.add_argument ("--capflag", dest = 'CapsuleFlag', action='append', 
default = [],
- choices=['PersistAcrossReset', 'PopulateSystemTable', 
'InitiateReset'],
- help = "Capsule flag can be PersistAcrossReset, or 
PopulateSystemTable or InitiateReset or not set")
+ choices=['PersistAcrossReset', 'InitiateReset'],
+ help = "Capsule flag can be PersistAcrossReset or 
InitiateReset or not set")
 parser.add_argument ("--capoemflag", dest = 'CapsuleOemFlag', type = 
ValidateUnsignedInteger, default = 0x,
  help = "Capsule OEM Flag is an integer between 0x 
and 0x.")
 
@@ -294,8 +294,6 @@ if __name__ == '__main__':
 if args.Guid is None:
 parser.error ('the following option is required: --guid')
 if 'PersistAcrossReset' not in args.CapsuleFlag:
-if 'PopulateSystemTable' in args.CapsuleFlag:
-parser.error ('--capflag PopulateSystemTable also requires 
--capflag PersistAcrossReset')
 if 'InitiateReset' in args.CapsuleFlag:
 parser.error ('--capflag InitiateReset also requires --capflag 
PersistAcrossReset')
 if args.CapsuleOemFlag > 0x:
@@ -421,7 +419,7 @@ if __name__ == '__main__':
 try:
 UefiCapsuleHeader.OemFlags= args.CapsuleOemFlag
 UefiCapsuleHeader.PersistAcrossReset  = 'PersistAcrossReset'  in 
args.CapsuleFlag
-UefiCapsuleHeader.PopulateSystemTable = 'PopulateSystemTable' in 
args.CapsuleFlag
+UefiCapsuleHeader.PopulateSystemTable = False
 UefiCapsuleHeader.InitiateReset   = 'InitiateReset'   in 
args.CapsuleFlag
 UefiCapsuleHeader.Payload = Result
 Result = UefiCapsuleHeader.Encode ()
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 01/10] BaseTools/Capsule: Add Capsule Generation Tools

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=945

Based on content from the following branch

https://github.com/Microsoft/MS_UEFI/tree/share/beta/CapsuleTools

* Convert C tools to Python
* Add common python modules to:
BaseTools/Source/Python/Common/Uefi/Capsule
BaseTools/Source/Python/Common/Edk2/Capsule
* Add GenerateCapsule.py to BaseTools/Source/Python/Capsule
* Add Windows and Posix wrappers for GenerateCapsule.py

usage: GenerateCapsule [-h] [-o OUTPUTFILE] (-e | -d | --dump-info)
   [--capflag 
{PersistAcrossReset,PopulateSystemTable,InitiateReset}]
   [--capoemflag CAPSULEOEMFLAG] [--guid GUID]
   [--hardware-instance HARDWAREINSTANCE]
   [--monotonic-count MONOTONICCOUNT]
   [--fw-version FWVERSION] [--lsv LOWESTSUPPORTEDVERSION]
   [--pfx-file SIGNTOOLPFXFILE]
   [--signer-private-cert OPENSSLSIGNERPRIVATECERTFILE]
   [--other-public-cert OPENSSLOTHERPUBLICCERTFILE]
   [--trusted-public-cert OPENSSLTRUSTEDPUBLICCERTFILE]
   [--signing-tool-path SIGNINGTOOLPATH] [--version] [-v]
   [-q] [--debug [0-9]]
   InputFile

Generate a capsule. Copyright (c) 2018, Intel Corporation. All rights
reserved.

positional arguments:
  InputFile Input binary payload filename.

optional arguments:
  -h, --helpshow this help message and exit
  -o OUTPUTFILE, --output OUTPUTFILE
Output filename.
  -e, --encode  Encode file
  -d, --decode  Decode file
  --dump-info   Display FMP Payload Header information
  --capflag {PersistAcrossReset,PopulateSystemTable,InitiateReset}
Capsule flag can be PersistAcrossReset, or
PopulateSystemTable or InitiateReset or not set
  --capoemflag CAPSULEOEMFLAG
Capsule OEM Flag is an integer between 0x and
0x.
  --guid GUID   The FMP/ESRT GUID in registry format. Required for
encode operations.
  --hardware-instance HARDWAREINSTANCE
The 64-bit hardware instance. The default is
0x
  --monotonic-count MONOTONICCOUNT
64-bit monotonic count value in header. Default is
0x.
  --fw-version FWVERSION
The 32-bit version of the binary payload (e.g.
0x11223344 or 5678).
  --lsv LOWESTSUPPORTEDVERSION
The 32-bit lowest supported version of the binary
payload (e.g. 0x11223344 or 5678).
  --pfx-file SIGNTOOLPFXFILE
signtool PFX certificate filename.
  --signer-private-cert OPENSSLSIGNERPRIVATECERTFILE
OpenSSL signer private certificate filename.
  --other-public-cert OPENSSLOTHERPUBLICCERTFILE
OpenSSL other public certificate filename.
  --trusted-public-cert OPENSSLTRUSTEDPUBLICCERTFILE
OpenSSL trusted public certificate filename.
  --signing-tool-path SIGNINGTOOLPATH
Path to signtool or OpenSSL tool. Optional if path to
tools are already in PATH.
  --version show program's version number and exit
  -v, --verbose Turn on verbose output with informational messages
printed, including capsule headers and warning
messages.
  -q, --quiet   Disable all messages except fatal errors.
  --debug [0-9] Set debug level

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 BaseTools/BinWrappers/PosixLike/GenerateCapsule|  14 +
 .../BinWrappers/WindowsLike/GenerateCapsule.bat|   1 +
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 522 +
 .../Python/Common/Edk2/Capsule/FmpPayloadHeader.py |  91 
 .../Source/Python/Common/Edk2/Capsule/__init__.py  |  15 +
 BaseTools/Source/Python/Common/Edk2/__init__.py|  15 +
 .../Python/Common/Uefi/Capsule/FmpAuthHeader.py| 184 
 .../Python/Common/Uefi/Capsule/FmpCapsuleHeader.py | 302 
 .../Common/Uefi/Capsule/UefiCapsuleHeader.py   | 136 ++
 .../Source/Python/Common/Uefi/Capsule/__init__.py  |  15 +
 BaseTools/Source/Python/Common/Uefi/__init__.py|  15 +
 11 files changed, 1310 insertions(+)
 create mode 100644 BaseTools/BinWrappers/PosixLike/GenerateCapsule
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat
 create mode 100644 BaseTools/Source/Python/Capsule/GenerateCapsule.py
 create mode 100644 
BaseTools/Source/Python/Common/Edk2/Capsule/FmpPayloadHeader.py
 create mode 100644 

[edk2] [Patch v3 06/10] BaseTools/Capsule: Do not support -o with --dump-info

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=1025

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 34337b2710..3c641bdca7 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -339,6 +339,10 @@ if __name__ == '__main__':
 args.OpenSslOtherPublicCertFile   = 
args.OpenSslOtherPublicCertFile.name
 args.OpenSslTrustedPublicCertFile = 
args.OpenSslTrustedPublicCertFile.name
 
+if args.DumpInfo:
+if args.OutputFile is not None:
+parser.error ('the following option is not supported for dumpinfo 
operations: --output')
+
 #
 # Read binary input file
 #
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 09/10] BaseTools/Capsule: Prevent traceback during signing operations

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=1046
https://bugzilla.tianocore.org/show_bug.cgi?id=1048
https://bugzilla.tianocore.org/show_bug.cgi?id=1050

Remove raise statements that generate Tracebacks that were only
intended for development/debug.  With the raise statements removed
proper error messages are shown.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index d829000849..42cd1fb8ba 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -408,7 +408,6 @@ if __name__ == '__main__':
  )
 except:
 print ('GenerateCapsule: error: can not sign payload')
-raise
 sys.exit (1)
 
 try:
@@ -496,7 +495,6 @@ if __name__ == '__main__':
 print ('')
 except:
 print ('GenerateCapsule: error: can not decode capsule')
-raise
 sys.exit (1)
 
 elif args.DumpInfo:
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 02/10] BaseTools GenerateCapsule: Change property to executable for Linux

2018-08-01 Thread Kinney, Michael D
From: Star Zeng 

Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
Reviewed-by: Michael D Kinney 
---
 BaseTools/BinWrappers/PosixLike/GenerateCapsule | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 BaseTools/BinWrappers/PosixLike/GenerateCapsule

diff --git a/BaseTools/BinWrappers/PosixLike/GenerateCapsule 
b/BaseTools/BinWrappers/PosixLike/GenerateCapsule
old mode 100644
new mode 100755
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 00/10] Add Capsule Generation Tools

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=945

Based on content from the following branch

https://github.com/Microsoft/MS_UEFI/tree/share/beta/CapsuleTools

Command line unit tests for python modules available from following branch:

https://github.com/mdkinney/edk2/tree/Bug_945_StandAloneCapsuleTools_V2/BaseToolsUnitTest

Further development and testing of Capsule Generation Tools was performed at:
  https://github.com/tianocore/edk2-staging/tree/FmpDevicePkg-master
  https://github.com/tianocore/edk2-staging/tree/FmpDevicePkg-UDK2018

Summary of changes since original version
* Convert C tools to Python
* Add common python modules to:
BaseTools/Source/Python/Common/Uefi/Capsule
BaseTools/Source/Python/Common/Edk2/Capsule
* Add GenerateCapsule.py to BaseTools/Source/Python/Capsule
* Add Windows and Posix wrappers for GenerateCapsule.py
* Add max value checks to Capsule Generation tools
  https://bugzilla.tianocore.org/show_bug.cgi?id=1021
  https://bugzilla.tianocore.org/show_bug.cgi?id=1022
  https://bugzilla.tianocore.org/show_bug.cgi?id=1026
* Remove support for PopulateSystemTable
  https://bugzilla.tianocore.org/show_bug.cgi?id=1030
* Fix CertType GUID byte order
  https://bugzilla.tianocore.org/show_bug.cgi?id=1024
* Do not support -o with --dump-info
  https://bugzilla.tianocore.org/show_bug.cgi?id=1025
* Update help for --fw-version and --lsv
  https://bugzilla.tianocore.org/show_bug.cgi?id=1029
* Update file header with tool limitations
  https://bugzilla.tianocore.org/show_bug.cgi?id=1031
* Prevent traceback during signing operations
  https://bugzilla.tianocore.org/show_bug.cgi?id=1046
  https://bugzilla.tianocore.org/show_bug.cgi?id=1048
  https://bugzilla.tianocore.org/show_bug.cgi?id=1050  
* Support capsules without a payload header
  https://bugzilla.tianocore.org/show_bug.cgi?id=1028

usage: GenerateCapsule [-h] [-o OUTPUTFILE] (-e | -d | --dump-info)
   [--capflag {PersistAcrossReset,InitiateReset}]
   [--capoemflag CAPSULEOEMFLAG] [--guid GUID]
   [--hardware-instance HARDWAREINSTANCE]
   [--monotonic-count MONOTONICCOUNT]
   [--fw-version FWVERSION] [--lsv LOWESTSUPPORTEDVERSION]
   [--pfx-file SIGNTOOLPFXFILE]
   [--signer-private-cert OPENSSLSIGNERPRIVATECERTFILE]
   [--other-public-cert OPENSSLOTHERPUBLICCERTFILE]
   [--trusted-public-cert OPENSSLTRUSTEDPUBLICCERTFILE]
   [--signing-tool-path SIGNINGTOOLPATH] [--version] [-v]
   [-q] [--debug [0-9]]
   InputFile

Generate a capsule. Copyright (c) 2018, Intel Corporation. All rights
reserved.

positional arguments:
  InputFile Input binary payload filename.

optional arguments:
  -h, --helpshow this help message and exit
  -o OUTPUTFILE, --output OUTPUTFILE
Output filename.
  -e, --encode  Encode file
  -d, --decode  Decode file
  --dump-info   Display FMP Payload Header information
  --capflag {PersistAcrossReset,InitiateReset}
Capsule flag can be PersistAcrossReset or
InitiateReset or not set
  --capoemflag CAPSULEOEMFLAG
Capsule OEM Flag is an integer between 0x and
0x.
  --guid GUID   The FMP/ESRT GUID in registry format. Required for
encode operations.
  --hardware-instance HARDWAREINSTANCE
The 64-bit hardware instance. The default is
0x
  --monotonic-count MONOTONICCOUNT
64-bit monotonic count value in header. Default is
0x.
  --fw-version FWVERSION
The 32-bit version of the binary payload (e.g.
0x11223344 or 5678). Required for encode operations
that sign a payload.
  --lsv LOWESTSUPPORTEDVERSION
The 32-bit lowest supported version of the binary
payload (e.g. 0x11223344 or 5678). Required for encode
operations that sign a payload.
  --pfx-file SIGNTOOLPFXFILE
signtool PFX certificate filename.
  --signer-private-cert OPENSSLSIGNERPRIVATECERTFILE
OpenSSL signer private certificate filename.
  --other-public-cert OPENSSLOTHERPUBLICCERTFILE
OpenSSL other public certificate filename.
  --trusted-public-cert OPENSSLTRUSTEDPUBLICCERTFILE
OpenSSL trusted public certificate filename.
  --signing-tool-path SIGNINGTOOLPATH
Path to signtool or OpenSSL tool. Optional if path to
tools are already in PATH.
  --version show program's version number and exit
  -v, 

[edk2] [Patch v3 07/10] BaseTools/Capsule: Update help for --fw-version and --lsv

2018-08-01 Thread Kinney, Michael D
Update help to state that --fw-version and -=-lsv are required
for encode operations that sign a payload.

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

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 3c641bdca7..76426dcf66 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -254,9 +254,9 @@ if __name__ == '__main__':
  help = "64-bit monotonic count value in header.  
Default is 0x.")
 
 parser.add_argument ("--fw-version", dest = 'FwVersion', type = 
ValidateUnsignedInteger,
- help = "The 32-bit version of the binary payload 
(e.g. 0x11223344 or 5678).")
+ help = "The 32-bit version of the binary payload 
(e.g. 0x11223344 or 5678).  Required for encode operations that sign a 
payload.")
 parser.add_argument ("--lsv", dest = 'LowestSupportedVersion', type = 
ValidateUnsignedInteger,
- help = "The 32-bit lowest supported version of the 
binary payload (e.g. 0x11223344 or 5678).")
+ help = "The 32-bit lowest supported version of the 
binary payload (e.g. 0x11223344 or 5678).  Required for encode operations that 
sign a payload.")
 
 parser.add_argument ("--pfx-file", dest='SignToolPfxFile', 
type=argparse.FileType('rb'),
  help="signtool PFX certificate filename.")
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 05/10] BaseTools/Capsule: Fix CertType GUID byte order

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=1024

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py 
b/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py
index aec52bf772..ae5c1df8a4 100644
--- a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py
+++ b/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py
@@ -166,7 +166,7 @@ class FmpAuthHeaderClass (object):
 self.dwLength = dwLength
 self.wRevision= wRevision
 self.wCertificateType = wCertificateType
-self.CertType = uuid.UUID (bytes = CertType)
+self.CertType = uuid.UUID (bytes_le = CertType)
 self.CertData = 
Buffer[self._StructSize:self._MonotonicCountSize + self.dwLength]
 self.Payload  = Buffer[self._MonotonicCountSize + 
self.dwLength:]
 self._Valid   = True
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 03/10] BaseTools/Capsule: Add max value checks to Capsule Generation tools

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=1021
https://bugzilla.tianocore.org/show_bug.cgi?id=1022
https://bugzilla.tianocore.org/show_bug.cgi?id=1026

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 4018dc0420..5398c12a9c 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -298,6 +298,12 @@ if __name__ == '__main__':
 parser.error ('--capflag PopulateSystemTable also requires 
--capflag PersistAcrossReset')
 if 'InitiateReset' in args.CapsuleFlag:
 parser.error ('--capflag InitiateReset also requires --capflag 
PersistAcrossReset')
+if args.CapsuleOemFlag > 0x:
+parser.error ('--capoemflag must be an integer between 0x and 
0x')
+if args.HardwareInstance > 0x:
+parser.error ('--hardware-instance must be an integer in range 
0x0..0x')
+if args.MonotonicCount > 0x:
+parser.error ('--monotonic-count must be an integer in range 
0x0..0x')
 
 UseSignTool = args.SignToolPfxFile is not None
 UseOpenSsl  = (args.OpenSslSignerPrivateCertFile is not None and
@@ -319,6 +325,10 @@ if __name__ == '__main__':
 if args.Encode and (UseSignTool or UseOpenSsl):
 if args.FwVersion is None or args.LowestSupportedVersion is None:
 parser.error ('the following options are required: 
--fw-version, --lsv')
+if args.FwVersion > 0x:
+parser.error ('--fw-version must be an integer in range 
0x0..0x')
+if args.LowestSupportedVersion > 0x:
+parser.error ('--lsv must be an integer in range 
0x0..0x')
 
 if UseSignTool:
 args.SignToolPfxFile.close()
-- 
2.14.2.windows.3

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


[edk2] [Patch v3 10/10] BaseTools/Capsule: Support capsules without a payload header

2018-08-01 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=1028

Update --dump-info and --decode to show auth header information
even if a payload header is not present.  The --decode operation
still fails if a payload header is not present.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Yonghong Zhu 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Reviewed-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py 
b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 42cd1fb8ba..7b08918857 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -455,6 +455,9 @@ if __name__ == '__main__':
 FmpCapsuleHeader.DumpInfo ()
 if UseSignTool or UseOpenSsl:
 Result = FmpAuthHeader.Decode (Result)
+if args.Verbose:
+print ('')
+FmpAuthHeader.DumpInfo ()
 
 #
 # Verify Image with 64-bit MonotonicCount appended to end of 
image
@@ -479,20 +482,25 @@ if __name__ == '__main__':
 except ValueError:
 print ('GenerateCapsule: warning: can not verify payload.')
 
-Result = FmpPayloadHeader.Decode (Result)
-if args.Verbose:
-print ('')
-FmpAuthHeader.DumpInfo ()
-print ('')
-FmpPayloadHeader.DumpInfo ()
+try:
+Result = FmpPayloadHeader.Decode (Result)
+if args.Verbose:
+print ('')
+FmpPayloadHeader.DumpInfo ()
+print ('')
+except:
+if args.Verbose:
+print ('')
+print ('No FMP_PAYLOAD_HEADER')
+print ('')
+raise
 else:
 if args.Verbose:
 print ('')
 print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION')
 print ('')
 print ('No FMP_PAYLOAD_HEADER')
-if args.Verbose:
-print ('')
+print ('')
 except:
 print ('GenerateCapsule: error: can not decode capsule')
 sys.exit (1)
@@ -508,11 +516,15 @@ if __name__ == '__main__':
 FmpCapsuleHeader.DumpInfo ()
 try:
 Result = FmpAuthHeader.Decode (Result)
-Result = FmpPayloadHeader.Decode (Result)
 print ('')
 FmpAuthHeader.DumpInfo ()
-print ('')
-FmpPayloadHeader.DumpInfo ()
+try:
+Result = FmpPayloadHeader.Decode (Result)
+print ('')
+FmpPayloadHeader.DumpInfo ()
+except:
+print ('')
+print ('No FMP_PAYLOAD_HEADER')
 except:
 print ('')
 print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION')
-- 
2.14.2.windows.3

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