Re: [edk2] Edk2 uni file encoding

2018-11-07 Thread Sean Brogan via edk2-devel
Liming,
That was exactly what I was looking for.  

Thanks
Sean




-Original Message-
From: Gao, Liming  
Sent: Wednesday, November 7, 2018 10:01 PM
To: Sean Brogan 
Cc: edk2-devel@lists.01.org
Subject: RE: Edk2 uni file encoding

Sean:
  EDKII UNI spec 
(https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-Specificationsdata=02%7C01%7Csean.brogan%40microsoft.com%7C5ffeb105737e4c00150208d6453fa46a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636772536983024335sdata=veov60rbEtr3ub7RcreuFuqJvc4%2BdtAowph7kBGXW54%3Dreserved=0)
 Chapter 2 defines UNI file format. EdkCompatibilityPkg is obsolete. BZ 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1103data=02%7C01%7Csean.brogan%40microsoft.com%7C5ffeb105737e4c00150208d6453fa46a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636772536983024335sdata=LOLezJzuK9kwu8QK78UM5nnCD%2FZEY5fxr1VQzk8sqY8%3Dreserved=0
 is submitted to delete EdkCompatibilityPkg from edk2/master. We will work on 
it. 

EDK II Unicode files are used for mapping token names to localized strings that 
are identified by an RFC4646 language code. The format for storing EDK II 
Unicode files on disk is UTF-8 (without a BOM character) or UTF-16LE (with a 
BOM character). The character content must be UCS-2.

Thanks
Liming
>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
>Sean Brogan via edk2-devel
>Sent: Thursday, November 08, 2018 7:00 AM
>To: edk2-devel@lists.01.org
>Subject: [edk2] Edk2 uni file encoding
>
>Is there a definitive answer for the file encoding for all UNI files in edk2?
>If not I would like to propose one.  Incorrect encoding causes tool 
>issues and is something we can easily check for and fix.
>
>Proposal: All UNI files in edk2 should be
>
>
>  1.  UTF-8
>Or
>
>  1.  Use a BOM and be UTF-16
>
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wik
>ipedia.org%2Fwiki%2FByte_order_markdata=02%7C01%7Csean.brogan%40mi
>crosoft.com%7C5ffeb105737e4c00150208d6453fa46a%7C72f988bf86f141af91ab2d
>7cd011db47%7C1%7C0%7C636772536983024335sdata=1IET4LN5l9FfMscffzgk0
>t7IqYGyYNU9IrZafvi9osU%3Dreserved=0
>
>Results from searching edk2:
>1 - UTF-16 LE BOM file:
>EdkCompatibilityPkg\Compatibility\FrameworkHiiOnUefiHiiThunk\Strings.un
>i
>919 - Without BOM and decoded as UTF-8
>
>Thoughts?
>
>Future question:  Can we make rule for all other standard file types 
>(c, h, dec, dsc, fdf, inf,)?
>
>Thanks
>Sean
>
>
>
>___
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.
>01.org%2Fmailman%2Flistinfo%2Fedk2-develdata=02%7C01%7Csean.brogan
>%40microsoft.com%7C5ffeb105737e4c00150208d6453fa46a%7C72f988bf86f141af9
>1ab2d7cd011db47%7C1%7C0%7C636772536983024335sdata=HhfPaCyS0sKHu1fF
>Gkfh%2FQ4pm34X68YKiaM6IN7%2Fzj0%3Dreserved=0
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Edk2 uni file encoding

2018-11-07 Thread Sean Brogan via edk2-devel
Is there a definitive answer for the file encoding for all UNI files in edk2?
If not I would like to propose one.  Incorrect encoding causes tool issues and 
is something we can easily check for and fix.

Proposal: All UNI files in edk2 should be


  1.  UTF-8
Or

  1.  Use a BOM and be UTF-16

https://en.wikipedia.org/wiki/Byte_order_mark

Results from searching edk2:
1 - UTF-16 LE BOM file: 
EdkCompatibilityPkg\Compatibility\FrameworkHiiOnUefiHiiThunk\Strings.uni
919 - Without BOM and decoded as UTF-8

Thoughts?

Future question:  Can we make rule for all other standard file types (c, h, 
dec, dsc, fdf, inf,)?

Thanks
Sean



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


Re: [edk2] Capsules and versions

2018-11-01 Thread Sean Brogan via edk2-devel
Tom,

Short answer:  It is tool dependent. 

On Windows where the ESRT and FMP have been used for years there is another 
file that contains that information (Capsules are just driver packages so there 
is an INF and CAT file along with the BIN).  
Once the firmware gets to processing the actual payload (after stripping all 
the standard headers/structures) our firmware implementation makes use of a 
EDK2 defined header that contains this information as well as lowest supported 
version.   See here.  
https://github.com/tianocore/edk2/blob/master/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
  

Hope that helps. 

Thanks
Sean



-Original Message-
From: edk2-devel  On Behalf Of Tomas Pilar 
(tpilar)
Sent: Thursday, November 1, 2018 7:22 AM
To: edk2-devel@lists.01.org
Subject: [edk2] Capsules and versions

Hi,

I am trying to implement FMP in our IHV UEFI driver so that we can update 
firmware and the driver using capsules. I get the ESRT populated by the 
platform EsrtFmpDxe, that's all great.

However, it seems that EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER does not 
contain any version information about the firmware blob (neither Version nor 
ImageId). How is the OS tool that stages capsules supposed to know whether the 
capsule contains firmware that has been in fact already applied?

Cheers,
Tom
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org%2Fmailman%2Flistinfo%2Fedk2-develdata=02%7C01%7Csean.brogan%40microsoft.com%7Cdbe4babaafe84ee0a01c08d6400699cd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636766794429049806sdata=CaAhG3UhI2%2BqSA6ml7USrFpGjuENBMNS4HK5xKuUGec%3Dreserved=0
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch V2 0/9] Add DisplayUpdateProgressLib for capsules

2018-04-19 Thread Sean Brogan
Reviewed-by: Sean Brogan <sean.bro...@microsoft.com>


-Original Message-
From: Kinney, Michael D <michael.d.kin...@intel.com> 
Sent: Wednesday, April 11, 2018 5:48 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Zeng, Star <star.z...@intel.com>; 
Dong, Eric <eric.d...@intel.com>; Yao, Jiewen <jiewen@intel.com>; Wei, 
David <david@intel.com>; Guo, Mang <mang@intel.com>; Steele, Kelly 
<kelly.ste...@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>
Subject: [Patch V2 0/9] Add DisplayUpdateProgressLib for capsules

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

Based on content from:

https://github.com/Microsoft/MS_UEFI/blob/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Include/Library/DisplayUpdateProgressLib.h
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgressGraphicsLib
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgressTextLib

Updates for V2
==
* Change DisplayUpdateProgressGraphicsLib to DisplayUpdateProgressLibGraphics
* Change DisplayUpdateProgressTextLib to DisplayUpdateProgressLibText
* Clarify that color in Firmware Management Progress Protocol is the foreground 
color
* Add missing parameters to PerformFlashWriteWithProgress() function header.
* Update PerformFlashWriteWithProgress() function header describing the use of
  the start and end percentage values.
* Update QuarkPlatformPkg PerformFlashWriteWithProgress() to call Progress() for
  the end precentage.
* Update Vlv2Tbl2DevicePkg PerformFlashWriteWithProgress() to call Progress()
  for the end precentage.

Add DisplayUpdateProgressLib class along implementations for both graphical 
(Graphics Output Protocol based) and text (Simple Text Output Protocol based) 
consoles.  Also add the EDK II Firmware Management Progress Protocol that is an 
optional protocol that provides the progress bar color and a watchdog timeout 
value thaty can be used when a firmware image is updated in a firmware device.

* Add progress support to DxeCapsuleLibFmp
* Add progress support to SystemFirmwareUpdateDxe
* Add progress support to PlatformFlashAccessLib class and instances.
* Reduce Print() calls during a firmware update.

Cc: Sean Brogan <sean.bro...@microsoft.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Cc: Jiewen Yao <jiewen@intel.com>
Cc: David Wei <david@intel.com>
Cc: Mang Guo <mang@intel.com>
Cc: Kelly Steele <kelly.ste...@intel.com>

Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1

Kinney, Michael D (3):
  QuarkPlatformPkg: Add DisplayUpdateProgressLib mapping
  MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
  SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API

Michael D Kinney (6):
  MdeModulePkg: Add DisplayUpdateProgressLib class
  MdeModulePkg: Add DisplayUpdateProgressLib instances
  Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping
  SignedCapsulePkg/PlatformFlashAccessLib: Add progress API
  Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API
  QuarkPlatformPkg/PlatformFlashAccessLib: Add progress API

 .../Include/Library/DisplayUpdateProgressLib.h |  65 +++
 .../Include/Protocol/FirmwareManagementProgress.h  |  51 +++
 .../DisplayUpdateProgressLibGraphics.c | 475 +
 .../DisplayUpdateProgressLibGraphics.inf   |  60 +++
 .../DisplayUpdateProgressLibGraphics.uni   |  18 +
 .../DisplayUpdateProgressLibText.c | 174 
 .../DisplayUpdateProgressLibText.inf   |  53 +++
 .../DisplayUpdateProgressLibText.uni   |  18 +
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c   |  47 +-
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf |   8 +-
 .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c|  84 +++-
 .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c|  21 +-
 .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf  |   7 +-
 MdeModulePkg/MdeModulePkg.dec  |  11 +
 MdeModulePkg/MdeModulePkg.dsc  |   3 +
 .../PlatformFlashAccessLibDxe.c|  78 +++-
 QuarkPlatformPkg/Quark.dsc |   1 +
 .../Include/Library/PlatformFlashAccessLib.h   |  49 ++-
 .../PlatformFlashAccessLibNull.c   |  70 ++-
 .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c |  90 +++-
 .../PlatformFlashAccessLib.c   | 102 +++--
 .../PlatformFlashAccessLib.inf |   3 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|   1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |   1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |   1 +
 25 files changed, 1387 insertions(+), 104 deletions(-)  create mode 10064

Re: [edk2] [RFC v2 4/4] FmpDevicePkg: Add DSC file to build all package components

2018-04-17 Thread Sean Brogan
Signed-off-by: Sean Brogan <sean.bro...@microsoft.com>

-Original Message-
From: Kinney, Michael D <michael.d.kin...@intel.com> 
Sent: Tuesday, April 17, 2018 2:05 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Jiewen Yao <jiewen@intel.com>; 
Michael D Kinney <michael.d.kin...@intel.com>
Subject: [RFC v2 4/4] FmpDevicePkg: Add DSC file to build all package components

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D922=02%7C01%7Csean.brogan%40microsoft.com%7C1c8ccfb7e03541ef276008d5a4a6f35c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959310987323=c5VXpiX%2Bum%2Fyo4xL4tq1M6%2FAOo2I0jpKoor3APsOiIQ%3D=0

Based on content from the following branch:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMS_UEFI%2Ftree%2Fshare%2FMsCapsuleSupport%2FMsCapsuleUpdatePkg=02%7C01%7Csean.brogan%40microsoft.com%7C1c8ccfb7e03541ef276008d5a4a6f35c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959310987323=fXTprDEZ5dkcrsaj%2BNyjke5llRVQYSV72%2BBbtKRat70%3D=0

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

Cc: Sean Brogan <sean.bro...@microsoft.com>
Cc: Jiewen Yao <jiewen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
---
 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|MdeP

Re: [edk2] [RFC v2 2/4] FmpDevicePkg: Add library instances

2018-04-17 Thread Sean Brogan
Signed-off-by: Sean Brogan <sean.bro...@microsoft.com>

-Original Message-
From: Kinney, Michael D <michael.d.kin...@intel.com> 
Sent: Tuesday, April 17, 2018 2:05 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Jiewen Yao <jiewen@intel.com>; 
Michael D Kinney <michael.d.kin...@intel.com>
Subject: [RFC v2 2/4] FmpDevicePkg: Add library instances

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D922=02%7C01%7Csean.brogan%40microsoft.com%7Ce9788e2e77ea4e1d928208d5a4a6f285%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959307464376=5xeGnjEngnIbzVFfF70RSsyjj3nCizvNilN3nansWjo%3D=0

Based on content from the following branch:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMS_UEFI%2Ftree%2Fshare%2FMsCapsuleSupport%2FMsCapsuleUpdatePkg=02%7C01%7Csean.brogan%40microsoft.com%7Ce9788e2e77ea4e1d928208d5a4a6f285%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959307464376=uadGKsQDA0CdKCD1rRdqulqAysgTOjYGCorgCHFhPcc%3D=0

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 <sean.bro...@microsoft.com>
Cc: Jiewen Yao <jiewen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
---
 .../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..943fe372cb
--- /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 INTE

Re: [edk2] [RFC v2 1/4] FmpDevicePkg: Add package, library classes, and PCDs

2018-04-17 Thread Sean Brogan
Signed-off-by: Sean Brogan <sean.bro...@microsoft.com>

-Original Message-
From: Kinney, Michael D <michael.d.kin...@intel.com> 
Sent: Tuesday, April 17, 2018 2:05 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Jiewen Yao <jiewen@intel.com>; 
Michael D Kinney <michael.d.kin...@intel.com>
Subject: [RFC v2 1/4] FmpDevicePkg: Add package, library classes, and PCDs

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D922=02%7C01%7Csean.brogan%40microsoft.com%7C04f31611ee15497b0dc008d5a4a6f254%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959308945858=8ZqxciO9%2BNUehHIZ%2B8PbZJYK8c%2FAzBZy1Z7c8x8GkSo%3D=0

Based on content from the following branch:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMS_UEFI%2Ftree%2Fshare%2FMsCapsuleSupport%2FMsCapsuleUpdatePkg=02%7C01%7Csean.brogan%40microsoft.com%7C04f31611ee15497b0dc008d5a4a6f254%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959308945858=BEp%2F7u4rN5Jx%2FY8Qh9I847n4yF6LyisgSl1r%2FgCtmPU%3D=0

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 <sean.bro...@microsoft.com>
Cc: Jiewen Yao <jiewen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
---
 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 

Re: [edk2] [RFC v2 3/4] FmpDevicePkg: Add FmpDxe module

2018-04-17 Thread Sean Brogan
Signed-off-by: Sean Brogan <sean.bro...@microsoft.com>

-Original Message-
From: Kinney, Michael D <michael.d.kin...@intel.com> 
Sent: Tuesday, April 17, 2018 2:05 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Jiewen Yao <jiewen@intel.com>; 
Michael D Kinney <michael.d.kin...@intel.com>
Subject: [RFC v2 3/4] FmpDevicePkg: Add FmpDxe module

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D922=02%7C01%7Csean.brogan%40microsoft.com%7Cc8dd8cc458624ab2056f08d5a4a6f32d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959334021874=wC8GoJQOI6dYqkzKcdYG0Tz5hAE1%2F%2B6LFK7EszMa5EY%3D=0

Based on content from the following branch:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMS_UEFI%2Ftree%2Fshare%2FMsCapsuleSupport%2FMsCapsuleUpdatePkg=02%7C01%7Csean.brogan%40microsoft.com%7Cc8dd8cc458624ab2056f08d5a4a6f32d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636595959334021874=w8aBnZeerV8lzfg6xHArKoNlyRzsqjBvAnjLfwgCgOQ%3D=0

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 <sean.bro...@microsoft.com>
Cc: Jiewen Yao <jiewen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
---
 FmpDevicePkg/FmpDxe/DetectTestKey.c   |  166 
 FmpDevicePkg/FmpDxe/FmpDxe.c  | 1451 +
 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, 2479 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 i

Re: [edk2] [Patch v2 0/3] MdeModulePkg: Add Boot Logo 2 Protocol

2018-02-27 Thread Sean Brogan
Reviewed-by: Sean Brogan <sean.bro...@microsoft.com>


-Original Message-
From: Kinney, Michael D <michael.d.kin...@intel.com> 
Sent: Thursday, February 15, 2018 2:52 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Bret Barkelew 
<bret.barke...@microsoft.com>; Yao, Jiewen <jiewen@intel.com>; Zeng, Star 
<star.z...@intel.com>; Dong, Eric <eric.d...@intel.com>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Subject: [Patch v2 0/3] MdeModulePkg: Add Boot Logo 2 Protocol

V2:
* Make Boot Logo2 Protocol higher priority than Boot Logo Protocol.
  If both are present, then only use Boot Logo 2 Protocol

Branch for review:
https://github.com/mdkinney/edk2/tree/Bug_799_BootLogo2Protocol_V4

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

Based on content from the following branch/commit:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d

Add new Boot Logo 2 Protocol that adds a GetBootLogo() service that can be used 
to retrieve the GOP BLT buffer, location, and size of the boot logo that was 
previously registered with the SetBootLogo() service.

The Boot Logo 2 Protocol service GetBootLogo() is amended to return the pointer 
to the GOP BLT buffer previously registered with the SetBootLogo() service.

Cc: Sean Brogan <sean.bro...@microsoft.com>
Cc: Bret Barkelew <bret.barke...@microsoft.com>
Cc: Jiewen Yao <jiewen@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>

Kinney, Michael D (2):
  MdeModulePkg: Add Boot Logo 2 Protocol
  MdeModulePkg/BootLogoLib: Use Boot Logo 2 Protocol

Michael D Kinney (1):
  MdeModulePkg/BootGraphicsResourceDxe: Add Boot Logo 2 Protocol

 MdeModulePkg/Include/Protocol/BootLogo2.h  | 118 
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.c |  32 +++-
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf   |   2 +
 MdeModulePkg/MdeModulePkg.dec  |   3 +
 .../BootGraphicsResourceTableDxe.c | 208 +++--
 .../BootGraphicsResourceTableDxe.inf   |   2 +
 6 files changed, 349 insertions(+), 16 deletions(-)  create mode 100644 
MdeModulePkg/Include/Protocol/BootLogo2.h

--
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 3/3] MdeModulePkg/BootLogoLib: Use Boot Logo 2 Protocol

2018-02-13 Thread Sean Brogan
Mike,

Looking over the MdeModulePkg library changes it seems wasteful to call both 
protocols for Set.  In the previously submitted protocol implementation you 
actually allocate/free memory and copy the buffer in the set routines.   For a 
high resolution screen/logo this could be an expensive operation.

I would suggest that if BootLogo2 exists then maybe BootLogo can be ignored?



   if (!EFI_ERROR (Status)) {
-BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, LogoWidth, 
LogoHeight);
+if (BootLogo != NULL) {
+  BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, 
LogoWidth, LogoHeight);
+}
+if (BootLogo2 != NULL) {
+  BootLogo2->SetBootLogo (BootLogo2, LogoBlt, LogoDestX, LogoDestY, 
LogoWidth, LogoHeight);
+}
   }



Thanks

Sean



From: Kinney, Michael D <michael.d.kin...@intel.com>
Sent: Tuesday, February 13, 2018 6:07 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan; Bret Barkelew; Jiewen Yao; Star Zeng; Eric Dong; Michael D 
Kinney
Subject: [Patch 3/3] MdeModulePkg/BootLogoLib: Use Boot Logo 2 Protocol

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D799=04%7C01%7Csean.brogan%40microsoft.com%7Cb3a0f58079524830920308d5734fb3d2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636541708515157356%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1=p7ewroezUhc94MuBjA%2Fo9GziZ5wSpS9Yb876GKyzvuY%3D=0

Based on content from the following branch/commit:
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMS_UEFI%2Ftree%2Fshare%2FMsCapsuleSupport=04%7C01%7Csean.brogan%40microsoft.com%7Cb3a0f58079524830920308d5734fb3d2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636541708515157356%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1=ByXtODKvhwrOV3mkK5MnCXLzYwFy9tKyIr16FRkDmB0%3D=0
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMS_UEFI%2Fcommit%2F33bab4031a417d7d5a7d356c15a14c2e60302b2d=04%7C01%7Csean.brogan%40microsoft.com%7Cb3a0f58079524830920308d5734fb3d2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636541708515157356%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1=TWY5Okohr1%2FbJ1Wpyx12QF4ZgRikfvuCk%2FE6B3DT9sM%3D=0

Add check to see if the Boot Logo 2 Protocol is available
and attempt to set the location and size of the boot logo
using both the Boot Logo Protocol and the Boot Logo 2
Protocol.

Cc: Sean Brogan <sean.bro...@microsoft.com>
Cc: Bret Barkelew <bret.barke...@microsoft.com>
Cc: Jiewen Yao <jiewen@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
---
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.c   | 18 +-
 MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c 
b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
index 8bd9985cb2..9872f7eeea 100644
--- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
+++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
@@ -3,6 +3,7 @@
   to show progress bar and LOGO.

 Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2016, Microsoft Corporation
 This program and the accompanying materials are licensed and made available 
under
 the terms and conditions of the BSD License that accompanies this distribution.
 The full text of the license may be found at
@@ -26,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 

 /**
   Show LOGO returned from Edkii Platform Logo protocol on all consoles.
@@ -56,6 +58,7 @@ BootLogoEnableLogo (
   UINT32RefreshRate;
   EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
   EFI_BOOT_LOGO_PROTOCOL*BootLogo;
+  EDKII_BOOT_LOGO2_PROTOCOL *BootLogo2;
   UINTN NumberOfLogos;
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;
   UINTN LogoDestX;
@@ -98,6 +101,14 @@ BootLogoEnableLogo (
 BootLogo = NULL;
   }

+  //
+  // Try to open Boot Logo 2 Protocol.
+  //
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  if (EFI_ERROR (Status)) {
+BootLogo2 = NULL;
+  }
+
   //
   // Erase Cursor from screen
   //
@@ -330,7 +341,12 @@ BootLogoEnableLogo (
   }

   if (!EFI_ERROR (Status)) {
-BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, LogoWidth, 
LogoHeight);
+if (BootLogo != NULL) {
+  BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, 
LogoWidth, LogoHeight);
+}
+if (B

Re: [edk2] [staging/edk2-test Patch 00/10] MsUnitTestPkg: Add Unit Test Support and sample

2018-01-18 Thread Sean Brogan
Reviewed-by: Sean Brogan <sean.bro...@microsoft.com>

-Original Message-
From: Kinney, Michael D [mailto:michael.d.kin...@intel.com] 
Sent: Tuesday, December 19, 2017 4:00 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Gao, Liming 
<liming@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>
Subject: [staging/edk2-test Patch 00/10] MsUnitTestPkg: Add Unit Test Support 
and sample

Cherry-picked from branch:
https://github.com/Microsoft/MS_UEFI/tree/share/XmlAndUnitTest

Commit:
https://github.com/Microsoft/MS_UEFI/commit/f2b2a2cb8f4331692297d0cab67a333714d71165
https://github.com/Microsoft/MS_UEFI/commit/928546fd6709ceff1f185ecb901e5cd4d0f82c7c
https://github.com/Microsoft/MS_UEFI/commit/d2901abfc9823c21d3a962fa69e025a92832466b

Additional updates for 32-bit systems, VS2017, GCC, safe string functions, 
missing DEC file declarations, missing DSC file, and EDK II style issues.

Cc: Sean Brogan <sean.bro...@microsoft.com>
Cc: Liming Gao <liming@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>

Kinney, Michael D (7):
  MsUnitTestPkg/Include: Remove use of variadic macros
  MsUnitTestPkg/Library: Use safe string functions
  MsUnitTestPkg/UnitTestLib: Fix GCC build errors
  MsUnitTestPkg/Library: Update __FUNCTION__ usage
  MsUnitTestPkg: Add missing library classes
  MsUnitTestPkg: Add missing DSC file
  MsUnitTestPkg: Fix EDK II style issues

Sean Brogan (3):
  MsUnitTestPkg: Add Unit Test Support and sample
  MsUnitTestPkg: Update copyright and license info
  MsUnitTestPkg: Update for VS2017 and 32-bit apps

 .../Include/Guid/MsUnitTestPkgTokenSpace.h |  33 +
 MsUnitTestPkg/Include/Library/UnitTestAssertLib.h  | 146   
MsUnitTestPkg/Include/Library/UnitTestBootUsbLib.h |  44 +
 MsUnitTestPkg/Include/Library/UnitTestLib.h| 114 +++
 MsUnitTestPkg/Include/Library/UnitTestLogLib.h |  68 ++
 .../Include/Library/UnitTestPersistenceLib.h   |  95 +++
 .../Include/Library/UnitTestResultReportLib.h  |  43 +
 MsUnitTestPkg/Include/UnitTestTypes.h  | 221 +
 .../Library/UnitTestAssertLib/UnitTestAssertLib.c  | 318 +++
 .../UnitTestAssertLib/UnitTestAssertLib.inf|  54 ++
 .../UnitTestBootUsbClassLib/UnitTestBootUsb.c  | 137 +++
 .../UnitTestBootUsbClassLib.inf|  58 ++
 .../UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c  | 153 
 .../UnitTestBootUsbMicrosoftLib.inf|  57 ++
 MsUnitTestPkg/Library/UnitTestLib/Md5.c| 352 
 MsUnitTestPkg/Library/UnitTestLib/Md5.h|  75 ++
 MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c| 932 +
 MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.inf  |  61 ++
 .../Library/UnitTestLogLib/UnitTestLogLib.c| 261 ++
 .../Library/UnitTestLogLib/UnitTestLogLib.inf  |  60 ++
 .../UnitTestPersistenceFileSystemLib.c | 407 +
 .../UnitTestPersistenceFileSystemLib.inf   |  71 ++
 .../UnitTestPersistenceLibNull.c   | 100 +++
 .../UnitTestPersistenceLibNull.inf |  48 ++
 .../UnitTestResultReportLib.c  | 221 +
 .../UnitTestResultReportLib.inf|  53 ++
 MsUnitTestPkg/MsUnitTestPkg.dec|  70 ++
 MsUnitTestPkg/MsUnitTestPkg.dsc|  65 ++
 MsUnitTestPkg/ReadMe.md|  65 ++
 .../Sample/SampleUnitTestApp/SampleUnitTestApp.c   | 214 +
 .../Sample/SampleUnitTestApp/SampleUnitTestApp.inf |  63 ++
 31 files changed, 4659 insertions(+)
 create mode 100644 MsUnitTestPkg/Include/Guid/MsUnitTestPkgTokenSpace.h
 create mode 100644 MsUnitTestPkg/Include/Library/UnitTestAssertLib.h
 create mode 100644 MsUnitTestPkg/Include/Library/UnitTestBootUsbLib.h
 create mode 100644 MsUnitTestPkg/Include/Library/UnitTestLib.h
 create mode 100644 MsUnitTestPkg/Include/Library/UnitTestLogLib.h
 create mode 100644 MsUnitTestPkg/Include/Library/UnitTestPersistenceLib.h
 create mode 100644 MsUnitTestPkg/Include/Library/UnitTestResultReportLib.h
 create mode 100644 MsUnitTestPkg/Include/UnitTestTypes.h
 create mode 100644 MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
 create mode 100644 
MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.inf
 create mode 100644 
MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
 create mode 100644 
MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsbClassLib.inf
 create mode 100644 
MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
 create mode 100644 
MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsbMicrosoftLib.inf
 create mode 100644 MsUnitTestPkg/Library/UnitTestLib/Md5.c
 create mode 100644 MsUnitTestPkg/Library/UnitTestLib/Md5.h
 create mode 100644 MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
 create mode 100644 MsUnitT

Re: [edk2] [staging/edk2-test Patch 0/2] MdePkgUnitTest: Add unit test package for MdePkg

2018-01-18 Thread Sean Brogan
Reviewed-by: Sean Brogan <sean.bro...@microsoft.com>

-Original Message-
From: Kinney, Michael D [mailto:michael.d.kin...@intel.com] 
Sent: Tuesday, December 19, 2017 4:16 PM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.bro...@microsoft.com>; Gao, Liming 
<liming@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>
Subject: [staging/edk2-test Patch 0/2] MdePkgUnitTest: Add unit test package 
for MdePkg

Initial version of a unit test package for the MdePkg that uses services from 
the MsUnitTestPkg to implement test cases for the SafeIntLib in the MdePkg.

The initial version of these tests is from the following branch and commit:

https://github.com/Microsoft/MS_UEFI/tree/share/intsafelib/MdeModulePkg/UnitTests/IntSafeLib
https://github.com/Microsoft/MS_UEFI/commit/cc2e9d229d4e876ab64d75dee16761a297582fd9

Additional updates for CPU compatibility, CHAR8 signed/unsigned, and EDK II 
code style issues.

Cc: Sean Brogan <sean.bro...@microsoft.com>
Cc: Liming Gao <liming@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>

Kinney, Michael D (1):
  MdePkgUnitTest: Fix EDK II style issues

Michael D Kinney (1):
  MdePkgUnitTest: Add unit test package for MdePkg

 MdePkgUnitTest/MdePkgUnitTest.dec  |   20 +
 MdePkgUnitTest/MdePkgUnitTest.dsc  |   57 +
 .../SafeIntLib/SafeIntLibUintnIntnUnitTests32.c|   54 +
 .../SafeIntLib/SafeIntLibUintnIntnUnitTests64.c|   54 +
 .../SafeIntLib/SafeIntLibUintnIntnUnitTestsEbc.c   |   65 +
 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests.c| 3667 
 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests.h|  155 +
 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests.inf  |   69 +
 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests32.c  |  635   
MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests64.c  |  639 
 10 files changed, 5415 insertions(+)
 create mode 100644 MdePkgUnitTest/MdePkgUnitTest.dec  create mode 100644 
MdePkgUnitTest/MdePkgUnitTest.dsc  create mode 100644 
MdePkgUnitTest/SafeIntLib/SafeIntLibUintnIntnUnitTests32.c
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUintnIntnUnitTests64.c
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUintnIntnUnitTestsEbc.c
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests.c
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests.h
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests.inf
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests32.c
 create mode 100644 MdePkgUnitTest/SafeIntLib/SafeIntLibUnitTests64.c

--
2.14.2.windows.3

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


Re: [edk2] Adding OpenSSL as the submodule of EDKII project...

2017-07-21 Thread Sean Brogan
Long,Qin

I think this is a great idea and great step forward for making edk2 more 
consumable.  We already do this for our internal clones of edk2 and would like 
to see more work like this done to make edk2 consumable in a sustainable and 
easy way.  For example we also use submodules within our clone of edk2 for 
win32 basetools bin and nasm.  We then use submodules exclusively to manage 
consuming edk2 into our project repos.  This gives us great flexibility and 
agility to manage, update, and sustain our code trees.  TianoCore should think 
of itself not as the final repo but as an ingredient in a larger repository for 
building and shipping UEFI based products.   In that end I would like to see 
EDK2 break into smaller repositories (but I'll save that for another day).  

Thanks
Sean


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Long, Qin
Sent: Thursday, July 20, 2017 12:18 AM
To: edk2-devel@lists.01.org
Cc: Long, Qin 
Subject: [edk2] Adding OpenSSL as the submodule of EDKII project...

Hi,

The Git submodule allows us to keep another Git repository in a subdirectory of 
main project. The Submodule repository has its own history, which does not 
interfere with the history of the current repository. This can be used to have 
external dependencies such as third party libraries.

After the extra patch for EDKII-OpenSSL build was removed, OpenSSL can be one 
typical use case of Git Submodule in EDKII project. The Git parent (EDKII) will 
keep track of the release version / tag IDs of Submodules when the module owner 
commit. That will also help to ensure that when we check out the EDKII project 
then the openssl Submodule will also contain its right tags.

One forked EDK2 repository with OpenSSL submodule support was available at 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fqloong%2Fedk2=02%7C01%7Csean.brogan%40microsoft.com%7C25cfc5e585ab4364560708d4cf3f860c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636361319131460644=JlxveSrNDXpxECNOAS7zxfDkOvz%2FX5rc9RE%2FA9XYroA%3D=0
 for testing.

For EDKII developers, the possible impacts will include (comparing to the 
original openssl source download / unpacking mechanism):

-  Cloning EDKII project with Submodules
The user can use the following commands to clone both main EDKII repo and 
openssl submodule:
1) Add the "--recursive" flag to their git clone command:
  $ git clone --recursive 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fqloong%2Fedk2=02%7C01%7Csean.brogan%40microsoft.com%7C25cfc5e585ab4364560708d4cf3f860c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636361319131460644=JlxveSrNDXpxECNOAS7zxfDkOvz%2FX5rc9RE%2FA9XYroA%3D=0
or
2) Manually initialize and update the submodules after the clone operation on 
main project:
  $ git clone 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fqloong%2Fedk2=02%7C01%7Csean.brogan%40microsoft.com%7C25cfc5e585ab4364560708d4cf3f860c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636361319131460644=JlxveSrNDXpxECNOAS7zxfDkOvz%2FX5rc9RE%2FA9XYroA%3D=0
  $ git submodule update -init -recursive


-  Pulling in Upstream Changes
For Pull operations, one single "git pull" will not update the submodule 
repository. So the following combined commands can be used to pull the remote 
submodule updates (e.g. updating to new supported OpenSSL release tag) $ git 
pull -recurse-submodules && git submodule update -recursive -remote

(For any third-party GUI tools (e.g. TortoiseGit), there are also no direct 
support to sync-up the primary and submodule repo. We need to use extra 
"Pull..." and "Submodule Update..." to handle this case.)

Let me know your comments & suggestions on this possible submodule updates 
(advantage or disadvantage of this change? Any impacts? ...). Thanks.


Best Regards & Thanks,
LONG, Qin
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org%2Fmailman%2Flistinfo%2Fedk2-devel=02%7C01%7Csean.brogan%40microsoft.com%7C25cfc5e585ab4364560708d4cf3f860c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636361319131460644=SU3grvQcPSSDREJnEvg%2F6m55JCXJV01jAoSZi2nwcZA%3D=0
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] question about a compressed Ffs3 file inside FFS2 filesystem

2016-10-21 Thread Sean Brogan
Star,  

Thanks.  That was the issue and that fixed the problem.   How about adding an 
assert in PeiServicesLib?  

MdePkg\Library\PeiServicesLib\PeiServicesLib.c ~ line 642 

add the assert for the else case.  

if (FvFormat != NULL) {
CopyGuid (>FvFormat, FvFormat);
  } else {
CopyGuid (>FvFormat, );
//Since FileSystem 2 is being assumed check the FV
//Check that the File system matches.  
ASSERT(CompareGuid(&(((EFI_FIRMWARE_VOLUME_HEADER 
*)FvInfo)->FileSystemGuid), ));
  }


Thanks again
Sean


This email message may contain confidential and privileged information.  Any 
unauthorized use is prohibited.  If you are not the intended recipient, please 
contact the sender by reply email and destroy all copies of the original 
message.

> -Original Message-
> From: Zeng, Star [mailto:star.z...@intel.com]
> Sent: Thursday, October 20, 2016 6:02 PM
> To: Sean Brogan <sean.bro...@microsoft.com>; Gao, Liming
> <liming@intel.com>; edk2-devel@lists.01.org
> Cc: Zeng, Star <star.z...@intel.com>
> Subject: RE: [edk2] question about a compressed Ffs3 file inside FFS2
> filesystem
> 
> Sean,
> 
> I guess the codes are reporting FvInfo PPI like below that makes the
> problem.
> 
>   PeiServicesInstallFvInfoPpi(
> NULL,
> (VOID *)PcdGet32(PcdFlashFvXXXBase),
> PcdGet32(PcdFlashFvXXXSize),
> NULL,
> NULL
> );
> 
> PeiServicesInstallFvInfoPpi() has below comments for FvFormat parameter.
>   @param  FvFormat Unique identifier of the format of the memory-
> mapped
>firmware volume.  This parameter is optional 
> and
>may be NULL.  If NULL is specified, the
>*EFI_FIRMWARE_FILE_SYSTEM2_GUID* format is 
> assumed.
> 
> I suggest the codes can be updated to:
> 
>   PeiServicesInstallFvInfoPpi(
> &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN)
> PcdGet32(PcdFlashFvXXXBase))->FileSystemGuid),
> (VOID *)PcdGet32(PcdFlashFvXXXBase),
> PcdGet32(PcdFlashFvXXXSize),
> NULL,
> NULL
> );
> 
> Thanks,
> Star
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Sean Brogan
> Sent: Thursday, October 20, 2016 10:49 PM
> To: Gao, Liming <liming@intel.com>; edk2-devel@lists.01.org
> Subject: Re: [edk2] question about a compressed Ffs3 file inside FFS2
> filesystem
> 
> Liming,
> 
> Good catch not sure how that happened. Unfortunately now the problem
> doesn't make sense.  The code should have IsFfs3Fv = True and the debug
> message that indicates the code path which ignores the section should not
> get executed.  I'll look at it again today as the problem still exists, just 
> my
> analysis is incorrect.
> 
> Current workaround is to make sure FFS2 sizes and guids are used
> everywhere so a problem with FFS3 is lurking somewhere.
> 
> Thanks
> Sean
> 
> 
> > -Original Message-
> > From: Gao, Liming [mailto:liming@intel.com]
> > Sent: Thursday, October 20, 2016 1:27 AM
> > To: Sean Brogan <sean.bro...@microsoft.com>; edk2-devel@lists.01.org
> > Subject: RE: [edk2] question about a compressed Ffs3 file inside FFS2
> > filesystem
> >
> > Sean:
> >   In MdePkg.dec, gEfiFirmwareFileSystem2Guid and
> > gEfiFirmwareFileSystem3Guid are defined below.
> >   gEfiFirmwareFileSystem2Guid = { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99,
> 0x35,
> > 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 }}
> > gEfiFirmwareFileSystem3Guid  = { 0x5473c07a, 0x3dcb, 0x4dca, { 0xbd,
> 0x6f,
> > 0x1e, 0x96, 0x89, 0xe7, 0x34, 0x9a }}
> >
> >   From the dump message, the root FV File System ID is
> > 5473c07a-3dcb-4dca- bd6f-1e9689e7349a. It is FF3 file system.
> >
> > Thanks
> > Liming
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> > > Of Sean Brogan
> > > Sent: Thursday, October 20, 2016 7:09 AM
> > > To: edk2-devel@lists.01.org
> > > Subject: [edk2] question about a compressed Ffs3 file inside FFS2
> > > filesystem
> > >
> > > We have a condition that occurs when we boot where we see the
> > > following message and our boot fails because of it.
> > > DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted section in a non-FFS3
> > > formatted FV.\n"));
> > >
> > > Which is on line 773 of FwVol.c
> > > (
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Pe
> > > i/FwVol/FwVol.c )
> &g

Re: [edk2] question about a compressed Ffs3 file inside FFS2 filesystem

2016-10-20 Thread Sean Brogan
Liming,

Good catch not sure how that happened. Unfortunately now the problem doesn't 
make sense.  The code should have IsFfs3Fv = True and the debug message that 
indicates the code path which ignores the section should not get executed.  
I'll look at it again today as the problem still exists, just my analysis is 
incorrect.  

Current workaround is to make sure FFS2 sizes and guids are used everywhere so 
a problem with FFS3 is lurking somewhere.  

Thanks
Sean


> -Original Message-
> From: Gao, Liming [mailto:liming@intel.com]
> Sent: Thursday, October 20, 2016 1:27 AM
> To: Sean Brogan <sean.bro...@microsoft.com>; edk2-devel@lists.01.org
> Subject: RE: [edk2] question about a compressed Ffs3 file inside FFS2 
> filesystem
> 
> Sean:
>   In MdePkg.dec, gEfiFirmwareFileSystem2Guid and
> gEfiFirmwareFileSystem3Guid are defined below.
>   gEfiFirmwareFileSystem2Guid = { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 
> 0x35,
> 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 }}
> gEfiFirmwareFileSystem3Guid  = { 0x5473c07a, 0x3dcb, 0x4dca, { 0xbd, 0x6f,
> 0x1e, 0x96, 0x89, 0xe7, 0x34, 0x9a }}
> 
>   From the dump message, the root FV File System ID is 5473c07a-3dcb-4dca-
> bd6f-1e9689e7349a. It is FF3 file system.
> 
> Thanks
> Liming
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Sean Brogan
> > Sent: Thursday, October 20, 2016 7:09 AM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] question about a compressed Ffs3 file inside FFS2
> > filesystem
> >
> > We have a condition that occurs when we boot where we see the
> > following message and our boot fails because of it.
> > DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted section in a non-FFS3
> > formatted FV.\n"));
> >
> > Which is on line 773 of FwVol.c
> > ( https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Pe
> > i/FwVol/FwVol.c )
> >
> > The condition is caused by a large firmware volume (greater than 16mb)
> > that is compressed and put into a smaller FV (less than 16mb).  My
> > question is why isn't this allowed (seems like a valid scenario).
> > Volinfo supports this and decodes binary fine.  The PI Vol 3 spec has
> > a section 3.2.2 EFI_FIRMWARE_FILE_SYSTEM3_GUID which says FileSystem2
> > doesn't support large files but it seems that the code is not taking
> > into account that the section is compressed and therefore you can have
> > a large file inside a compressed section inside a FV with File System2.
> >
> > Feedback/thoughts/comments/Bug?
> >
> > Here are some details of my scenario.
> > Compressed FV has filesystem == 8c8ce578-8a3d-4f1c-9935-896185c32dd3
> > (ffs3)
> > Non compressed FV has filesystem == 5473c07a-3dcb-4dca-bd6f-
> > 1e9689e7349a (ffs2)
> >
> > VolInfo dump of the Non Compressed FV showing the nested/compressed FV
> > inside.
> >
> > Decoding
> > VolInfo Version 1.0 Build Build 20909
> > Signature:_FVH (4856465F)
> > Attributes:   4FEFF
> >EFI_FVB2_READ_DISABLED_CAP
> >EFI_FVB2_READ_ENABLED_CAP
> >EFI_FVB2_READ_STATUS
> >EFI_FVB2_WRITE_DISABLED_CAP
> >EFI_FVB2_WRITE_ENABLED_CAP
> >EFI_FVB2_WRITE_STATUS
> >EFI_FVB2_LOCK_CAP
> >EFI_FVB2_LOCK_STATUS
> >EFI_FVB2_STICKY_WRITE
> >EFI_FVB2_MEMORY_MAPPED
> >EFI_FVB2_ERASE_POLARITY
> >EFI_FVB2_READ_LOCK_CAP
> >EFI_FVB2_READ_LOCK_STATUS
> >EFI_FVB2_WRITE_LOCK_CAP
> >EFI_FVB2_WRITE_LOCK_STATUS
> > EFI_FVB2_ALIGNMENT_16
> > EFI_FVB2_ALIGNMENT_32
> > EFI_FVB2_ALIGNMENT_64
> > EFI_FVB2_ALIGNMENT_128
> > EFI_FVB2_ALIGNMENT_4K
> > EFI_FVB2_ALIGNMENT_8K
> > EFI_FVB2_ALIGNMENT_16K
> > EFI_FVB2_ALIGNMENT_32K
> > EFI_FVB2_ALIGNMENT_1M
> > EFI_FVB2_ALIGNMENT_2M
> >EFI_FVB2_ALIGNMENT_4M
> > EFI_FVB2_ALIGNMENT_8M
> > EFI_FVB2_ALIGNMENT_256M
> > EFI_FVB2_ALIGNMENT_512M
> > EFI_FVB2_ALIGNMENT_1G
> > EFI_FVB2_ALIGNMENT_2G
> > Header Length: 0x0048
> > File System ID:5473c07a-3dcb-4dca-bd6f-1e9689e7349a
> > Revision:  0x0002
> > Number of Blocks:  0x0028
> > Block Length:  0x0001
> > Total Volume Size: 0x0028
> > ==
> > ==
> > File Name:9E21FD93-9C72-4C15-8C4B-E77F1DB2D792
> > File Off

Re: [edk2] question about a compressed Ffs3 file inside FFS2 filesystem

2016-10-19 Thread Sean Brogan
Yes. I think the challenge in the code is the compressed section is a guided 
section and the decompression is all handled transparently.  
One solution might be that once a section was processed that had attributes of 
EFI_GUIDED_SECTION_PROCESSING_REQUIRED then the check for filesystems should no 
longer be performed.  

Thanks
Sean


> -Original Message-
> From: af...@apple.com [mailto:af...@apple.com]
> Sent: Wednesday, October 19, 2016 4:40 PM
> To: Sean Brogan <sean.bro...@microsoft.com>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] question about a compressed Ffs3 file inside FFS2
> filesystem
> 
> 
> > On Oct 19, 2016, at 4:09 PM, Sean Brogan <sean.bro...@microsoft.com>
> wrote:
> >
> > We have a condition that occurs when we boot where we see the following
> message and our boot fails because of it.
> > DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted section in a non-FFS3
> > formatted FV.\n"));
> >
> > Which is on line 773 of FwVol.c (
> >
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Pei/
> Fw
> > Vol/FwVol.c )
> >
> > The condition is caused by a large firmware volume (greater than 16mb)
> that is compressed and put into a smaller FV (less than 16mb).  My question
> is why isn't this allowed (seems like a valid scenario).  Volinfo supports 
> this
> and decodes binary fine.  The PI Vol 3 spec has a section 3.2.2
> EFI_FIRMWARE_FILE_SYSTEM3_GUID which says FileSystem2 doesn't
> support large files but it seems that the code is not taking into account that
> the section is compressed and therefore you can have a large file inside a
> compressed section inside a FV with File System2.
> >
> > Feedback/thoughts/comments/Bug?
> >
> 
> Sean,
> 
> If I understand correctly you are stating that the contents of an 
> Encapsulation
> section should not have any restrictions on content type. The only error
> checking should be that the raw encapsulation section data needs to fit into
> the file type. That seems reasonable to me? I'm not sure if the PI spec makes
> some statement that the code is enforcing, or I guess the PI spec could be
> vague and people are interpreting it differently.
> 
> Thanks,
> 
> Andrew Fish
> 
> > Here are some details of my scenario.
> > Compressed FV has filesystem == 8c8ce578-8a3d-4f1c-9935-896185c32dd3
> > (ffs3) Non compressed FV has filesystem ==
> > 5473c07a-3dcb-4dca-bd6f-1e9689e7349a (ffs2)
> >
> > VolInfo dump of the Non Compressed FV showing the nested/compressed
> FV inside.
> >
> > Decoding
> > VolInfo Version 1.0 Build Build 20909
> > Signature:_FVH (4856465F)
> > Attributes:   4FEFF
> >   EFI_FVB2_READ_DISABLED_CAP
> >   EFI_FVB2_READ_ENABLED_CAP
> >   EFI_FVB2_READ_STATUS
> >   EFI_FVB2_WRITE_DISABLED_CAP
> >   EFI_FVB2_WRITE_ENABLED_CAP
> >   EFI_FVB2_WRITE_STATUS
> >   EFI_FVB2_LOCK_CAP
> >   EFI_FVB2_LOCK_STATUS
> >   EFI_FVB2_STICKY_WRITE
> >   EFI_FVB2_MEMORY_MAPPED
> >   EFI_FVB2_ERASE_POLARITY
> >   EFI_FVB2_READ_LOCK_CAP
> >   EFI_FVB2_READ_LOCK_STATUS
> >   EFI_FVB2_WRITE_LOCK_CAP
> >   EFI_FVB2_WRITE_LOCK_STATUS
> >EFI_FVB2_ALIGNMENT_16
> >EFI_FVB2_ALIGNMENT_32
> >EFI_FVB2_ALIGNMENT_64
> >EFI_FVB2_ALIGNMENT_128
> >EFI_FVB2_ALIGNMENT_4K
> >EFI_FVB2_ALIGNMENT_8K
> >EFI_FVB2_ALIGNMENT_16K
> >EFI_FVB2_ALIGNMENT_32K
> >EFI_FVB2_ALIGNMENT_1M
> >EFI_FVB2_ALIGNMENT_2M
> >   EFI_FVB2_ALIGNMENT_4M
> >EFI_FVB2_ALIGNMENT_8M
> >EFI_FVB2_ALIGNMENT_256M
> >EFI_FVB2_ALIGNMENT_512M
> >EFI_FVB2_ALIGNMENT_1G
> >EFI_FVB2_ALIGNMENT_2G
> > Header Length: 0x0048
> > File System ID:5473c07a-3dcb-4dca-bd6f-1e9689e7349a
> > Revision:  0x0002
> > Number of Blocks:  0x0028
> > Block Length:  0x0001
> > Total Volume Size: 0x0028
> >
> ==
> ==
> > File Name:9E21FD93-9C72-4C15-8C4B-E77F1DB2D792
> > File Offset:  0x0048
> > File Length:  0x001F3FFD
> > File Attributes:  0x00
> > File State:   0xF8
> >EFI_FILE_DATA_VALID
> > File Type:0x0B  EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
> > 
> >  Type:  EFI_SECTION_GUID_DEFINED
> >  Size:  0x001F3FE5
> >  SectionDefinitionGuid:  ee4e58

Re: [edk2] [PATCH V2 09/50] MdeModulePkg/FmpAuthenticationLib: Add FmpAuthenticationLib instance.

2016-10-11 Thread Sean Brogan
In ExecuteFmpAuthenticationHandler and other functions you use asserts to 
handle parameter validation.  I didn't see in the caller any protections 
against bad parameters so on builds with ASSERT disabled this code will not be 
safe.  

Can you explain how you are using monotonic count?  Your comment says you are 
incrementing the PCD to avoid rollback (line 246: It is incremented during each 
firmware image operation.)
Looks like it is just being compared to make sure capsule counter not less than 
PCD based value?  

Same comments as patch 3.  In my opinion library registration pattern is 
overkill for this usage.  

Thanks
Sean
 


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 09/50] MdeModulePkg/FmpAuthenticationLib: Add
> FmpAuthenticationLib instance.
> 
> This library is used to authenticate a UEFI defined FMP Capsule.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Library/FmpAuthenitcationLib/FmpAuthenitcationLib.c   | 277
> 
>  MdeModulePkg/Library/FmpAuthenitcationLib/FmpAuthenitcationLib.inf |  47
>   MdeModulePkg/Library/FmpAuthenitcationLib/FmpAuthenitcationLib.uni
> |  22 ++
>  3 files changed, 346 insertions(+)
> 
> diff --git
> a/MdeModulePkg/Library/FmpAuthenitcationLib/FmpAuthenitcationLib.c
> b/MdeModulePkg/Library/FmpAuthenitcationLib/FmpAuthenitcationLib.c
> new file mode 100644
> index 000..878cbf9
> --- /dev/null
> +++ b/MdeModulePkg/Library/FmpAuthenitcationLib/FmpAuthenitcationLib.c
> @@ -0,0 +1,277 @@
> +/** @file
> +  Provide generic FMP authentication functions for DXE/PEI post memory
> phase.
> +
> +  ExecuteFmpAuthenticationHandler() will receive untrusted input and do
> + basic  validation.
> +
> +  Copyright (c) 2016, Intel Corporation. All rights reserved.  This
> + program and the accompanying materials  are licensed and made
> + available under the terms and conditions of the BSD License  which
> + accompanies this distribution.  The full text of the license may be
> + found at  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +
> +#include 
> +#include 
> +#include  #include
> + #include  #include
> + #include 
> +
> +#define FMP_AUTHENTICATION_HANDLER_TABLE_SIZE   0x10
> +
> +UINT64   mMonotonicCount;
> +
> +UINT32   mNumberOfFmpAuthenticationHandler = 0;
> +UINT32   mMaxNumberOfFmpAuthenticationHandler = 0;
> +
> +GUID *mFmpAuthenticationHandlerGuidTable = NULL;
> +FMP_AUTHENTICATION_HANDLER   *mFmpAuthenticationHandlerTable =
> NULL;
> +
> +/**
> +  Reallocates more global memory to store the registered guid and Handler
> list.
> +
> +  @retval  RETURN_SUCCESSReallocated more global memory space to
> store guid and function tables.
> +  @retval  RETURN_OUT_OF_RESOURCES   Not enough memory to allocate.
> +**/
> +RETURN_STATUS
> +EFIAPI
> +ReallocateFmpAuthenticationHandlerTable (
> +  )
> +{
> +  //
> +  // Reallocate memory for GuidTable
> +  //
> +  mFmpAuthenticationHandlerGuidTable = ReallocatePool (
> + 
> mMaxNumberOfFmpAuthenticationHandler * sizeof
> (GUID),
> + 
> (mMaxNumberOfFmpAuthenticationHandler +
> FMP_AUTHENTICATION_HANDLER_TABLE_SIZE) * sizeof (GUID),
> + mFmpAuthenticationHandlerGuidTable
> + );
> +  if (mFmpAuthenticationHandlerGuidTable == NULL) {
> +goto Done;
> +  }
> +
> +  //
> +  // Reallocate memory for Authentication handler Table  //
> + mFmpAuthenticationHandlerTable = ReallocatePool (
> + mMaxNumberOfFmpAuthenticationHandler * 
> sizeof
> (FMP_AUTHENTICATION_HANDLER),
> + (mMaxNumberOfFmpAuthenticationHandler +
> FMP_AUTHENTICATION_HANDLER_TABLE_SIZE) * sizeof
> (FMP_AUTHENTICATION_HANDLER),
> + mFmpAuthenticationHandlerTable
> + );  if
> + (mFmpAuthenticationHandlerTable == NULL) {
> +goto Done;
> +  }
> +
> +  //
> +  // Increase max handler 

Re: [edk2] [PATCH V2 07/50] MdeModulePkg/MdeModulePkg.dec: Add capsule related definition.

2016-10-11 Thread Sean Brogan
This would all go in the new package instead of MdeModulePkg.  

Thanks
Sean


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 07/50] MdeModulePkg/MdeModulePkg.dec: Add
> capsule related definition.
> 
> 1) Add capsule related GUID.
>EdkiiSystemFmpCapsule
> 2) Add capsule related library.
>EdkiiSystemCapsuleLib
>FmpAuthenticationLib
>IniParsingLib
>PlatformFlashAccessLib.c
> 3) Add capsule related status code PCD.
>PcdStatusCodeSubClassCapsule
>PcdCapsuleStatusCodeProcessCapsulesBegin
>PcdCapsuleStatusCodeProcessCapsulesEnd
>PcdCapsuleStatusCodeUpdatingFirmware
>PcdCapsuleStatusCodeUpdateFirmwareSuccess
>PcdCapsuleStatusCodeUpdateFirmwareFailed
>PcdCapsuleStatusCodeResettingSystem
> 4) Add capsule status variable PCD - CapsuleMax value.
>PcdCapsuleMax
> 5) Add EDKII system capsule related DynamicEx PCD
>PcdEdkiiSystemFmpCapsuleMonotonicCount
>PcdEdkiiSystemFirmwareImageDescriptor
>PcdEdkiiSystemFirmwareFileGuid
>PcdEdkiiSystemFmpCapsuleImageTypeIdGuid
>NOTE: We use DynamicEx here because the update driver may be in
>the capsule FMP, instead of system firmware.
>The update driver MUST use the PCD info produced system firmware.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 106 
>  1 file changed, 106 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 8d90f16..ab23af7 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -157,6 +157,22 @@
>#
>MemoryProfileLib|Include/Library/MemoryProfileLib.h
> 
> +  ## @libraryclass  Provides services to authenticate a UEFI defined FMP
> Capsule.
> +  #
> +  FmpAuthenticationLib|Include/Library/FmpAuthenticationLib.h
> +
> +  ## @libraryclass  Provides services for EDKII system FMP capsule.
> +  #
> +  EdkiiSystemCapsuleLib|Include/Library/EdkiiSystemCapsuleLib.h
> +
> +  ## @libraryclass  Provides services to parse the INI configuration file.
> +  #
> +  IniParsingLib|Include/Library/IniParsingLib.h
> +
> +  ## @libraryclass  Provides services to access flash device.
> +  #
> +  PlatformFlashAccessLib|Include/Library/PlatformFlashAccessLib.h
> +
>  [Guids]
>## MdeModule package token space guid
># Include/Guid/MdeModulePkgTokenSpace.h
> @@ -355,6 +371,11 @@
>## Include/Guid/PiSmmCommunicationRegionTable.h
>gEdkiiPiSmmCommunicationRegionTableGuid = { 0x4e28ca50, 0xd582,
> 0x44ac, {0xa1, 0x1f, 0xe3, 0xd5, 0x65, 0x26, 0xdb, 0x34}}
> 
> +  ## Include/Guid/EdkiiSystemFmpCapsule.h
> +  gEdkiiSystemFirmwareImageDescriptorFileGuid = {0x90b2b846, 0xca6d,
> 0x4d6e, {0xa8, 0xd3, 0xc1, 0x40, 0xa8, 0xe1, 0x10, 0xac}}
> +  gEdkiiSystemFmpCapsuleConfigFileGuid= {0x812136d3, 0x4d3a, 0x433a,
> {0x94, 0x18, 0x29, 0xbb, 0x9b, 0xf7, 0x8f, 0x6e}}
> +  gEdkiiSystemFmpCapsuleDriverFvFileGuid  = {0xce57b167, 0xb0e4,
> 0x41e8, {0xa8, 0x97, 0x5f, 0x4f, 0xeb, 0x78, 0x1d, 0x40}}
> +
>  [Ppis]
>## Include/Ppi/AtaController.h
>gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 
> 0x7a,
> 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
> @@ -1130,6 +1151,52 @@
># @Prompt MAX repair count
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxRepairCount|0x00|UINT32|0x000
> 10076
> 
> +  ## Status Code for Capsule subclass definitions.  #
> + EFI_SOFTWARE_CAPSULE  = (EFI_SOFTWARE | 0x0015) =
> 0x0315
> + # @Prompt Status Code for Capsule subclass definitions  # @ValidList
> + 0x8003 | 0x0315
> +
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeSubClassCapsule|0x031500
> 00
> + |UINT32|0x0100
> +
> +  ## Status Code for Capsule definitions.  #
> + EFI_CAPSULE_PROCESS_CAPSULES_BEGIN  = (EFI_SUBCLASS_SPECIFIC |
> + 0x0001) = 0x00010001  # @Prompt Status Code for Capsule
> + definitions  # @ValidList  0x8003 | 0x00010001
> +
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeProcessCapsulesBeg
> i
> + n|0x00010001|UINT32|0x0101
> +
> +  ## Status Code for Capsule definitions.
> +  #  EFI_CAPSULE_PROCESS_CAPSULES_END= (EFI_SUBCLASS_SPECIFIC |
> 0x0002) = 0x00010002
> +  # @Prompt Status Code for Capsule definitions  # @ValidList
> + 0x8003 | 0x00010002
> +
> +
> 

Re: [edk2] [PATCH V2 06/50] MdeModulePkg/CapsuleLib: Add ProcessCapsules() API.

2016-10-11 Thread Sean Brogan
Comment about calling ProcessCapsules twice will break in some scenarios.  For 
example windows capsule update will stage multiple capsules at once.  If it 
mixes capsules from both stages and you use memory to preserve capsule contents 
you will lose your non system capsule because of the reboot.  

2nd - For capsules that are not FMP or update capsules but capsules being 
requested to be put in the system table you will still need to process them 
even though the boot mode should not be BOOT_ON_FLASH_UPDATE.  

Thanks
Sean


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 06/50] MdeModulePkg/CapsuleLib: Add
> ProcessCapsules() API.
> 
> ProcessCapsules() API can be used by platform BDS to process all capsules.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Library/CapsuleLib.h | 45 ++--
>  1 file changed, 42 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Include/Library/CapsuleLib.h
> b/MdeModulePkg/Include/Library/CapsuleLib.h
> index 487cb0f..659c077 100644
> --- a/MdeModulePkg/Include/Library/CapsuleLib.h
> +++ b/MdeModulePkg/Include/Library/CapsuleLib.h
> @@ -2,7 +2,7 @@
> 
>This library class defines a set of interfaces for how to process capsule 
> image
> updates.
> 
> -Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
> +Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
>  This program and the accompanying materials are licensed and made available
> under  the terms and conditions of the BSD License that accompanies this
> distribution.
>  The full text of the license may be found at @@ -20,7 +20,9 @@ WITHOUT
> WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
> IMPLIED.
>The firmware checks whether the capsule image is supported
>by the CapsuleGuid in CapsuleHeader or if there is other specific 
> information
> in
>the capsule image.
> -
> +
> +  Caution: This function may receive untrusted input.
> +
>@param  CapsuleHeaderPointer to the UEFI capsule image to be checked.
> 
>@retval EFI_SUCESS   Input capsule is supported by firmware.
> @@ -35,7 +37,9 @@ SupportCapsuleImage (
>  /**
>The firmware-specific implementation processes the capsule image
>if it recognized the format of this capsule image.
> -
> +
> +  Caution: This function may receive untrusted input.
> +
>@param  CapsuleHeaderPointer to the UEFI capsule image to be processed.
> 
>@retval EFI_SUCESS   Capsule Image processed successfully.
> @@ -47,4 +51,39 @@ ProcessCapsuleImage (
>IN EFI_CAPSULE_HEADER *CapsuleHeader
>);
> 
> +/**
> +
> +  This routine is called to process capsules.
> +
> +  Caution: This function may receive untrusted input.
> +
> +  If the current boot mode is NOT BOOT_ON_FLASH_UPDATE, this routine does
> nothing.
> +  If the current boot mode is BOOT_ON_FLASH_UPDATE, the capsules
> + reported in  EFI_HOB_UEFI_CAPSULE are processed. If there is no
> + EFI_HOB_UEFI_CAPSULE, this  routine does nothing.
> +
> +  This routine should be called twice in BDS.
> +  1) The first call must be before EndOfDxe. The system capsules is 
> processed.
> + If device capsule FMP protocols are exposted at this time, the device
> + capsules are processed.
> + Each individual capsule result is recorded in capsule record variable.
> + System may reset in this function, if reset is required by capsule.
> +
> +  2) The second call must be after EndOfDxe and after ConnectAll, so that all
> + device capsule FMP protocols are exposed.
> + The system capsules are skipped. If the device capsules are NOT 
> processed
> + in first call, they are processed here.
> + Each individual capsule result is recorded in capsule record variable.
> + System may reset in this function, if reset is required by capsule.
> +
> +  @retval EFI_SUCCESS There is no error when processing capsules.
> +  @retval EFI_OUT_OF_RESOURCESNo enough resource to process capsules.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +ProcessCapsules(
> +  VOID
> +  );
> +
>  #endif
> --
> 2.7.4.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

Re: [edk2] [PATCH V2 06/50] MdeModulePkg/CapsuleLib: Add ProcessCapsules() API.

2016-10-11 Thread Sean Brogan


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 06/50] MdeModulePkg/CapsuleLib: Add
> ProcessCapsules() API.
> 
> ProcessCapsules() API can be used by platform BDS to process all capsules.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Library/CapsuleLib.h | 45 ++--
>  1 file changed, 42 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Include/Library/CapsuleLib.h
> b/MdeModulePkg/Include/Library/CapsuleLib.h
> index 487cb0f..659c077 100644
> --- a/MdeModulePkg/Include/Library/CapsuleLib.h
> +++ b/MdeModulePkg/Include/Library/CapsuleLib.h
> @@ -2,7 +2,7 @@
> 
>This library class defines a set of interfaces for how to process capsule 
> image
> updates.
> 
> -Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
> +Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
>  This program and the accompanying materials are licensed and made available
> under  the terms and conditions of the BSD License that accompanies this
> distribution.
>  The full text of the license may be found at @@ -20,7 +20,9 @@ WITHOUT
> WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
> IMPLIED.
>The firmware checks whether the capsule image is supported
>by the CapsuleGuid in CapsuleHeader or if there is other specific 
> information
> in
>the capsule image.
> -
> +
> +  Caution: This function may receive untrusted input.
> +
>@param  CapsuleHeaderPointer to the UEFI capsule image to be checked.
> 
>@retval EFI_SUCESS   Input capsule is supported by firmware.
> @@ -35,7 +37,9 @@ SupportCapsuleImage (
>  /**
>The firmware-specific implementation processes the capsule image
>if it recognized the format of this capsule image.
> -
> +
> +  Caution: This function may receive untrusted input.
> +
>@param  CapsuleHeaderPointer to the UEFI capsule image to be processed.
> 
>@retval EFI_SUCESS   Capsule Image processed successfully.
> @@ -47,4 +51,39 @@ ProcessCapsuleImage (
>IN EFI_CAPSULE_HEADER *CapsuleHeader
>);
> 
> +/**
> +
> +  This routine is called to process capsules.
> +
> +  Caution: This function may receive untrusted input.
> +
> +  If the current boot mode is NOT BOOT_ON_FLASH_UPDATE, this routine does
> nothing.
> +  If the current boot mode is BOOT_ON_FLASH_UPDATE, the capsules
> + reported in  EFI_HOB_UEFI_CAPSULE are processed. If there is no
> + EFI_HOB_UEFI_CAPSULE, this  routine does nothing.
> +
> +  This routine should be called twice in BDS.
> +  1) The first call must be before EndOfDxe. The system capsules is 
> processed.
> + If device capsule FMP protocols are exposted at this time, the device
> + capsules are processed.
> + Each individual capsule result is recorded in capsule record variable.
> + System may reset in this function, if reset is required by capsule.
> +
> +  2) The second call must be after EndOfDxe and after ConnectAll, so that all
> + device capsule FMP protocols are exposed.
> + The system capsules are skipped. If the device capsules are NOT 
> processed
> + in first call, they are processed here.
> + Each individual capsule result is recorded in capsule record variable.
> + System may reset in this function, if reset is required by capsule.
> +
> +  @retval EFI_SUCCESS There is no error when processing capsules.
> +  @retval EFI_OUT_OF_RESOURCESNo enough resource to process capsules.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +ProcessCapsules(
> +  VOID
> +  );
> +
>  #endif
> --
> 2.7.4.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 05/50] MdeModulePkg/Include: Add PlatformFlashAccessLib header.

2016-10-11 Thread Sean Brogan
My suggestion is to move to implementation specific package. 


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 05/50] MdeModulePkg/Include: Add
> PlatformFlashAccessLib header.
> 
> This library is used to abstract platform flash access.
> This library is consumed by a capsule update module.
> It may cover SystemFirmware region and/or non-SystemFirmware region.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Library/PlatformFlashAccessLib.h | 59
> 
>  1 file changed, 59 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Library/PlatformFlashAccessLib.h
> b/MdeModulePkg/Include/Library/PlatformFlashAccessLib.h
> new file mode 100644
> index 000..0ce7e29
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/PlatformFlashAccessLib.h
> @@ -0,0 +1,59 @@
> +/** @file
> +  Platform flash device access library.
> +
> +  Copyright (c) 2016, Intel Corporation. All rights reserved.  This
> + program and the accompanying materials  are licensed and made
> + available under the terms and conditions of the BSD License  which
> + accompanies this distribution.  The full text of the license may be
> + found at  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +
> +#ifndef __PLATFORM_FLASH_ACCESS_LIB_H__ #define
> +__PLATFORM_FLASH_ACCESS_LIB_H__
> +
> +typedef enum {
> +  FlashAddressTypeRelativeAddress,
> +  FlashAddressTypeAbsoluteAddress,
> +  FlashAddressTypeMax,
> +} FLASH_ADDRESS_TYPE;
> +
> +//
> +// Type 0 ~ 0x7FFF is defined in this library.
> +// Type 0x8000 ~ 0x is reserved for OEM.
> +//
> +typedef enum {
> +  PlatformFirmwareTypeSystemFirmware,
> +  PlatformFirmwareTypeNvRam,
> +  PlatformFirmwareTypeMax,
> +} PLATFORM_FIRMWARE_TYPE;
> +
> +/**
> +  Perform flash write opreation.
> +
> +  @param FirmwareType  The type of firmware.
> +  @param FlashAddress  The address of flash device to be accessed.
> +  @param FlashAddressType  The type of flash device address.
> +  @param BufferThe pointer to the data buffer.
> +  @param LengthThe length of data buffer in bytes.
> +
> +  @retval EFI_SUCCESS   The operation returns successfully.
> +  @retval EFI_WRITE_PROTECTED   The flash device is read only.
> +  @retval EFI_UNSUPPORTED   The flash device access is unsupported.
> +  @retval EFI_INVALID_PARAMETER The input parameter is not valid.
> +**/
> +EFI_STATUS
> +EFIAPI
> +PerformFlashWrite (
> +  IN PLATFORM_FIRMWARE_TYPE   FirmwareType,
> +  IN EFI_PHYSICAL_ADDRESS FlashAddress,
> +  IN FLASH_ADDRESS_TYPE   FlashAddressType,
> +  IN VOID *Buffer,
> +  IN UINTNLength
> +  );
> +
> +#endif
> --
> 2.7.4.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 04/50] MdeModulePkg/Include: Add IniParsingLib header.

2016-10-11 Thread Sean Brogan
This is specific to your implementation and would again suggest moving to your 
new package.  
 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 04/50] MdeModulePkg/Include: Add IniParsingLib
> header.
> 
> This library is used to parse the INI configuration file.
> The INI configuration file is used in EDKII capsule image to describe the 
> capsule
> information.
> 
> Detail format is documented in header file.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Library/IniParsingLib.h | 166 
>  1 file changed, 166 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Library/IniParsingLib.h
> b/MdeModulePkg/Include/Library/IniParsingLib.h
> new file mode 100644
> index 000..447a2e6
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/IniParsingLib.h
> @@ -0,0 +1,166 @@
> +/** @file
> +  INI configuration parsing library.
> +
> +  The INI file format is:
> +
> +[SectionName]
> +EntryName=EntryValue
> +
> +
> +Where:
> +  1) SectionName is an ASCII string. The valid format is [A-Za-z0-9_]+
> +  2) EntryName is an ASCII string. The valid format is [A-Za-z0-9_]+
> +  3) EntryValue can be:
> + 3.1) an ASCII String. The valid format is [A-Za-z0-9_]+
> + 3.2) a GUID. The valid format is 
> ----,
> where x is [A-Fa-f0-9]
> + 3.3) a decimal value. The valid format is [0-9]+
> + 3.4) a heximal value. The valid format is 0x[A-Fa-f0-9]+
> +  4) '#' or ';' can be used as comment at anywhere.
> +  5) TAB(0x20) or SPACE(0x9) can be used as separator.
> +  6) LF(\n, 0xA) or CR(\r, 0xD) can be used as line break.
> +
> +Copyright (c) 2016, Intel Corporation. All rights reserved. This
> +program and the accompanying materials are licensed and made available
> +under the terms and conditions of the BSD License which accompanies
> +this distribution.  The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> +
> +**/
> +
> +
> +#ifndef __INI_PARSING_LIB_H__
> +#define __INI_PARSING_LIB_H__
> +
> +/**
> +  Open an INI config file and return a context.
> +
> +  @param DataBuffer  Config raw file buffer.
> +  @param BufferSize  Size of raw buffer.
> +
> +  @return   Config data buffer is opened and context is returned.
> +  @retval NULL  No enough memory is allocated.
> +  @retval NULL  Config data buffer is invalid.
> +**/
> +VOID *
> +EFIAPI
> +OpenIniFile (
> +  IN  UINT8 *DataBuffer,
> +  IN  UINTN BufferSize
> +  );
> +
> +/**
> +  Get section entry string value.
> +
> +  @param Context INI Config file context.
> +  @param SectionName Section name.
> +  @param EntryName   Section entry name.
> +  @param EntryValue  Point to the got entry string value.
> +
> +  @retval EFI_SUCCESSSection entry string value is got.
> +  @retval EFI_NOT_FOUND  Section is not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetStringFromDataFile(
> +  IN  VOID  *Context,
> +  IN  CHAR8 *SectionName,
> +  IN  CHAR8 *EntryName,
> +  OUT CHAR8 **EntryValue
> +  );
> +
> +/**
> +  Get section entry GUID value.
> +
> +  @param Context INI Config file context.
> +  @param SectionName Section name.
> +  @param EntryName   Section entry name.
> +  @param GuidPoint to the got GUID value.
> +
> +  @retval EFI_SUCCESSSection entry GUID value is got.
> +  @retval EFI_NOT_FOUND  Section is not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetGuidFromDataFile(
> +  IN  VOID  *Context,
> +  IN  CHAR8 *SectionName,
> +  IN  CHAR8 *EntryName,
> +  OUT EFI_GUID  *Guid
> +  );
> +
> +/**
> +  Get section entry decimal UINTN value.
> +
> +  @param Context INI Config file context.
> +  @param SectionName Section name.
> +  @param EntryName   Section entry name.
> +  

Re: [edk2] [PATCH V2 03/50] MdeModulePkg/Include: Add FmpAuthenticationLib header.

2016-10-11 Thread Sean Brogan
I think this library and the design of registering different auth handlers is 
not the right design for FMP auth verification.   This isn't something that 
needs extension thru registration. This is a controlled environment.  I also 
don't think the capsule runtime should be using these auth services.  How I see 
it the design abstraction of FMP is that the FMP instance does the verification 
and unwrapping of the capsule in its checkimage/set image routines.  By keeping 
FMP self-contained a platform gains a lot of flexibility.  FMP SetImage can be 
called from the UEFI shell or other application before exit boot services so it 
must always verify the image before applying anyway.   
 
I would ask that this too be moved to your new sample package or removed from 
the design.  

Thanks
Sean
 



> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 03/50] MdeModulePkg/Include: Add
> FmpAuthenticationLib header.
> 
> This library is used to authenticate a UEFI defined FMP Capsule.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Library/FmpAuthenticationLib.h | 91
> 
>  1 file changed, 91 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Library/FmpAuthenticationLib.h
> b/MdeModulePkg/Include/Library/FmpAuthenticationLib.h
> new file mode 100644
> index 000..895698e
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/FmpAuthenticationLib.h
> @@ -0,0 +1,91 @@
> +/** @file
> +  FMP capsule authenitcation Library.
> +
> +Copyright (c) 2016, Intel Corporation. All rights reserved. This
> +program and the accompanying materials are licensed and made available
> +under the terms and conditions of the BSD License which accompanies
> +this distribution.  The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> +
> +**/
> +
> +
> +#ifndef __FMP_AUTHENTICATION_LIB_H__
> +#define __FMP_AUTHENTICATION_LIB_H__
> +
> +/**
> +  The handler is used to do the authentication for FMP capsule based
> +upon
> +  EFI_FIRMWARE_IMAGE_AUTHENTICATION.
> +
> +  Caution: This function may receive untrusted input.
> +
> +  @param[in]Image  Points to the new FMP authentication 
> image,
> +   start from 
> EFI_FIRMWARE_IMAGE_AUTHENTICATION.
> +  @param[in]ImageSize  Size of the authentication image in bytes.
> +  @param[out]   LastAttemptStatus  The last attempt status, which will be
> recorded
> +   in ESRT and FMP 
> EFI_FIRMWARE_IMAGE_DESCRIPTOR.
> +
> +  @retval RETURN_SUCCESSAuthentication pass.
> +  @retval RETURN_SECURITY_VIOLATION Authentication fail.
> +The detail reson is recorded in 
> LastAttemptStatus.
> +**/
> +typedef
> +RETURN_STATUS
> +(EFIAPI *FMP_AUTHENTICATION_HANDLER) (
> +  IN VOID *Image,
> +  IN UINTNImageSize,
> +  OUT UINT32  *LastAttemptStatus
> +  );
> +
> +/**
> +  Register FMP authentication handler with CertType.
> +
> +  If CertType is NULL, then ASSERT().
> +  If FmpAuthenticationHandler is NULL, then ASSERT().
> +
> +  @param[in]  CertType   The certificate type associated 
> with the
> FMP auth handler.
> +  @param[in]  FmpAuthenticationHandler   The FMP authentication handler to
> be registered.
> +
> +  @retval  RETURN_SUCCESS   The handlers were registered.
> +  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources
> available to register the handlers.
> +**/
> +RETURN_STATUS
> +EFIAPI
> +RegisterFmpAuthenticationHandler(
> +  IN GUID *CertType,
> +  IN FMP_AUTHENTICATION_HANDLER   FmpAuthenticationHandler
> +  );
> +
> +/**
> +  Execute FMP authentication handlers.
> +
> +  Caution: This function may receive untrusted input.
> +
> +  If Image is NULL, then ASSERT().
> +  If ImageSize is 0, then ASSERT().
> +  If LastAttemptStatus is NULL, then ASSERT().
> +
> +  @param[in]Image  Points to the new FMP authentication 
> image,
> +   start from 
> 

Re: [edk2] [PATCH V2 02/50] MdeModulePkg/Include: Add EdkiiSystemCapsuleLib definition.

2016-10-11 Thread Sean Brogan
I would suggest moving this to the "new" package.  

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 02/50] MdeModulePkg/Include: Add
> EdkiiSystemCapsuleLib definition.
> 
> This library is used to abstract the action for EDKII system FMP capsule, 
> such as
> extracting a component from capsule, or authenticate the capsule.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Library/EdkiiSystemCapsuleLib.h | 154
> 
>  1 file changed, 154 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Library/EdkiiSystemCapsuleLib.h
> b/MdeModulePkg/Include/Library/EdkiiSystemCapsuleLib.h
> new file mode 100644
> index 000..db0ce79
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/EdkiiSystemCapsuleLib.h
> @@ -0,0 +1,154 @@
> +/** @file
> +  EDKII System Capsule library.
> +
> +Copyright (c) 2016, Intel Corporation. All rights reserved. This
> +program and the accompanying materials are licensed and made available
> +under the terms and conditions of the BSD License which accompanies
> +this distribution.  The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> +
> +**/
> +
> +
> +#ifndef __EDKII_SYSTEM_CAPSULE_LIB_H__
> +#define __EDKII_SYSTEM_CAPSULE_LIB_H__
> +
> +#include 
> +
> +/**
> +  Extract ImageFmpInfo from system firmware.
> +
> +  @param[in]  SystemFirmwareImage The System Firmware image.
> +  @param[in]  SystemFirmwareImageSize The size of the System Firmware
> image in bytes.
> +  @param[out] ImageFmpInfoThe ImageFmpInfo.
> +  @param[out] ImageFmpInfoSizeThe size of the ImageFmpInfo in bytes.
> +
> +  @retval TRUE  The ImageFmpInfo is extracted.
> +  @retval FALSE The ImageFmpInfo is not extracted.
> +**/
> +BOOLEAN
> +EFIAPI
> +ExtractSystemFirmwareImageFmpInfo(
> +  IN VOID  *SystemFirmwareImage,
> +  IN UINTN SystemFirmwareImageSize,
> +  OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR   **ImageFmpInfo,
> +  OUT UINTN*ImageFmpInfoSize
> +  );
> +
> +/**
> +  Extract the driver FV from an authenticated image.
> +
> +  @param[in]  AuthenticatedImage  The authenticated capsule image.
> +  @param[in]  AuthenticatedImageSize  The size of the authenticated capsule
> image in bytes.
> +  @param[out] DriverFvImage   The driver FV image.
> +  @param[out] DriverFvImageSize   The size of the driver FV image in 
> bytes.
> +
> +  @retval TRUE  The driver Fv is extracted.
> +  @retval FALSE The driver Fv is not extracted.
> +**/
> +BOOLEAN
> +EFIAPI
> +ExtractDriverFvImage(
> +  IN VOID *AuthenticatedImage,
> +  IN UINTNAuthenticatedImageSize,
> +  OUT VOID**DriverFvImage,
> +  OUT UINTN   *DriverFvImageSize
> +  );
> +
> +/**
> +  Extract the config image from an authenticated image.
> +
> +  @param[in]  AuthenticatedImage  The authenticated capsule image.
> +  @param[in]  AuthenticatedImageSize  The size of the authenticated capsule
> image in bytes.
> +  @param[out] ConfigImage The config image.
> +  @param[out] ConfigImageSize The size of the config image in bytes.
> +
> +  @retval TRUE  The config image is extracted.
> +  @retval FALSE The config image is not extracted.
> +**/
> +BOOLEAN
> +EFIAPI
> +ExtractConfigImage(
> +  IN VOID *AuthenticatedImage,
> +  IN UINTNAuthenticatedImageSize,
> +  OUT VOID**ConfigImage,
> +  OUT UINTN   *ConfigImageSize
> +  );
> +
> +/**
> +  Extract the System Firmware image from an authenticated image.
> +
> +  @param[in]  AuthenticatedImage  The authenticated capsule image.
> +  @param[in]  AuthenticatedImageSize  The size of the authenticated capsule
> image in bytes.
> +  @param[out] SystemFirmwareImage The System Firmware image.
> +  @param[out] SystemFirmwareImageSize The size of the System Firmware
> image in bytes.
> +
> +  @retval TRUE  The System Firmware image is extracted.
> +  @retval 

Re: [edk2] [PATCH V2 01/50] MdeModulePkg/Include: Add EDKII system FMP capsule header.

2016-10-11 Thread Sean Brogan
This file is for your implementation.  I would suggest removing it from 
MdeModulePkg and into your new package.  


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jiewen Yao
> Sent: Friday, September 30, 2016 5:21 AM
> To: edk2-devel@lists.01.org
> Cc: Michael D Kinney ; Feng Tian
> ; Chao Zhang ; Liming Gao
> ; Star Zeng 
> Subject: [edk2] [PATCH V2 01/50] MdeModulePkg/Include: Add EDKII system
> FMP capsule header.
> 
> Add EDKII system FMP capsule header file.
> This describes the EDKII system FMP capsule format.
> 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> Reviewed-by: Liming Gao 
> ---
>  MdeModulePkg/Include/Guid/EdkiiSystemFmpCapsule.h | 110
> 
>  1 file changed, 110 insertions(+)
> 
> diff --git a/MdeModulePkg/Include/Guid/EdkiiSystemFmpCapsule.h
> b/MdeModulePkg/Include/Guid/EdkiiSystemFmpCapsule.h
> new file mode 100644
> index 000..0bd84f5
> --- /dev/null
> +++ b/MdeModulePkg/Include/Guid/EdkiiSystemFmpCapsule.h
> @@ -0,0 +1,110 @@
> +/** @file
> +  Guid & data structure used for Delivering Capsules Containing Updates
> +to
> +  EDKII System Firmware Management Protocol
> +
> +  Copyright (c) 2016, Intel Corporation. All rights reserved.  This
> + program and the accompanying materials  are licensed and made
> + available under the terms and conditions of the BSD License  which
> + accompanies this distribution.  The full text of the license may be
> + found at  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +
> +#ifndef __EDKII_SYSTEM_FMP_CAPSULE_GUID_H__
> +#define __EDKII_SYSTEM_FMP_CAPSULE_GUID_H__
> +
> +/**
> +
> +  Capsule Layout is below:
> +  +--+
> +  |Capsule Header (OPTIONAL, WFU)| <== ESRT.FwClass (Optional)
> +  +--+
> +  |  FMP Capsule Header  | <==
> EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID
> +  +--+
> +  | FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER | <==
> + PcdEdkiiSystemFmpCapsuleImageTypeIdGuid
> +  +--+
> +  | EFI_FIRMWARE_IMAGE_AUTHENTICATION|
> +  +--+
> +  | FMP Payload  |
> +  +--+
> +
> +  System FMP Payload is below:
> +  +--+
> +  |EFI_FIRMWARE_VOLUME   |
> +  |  ++  |
> +  |  |   FFS (Configure File) |  | <==
> gEdkiiSystemFmpCapsuleConfigFileGuid
> +  |  ++  |
> +  |  | FFS (Driver FV)|  | <==
> gEdkiiSystemFmpCapsuleDriverFvFileGuid
> +  |  ++  |
> +  |  |FFS (System Firmware Image) |  | <==
> PcdEdkiiSystemFirmwareFileGuid
> +  |  |  +--+  |  |
> +  |  |  |  FV Recovery |  |  |
> +  |  |  |--|  |  |
> +  |  |  |   Fv Main|  |  |
> +  |  |  +--+  |  |  |
> + ++  |
> + +--+
> +
> +**/
> +
> +#define EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE
> +SIGNATURE_32('S', 'F', 'I', 'D')
> +
> +#pragma pack(1)
> +typedef struct {
> +  UINT32Signature;
> +  UINT32HeaderLength; // Length of
> EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR, excluding NameString
> +  UINT32Length;   // Length of the data 
> structure,
> including NameString
> +  // Below structure is similar as UEFI
> EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetPackageInfo()
> +  UINT32PackageVersion;
> +  UINT32PackageVersionNameStringOffset; // 
> Offset from
> head, CHAR16 string including NULL terminate char
> +  // Below structure is similar as UEFI EFI_FIRMWARE_IMAGE_DESCRIPTOR
> +  UINT8 ImageIndex;
> +  UINT8 Reserved[3];
> +  EFI_GUID  ImageTypeId;
> +  UINT64ImageId;
> +  UINT32ImageIdNameStringOffset; // Offset 
> from head,
> CHAR16 

Re: [edk2] [PATCH V2 00/50] Add capsule update and recovery sample.

2016-10-11 Thread Sean Brogan
Jiewen,
I responded to Mikes email which has similar statement.  

As for the example modules you listed that are in MdeModulePkg, I don't think 
they should be in MdeModulePkg.  We should be working to minimize the core of 
the src tree (mde*) to only what is needed and then use other modules, 
libraries, and other methods to implement advanced features. 

More feedback to come on the individual patches of the capsule update set.  

Thanks
Sean




From: Yao, Jiewen [mailto:jiewen@intel.com] 
Sent: Monday, October 10, 2016 4:25 PM
To: Sean Brogan <sean.bro...@microsoft.com>; edk2-devel@lists.01.org; Kinney, 
Michael D <michael.d.kin...@intel.com>
Subject: RE: [edk2] [PATCH V2 00/50] Add capsule update and recovery sample.

HI
Correct me if I am wrong.
I believe the package position in edkii is that: *only* MdePkg is industry 
standard. MdeModulePkg is *EDKII implementation*, instead of industry standard.

That is why we separate MdeModulePkg from MdePkg. You may find some EDKII_* 
protocol in MdeModulePkg. But all UEFI/PI/ACPI defined protocol/PPI/GUI are in 
MdePkg.

For example: 
1) MdeModulePkg\Application\UiApp - it is sample front page UI. The production 
BIOS may use different UI.
2) MdeModulePkg\Universal\SetupBrowserDxe - it is sample browser. The 
production BIOS may use different browser, such as graphic browser.
3) MdeModulePkg\Universal\Acpi\AcpiPlatformDxe - it is sample ACPI platform 
driver. I do not believe any production is using that. It is only reference.
4) MdeModulePkg\Universal\DriverSampleDxe - it is sample setup driver to 
demonstrate how construct IFT OPCODE. I do not believe any production is using 
that.

Of course, we are trying to make solution as generic as possible to fit the 
need for most platforms. But they are not required to be used.

Thank you
Yao Jiewen

From: Sean Brogan [mailto:sean.bro...@microsoft.com] 
Sent: Tuesday, October 11, 2016 5:22 AM
To: Yao, Jiewen <mailto:jiewen@intel.com>; mailto:edk2-devel@lists.01.org; 
Kinney, Michael D <mailto:michael.d.kin...@intel.com>
Subject: RE: [edk2] [PATCH V2 00/50] Add capsule update and recovery sample.

Jiewen, Mike, and the EDK2 list,

This is not a feedback directly on this patch and the C code but more on the 
overall feature of capsule update/recovery.  

You are implementing one specific way to do capsule update.  There are infinite 
other implementations and my issue is how this implementation is scattering 
thru the Industry standard (Mde*) packages.  I think our shared goal for 
Tianocore and edk2 is to create a well-designed, modular, flexible codebase for 
the UEFI FW producing industry.   As part of those goals I really want to see 
the standards based packages shrink to the minimum necessary to create a secure 
and robust core, and optional/advanced features should reside in other packages 
that a consumer can pick and choose from.  This set of patches is counter to 
that goal.  It contains over 50 patches, most are in the MdeModulePkg, and 
introduces new dependencies across the entire tree for this implementation 
choice.   

Thoughts?  


Thanks
Sean


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Yao, Jiewen
> Sent: Friday, September 30, 2016 5:32 AM
> To: Yao, Jiewen <mailto:jiewen@intel.com>; mailto:edk2-devel@lists.01.org
> Cc: Tian, Feng <mailto:feng.t...@intel.com>; Gao, Liming 
><mailto:liming@intel.com>;
> Zeng, Star <mailto:star.z...@intel.com>; Kinney, Michael D
> <mailto:michael.d.kin...@intel.com>; Fan, Jeff <mailto:jeff@intel.com>; 
>Zhang, Chao
> B <mailto:chao.b.zh...@intel.com>
> Subject: Re: [edk2] [PATCH V2 00/50] Add capsule update and recovery
> sample.
> 
> Hi
> Here is V2 serial.
> I forgot to mention:
> 1) This series is also pushed to mailto:g...@github.com:jyao1/edk2.git.
> 2) Below is test I did for IniParsingLib.
> 2.1) Unit test:
>   { EFI_SUCCESS,   "[a]\nb=c\n" },
>   { EFI_SUCCESS,   "[_]\n_=0\n" },
>   { EFI_SUCCESS,   "[a]\nb=----
> \n" },
>   { EFI_INVALID_PARAMETER, "[]\n" },
>   { EFI_INVALID_PARAMETER, "[[\n" },
>   { EFI_INVALID_PARAMETER, "[[a]]\n" },
>   { EFI_INVALID_PARAMETER, "[\n" },
>   { EFI_INVALID_PARAMETER, "]\n" },
>   { EFI_INVALID_PARAMETER, "a\n" },
>   { EFI_INVALID_PARAMETER, "=\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb\n" },
>   { EFI_INVALID_PARAMETER, "[a]\n[=c" },
>   { EFI_INVALID_PARAMETER, "[a]\n=\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=#\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=;\n" },
>   { EFI_INVAL

Re: [edk2] [PATCH V2 00/50] Add capsule update and recovery sample.

2016-10-11 Thread Sean Brogan
Mike,
Comments inline. 
I'll reply with code review comments to the individual patches. 

Thanks
Sean


> -Original Message-
> From: Kinney, Michael D [mailto:michael.d.kin...@intel.com]
> Sent: Monday, October 10, 2016 4:29 PM
> To: Sean Brogan <sean.bro...@microsoft.com>; Yao, Jiewen
> <jiewen@intel.com>; edk2-devel@lists.01.org; Kinney, Michael D
> <michael.d.kin...@intel.com>
> Subject: RE: [edk2] [PATCH V2 00/50] Add capsule update and recovery sample.
> 
> Sean,
> 
> Thanks for the feedback.
> 
> There are no touches to the MdePkg that contains the includes/libs for 
> industry
> standard specifications.  23 of the patches are against MdeModulePkg,
> IntelFrameworkModulePkg, and the SecurityPkg.  The MdeModulePkg contains
> modules that are allowed to depend on the MdePkg and any additional
> definitions in the MdeModulePkg itself.  Definitions that are added to the
> MdeModulePkg are for features that are specific to the EDK II implementation.
> Jiewen has followed the guidelines for where content could be placed without
> adding any new packages.

[Sean Brogan] - I agree but I think tianocore would be best served if 
MdeModulePkg contained bare bones implementations with as few assumptions and 
implementation specific features hardcoded into those modules.  When I look at 
the various production code bases I have seen the modules that cause the least 
maintenance overhead/customization/overriding/security problems are those 
modules that strictly implement basic functionality.  I am all for a module 
having a set of well-constructed library callouts to allow a plug-in or 
advanced feature but I just don't like to see that logic hard coded into any 
MdeModulePkg module.  I also don't think those advanced features should be 
implemented in the MdeModulePkg.  

> 
> I idea of putting the platform agnostic elements of the recovery and capsule
> update features into its their own package seems like a reasonable idea.  Do
> you have a proposal for a package name, package contents, and package
> organization?
[Sean Brogan]  - SampleSystemFirmwareUpdatePkg


> 
> The remaining patches against the Quark, VLV2, and UefiCpuPkg are working
> examples of using the firmware update and recovery features.  It would be
> reasonable, and maybe easier to review if this patch series have been broken
> up into 4 series (Generic content, Quark, VLV2, and UefiCpuPkg).
[Sean Brogan] - yes I agree.  
> 
> One of the goals of providing a complete implementation of the Firmware
> Management Protocol
> (FMP) in EDK II is to provide one implementation that we can all agree meets
> our collective platform requirements to reduce fragmentation of recovery and
> capsule update solutions.
> We can then focus review and validation efforts on this one solution.
[Sean Brogan] - I am working on code review comments.   Will try to respond to 
the individual patch emails as appropriate.  

> 
> I agree with your observation that the UEFI/PI specification contents for FMP,
> capsules, and recovery support a wide array of possible implementations.  The
> same could be said about the implementation of the PEI Core and DXE Core
> and many other components in the MdeModulePkg.  There are many ways to
> implement those components that meet the UEFI/PI Specification
> requirements.  However, we tend to see only one implementation in the EDK II
> and we update that implementation as needed to improve platform
> compatibility and accommodate new requirements.
> 
> Do you have additional requirements for the current patch that would help
> prevent the need for future fragmentation of this solution?
> 
> Can you elaborate on the dependencies you see across the tree?  I do not think
> that was the intent, and if there are ways to reduce those dependencies, I 
> want
> to help drive those changes.  It is my understanding that a platform that 
> wants
> to use these recovery and capsule update features would depend on the
> MdeModulePkg and the SecurityPkg.
> 
> Thanks,
> 
> Mike
> 
> 
> > -Original Message-
> > From: Sean Brogan [mailto:sean.bro...@microsoft.com]
> > Sent: Monday, October 10, 2016 2:22 PM
> > To: Yao, Jiewen <jiewen@intel.com>; edk2-devel@lists.01.org;
> > Kinney, Michael D <michael.d.kin...@intel.com>
> > Subject: RE: [edk2] [PATCH V2 00/50] Add capsule update and recovery
> sample.
> >
> > Jiewen, Mike, and the EDK2 list,
> >
> > This is not a feedback directly on this patch and the C code but more
> > on the overall feature of capsule update/recovery.
> >
> > You are implementing one specific way to do capsule update.  There are
> > infinite other implementations and my issue is how this implem

Re: [edk2] [PATCH V2 00/50] Add capsule update and recovery sample.

2016-10-10 Thread Sean Brogan
Jiewen, Mike, and the EDK2 list,

This is not a feedback directly on this patch and the C code but more on the 
overall feature of capsule update/recovery.  

You are implementing one specific way to do capsule update.  There are infinite 
other implementations and my issue is how this implementation is scattering 
thru the Industry standard (Mde*) packages.  I think our shared goal for 
Tianocore and edk2 is to create a well-designed, modular, flexible codebase for 
the UEFI FW producing industry.   As part of those goals I really want to see 
the standards based packages shrink to the minimum necessary to create a secure 
and robust core, and optional/advanced features should reside in other packages 
that a consumer can pick and choose from.  This set of patches is counter to 
that goal.  It contains over 50 patches, most are in the MdeModulePkg, and 
introduces new dependencies across the entire tree for this implementation 
choice.   

Thoughts?  


Thanks
Sean


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Yao, Jiewen
> Sent: Friday, September 30, 2016 5:32 AM
> To: Yao, Jiewen ; edk2-devel@lists.01.org
> Cc: Tian, Feng ; Gao, Liming ;
> Zeng, Star ; Kinney, Michael D
> ; Fan, Jeff ; Zhang, Chao
> B 
> Subject: Re: [edk2] [PATCH V2 00/50] Add capsule update and recovery
> sample.
> 
> Hi
> Here is V2 serial.
> I forgot to mention:
> 1) This series is also pushed to g...@github.com:jyao1/edk2.git.
> 2) Below is test I did for IniParsingLib.
> 2.1) Unit test:
>   { EFI_SUCCESS,   "[a]\nb=c\n" },
>   { EFI_SUCCESS,   "[_]\n_=0\n" },
>   { EFI_SUCCESS,   "[a]\nb=----
> \n" },
>   { EFI_INVALID_PARAMETER, "[]\n" },
>   { EFI_INVALID_PARAMETER, "[[\n" },
>   { EFI_INVALID_PARAMETER, "[[a]]\n" },
>   { EFI_INVALID_PARAMETER, "[\n" },
>   { EFI_INVALID_PARAMETER, "]\n" },
>   { EFI_INVALID_PARAMETER, "a\n" },
>   { EFI_INVALID_PARAMETER, "=\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb\n" },
>   { EFI_INVALID_PARAMETER, "[a]\n[=c" },
>   { EFI_INVALID_PARAMETER, "[a]\n=\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=#\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=;\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=~\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=!\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=@\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=$\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=%\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=^\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=&\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=*\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=(\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=)\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=-\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=+\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb={\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=}\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=[\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=]\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=;\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=:\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb='\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=\"\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=<\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=>\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=,\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=.\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=?\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=/\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=|\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=\\\n" },
>   { EFI_INVALID_PARAMETER, "[a]\nb=----
> C\n" },
> 2.2) Fuzzing test:
>   a) Randomize a block of valid data.
>   b) Randomize the length of valid data file.
>   c) Inject random char as data file.
> 
> Thank you
> Yao Jiewen
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Jiewen Yao
> > Sent: Friday, September 30, 2016 8:21 PM
> > To: edk2-devel@lists.01.org
> > Cc: Tian, Feng ; Gao, Liming
> > ; Zeng, Star ; Kinney,
> > Michael D ; Fan, Jeff
> > ; Zhang, Chao B 
> > Subject: [edk2] [PATCH V2 00/50] Add capsule update and recovery
> sample.
> >
> > ==Below is V2 description==
> > The V2 series patch incorporated the feedback for V1.
> >
> > There are 3 major updates.
> > 1) BDS is update to display a warning message if TEST key is used to
> > sign recovery image or capsule image.
> > So a production BIOS should always use its own production singing key
> > for the capsule image generation. A production BIOS should never use
> > test key.
> > 2) IniParsingLib is enhanced to do more sanity check for invalid
> > input. The detail data format is added in