public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [RFC 0/4] Add FmpDevicePkg
@ 2018-04-04 21:28 Michael D Kinney
  2018-04-04 21:28 ` [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs Michael D Kinney
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Michael D Kinney @ 2018-04-04 21:28 UTC (permalink / raw)
  To: edk2-devel; +Cc: Sean Brogan, Jiewen Yao

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

Based on content from the following branch:

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

Branch for review:

https://github.com/mdkinney/edk2/tree/Bug_922_FmpDevicePkg

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

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>

Kinney, Michael D (4):
  FmpDevicePkg: Add package, library classes, and PCDs
  FmpDevicePkg: Add library instances
  FmpDevicePkg: Add FmpDxe module
  FmpDevicePkg: Add DSC file to build all package components

 FmpDevicePkg/FmpDevicePkg.dec                      |  126 ++
 FmpDevicePkg/FmpDevicePkg.dsc                      |  119 ++
 FmpDevicePkg/FmpDevicePkg.uni                      |   75 +
 FmpDevicePkg/FmpDevicePkgExtra.uni                 |   18 +
 FmpDevicePkg/FmpDxe/FmpDxe.c                       | 1533 ++++++++++++++++++++
 FmpDevicePkg/FmpDxe/FmpDxe.inf                     |   96 ++
 FmpDevicePkg/FmpDxe/FmpDxe.uni                     |   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni                |   18 +
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf                  |   93 ++
 FmpDevicePkg/FmpDxe/VariableSupport.c              |  431 ++++++
 FmpDevicePkg/FmpDxe/VariableSupport.h              |  180 +++
 .../Include/Library/CapsuleUpdatePolicyLib.h       |  120 ++
 FmpDevicePkg/Include/Library/FmpDeviceLib.h        |  385 +++++
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h |  100 ++
 .../CapsuleUpdatePolicyLibNull.c                   |  136 ++
 .../CapsuleUpdatePolicyLibNull.inf                 |   45 +
 .../CapsuleUpdatePolicyLibNull.uni                 |   17 +
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c        |  395 +++++
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |   48 +
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |   18 +
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c    |  188 +++
 .../FmpPayloadHeaderLibV1.inf                      |   48 +
 .../FmpPayloadHeaderLibV1.uni                      |   21 +
 23 files changed, 4230 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dec
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc
 create mode 100644 FmpDevicePkg/FmpDevicePkg.uni
 create mode 100644 FmpDevicePkg/FmpDevicePkgExtra.uni
 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
 create mode 100644 FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpDeviceLib.h
 create mode 100644 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
 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

-- 
2.14.2.windows.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs
  2018-04-04 21:28 [RFC 0/4] Add FmpDevicePkg Michael D Kinney
@ 2018-04-04 21:28 ` Michael D Kinney
  2018-04-08  9:18   ` Zeng, Star
  2018-04-04 21:28 ` [RFC 2/4] FmpDevicePkg: Add library instances Michael D Kinney
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Michael D Kinney @ 2018-04-04 21:28 UTC (permalink / raw)
  To: edk2-devel; +Cc: Kinney, Michael D, Sean Brogan, Jiewen Yao

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch:

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

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

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

PCDs set per module
====================
* PcdFmpDeviceSystemResetRequired - Indicates if a full
  system reset is required before a firmware update to a
  firmware devices takes effect
* 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.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 FmpDevicePkg/FmpDevicePkg.dec                      | 126 +++++++
 FmpDevicePkg/FmpDevicePkg.uni                      |  75 ++++
 FmpDevicePkg/FmpDevicePkgExtra.uni                 |  18 +
 .../Include/Library/CapsuleUpdatePolicyLib.h       | 120 +++++++
 FmpDevicePkg/Include/Library/FmpDeviceLib.h        | 385 +++++++++++++++++++++
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h | 100 ++++++
 6 files changed, 824 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 0000000000..62fb98dbdb
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -0,0 +1,126 @@
+## @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.<BR>
+# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+# 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]
+  DEC_SPECIFICATION = 0x00010005
+  PACKAGE_NAME      = FmpDevicePkg
+  PACKAGE_UNI_FILE  = FmpDevicePkg.uni
+  PACKAGE_GUID      = 080b5b4f-27c6-11e8-84d1-f8597177a00a
+  PACKAGE_VERSION   = 0.1
+
+[Includes]
+  Include
+
+[LibraryClasses]
+  ##  @libraryclass  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.
+  FmpPayloadHeaderLib|Include/Library/FmpPayloadHeaderLib.h
+
+  ##  @libraryclass  Provides platform policy services used during a capsule
+  #                  update.
+  CapsuleUpdatePolicyLib|Include/Library/CapsuleUpdatePolicyLib.h
+
+  ##  @libraryclass  Provides firmware device specific services to support
+  #                  updates of a firmware image stored in a firmware device.
+  FmpDeviceLib|Include/Library/FmpDeviceLib.h
+
+[Guids]
+  ## Firmware Management Protocol Device Package Token Space GUID
+  gFmpDevicePkgTokenSpaceGuid = { 0x40b2d964, 0xfe11, 0x40dc, { 0x82, 0x83, 0x2e, 0xfb, 0xda, 0x29, 0x53, 0x56 } }
+
+[PcdsFeatureFlag]
+  ## Indicates if a full system reset is required before a firmware update to a
+  #  firmware devices takes effect.<BR><BR>
+  #   TRUE  - System reset is required.<BR>
+  #   FALSE - System reset is not required.<BR>
+  # @Prompt FMP Device System Reset Required.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired|TRUE|BOOLEAN|0x40000008
+
+[PcdsFixedAtBuild, PcdsPatchableInModule]
+  ## The color of the progress bar during a firmware update.  Each firmware
+  #  device can set its own color.  The default color is white.<BR><BR>
+  #  Bits  7..0  - Red<BR>
+  #  Bits 15..8  - Green<BR>
+  #  Bits 23..16 - Blue<BR>
+  # @Prompt Firmware Device Progress Bar Color.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor|0x00FFFFFF|UINT32|0x40000004
+
+  ## 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.  An ImageIdName string must be provided for each firmware device.
+  #  The default value is an empty string.
+  # @Prompt Firmware Device ImageIdName string.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L""|VOID*|0x40000007
+
+  ## 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.  This value is
+  #  only used if the firmware device does not provide a method to report the
+  #  lowest supported version value from the current firmware image and the
+  #  UEFI variable used to provide the lowest supported version value does not
+  #  exist.  The default value is 0.
+  # @Prompt Build Time Firmware Device Lowest Support Version.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion|0x0|UINT32|0x4000000C
+
+  ## The time in seconds to arm a watchdog timer during the update of a firmware
+  #  device.  The watchdog is re-armed each time the FmpDeviceLib calls the
+  #  Progress() function passed into FmpDeviceSetImage() function.  The
+  #  FmpDeviceLib calls Progress() to update the percent completion of a
+  #  firmware update.  If the watchdog timer expires, the system reboots.  A
+  #  value of 0 disables the watchdog timer.  The default value is 0 (watchdog
+  #  disabled).
+  # @Prompt Firmware Device Watchdog Time in Seconds.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds|0x0|UINT8|0x4000000D
+
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+  ## One or more PKCS7 certificates used to verify a firmware device capsule
+  #  update image.  Encoded using the Variable-Length Opaque Data format of RFC
+  #  4506 External Data Representation Standard (XDR).  The default value is
+  #  empty with 0 certificates.
+  # @Prompt One or more XDR encoded PKCS7 certificates used to verify firmware device capsule update images.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr|{0x0}|VOID*|0x4000000E
+
+  ## An event GUID that locks the firmware device when the event is signaled.
+  #  If this PCD is not a valid GUID value, then the firmware device is locked
+  #  when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  The
+  #  default value is empty, so by default the firmware device is locked at the
+  #  end of the DXE phase.
+  # @Prompt Firmware Device Lock Event GUID.
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid|{0}|VOID*|0x4000000F
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  FmpDevicePkgExtra.uni
diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni
new file mode 100644
index 0000000000..ba3f6d64c2
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.uni
@@ -0,0 +1,75 @@
+// /** @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) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials are licensed and made available under
+// the terms and conditions of the BSD License 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.
+//
+// **/
+
+#string STR_PACKAGE_ABSTRACT     #language en-US  "Firmware Management Protocol Software Development Kit"
+
+#string STR_PACKAGE_DESCRIPTION  #language en-US  "This package provides libraries that support the implementation of a module that produces the Firmware Management Protocol to support the update of a system firmware component."
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_PROMPT  #language en-US "FMP Device System Reset Required."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_HELP    #language en-US "Indicates if a full system reset is required before a firmware update to a firmware device takes effect.<BR><BR>\n"
+                                                                                                "TRUE  - System reset is required.<BR>\n"
+                                                                                                "FALSE - System reset is not required.<BR>"
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressColor_PROMPT  #language en-US "Firmware Device Progress Bar Color."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressColor_HELP    #language en-US "The color of the progress bar during a firmware update.  Each firmware"
+                                                                                          "device can set its own color.  The default color is white.<BR><BR>\n"
+                                                                                          "Bits  7..0  - Red<BR>\n"
+                                                                                          "Bits 15..8  - Green<BR>\n"
+                                                                                          "Bits 23..16 - Blue<BR>\n"
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageIdName_PROMPT  #language en-US "Firmware Device ImageIdName string."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageIdName_HELP    #language en-US "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.  An ImageIdName string must be provided for each firmware device."
+                                                                                        "The default value is an empty string."
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceBuildTimeLowestSupportedVersion_PROMPT  #language en-US "Build Time Firmware Device Lowest Support Version."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceBuildTimeLowestSupportedVersion_HELP    #language en-US "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.  This value is"
+                                                                                                            "only used if the firmware device does not provide a method to report the"
+                                                                                                            "lowest supported version value from the current firmware image and the"
+                                                                                                            "UEFI variable used to provide the lowest supported version value does not"
+                                                                                                            "exist.  The default value is 0."
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressWatchdogTimeInSeconds_PROMPT  #language en-US "Firmware Device Watchdog Time in Seconds."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressWatchdogTimeInSeconds_HELP    #language en-US "Indicates the time in seconds to arm a watchdog timer during the update of"
+                                                                                                          "a firmware device.  The watchdog is re-armed each time the FmpDeviceLib"
+                                                                                                          "calls the Progress() function passed into FmpDeviceSetImage() function."
+                                                                                                          "The FmpDeviceLib calls Progress() to update the percent completion of a"
+                                                                                                          "firmware update.  If the watchdog timer expires, the system reboots.  A"
+                                                                                                          "value of 0 disables the watchdog timer.  The default value is 0 (watchdog"
+                                                                                                          "disabled)."
+
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT  #language en-US "One or more XDR encoded PKCS7 certificates used to verify firmware device capsule update images"
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP    #language en-US "Provides one or more PKCS7 certificates used to verify a firmware device"
+                                                                                                 "capsule update image.  This PCD is encoded using the Variable-Length Opaque"
+                                                                                                 "Data format of RFC 4506 External Data Representation Standard (XDR)."
+                                                                                                 "The default value is empty with 0 certificates."
+
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_PROMPT  #language en-US "Firmware Device Lock Event GUID."
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_HELP    #language en-US "An event GUID that locks the firmware device when the event is signaled."
+                                                                                            "If this PCD is not a valid GUID value, then the firmware device is locked"
+                                                                                            "when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  The"
+                                                                                            "default value is empty, so by default the firmware device is locked at the"
+                                                                                            "end of the DXE phase."
+
+
diff --git a/FmpDevicePkg/FmpDevicePkgExtra.uni b/FmpDevicePkg/FmpDevicePkgExtra.uni
new file mode 100644
index 0000000000..fe49e8cd6c
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkgExtra.uni
@@ -0,0 +1,18 @@
+// /** @file
+// Firmware Management Protocol Device Package Localized Strings and Content.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials are licensed and made available under
+// the terms and conditions of the BSD License 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.
+//
+// **/
+
+#string STR_PROPERTIES_PACKAGE_NAME
+#language en-US
+"Firmware Management Protocol Device package"
diff --git a/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h b/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
new file mode 100644
index 0000000000..b38f212859
--- /dev/null
+++ b/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
@@ -0,0 +1,120 @@
+/**  @file
+  Provides platform policy services used during a capsule update.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef __CAPSULE_UPDATE_POLICY_LIB__
+#define __CAPSULE_UPDATE_POLICY_LIB__
+
+/**
+  Determine if the system power state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system power state supports a capsule
+                    update.  Returns FALSE if system power state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System power state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemPower (
+  OUT BOOLEAN  *Good
+  );
+
+/**
+  Determines if the system thermal state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system thermal state supports a capsule
+                    update.  Returns FALSE if system thermal state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System thermal state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemThermal (
+  IN OUT BOOLEAN  *Good
+  );
+
+/**
+  Determines if the system environment state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system environment state supports a capsule
+                    update.  Returns FALSE if system environment state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System environment state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemEnvironment (
+  IN OUT BOOLEAN  *Good
+  );
+
+/**
+  Determines if the Lowest Supported Version checks should be performed.  The
+  expected result from this function is TRUE.  A platform can choose to return
+  FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a
+  version below the current Lowest Supported Version.
+
+  @retval TRUE   Perform Lowest Support Version check.
+  @retval FALSE  Do not perform Lowest Support Version check.
+
+**/
+BOOLEAN
+EFIAPI
+CheckLowestSupportedVersion (
+  VOID
+  );
+
+/**
+  Determines if the FMP device should be locked when the event specified by
+  PcdFmpDeviceLockEventGuid is signaled. The expected result from this function
+  is TRUE so the FMP device is always locked.  A platform can choose to return
+  FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.
+
+  @retval TRUE   Perform Lowest Support Version check.
+  @retval FALSE  Do not perform Lowest Support Version check.
+
+**/
+BOOLEAN
+EFIAPI
+LockFmpDeviceAtLockEventGuid (
+  VOID
+  );
+
+#endif
diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
new file mode 100644
index 0000000000..cdbe980183
--- /dev/null
+++ b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
@@ -0,0 +1,385 @@
+/**  @file
+  Provides firmware device specific services to support updates of a firmware
+  image stored in a firmware device.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef __FMP_DEVICE_LIB__
+#define __FMP_DEVICE_LIB__
+
+#include <Protocol/FirmwareManagement.h>
+
+/**
+  Callback function that installs a Firmware Management Protocol instance onto
+  a handle.
+
+  @param[in]  Handle  The device handle to install a Firmware Management
+                      Protocol instance.
+
+  @retval  EFI_SUCCESS            A Firmware Management Protocol instance was
+                                  installed onto Handle.
+  @retval  EFI_INVALID_PARAMETER  Handle is invalid
+  @retval  other                  A Firmware Management Protocol instance could
+                                  not be installed onto Handle.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER)(
+  IN  EFI_HANDLE      Handle
+  );
+
+/**
+  Provide a function to install the Firmware Management Protocol instance onto a
+  device handle when the device is managed by a driver that follows the UEFI
+  Driver Model.  If the device is not managed by a driver that follows the UEFI
+  Driver Model, then EFI_UNSUPPORTED is returned.
+
+  @param[in] FmpInstaller  Function that installs the Firmware Management
+                           Protocol.
+
+  @retval EFI_SUCCESS      The device is managed by a driver that follows the
+                           UEFI Driver Model.  FmpInstaller must be called on
+                           each Driver Binding Start().
+  @retval EFI_UNSUPPORTED  The device is not managed by a driver that follows
+                           the UEFI Driver Model.
+  @retval other            The Firmware Management Protocol for this firmware
+                           device is not installed.  The firmware device is
+                           still locked using FmpDeviceLock().
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterFmpInstaller (
+  IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER  FmpInstaller
+  );
+
+/**
+  Returns the size, in bytes, of the firmware image currently stored in the
+  firmware device.  This function is used to by the GetImage() and
+  GetImageInfo() services of the Firmware Management Protocol.  If the image
+  size can not be determined from the firmware device, then 0 must be returned.
+
+  @return  The size, in bytes, of the firmware image current stored in the
+           firmware device.  Return 0 if the size can not be determined.
+
+**/
+UINTN
+EFIAPI
+FmpDeviceGetSize (
+  VOID
+  );
+
+/**
+  Returns the GUID value used to fill in the ImageTypeId field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  If EFI_UNSUPPORTED is returned,
+  then the ImageTypeId field is set to gEfiCallerIdGuid.  If EFI_SUCCESS is
+  returned, then ImageTypeId is set to the Guid returned from this function.
+
+  @param[out] Guid  Double pointer to a GUID value that is updated to point to
+                    to a GUID value.  The GUID value is not allocated and must
+                    not be modified or freed by the caller.
+
+  @retval EFI_SUCCESS      EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set
+                           to the returned Guid value.
+  @retval EFI_UNSUPPORTED  EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set
+                           to gEfiCallerIdGuid.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetImageTypeIdGuidPtr (
+  OUT EFI_GUID  **Guid
+  );
+
+/**
+  Returns values used to fill in the AttributesSupported and AttributesSettings
+  fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the
+  GetImageInfo() service of the Firmware Management Protocol.  The following
+  bit values from the Firmware Management Protocol may be combined:
+    IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
+    IMAGE_ATTRIBUTE_RESET_REQUIRED
+    IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
+    IMAGE_ATTRIBUTE_IN_USE
+    IMAGE_ATTRIBUTE_UEFI_IMAGE
+
+  @param[out] Supported  Attributes supported by this firmware device.
+  @param[out] Setting    Attributes settings for this firmware device.
+
+**/
+VOID
+EFIAPI
+FmpDeviceGetAttributes (
+  IN OUT UINT64  *Supported,
+  IN OUT UINT64  *Setting
+  );
+
+/**
+  Returns the 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.  If EFI_SUCCESS is returned, then
+  the firmware device supports a method to report the LowestSupportedVersion
+  value from the currently stored firmware image.  If the value can not be
+  reported for the firmware image currently stored in the firmware device, then
+  EFI_UNSUPPORTED must be returned.  EFI_DEVICE_ERROR is returned if an error
+  occurs attempting to retrieve the LowestSupportedVersion value for the
+  currently stored firmware image.
+
+  @note It is recommended that all firmware devices support a method to report
+        the LowestSupportedVersion value from the currently stored firmware
+        image.
+
+  @param[out] LowestSupportedVersion  LowestSupportedVersion value retrieved
+                                      from the currently stored firmware image.
+
+  @retval EFI_SUCCESS       The lowest supported version of currently stored
+                            firmware image was returned in LowestSupportedVersion.
+  @retval EFI_UNSUPPORTED   The firmware device does not support a method to
+                            report the lowest supported version of the currently
+                            stored firmware image.
+  @retval EFI_DEVICE_ERROR  An error occurred attempting to retrieve the lowest
+                            supported version of the currently stored firmware
+                            image.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetLowestSupportedVersion (
+  OUT UINT32  *LowestSupportedVersion
+  );
+
+/**
+  Returns the Null-terminated Unicode string that is used to fill in the
+  VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is
+  returned by the GetImageInfo() service of the Firmware Management Protocol.
+  If the VersionName string can not be reported by the firmware image currently
+  stored in the firmware device, then NULL must be returned.  Otherwise,
+  a Null-terminated Unicode string containing the VersioName is returned.
+  The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().
+
+  @note It is recommended that all firmware devices support a method to report
+        the VersionName string from the currently stored firmware image.
+
+  @retval NULL       The firmware device does not support a method to report the
+                     version string for the currently stored firmware image.
+  @retval NULL       An error occurred attempting to retrieve the version string
+                     for the currently stored firmware image.
+  @retval non NULL   A pointer to an allocated buffer containing the version
+                     string for the currently stored firmware image.
+
+**/
+CHAR16 *
+EFIAPI
+FmpDeviceGetVersionString (
+  VOID
+  );
+
+/**
+  Returns the value used to fill in the Version field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  If EFI_SUCCESS is returned, then
+  the firmware device supports a method to report the Version value from the
+  currently stored firmware image.  If the value can not be reported for the
+  firmware image currently stored in the firmware device, then EFI_UNSUPPORTED
+  must be returned.  EFI_DEVICE_ERROR is returned if an error occurs attempting
+  to retrieve the LowestSupportedVersion value for the currently stored firmware
+  image.
+
+  @note It is recommended that all firmware devices support a method to report
+        the Version value from the currently stored firmware image.
+
+  @param[out] Version  The version value retrieved from the currently stored
+                       firmware image.
+
+  @retval EFI_SUCCESS       The version of currently stored firmware image was
+                            returned in Version.
+  @retval EFI_UNSUPPORTED   The firmware device does not support a method to
+                            report the version of the currently stored firmware
+                            image.
+  @retval EFI_DEVICE_ERROR  An error occurred attempting to retrieve the version
+                            of the currently stored firmware image.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetVersion (
+  OUT UINT32  *Version
+  );
+
+/**
+  Returns a copy of the firmware image currently stored in the firmware device.
+
+  @note It is recommended that all firmware devices support a method to retrieve
+        a copy currently stored firmware image.  This can be used to support
+        features such as recovery and rollback.
+
+  @param[out]    Image      Pointer to a caller allocated buffer where the
+                            currently stored firmware image is copied to.
+  @param[in out] ImageSize  Pointer the size, in bytes, of the Image buffer.
+                            On return, points to the size, in bytes, of firmware
+                            image currently stored in the firmware device.
+
+  @retval EFI_SUCCESS            Image contains a copy of the firmware image
+                                 currently stored in the firmware device, and
+                                 ImageSize contains the size, in bytes, of the
+                                 firmware image currently stored in the
+                                 firmware device.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small
+                                 to hold the firmware image currently stored in
+                                 the firmware device. The buffer size required
+                                 is returned in ImageSize.
+  @retval EFI_INVALID_PARAMETER  The Image is NULL.
+  @retval EFI_INVALID_PARAMETER  The ImageSize is NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_DEVICE_ERROR       An error occurred attempting to retrieve the
+                                 firmware image currently stored in the firmware
+                                 device.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetImage (
+  IN OUT    VOID   *Image,
+  IN IN OUT UINTN  *ImageSize
+  );
+
+/**
+  Checks if a new firmware image is valid for the firmware device.  This
+  function allows firmware update operation to validate the firmware image
+  before FmpDeviceSetImage() is called.
+
+  @param[in]  Image           Points to a new firmware image.
+  @param[in]  ImageSize       Size, in bytes, of a new firmware image.
+  @param[out] ImageUpdatable  Indicates if a new firmware image is valid for
+                              a firmware update to the firmware device.  The
+                              following values from the Firmware Management
+                              Protocol are supported:
+                                IMAGE_UPDATABLE_VALID
+                                IMAGE_UPDATABLE_INVALID
+                                IMAGE_UPDATABLE_INVALID_TYPE
+                                IMAGE_UPDATABLE_INVALID_OLD
+                                IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+
+  @retval EFI_SUCCESS            The image was successfully checked.  Additional
+                                 status information is returned in
+                                 ImageUpdateable.
+  @retval EFI_INVALID_PARAMETER  Image is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageUpdateable is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceCheckImage (
+  IN  CONST VOID  *Image,
+  IN  UINTN       ImageSize,
+  OUT UINT32      *ImageUpdateable
+  );
+
+/**
+  Updates a firmware device with a new firmware image.  This function returns
+  EFI_UNSUPPORTED if the firmware image is not updatable.  If the firmware image
+  is updatable, the function should perform the following minimal validations
+  before proceeding to do the firmware image update.
+    - Validate that the image is a supported image for this firmware device.
+      Return EFI_ABORTED if the image is not supported.  Additional details
+      on why the image is not a supported image may be returned in AbortReason.
+    - Validate the data from VendorCode if is not NULL.  Firmware image
+      validation must be performed before VendorCode data validation.
+      VendorCode data is ignored or considered invalid if image validation
+      fails.  Return EFI_ABORTED if the VendorCode data is invalid.
+
+  VendorCode enables vendor to implement vendor-specific firmware image update
+  policy.  Null if the caller did not specify the policy or use the default
+  policy.  As an example, vendor can implement a policy to allow an option to
+  force a firmware image update when the abort reason is due to the new firmware
+  image version is older than the current firmware image version or bad image
+  checksum.  Sensitive operations such as those wiping the entire firmware image
+  and render the device to be non-functional should be encoded in the image
+  itself rather than passed with the VendorCode.  AbortReason enables vendor to
+  have the option to provide a more detailed description of the abort reason to
+  the caller.
+
+  @param[in]  Image             Points to the new firmware image.
+  @param[in]  ImageSize         Size, in bytes, of the new firmware image.
+  @param[in]  VendorCode        This enables vendor to implement vendor-specific
+                                firmware image update policy.  NULL indicates
+                                the caller did not specify the policy or use the
+                                default policy.
+  @param[in]  Progress          A function used to report the progress of
+                                updating the firmware device with the new
+                                firmware image.
+  @param[in]  CapsuleFwVersion  The version of the new firmware image from the
+                                update capsule that provided the new firmware
+                                image.
+  @param[out] AbortReason       A pointer to a pointer to a Null-terminated
+                                Unicode string providing more details on an
+                                aborted operation. The buffer is allocated by
+                                this function with
+                                EFI_BOOT_SERVICES.AllocatePool().  It is the
+                                caller's responsibility to free this buffer with
+                                EFI_BOOT_SERVICES.FreePool().
+
+  @retval EFI_SUCCESS            The firmware device was successfully updated
+                                 with the new firmware image.
+  @retval EFI_ABORTED            The operation is aborted.  Additional details
+                                 are provided in AbortReason.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceSetImage (
+  IN  CONST VOID                                     *Image,
+  IN  UINTN                                          ImageSize,
+  IN  CONST VOID                                     *VendorCode,       OPTIONAL
+  IN  EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,          OPTIONAL
+  IN  UINT32                                         CapsuleFwVersion,
+  OUT CHAR16                                         **AbortReason
+  );
+
+/**
+  Lock the firmware device that contains a firmware image.  Once a firmware
+  device is locked, any attempts to modify the firmware image contents in the
+  firmware device must fail.
+
+  @note It is recommended that all firmware devices support a lock method to
+        prevent modifications to a stored firmware image.
+
+  @note A firmware device lock mechanism is typically only cleared by a full
+        system reset (not just sleep state/low power mode).
+
+  @retval  EFI_SUCCESS      The firmware device was locked.
+  @retval  EFI_UNSUPPORTED  The firmware device does not support locking
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceLock (
+  VOID
+  );
+
+#endif
diff --git a/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h b/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
new file mode 100644
index 0000000000..cb5622e9ce
--- /dev/null
+++ b/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
@@ -0,0 +1,100 @@
+/**  @file
+  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.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef _FMP_PAYLOAD_HEADER_LIB_H__
+#define _FMP_PAYLOAD_HEADER_LIB_H__
+
+/**
+  Returns the FMP Payload Header size in bytes.
+
+  @param[in]  Header          FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize  Size of FMP payload
+  @param[out] Size            The size, in bytes, of the FMP Payload Header.
+
+  @retval EFI_SUCCESS            The firmware version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  Size is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderSize (
+  IN  CONST VOID   *Header,
+  IN  CONST UINTN  FmpPayloadSize,
+  OUT UINT32       *Size
+  );
+
+/**
+  Returns the version described in the FMP Payload Header.
+
+  @param[in]  Header          FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize  Size of FMP payload
+  @param[out] Version         The firmware version described in the FMP Payload
+                              Header.
+
+  @retval EFI_SUCCESS            The firmware version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  Version is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderVersion (
+  IN  CONST VOID   *Header,
+  IN  CONST UINTN  FmpPayloadSize,
+  OUT UINT32       *Version
+  );
+
+/**
+  Returns the lowest supported version described in the FMP Payload Header.
+
+  @param[in]  Header                  FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize          Size of FMP payload
+  @param[out] LowestSupportedVersion  The lowest supported version described in
+                                      the FMP Payload Header.
+
+  @retval EFI_SUCCESS            The lowest support version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  LowestSupportedVersion is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderLowestSupportedVersion (
+  IN     CONST VOID   *Header,
+  IN     CONST UINTN  FmpPayloadSize,
+  IN OUT UINT32       *LowestSupportedVersion
+  );
+
+#endif
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC 2/4] FmpDevicePkg: Add library instances
  2018-04-04 21:28 [RFC 0/4] Add FmpDevicePkg Michael D Kinney
  2018-04-04 21:28 ` [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs Michael D Kinney
@ 2018-04-04 21:28 ` Michael D Kinney
  2018-04-04 21:28 ` [RFC 3/4] FmpDevicePkg: Add FmpDxe module Michael D Kinney
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Michael D Kinney @ 2018-04-04 21:28 UTC (permalink / raw)
  To: edk2-devel; +Cc: Kinney, Michael D, Sean Brogan, Jiewen Yao

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch:

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

Add library instances for FmpDeviceLib, CapsuleUpdatePolicyLib,
and FmpPayloadHeaderLib.

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

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../CapsuleUpdatePolicyLibNull.c                   | 136 +++++++
 .../CapsuleUpdatePolicyLibNull.inf                 |  45 +++
 .../CapsuleUpdatePolicyLibNull.uni                 |  17 +
 .../Library/FmpDeviceLibNull/FmpDeviceLib.c        | 395 +++++++++++++++++++++
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |  48 +++
 .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |  18 +
 .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c    | 188 ++++++++++
 .../FmpPayloadHeaderLibV1.inf                      |  48 +++
 .../FmpPayloadHeaderLibV1.uni                      |  21 ++
 9 files changed, 916 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 0000000000..943fe372cb
--- /dev/null
+++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c
@@ -0,0 +1,136 @@
+/**  @file
+  Provides platform policy services used during a capsule update.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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 <PiDxe.h>
+#include <Library/CapsuleUpdatePolicyLib.h>
+
+/**
+  Determine if the system power state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system power state supports a capsule
+                    update.  Returns FALSE if system power state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System power state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemPower (
+  OUT BOOLEAN  *Good
+  )
+{
+  *Good = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  Determines if the system thermal state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system thermal state supports a capsule
+                    update.  Returns FALSE if system thermal state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System thermal state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemThermal (
+  IN OUT BOOLEAN  *Good
+  )
+{
+  *Good = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  Determines if the system environment state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system environment state supports a capsule
+                    update.  Returns FALSE if system environment state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System environment state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemEnvironment (
+  IN OUT BOOLEAN  *Good
+  )
+{
+  *Good = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  Determines if the Lowest Supported Version checks should be performed.  The
+  expected result from this function is TRUE.  A platform can choose to return
+  FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a
+  version below the current Lowest Supported Version.
+
+  @retval TRUE   Perform Lowest Support Version check.
+  @retval FALSE  Do not perform Lowest Support Version check.
+
+**/
+BOOLEAN
+EFIAPI
+CheckLowestSupportedVersion (
+  VOID
+  )
+{
+  return TRUE;
+}
+
+/**
+  Determines if the FMP device should be locked when the event specified by
+  PcdFmpDeviceLockEventGuid is signaled. The expected result from this function
+  is TRUE so the FMP device is always locked.  A platform can choose to return
+  FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.
+
+  @retval TRUE   Perform Lowest Support Version check.
+  @retval FALSE  Do not perform Lowest Support Version check.
+
+**/
+BOOLEAN
+EFIAPI
+LockFmpDeviceAtLockEventGuid (
+  VOID
+  )
+{
+  return TRUE;
+}
diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
new file mode 100644
index 0000000000..c7c669e3e0
--- /dev/null
+++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
@@ -0,0 +1,45 @@
+## @file
+#  Provides platform policy services used during a capsule update.
+#
+#  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  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]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = CapsuleUpdatePolicyLibNull
+  MODULE_UNI_FILE = CapsuleUpdatePolicyLibNull.uni
+  FILE_GUID       = 8E36EC87-440D-44F9-AB2F-AA806C61A1A6
+  MODULE_TYPE     = BASE
+  VERSION_STRING  = 1.0
+  LIBRARY_CLASS   = CapsuleUpdatePolicyLib
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF ARM AARCH64
+#
+
+[Sources]
+  CapsuleUpdatePolicyLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  FmpDevicePkg/FmpDevicePkg.dec
diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.uni b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.uni
new file mode 100644
index 0000000000..0f16fea391
--- /dev/null
+++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.uni
@@ -0,0 +1,17 @@
+// /** @file
+// Provides platform policy services used during a capsule update.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// 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.
+//
+// **/
+
+#string STR_MODULE_ABSTRACT     #language en-US  "Provides platform policy services used during a capsule update."
+
+#string STR_MODULE_DESCRIPTION  #language en-US  "Provides platform policy services used during a capsule update."
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
new file mode 100644
index 0000000000..75f9638459
--- /dev/null
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
@@ -0,0 +1,395 @@
+/**  @file
+  Provides firmware device specific services to support updates of a firmware
+  image stored in a firmware device.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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 <PiDxe.h>
+#include <Library/FmpDeviceLib.h>
+
+/**
+  Provide a function to install the Firmware Management Protocol instance onto a
+  device handle when the device is managed by a driver that follows the UEFI
+  Driver Model.  If the device is not managed by a driver that follows the UEFI
+  Driver Model, then EFI_UNSUPPORTED is returned.
+
+  @param[in] FmpInstaller  Function that installs the Firmware Management
+                           Protocol.
+
+  @retval EFI_SUCCESS      The device is managed by a driver that follows the
+                           UEFI Driver Model.  FmpInstaller must be called on
+                           each Driver Binding Start().
+  @retval EFI_UNSUPPORTED  The device is not managed by a driver that follows
+                           the UEFI Driver Model.
+  @retval other            The Firmware Management Protocol for this firmware
+                           device is not installed.  The firmware device is
+                           still locked using FmpDeviceLock().
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterFmpInstaller (
+  IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER  Function
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Returns the size, in bytes, of the firmware image currently stored in the
+  firmware device.  This function is used to by the GetImage() and
+  GetImageInfo() services of the Firmware Management Protocol.  If the image
+  size can not be determined from the firmware device, then 0 must be returned.
+
+  @return  The size, in bytes, of the firmware image current stored in the
+           firmware device.  Return 0 if the size can not be determined.
+
+**/
+UINTN
+EFIAPI
+FmpDeviceGetSize (
+  VOID
+  )
+{
+  return 0;
+}
+
+/**
+  Returns the GUID value used to fill in the ImageTypeId field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  If EFI_UNSUPPORTED is returned,
+  then the ImageTypeId field is set to gEfiCallerIdGuid.  If EFI_SUCCESS is
+  returned, then ImageTypeId is set to the Guid returned from this function.
+
+  @param[out] Guid  Double pointer to a GUID value that is updated to point to
+                    to a GUID value.  The GUID value is not allocated and must
+                    not be modified or freed by the caller.
+
+  @retval EFI_SUCCESS      EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set
+                           to the returned Guid value.
+  @retval EFI_UNSUPPORTED  EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set
+                           to gEfiCallerIdGuid.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetImageTypeIdGuidPtr (
+  OUT EFI_GUID  **Guid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Returns values used to fill in the AttributesSupported and AttributesSettings
+  fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the
+  GetImageInfo() service of the Firmware Management Protocol.  The following
+  bit values from the Firmware Management Protocol may be combined:
+    IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
+    IMAGE_ATTRIBUTE_RESET_REQUIRED
+    IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
+    IMAGE_ATTRIBUTE_IN_USE
+    IMAGE_ATTRIBUTE_UEFI_IMAGE
+
+  @param[out] Supported  Attributes supported by this firmware device.
+  @param[out] Setting    Attributes settings for this firmware device.
+
+**/
+VOID
+EFIAPI
+FmpDeviceGetAttributes (
+  IN OUT UINT64  *Supported,
+  IN OUT UINT64  *Setting
+  )
+{
+  *Supported = 0;
+  *Setting   = 0;
+}
+
+/**
+  Returns the 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.  If EFI_SUCCESS is returned, then
+  the firmware device supports a method to report the LowestSupportedVersion
+  value from the currently stored firmware image.  If the value can not be
+  reported for the firmware image currently stored in the firmware device, then
+  EFI_UNSUPPORTED must be returned.  EFI_DEVICE_ERROR is returned if an error
+  occurs attempting to retrieve the LowestSupportedVersion value for the
+  currently stored firmware image.
+
+  @note It is recommended that all firmware devices support a method to report
+        the LowestSupportedVersion value from the currently stored firmware
+        image.
+
+  @param[out] LowestSupportedVersion  LowestSupportedVersion value retrieved
+                                      from the currently stored firmware image.
+
+  @retval EFI_SUCCESS       The lowest supported version of currently stored
+                            firmware image was returned in LowestSupportedVersion.
+  @retval EFI_UNSUPPORTED   The firmware device does not support a method to
+                            report the lowest supported version of the currently
+                            stored firmware image.
+  @retval EFI_DEVICE_ERROR  An error occurred attempting to retrieve the lowest
+                            supported version of the currently stored firmware
+                            image.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetLowestSupportedVersion (
+  OUT UINT32  *LowestSupportedVersion
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Returns the Null-terminated Unicode string that is used to fill in the
+  VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is
+  returned by the GetImageInfo() service of the Firmware Management Protocol.
+  If the VersionName string can not be reported by the firmware image currently
+  stored in the firmware device, then NULL must be returned.  Otherwise,
+  a Null-terminated Unicode string containing the VersioName is returned.
+  The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().
+
+  @note It is recommended that all firmware devices support a method to report
+        the VersionName string from the currently stored firmware image.
+
+  @retval NULL       The firmware device does not support a method to report the
+                     version string for the currently stored firmware image.
+  @retval NULL       An error occurred attempting to retrieve the version string
+                     for the currently stored firmware image.
+  @retval non NULL   A pointer to an allocated buffer containing the version
+                     string for the currently stored firmware image.
+
+**/
+CHAR16 *
+EFIAPI
+FmpDeviceGetVersionString (
+  VOID
+  )
+{
+  return NULL;
+}
+
+/**
+  Returns the value used to fill in the Version field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  If EFI_SUCCESS is returned, then
+  the firmware device supports a method to report the Version value from the
+  currently stored firmware image.  If the value can not be reported for the
+  firmware image currently stored in the firmware device, then EFI_UNSUPPORTED
+  must be returned.  EFI_DEVICE_ERROR is returned if an error occurs attempting
+  to retrieve the LowestSupportedVersion value for the currently stored firmware
+  image.
+
+  @note It is recommended that all firmware devices support a method to report
+        the Version value from the currently stored firmware image.
+
+  @param[out] Version  The version value retrieved from the currently stored
+                       firmware image.
+
+  @retval EFI_SUCCESS       The version of currently stored firmware image was
+                            returned in Version.
+  @retval EFI_UNSUPPORTED   The firmware device does not support a method to
+                            report the version of the currently stored firmware
+                            image.
+  @retval EFI_DEVICE_ERROR  An error occurred attempting to retrieve the version
+                            of the currently stored firmware image.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetVersion (
+  OUT UINT32  *Version
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Returns a copy of the firmware image currently stored in the firmware device.
+
+  @note It is recommended that all firmware devices support a method to retrieve
+        a copy currently stored firmware image.  This can be used to support
+        features such as recovery and rollback.
+
+  @param[out]    Image      Pointer to a caller allocated buffer where the
+                            currently stored firmware image is copied to.
+  @param[in out] ImageSize  Pointer the size, in bytes, of the Image buffer.
+                            On return, points to the size, in bytes, of firmware
+                            image currently stored in the firmware device.
+
+  @retval EFI_SUCCESS            Image contains a copy of the firmware image
+                                 currently stored in the firmware device, and
+                                 ImageSize contains the size, in bytes, of the
+                                 firmware image currently stored in the
+                                 firmware device.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small
+                                 to hold the firmware image currently stored in
+                                 the firmware device. The buffer size required
+                                 is returned in ImageSize.
+  @retval EFI_INVALID_PARAMETER  The Image is NULL.
+  @retval EFI_INVALID_PARAMETER  The ImageSize is NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_DEVICE_ERROR       An error occurred attempting to retrieve the
+                                 firmware image currently stored in the firmware
+                                 device.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetImage (
+  IN OUT    VOID   *Image,
+  IN IN OUT UINTN  *ImageSize
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Checks if a new firmware image is valid for the firmware device.  This
+  function allows firmware update operation to validate the firmware image
+  before FmpDeviceSetImage() is called.
+
+  @param[in]  Image           Points to a new firmware image.
+  @param[in]  ImageSize       Size, in bytes, of a new firmware image.
+  @param[out] ImageUpdatable  Indicates if a new firmware image is valid for
+                              a firmware update to the firmware device.  The
+                              following values from the Firmware Management
+                              Protocol are supported:
+                                IMAGE_UPDATABLE_VALID
+                                IMAGE_UPDATABLE_INVALID
+                                IMAGE_UPDATABLE_INVALID_TYPE
+                                IMAGE_UPDATABLE_INVALID_OLD
+                                IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+
+  @retval EFI_SUCCESS            The image was successfully checked.  Additional
+                                 status information is returned in
+                                 ImageUpdateable.
+  @retval EFI_INVALID_PARAMETER  Image is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageUpdateable is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceCheckImage (
+  IN  CONST VOID  *Image,
+  IN  UINTN       ImageSize,
+  OUT UINT32      *ImageUpdateable
+  )
+{
+  return EFI_SUCCESS;
+}
+
+/**
+  Updates a firmware device with a new firmware image.  This function returns
+  EFI_UNSUPPORTED if the firmware image is not updatable.  If the firmware image
+  is updatable, the function should perform the following minimal validations
+  before proceeding to do the firmware image update.
+    - Validate that the image is a supported image for this firmware device.
+      Return EFI_ABORTED if the image is not supported.  Additional details
+      on why the image is not a supported image may be returned in AbortReason.
+    - Validate the data from VendorCode if is not NULL.  Firmware image
+      validation must be performed before VendorCode data validation.
+      VendorCode data is ignored or considered invalid if image validation
+      fails.  Return EFI_ABORTED if the VendorCode data is invalid.
+
+  VendorCode enables vendor to implement vendor-specific firmware image update
+  policy.  Null if the caller did not specify the policy or use the default
+  policy.  As an example, vendor can implement a policy to allow an option to
+  force a firmware image update when the abort reason is due to the new firmware
+  image version is older than the current firmware image version or bad image
+  checksum.  Sensitive operations such as those wiping the entire firmware image
+  and render the device to be non-functional should be encoded in the image
+  itself rather than passed with the VendorCode.  AbortReason enables vendor to
+  have the option to provide a more detailed description of the abort reason to
+  the caller.
+
+  @param[in]  Image             Points to the new firmware image.
+  @param[in]  ImageSize         Size, in bytes, of the new firmware image.
+  @param[in]  VendorCode        This enables vendor to implement vendor-specific
+                                firmware image update policy.  NULL indicates
+                                the caller did not specify the policy or use the
+                                default policy.
+  @param[in]  Progress          A function used to report the progress of
+                                updating the firmware device with the new
+                                firmware image.
+  @param[in]  CapsuleFwVersion  The version of the new firmware image from the
+                                update capsule that provided the new firmware
+                                image.
+  @param[out] AbortReason       A pointer to a pointer to a Null-terminated
+                                Unicode string providing more details on an
+                                aborted operation. The buffer is allocated by
+                                this function with
+                                EFI_BOOT_SERVICES.AllocatePool().  It is the
+                                caller's responsibility to free this buffer with
+                                EFI_BOOT_SERVICES.FreePool().
+
+  @retval EFI_SUCCESS            The firmware device was successfully updated
+                                 with the new firmware image.
+  @retval EFI_ABORTED            The operation is aborted.  Additional details
+                                 are provided in AbortReason.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceSetImage (
+  IN  CONST VOID                                     *Image,
+  IN  UINTN                                          ImageSize,
+  IN  CONST VOID                                     *VendorCode,       OPTIONAL
+  IN  EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,          OPTIONAL
+  IN  UINT32                                         CapsuleFwVersion,
+  OUT CHAR16                                         **AbortReason
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Lock the firmware device that contains a firmware image.  Once a firmware
+  device is locked, any attempts to modify the firmware image contents in the
+  firmware device must fail.
+
+  @note It is recommended that all firmware devices support a lock method to
+        prevent modifications to a stored firmware image.
+
+  @note A firmware device lock mechanism is typically only cleared by a full
+        system reset (not just sleep state/low power mode).
+
+  @retval  EFI_SUCCESS      The firmware device was locked.
+  @retval  EFI_UNSUPPORTED  The firmware device does not support locking
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceLock (
+  VOID
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
new file mode 100644
index 0000000000..d51f69d0b9
--- /dev/null
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
@@ -0,0 +1,48 @@
+## @file
+#  Provides firmware device specific services to support updates of a firmware
+#  image stored in a firmware device.
+#
+#  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  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]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = FmpDeviceLibNull
+  MODULE_UNI_FILE = FmpDeviceLibNull.uni
+  FILE_GUID       = 8507642B-AE92-4664-B713-807F7774A96D
+  MODULE_TYPE     = DXE_DRIVER
+  VERSION_STRING  = 1.0
+  LIBRARY_CLASS   = FmpDeviceLib|DXE_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF ARM AARCH64
+#
+
+[Sources]
+  FmpDeviceLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  FmpDevicePkg/FmpDevicePkg.dec
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni
new file mode 100644
index 0000000000..bedb38e9cf
--- /dev/null
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.uni
@@ -0,0 +1,18 @@
+// /** @file
+// Provides firmware device specific services to support updates of a firmware
+// image stored in a firmware device.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// 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.
+//
+// **/
+
+#string STR_MODULE_ABSTRACT     #language en-US  "Provides firmware device specific services to support updates of a firmware image stored in a firmware device."
+
+#string STR_MODULE_DESCRIPTION  #language en-US  "Provides firmware device specific services to support updates of a firmware image stored in a firmware device."
diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c
new file mode 100644
index 0000000000..5f08e8b0fd
--- /dev/null
+++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c
@@ -0,0 +1,188 @@
+/**  @file
+  Provides services to retrieve values from Version 1 of a capsule's FMP Payload
+  Header. The FMP Payload Header structure is not defined 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.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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 <PiDxe.h>
+#include <Library/FmpPayloadHeaderLib.h>
+
+///
+/// Define FMP Payload Header structure here so it is not public
+///
+
+#pragma pack(1)
+
+typedef struct {
+  UINT32  Signature;
+  UINT32  HeaderSize;
+  UINT32  FwVersion;
+  UINT32  LowestSupportedVersion;
+} FMP_PAYLOAD_HEADER;
+
+#pragma pack()
+
+///
+/// Identifier is used to make sure the data in the header is for this structure
+/// and version.  If the structure changes update the last digit.
+///
+#define FMP_PAYLOAD_HEADER_SIGNATURE SIGNATURE_32 ('M', 'S', 'S', '1')
+
+/**
+  Returns the FMP Payload Header size in bytes.
+
+  @param[in]  Header          FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize  Size of FMP payload
+  @param[out] Size            The size, in bytes, of the FMP Payload Header.
+
+  @retval EFI_SUCCESS            The firmware version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  Size is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderSize (
+  IN  CONST VOID   *Header,
+  IN  CONST UINTN  FmpPayloadSize,
+  OUT UINT32       *Size
+  )
+{
+  FMP_PAYLOAD_HEADER  *FmpPayloadHeader;
+
+  FmpPayloadHeader = NULL;
+
+  if (Header == NULL || Size == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  FmpPayloadHeader = (FMP_PAYLOAD_HEADER *)Header;
+  if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
+      (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize ||
+      FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (FmpPayloadHeader->Signature != FMP_PAYLOAD_HEADER_SIGNATURE) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Size = FmpPayloadHeader->HeaderSize;
+  return EFI_SUCCESS;
+}
+
+/**
+  Returns the version described in the FMP Payload Header.
+
+  @param[in]  Header          FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize  Size of FMP payload
+  @param[out] Version         The firmware version described in the FMP Payload
+                              Header.
+
+  @retval EFI_SUCCESS            The firmware version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  Version is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderVersion (
+  IN  CONST VOID   *Header,
+  IN  CONST UINTN  FmpPayloadSize,
+  OUT UINT32       *Version
+  )
+{
+  FMP_PAYLOAD_HEADER  *FmpPayloadHeader;
+
+  FmpPayloadHeader = NULL;
+
+  if (Header == NULL || Version == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  FmpPayloadHeader = (FMP_PAYLOAD_HEADER *)Header;
+  if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
+      (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize ||
+      FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (FmpPayloadHeader->Signature != FMP_PAYLOAD_HEADER_SIGNATURE) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Version = FmpPayloadHeader->FwVersion;
+  return EFI_SUCCESS;
+}
+
+/**
+  Returns the lowest supported version described in the FMP Payload Header.
+
+  @param[in]  Header                  FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize          Size of FMP payload
+  @param[out] LowestSupportedVersion  The lowest supported version described in
+                                      the FMP Payload Header.
+
+  @retval EFI_SUCCESS            The lowest support version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  LowestSupportedVersion is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderLowestSupportedVersion (
+  IN     CONST VOID   *Header,
+  IN     CONST UINTN  FmpPayloadSize,
+  IN OUT UINT32       *LowestSupportedVersion
+  )
+{
+  FMP_PAYLOAD_HEADER  *FmpPayloadHeader;
+
+  FmpPayloadHeader = NULL;
+
+  if (Header == NULL || LowestSupportedVersion == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  FmpPayloadHeader = (FMP_PAYLOAD_HEADER *)Header;
+  if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
+      (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize ||
+      FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (FmpPayloadHeader->Signature != FMP_PAYLOAD_HEADER_SIGNATURE) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *LowestSupportedVersion = FmpPayloadHeader->LowestSupportedVersion;
+  return EFI_SUCCESS;
+}
diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
new file mode 100644
index 0000000000..41ed6e2aca
--- /dev/null
+++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
@@ -0,0 +1,48 @@
+## @file
+#  Provides services to retrieve values from Version 1 of a capsule's FMP Payload
+#  Header. The FMP Payload Header structure is not defined 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.
+#
+#  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  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]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = FmpPayloadHeaderLibV1
+  FILE_GUID                      = 98A79A6C-513C-4E72-8375-39C0A7244C4B
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = FmpPayloadHeaderLib|DXE_DRIVER UEFI_APPLICATION
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF ARM AARCH64
+#
+
+[Sources]
+  FmpPayloadHeaderLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  FmpDevicePkg/FmpDevicePkg.dec
diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.uni b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.uni
new file mode 100644
index 0000000000..4eef31753d
--- /dev/null
+++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.uni
@@ -0,0 +1,21 @@
+// /** @file
+// Provides services to retrieve values from Version 1 of a capsule's FMP Payload
+// Header. The FMP Payload Header structure is not defined 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.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// 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.
+//
+// **/
+
+#string STR_MODULE_ABSTRACT     #language en-US  "Provides services to retrieve values from Version 1 of a capsule's FMP Payload Header."
+
+#string STR_MODULE_DESCRIPTION  #language en-US  "Provides services to retrieve values from Version 1 of a capsule's FMP Payload Header."
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC 3/4] FmpDevicePkg: Add FmpDxe module
  2018-04-04 21:28 [RFC 0/4] Add FmpDevicePkg Michael D Kinney
  2018-04-04 21:28 ` [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs Michael D Kinney
  2018-04-04 21:28 ` [RFC 2/4] FmpDevicePkg: Add library instances Michael D Kinney
@ 2018-04-04 21:28 ` Michael D Kinney
  2018-04-04 21:28 ` [RFC 4/4] FmpDevicePkg: Add DSC file to build all package components Michael D Kinney
  2018-04-04 23:29 ` [RFC 0/4] Add FmpDevicePkg Yao, Jiewen
  4 siblings, 0 replies; 9+ messages in thread
From: Michael D Kinney @ 2018-04-04 21:28 UTC (permalink / raw)
  To: edk2-devel; +Cc: Kinney, Michael D, Sean Brogan, Jiewen Yao

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch:

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

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

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

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

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 FmpDevicePkg/FmpDxe/FmpDxe.c          | 1533 +++++++++++++++++++++++++++++++++
 FmpDevicePkg/FmpDxe/FmpDxe.inf        |   96 +++
 FmpDevicePkg/FmpDxe/FmpDxe.uni        |   20 +
 FmpDevicePkg/FmpDxe/FmpDxeExtra.uni   |   18 +
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf     |   93 ++
 FmpDevicePkg/FmpDxe/VariableSupport.c |  431 +++++++++
 FmpDevicePkg/FmpDxe/VariableSupport.h |  180 ++++
 7 files changed, 2371 insertions(+)
 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/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
new file mode 100644
index 0000000000..76a64dd468
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -0,0 +1,1533 @@
+/**  @file
+  Produces a Firmware Management Protocol that supports updates to a firmware
+  image stored in a firmware device with platform and firmware device specific
+  information provided through PCDs and libraries.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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 <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/FmpDeviceLib.h>
+#include <Library/FmpPayloadHeaderLib.h>
+#include <Library/CapsuleUpdatePolicyLib.h>
+#include <Library/HobLib.h>
+#include <Library/FmpAuthenticationLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Protocol/FirmwareManagement.h>
+#include <Protocol/FirmwareManagementProgress.h>
+#include <Guid/SystemResourceTable.h>
+#include <Guid/EventGroup.h>
+#include "VariableSupport.h"
+
+//
+// FILE_GUID from FmpDxe.inf.  When FmpDxe.inf is used in a platform, the
+// FILE_GUID must always be overridden in the <Defines> section to provide
+// the ESRT GUID value associated with the updatable firmware image.  A
+// check is made in this module's driver entry point to verify that a
+// new FILE_GUID value has been defined.
+//
+const EFI_GUID  mDefaultModuleFileGuid = {
+  0x78ef0a56, 0x1cf0, 0x4535, { 0xb5, 0xda, 0xf6, 0xfd, 0x2f, 0x40, 0x5a, 0x11 }
+};
+
+EFI_FIRMWARE_IMAGE_DESCRIPTOR  mDesc;
+BOOLEAN                        mDescriptorPopulated     = FALSE;
+BOOLEAN                        mRuntimeVersionSupported = TRUE;
+BOOLEAN                        mFmpInstalled            = FALSE;
+
+//
+//Function pointer to progress function
+//
+EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  mProgressFunc      = NULL;
+BOOLEAN                                        mProgressSupported = FALSE;
+
+CHAR16  *mImageIdName = NULL;
+UINT64  mImageId      = 0x1;
+CHAR16  *mVersionName = NULL;
+
+EFI_EVENT  mFmpDeviceLockEvent;
+BOOLEAN    mFmpDeviceLocked = FALSE;
+
+/**
+  Convert a version value to a Null-terminated Unicode version string.
+  This implementation uses 1 byte per version number.
+
+    Example: Converts 0x01020304 to 1.2.3.4
+
+  @param[in]  Version  32-bit version value.
+  @param[out] String   On return, a pointer to a Null-terminated Unicode string
+                       allocated using AllocatePool().
+
+  @retval  EFI_SUCCESS            The version string was allocated and returned
+                                  in String.
+  @retval  EFI_INVALID_PARAMETER  String is NULL.
+  @retval  EFI_INVALID_PARAMETER  *String is NULL.
+  @retval  EFI_OUT_OF_RESOURCES   There are not enough resources to allocate
+                                  the Null-terminated Unicode version string.
+
+**/
+EFI_STATUS
+ComputeVersionName (
+  IN  UINT32  Version,
+  OUT CHAR16  **String
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       *Byte;
+
+  Status = EFI_SUCCESS;
+  Byte   = (UINT8 *)&Version;
+
+  if (String == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Error: String must not be NULL\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  if (*String != NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Error: String must be pointer to NULL\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  //
+  // allocate memory for 000.000.000.000\0
+  // 16 chars x 2 for Unicode
+  //
+  *String = AllocatePool (16 * sizeof (CHAR16));
+  if (*String == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Insufficient memory for String.\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto cleanup;
+  }
+
+  UnicodeSPrint (*String, 32, L"%d.%d.%d.%d", *(Byte + 3), *(Byte + 2), *(Byte + 1), *(Byte));
+  DEBUG ((DEBUG_INFO, "FmpDxe: Converted 0x%x to %s\n", Version, *String));
+
+cleanup:
+
+  return Status;
+}
+
+/**
+  Callback function to report the process of the firmware updating.
+
+  Wrap the caller's version in this so that progress from the device lib is
+  within the expected range.  Convert device lib 0%-100% to 25%-98%.
+
+  FmpDxe        0% -   5%  for validation
+  FmpDeviceLib  6% -  98%  for flashing/update
+  FmpDxe       99% - 100%  finish
+
+  @param[in] Completion  A value between 1 and 100 indicating the current
+                         completion progress of the firmware update. Completion
+                         progress is reported as from 1 to 100 percent. A value
+                         of 0 is used by the driver to indicate that progress
+                         reporting is not supported.
+
+  @retval  EFI_SUCCESS      The progress was updated.
+  @retval  EFI_UNSUPPORTED  Updating progress is not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDxeProgress (
+  IN UINTN  Completion
+  )
+{
+  EFI_STATUS Status;
+
+  Status = EFI_UNSUPPORTED;
+
+  if (!mProgressSupported) {
+    return Status;
+  }
+
+  if (mProgressFunc == NULL) {
+    return Status;
+  }
+
+  //
+  // Reserve 6% - 98% for the FmpDeviceLib.  Call the real progress function.
+  //
+  Status = mProgressFunc (((Completion * 92) / 100) + 6);
+
+  if (Status == EFI_UNSUPPORTED) {
+    mProgressSupported = FALSE;
+    mProgressFunc = NULL;
+  }
+
+  return Status;
+}
+
+/**
+  Returns a pointer to the ImageTypeId GUID value.  An attempt is made to get
+  the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide
+  a GUID value, then gEfiCallerIdGuid is returned.
+
+  @return  The ImageTypeId GUID
+
+**/
+EFI_GUID *
+GetImageTypeIdGuid (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  EFI_GUID    *FmpDeviceLibGuid;
+
+  FmpDeviceLibGuid = NULL;
+  Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid);
+  if (EFI_ERROR (Status)) {
+    if (Status != EFI_UNSUPPORTED) {
+      DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", Status));
+    }
+    return &gEfiCallerIdGuid;
+  }
+  if (FmpDeviceLibGuid == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n"));
+    return &gEfiCallerIdGuid;
+  }
+  return FmpDeviceLibGuid;
+}
+
+/**
+  Returns a pointer to the Null-terminated Unicode ImageIdName string.
+
+  @return  Null-terminated Unicode ImageIdName string.
+
+**/
+CHAR16 *
+GetImageTypeNameString (
+  VOID
+  )
+{
+  return mImageIdName;
+}
+
+/**
+  Lowest supported version is a combo of three parts.
+  1. Check if the device lib has a lowest supported version
+  2. Check if we have a variable for lowest supported version (this will be updated with each capsule applied)
+  3. Check Fixed at build PCD
+
+  Take the largest value
+
+**/
+UINT32
+GetLowestSupportedVersion (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      DeviceLibLowestSupportedVersion;
+  UINT32      VariableLowestSupportedVersion;
+  UINT32      ReturnLsv;
+
+  //
+  // Get the LowestSupportedVersion.
+  //
+
+  DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
+  ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
+  if (CheckLowestSupportedVersion() == FALSE) {
+    return 1;
+  }
+
+  //
+  // Check the FmpDeviceLib
+  //
+  Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion);
+  if (EFI_ERROR (Status)) {
+    DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
+  }
+
+  if (DeviceLibLowestSupportedVersion > ReturnLsv) {
+    ReturnLsv = DeviceLibLowestSupportedVersion;
+  }
+
+  //
+  // Check the lowest supported version UEFI variable for this device
+  //
+  VariableLowestSupportedVersion = GetLowestSupportedVersionFromVariable();
+  if (VariableLowestSupportedVersion > ReturnLsv) {
+    ReturnLsv = VariableLowestSupportedVersion;
+  }
+
+  //
+  // Return the largest value
+  //
+  return ReturnLsv;
+}
+
+/**
+  Populates the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure in the module global
+  variable mDesc.
+
+**/
+VOID
+PopulateDescriptor (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  mDesc.ImageIndex = 1;
+  CopyGuid (&mDesc.ImageTypeId, GetImageTypeIdGuid());
+  mDesc.ImageId = mImageId;
+  mDesc.ImageIdName = GetImageTypeNameString();
+
+  //
+  // Get the version.  Some devices don't support getting the firmware version
+  // at runtime.  If FmpDeviceLib does not support returning a version, then
+  // it is stored in a UEFI variable.
+  //
+  Status = FmpDeviceGetVersion (&mDesc.Version);
+  if (Status == EFI_UNSUPPORTED) {
+    mRuntimeVersionSupported = FALSE;
+    mDesc.Version = GetVersionFromVariable();
+  } else if (EFI_ERROR (Status)) {
+    //
+    // Unexpected error.   Use default version.
+    //
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetVersion() from FmpDeviceLib (%s) returned %r\n", GetImageTypeNameString(), Status));
+    mDesc.Version = DEFAULT_VERSION;
+  }
+
+  //
+  // Free the current version name.  Shouldn't really happen but this populate
+  // function could be called multiple times (to refresh).
+  //
+  if (mVersionName != NULL) {
+    FreePool (mVersionName);
+    mVersionName = NULL;
+  }
+
+  //
+  // Attempt to get the version string from the FmpDeviceLib
+  //
+  mVersionName = FmpDeviceGetVersionString();
+  if (mVersionName == NULL) {
+    DEBUG ((DEBUG_INFO, "FmpDxe: GetVersionString() unsupported in FmpDeviceLib.  Using default version to version string converter.\n"));
+    //
+    // Convert 32-bit version value to a Null-terminated Unicode version string.
+    //
+    ComputeVersionName (mDesc.Version, &mVersionName);
+  }
+
+  mDesc.VersionName = mVersionName;
+
+  mDesc.LowestSupportedImageVersion = GetLowestSupportedVersion();
+
+  //
+  // Get attributes from the FmpDeviceLib
+  //
+  FmpDeviceGetAttributes (&mDesc.AttributesSupported, &mDesc.AttributesSetting);
+
+  //
+  // Force set the updatable bits in the attributes;
+  //
+  mDesc.AttributesSupported |= IMAGE_ATTRIBUTE_IMAGE_UPDATABLE;
+  mDesc.AttributesSetting   |= IMAGE_ATTRIBUTE_IMAGE_UPDATABLE;
+
+  //
+  // Force set the authentication bits in the attributes;
+  //
+  mDesc.AttributesSupported |= (IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
+  mDesc.AttributesSetting   |= (IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
+
+  mDesc.Compatibilities = 0;
+  mDesc.Size = FmpDeviceGetSize();
+
+  mDesc.LastAttemptVersion = GetLastAttemptVersionFromVariable ();
+  mDesc.LastAttemptStatus  = GetLastAttemptStatusFromVariable ();
+
+  mDescriptorPopulated = TRUE;
+}
+
+/**
+  Returns information about the current firmware image(s) of the device.
+
+  This function allows a copy of the current firmware image to be created and saved.
+  The saved copy could later been used, for example, in firmware image recovery or rollback.
+
+  @param[in]      This               A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
+  @param[in, out] ImageInfoSize      A pointer to the size, in bytes, of the ImageInfo buffer.
+                                     On input, this is the size of the buffer allocated by the caller.
+                                     On output, it is the size of the buffer returned by the firmware
+                                     if the buffer was large enough, or the size of the buffer needed
+                                     to contain the image(s) information if the buffer was too small.
+  @param[in, out] ImageInfo          A pointer to the buffer in which firmware places the current image(s)
+                                     information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
+  @param[out]     DescriptorVersion  A pointer to the location in which firmware returns the version number
+                                     associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[out]     DescriptorCount    A pointer to the location in which firmware returns the number of
+                                     descriptors or firmware images within this device.
+  @param[out]     DescriptorSize     A pointer to the location in which firmware returns the size, in bytes,
+                                     of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[out]     PackageVersion     A version number that represents all the firmware images in the device.
+                                     The format is vendor specific and new version must have a greater value
+                                     than the old version. If PackageVersion is not supported, the value is
+                                     0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison
+                                     is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates
+                                     that package version update is in progress.
+  @param[out]     PackageVersionName A pointer to a pointer to a null-terminated string representing the
+                                     package version name. The buffer is allocated by this function with
+                                     AllocatePool(), and it is the caller's responsibility to free it with a call
+                                     to FreePool().
+
+  @retval EFI_SUCCESS                The device was successfully updated with the new image.
+  @retval EFI_BUFFER_TOO_SMALL       The ImageInfo buffer was too small. The current buffer size
+                                     needed to hold the image(s) information is returned in ImageInfoSize.
+  @retval EFI_INVALID_PARAMETER      ImageInfoSize is NULL.
+  @retval EFI_DEVICE_ERROR           Valid information could not be returned. Possible corrupted image.
+
+**/
+EFI_STATUS
+EFIAPI
+GetTheImageInfo (
+  IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL       *This,
+  IN OUT    UINTN                           *ImageInfoSize,
+  IN OUT    EFI_FIRMWARE_IMAGE_DESCRIPTOR   *ImageInfo,
+  OUT       UINT32                          *DescriptorVersion,
+  OUT       UINT8                           *DescriptorCount,
+  OUT       UINTN                           *DescriptorSize,
+  OUT       UINT32                          *PackageVersion,
+  OUT       CHAR16                          **PackageVersionName
+  )
+{
+  EFI_STATUS Status;
+
+  Status = EFI_SUCCESS;
+
+  //
+  // Check for valid pointer
+  //
+  if (ImageInfoSize == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImageInfo() - ImageInfoSize is NULL.\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  //
+  // Check the buffer size
+  // NOTE: Check this first so caller can get the necessary memory size it must allocate.
+  //
+  if (*ImageInfoSize < (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR))) {
+    *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
+    DEBUG ((DEBUG_VERBOSE, "FmpDxe: GetImageInfo() - ImageInfoSize is to small.\n"));
+    Status = EFI_BUFFER_TOO_SMALL;
+    goto cleanup;
+  }
+
+  //
+  // Confirm that buffer isn't null
+  //
+  if ( (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount == NULL) || (DescriptorSize == NULL)
+       || (PackageVersion == NULL)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImageInfo() - Pointer Parameter is NULL.\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  //
+  // Set the size to whatever we need
+  //
+  *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
+
+
+  if (!mDescriptorPopulated) {
+    PopulateDescriptor();
+  }
+
+  //
+  // Copy the image descriptor
+  //
+  CopyMem (ImageInfo, &mDesc, sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR));
+
+  *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
+  *DescriptorCount = 1;
+  *DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
+  //
+  // means unsupported
+  //
+  *PackageVersion = 0xFFFFFFFF;
+
+  //
+  // Do not update PackageVersionName since it is not supported in this instance.
+  //
+
+cleanup:
+
+  return Status;
+}
+
+/**
+  Retrieves a copy of the current firmware image of the device.
+
+  This function allows a copy of the current firmware image to be created and saved.
+  The saved copy could later been used, for example, in firmware image recovery or rollback.
+
+  @param[in]  This               A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
+  @param[in]  ImageIndex         A unique number identifying the firmware image(s) within the device.
+                                 The number is between 1 and DescriptorCount.
+  @param[out] Image              Points to the buffer where the current image is copied to.
+  @param[out] ImageSize          On entry, points to the size of the buffer pointed to by Image, in bytes.
+                                 On return, points to the length of the image, in bytes.
+
+  @retval EFI_SUCCESS            The device was successfully updated with the new image.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to hold the
+                                 image. The current buffer size needed to hold the image is returned
+                                 in ImageSize.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_NOT_FOUND          The current image is not copied to the buffer.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.
+
+**/
+EFI_STATUS
+EFIAPI
+GetTheImage (
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN  UINT8                             ImageIndex,
+  IN  OUT  VOID                         *Image,
+  IN  OUT  UINTN                        *ImageSize
+  )
+{
+  EFI_STATUS Status;
+
+  Status = EFI_SUCCESS;
+
+  if ((ImageSize == NULL)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is NULL.\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  //
+  // Check the buffer size
+  //
+  if (*ImageSize < FmpDeviceGetSize()) {
+    *ImageSize = FmpDeviceGetSize();
+    DEBUG ((DEBUG_VERBOSE, "FmpDxe: GetImage() - ImageSize is to small.\n"));
+    Status = EFI_BUFFER_TOO_SMALL;
+    goto cleanup;
+  }
+
+  if (Image == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Pointer Parameter is NULL.\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  //
+  // Check to make sure index is 1 (only 1 image for this device)
+  //
+  if (ImageIndex != 1) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+
+  Status = FmpDeviceGetImage (Image, ImageSize);
+cleanup:
+
+  return Status;
+}
+
+/**
+  Helper function to safely retrieve the FMP header from
+  within an EFI_FIRMWARE_IMAGE_AUTHENTICATION structure.
+
+  @param[in]   Image        Pointer to the image.
+  @param[in]   ImageSize    Size of the image.
+  @param[out]  PayloadSize
+
+  @retval  !NULL  Valid pointer to the header.
+  @retval  NULL   Structure is bad and pointer cannot be found.
+
+**/
+VOID *
+GetFmpHeader (
+  IN  CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION  *Image,
+  IN  CONST UINTN                              ImageSize,
+  OUT UINTN                                    *PayloadSize
+  )
+{
+  //
+  // Check to make sure that operation can be safely performed.
+  //
+  if (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) < (UINTN)Image || \
+      ((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) >= (UINTN)Image + ImageSize) {
+    //
+    // Pointer overflow. Invalid image.
+    //
+    return NULL;
+  }
+
+  *PayloadSize = ImageSize - (sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength);
+  return (VOID *)((UINT8 *)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength);
+}
+
+/**
+  Helper function to safely calculate the size of all headers
+  within an EFI_FIRMWARE_IMAGE_AUTHENTICATION structure.
+
+  @param[in]  Image                 Pointer to the image.
+  @param[in]  AdditionalHeaderSize  Size of any headers that cannot be calculated by this function.
+
+  @retval  UINT32>0  Valid size of all the headers.
+  @retval  0         Structure is bad and size cannot be found.
+
+**/
+UINT32
+GetAllHeaderSize (
+  IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION  *Image,
+  IN UINT32                                   AdditionalHeaderSize
+  )
+{
+  UINT32 CalculatedSize;
+
+  CalculatedSize = sizeof (Image->MonotonicCount) +
+                   AdditionalHeaderSize +
+                   Image->AuthInfo.Hdr.dwLength;
+
+  //
+  // Check to make sure that operation can be safely performed.
+  //
+  if (CalculatedSize < sizeof (Image->MonotonicCount) ||
+      CalculatedSize < AdditionalHeaderSize           ||
+      CalculatedSize < Image->AuthInfo.Hdr.dwLength      ) {
+    //
+    // Integer overflow. Invalid image.
+    //
+    return 0;
+  }
+
+  return CalculatedSize;
+}
+
+/**
+  Checks if the firmware image is valid for the device.
+
+  This function allows firmware update application to validate the firmware image without
+  invoking the SetImage() first.
+
+  @param[in]  This               A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
+  @param[in]  ImageIndex         A unique number identifying the firmware image(s) within the device.
+                                 The number is between 1 and DescriptorCount.
+  @param[in]  Image              Points to the new image.
+  @param[in]  ImageSize          Size of the new image in bytes.
+  @param[out] ImageUpdatable     Indicates if the new image is valid for update. It also provides,
+                                 if available, additional information if the image is invalid.
+
+  @retval EFI_SUCCESS            The image was successfully checked.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckTheImage (
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN  UINT8                             ImageIndex,
+  IN  CONST VOID                        *Image,
+  IN  UINTN                             ImageSize,
+  OUT UINT32                            *ImageUpdateable
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       RawSize;
+  VOID        *FmpPayloadHeader;
+  UINTN       FmpPayloadSize;
+  UINT32      Version;
+  UINT32      FmpHeaderSize;
+  UINTN       AllHeaderSize;
+  UINT32      Index;
+  VOID        *PublicKeyData;
+  UINTN       PublicKeyDataLength;
+  UINT8       *PublicKeyDataXdr;
+  UINT8       *PublicKeyDataXdrEnd;
+
+  Status           = EFI_SUCCESS;
+  RawSize          = 0;
+  FmpPayloadHeader = NULL;
+  FmpPayloadSize   = 0;
+  Version          = 0;
+  FmpHeaderSize    = 0;
+  AllHeaderSize    = 0;
+
+  //
+  // make sure the descriptor has already been loaded
+  //
+  if (!mDescriptorPopulated) {
+    PopulateDescriptor();
+  }
+
+  if (ImageUpdateable == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckImage() - ImageUpdateable Pointer Parameter is NULL.\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  //
+  //Set to valid and then if any tests fail it will update this flag.
+  //
+  *ImageUpdateable = IMAGE_UPDATABLE_VALID;
+
+  if (Image == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckImage() - Image Pointer Parameter is NULL.\n"));
+    //
+    // not sure if this is needed
+    //
+    *ImageUpdateable = IMAGE_UPDATABLE_INVALID;
+    return EFI_INVALID_PARAMETER;
+  }
+
+  PublicKeyDataXdr    = PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
+  PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr);
+
+  if (PublicKeyDataXdr == NULL || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Invalid certificate, skipping it.\n"));
+    Status = EFI_ABORTED;
+  } else {
+    //
+    // Try each key from PcdFmpDevicePkcs7CertBufferXdr
+    //
+    for (Index = 1; PublicKeyDataXdr < PublicKeyDataXdrEnd; Index++) {
+      Index++;
+      DEBUG (
+        (DEBUG_INFO,
+        "FmpDxe: Certificate #%d [%p..%p].\n",
+        Index,
+        PublicKeyDataXdr,
+        PublicKeyDataXdrEnd
+        )
+        );
+
+      if ((PublicKeyDataXdr + sizeof (UINT32)) > PublicKeyDataXdrEnd) {
+        //
+        // Key data extends beyond end of PCD
+        //
+        DEBUG ((DEBUG_ERROR, "FmpDxe: Certificate size extends beyond end of PCD, skipping it.\n"));
+        Status = EFI_ABORTED;
+        break;
+      }
+      //
+      // Read key length stored in big-endian format
+      //
+      PublicKeyDataLength = SwapBytes32 (*(UINT32 *)(PublicKeyDataXdr));
+      //
+      // Point to the start of the key data
+      //
+      PublicKeyDataXdr += sizeof (UINT32);
+      if (PublicKeyDataXdr + PublicKeyDataLength > PublicKeyDataXdrEnd) {
+        //
+        // Key data extends beyond end of PCD
+        //
+        DEBUG ((DEBUG_ERROR, "FmpDxe: Certificate extends beyond end of PCD, skipping it.\n"));
+        Status = EFI_ABORTED;
+        break;
+      }
+      PublicKeyData = PublicKeyDataXdr;
+      Status = AuthenticateFmpImage (
+                 (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image,
+                 ImageSize,
+                 PublicKeyData,
+                 PublicKeyDataLength
+                 );
+      if (!EFI_ERROR (Status)) {
+        break;
+      }
+      PublicKeyDataXdr += PublicKeyDataLength;
+      PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
+    }
+  }
+
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - Authentication Failed %r.\n", Status));
+    goto cleanup;
+  }
+
+  //
+  // Check to make sure index is 1
+  //
+  if (ImageIndex != 1) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckImage() - Image Index Invalid.\n"));
+    *ImageUpdateable = IMAGE_UPDATABLE_INVALID_TYPE;
+    Status = EFI_SUCCESS;
+    goto cleanup;
+  }
+
+
+  //
+  // Check the FmpPayloadHeader
+  //
+  FmpPayloadHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, &FmpPayloadSize );
+  if (FmpPayloadHeader == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpHeader failed.\n"));
+    Status = EFI_ABORTED;
+    goto cleanup;
+  }
+  Status = GetFmpPayloadHeaderVersion (FmpPayloadHeader, FmpPayloadSize, &Version);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpPayloadHeaderVersion failed %r.\n", Status));
+    *ImageUpdateable = IMAGE_UPDATABLE_INVALID;
+    Status = EFI_SUCCESS;
+    goto cleanup;
+  }
+
+  //
+  // Check the lowest supported version
+  //
+  if (Version < mDesc.LowestSupportedImageVersion) {
+    DEBUG (
+      (DEBUG_ERROR,
+      "FmpDxe: CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n",
+      Version, mDesc.LowestSupportedImageVersion)
+      );
+    *ImageUpdateable = IMAGE_UPDATABLE_INVALID_OLD;
+    Status = EFI_SUCCESS;
+    goto cleanup;
+  }
+
+  //
+  // Get the FmpHeaderSize so we can determine the real payload size
+  //
+  Status = GetFmpPayloadHeaderSize (FmpPayloadHeader, FmpPayloadSize, &FmpHeaderSize);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpPayloadHeaderSize failed %r.\n", Status));
+    *ImageUpdateable = IMAGE_UPDATABLE_INVALID;
+    Status = EFI_SUCCESS;
+    goto cleanup;
+  }
+
+  //
+  // Call FmpDevice Lib Check Image on the
+  // Raw payload.  So all headers need stripped off
+  //
+  AllHeaderSize = GetAllHeaderSize ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize );
+  if (AllHeaderSize == 0) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetAllHeaderSize failed.\n"));
+    Status = EFI_ABORTED;
+    goto cleanup;
+  }
+  RawSize = ImageSize - AllHeaderSize;
+
+  //
+  // FmpDeviceLib CheckImage function to do any specific checks
+  //
+  Status = FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdateable);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", Status));
+  }
+
+cleanup:
+  return Status;
+}
+
+/**
+  Updates the firmware image of the device.
+
+  This function updates the hardware with the new firmware image.
+  This function returns EFI_UNSUPPORTED if the firmware image is not updatable.
+  If the firmware image is updatable, the function should perform the following minimal validations
+  before proceeding to do the firmware image update.
+  - Validate the image authentication if image has attribute
+    IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns
+    EFI_SECURITY_VIOLATION if the validation fails.
+  - Validate the image is a supported image for this device. The function returns EFI_ABORTED if
+    the image is unsupported. The function can optionally provide more detailed information on
+    why the image is not a supported image.
+  - Validate the data from VendorCode if not null. Image validation must be performed before
+    VendorCode data validation. VendorCode data is ignored or considered invalid if image
+    validation failed. The function returns EFI_ABORTED if the data is invalid.
+
+  VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if
+  the caller did not specify the policy or use the default policy. As an example, vendor can implement
+  a policy to allow an option to force a firmware image update when the abort reason is due to the new
+  firmware image version is older than the current firmware image version or bad image checksum.
+  Sensitive operations such as those wiping the entire firmware image and render the device to be
+  non-functional should be encoded in the image itself rather than passed with the VendorCode.
+  AbortReason enables vendor to have the option to provide a more detailed description of the abort
+  reason to the caller.
+
+  @param[in]  This               A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
+  @param[in]  ImageIndex         A unique number identifying the firmware image(s) within the device.
+                                 The number is between 1 and DescriptorCount.
+  @param[in]  Image              Points to the new image.
+  @param[in]  ImageSize          Size of the new image in bytes.
+  @param[in]  VendorCode         This enables vendor to implement vendor-specific firmware image update policy.
+                                 Null indicates the caller did not specify the policy or use the default policy.
+  @param[in]  Progress           A function used by the driver to report the progress of the firmware update.
+  @param[out] AbortReason        A pointer to a pointer to a null-terminated string providing more
+                                 details for the aborted operation. The buffer is allocated by this function
+                                 with AllocatePool(), and it is the caller's responsibility to free it with a
+                                 call to FreePool().
+
+  @retval EFI_SUCCESS            The device was successfully updated with the new image.
+  @retval EFI_ABORTED            The operation is aborted.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.
+
+**/
+EFI_STATUS
+EFIAPI
+SetTheImage (
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL               *This,
+  IN  UINT8                                          ImageIndex,
+  IN  CONST VOID                                     *Image,
+  IN  UINTN                                          ImageSize,
+  IN  CONST VOID                                     *VendorCode,
+  IN  EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,
+  OUT CHAR16                                         **AbortReason
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Updateable;
+  BOOLEAN     BooleanValue;
+  UINT32      FmpHeaderSize;
+  VOID        *FmpHeader;
+  UINTN       FmpPayloadSize;
+  UINT32      AllHeaderSize;
+  UINT32      IncommingFwVersion;
+  UINT32      LastAttemptStatus;
+
+  Status             = EFI_SUCCESS;
+  Updateable         = 0;
+  BooleanValue       = FALSE;
+  FmpHeaderSize      = 0;
+  FmpHeader          = NULL;
+  FmpPayloadSize     = 0;
+  AllHeaderSize      = 0;
+  IncommingFwVersion = 0;
+  LastAttemptStatus  = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+
+
+  SetLastAttemptVersionInVariable (IncommingFwVersion); //set to 0 to clear any previous results.
+
+  //
+  // if we have locked the device, then skip the set operation.
+  // it should be blocked by hardware too but we can catch here even faster
+  //
+  if (mFmpDeviceLocked) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Device is already locked.  Can't update.\n"));
+    Status = EFI_ACCESS_DENIED;
+    goto cleanup;
+  }
+
+  //
+  // Call check image to verify the image
+  //
+  Status = CheckTheImage (This, ImageIndex, Image, ImageSize, &Updateable);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Check The Image failed with %r.\n", Status));
+    if (Status == EFI_SECURITY_VIOLATION) {
+      LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;
+    }
+    goto cleanup;
+  }
+
+  //
+  // No functional error in CheckTheImage.  Attempt to get the Version to
+  // support better error reporting.
+  //
+  FmpHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, &FmpPayloadSize );
+  if (FmpHeader == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - GetFmpHeader failed.\n"));
+    Status = EFI_ABORTED;
+    goto cleanup;
+  }
+  Status = GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &IncommingFwVersion);
+  if (!EFI_ERROR (Status)) {
+    //
+    // Set to actual value
+    //
+    SetLastAttemptVersionInVariable (IncommingFwVersion);
+  }
+
+
+  if (Updateable != IMAGE_UPDATABLE_VALID) {
+    DEBUG (
+      (DEBUG_ERROR,
+      "FmpDxed: SetTheImage() - Check The Image returned that the Image was not valid for update.  Updatable value = 0x%X.\n",
+      Updateable)
+      );
+    Status = EFI_ABORTED;
+    goto cleanup;
+  }
+
+  if (Progress == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Invalid progress callback\n"));
+    Status = EFI_INVALID_PARAMETER;
+    goto cleanup;
+  }
+
+  mProgressFunc = Progress;
+  mProgressSupported = TRUE;
+
+  //
+  // Checking the image is at least 1%
+  //
+  Status = Progress (1);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Progress Callback failed with Status %r.\n", Status));
+  }
+
+  //
+  //Check System Power
+  //
+  Status = CheckSystemPower (&BooleanValue);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - CheckSystemPower - API call failed %r.\n", Status));
+    goto cleanup;
+  }
+  if (!BooleanValue) {
+    Status = EFI_ABORTED;
+    DEBUG (
+      (DEBUG_ERROR,
+      "FmpDxe: SetTheImage() - CheckSystemPower - returned False.  Update not allowed due to System Power.\n")
+      );
+    LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT;
+    goto cleanup;
+  }
+
+  Progress (2);
+
+  //
+  //Check System Thermal
+  //
+  Status = CheckSystemThermal (&BooleanValue);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - CheckSystemThermal - API call failed %r.\n", Status));
+    goto cleanup;
+  }
+  if (!BooleanValue) {
+    Status = EFI_ABORTED;
+    DEBUG (
+      (DEBUG_ERROR,
+      "FmpDxe: SetTheImage() - CheckSystemThermal - returned False.  Update not allowed due to System Thermal.\n")
+      );
+    goto cleanup;
+  }
+
+  Progress (3);
+
+  //
+  //Check System Environment
+  //
+  Status = CheckSystemEnvironment (&BooleanValue);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - CheckSystemEnvironment - API call failed %r.\n", Status));
+    goto cleanup;
+  }
+  if (!BooleanValue) {
+    Status = EFI_ABORTED;
+    DEBUG (
+      (DEBUG_ERROR,
+      "FmpDxe: SetTheImage() - CheckSystemEnvironment - returned False.  Update not allowed due to System Environment.\n")
+      );
+    goto cleanup;
+  }
+
+  Progress (4);
+
+  //
+  // Save LastAttemptStatus as error so that if SetImage never returns the error
+  // state is recorded.
+  //
+  SetLastAttemptStatusInVariable (LastAttemptStatus);
+
+  //
+  // Strip off all the headers so the device can process its firmware
+  //
+  Status = GetFmpPayloadHeaderSize (FmpHeader, FmpPayloadSize, &FmpHeaderSize);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n", Status));
+    goto cleanup;
+  }
+
+  AllHeaderSize = GetAllHeaderSize ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize );
+  if (AllHeaderSize == 0) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - GetAllHeaderSize failed.\n"));
+    Status = EFI_ABORTED;
+    goto cleanup;
+  }
+
+  //
+  // Indicate that control is handed off to FmpDeviceLib
+  //
+  Progress (5);
+
+  //
+  //Copy the requested image to the firmware using the FmpDeviceLib
+  //
+  Status = FmpDeviceSetImage (
+             (((UINT8 *)Image) + AllHeaderSize),
+             ImageSize - AllHeaderSize,
+             VendorCode,
+             FmpDxeProgress,
+             IncommingFwVersion,
+             AbortReason
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() SetImage from FmpDeviceLib failed. Status =  %r.\n", Status));
+    goto cleanup;
+  }
+
+
+  //
+  // Finished the update without error
+  // Indicate that control has been returned from FmpDeviceLib
+  //
+  Progress (99);
+
+  //
+  // Update the version stored in variable
+  //
+  if (!mRuntimeVersionSupported) {
+    UINT32 Version = DEFAULT_VERSION;
+    GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &Version);
+    SetVersionInVariable (Version);
+  }
+
+  //
+  // Update lowest supported variable
+  //
+  {
+    UINT32 Version = DEFAULT_LOWESTSUPPORTEDVERSION;
+    GetFmpPayloadHeaderLowestSupportedVersion (FmpHeader, FmpPayloadSize, &Version);
+    SetLowestSupportedVersionInVariable (Version);
+  }
+
+  LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+
+  //
+  // Set flag so the descriptor is repopulated
+  // This only applied to devices that do not require system reboot
+  //
+  if (!PcdGetBool (PcdFmpDeviceSystemResetRequired)) {
+    mDescriptorPopulated = FALSE;
+  }
+
+cleanup:
+  mProgressFunc = NULL;
+  mProgressSupported = FALSE;
+  SetLastAttemptStatusInVariable (LastAttemptStatus);
+
+  //
+  // Set progress to 100 after everything is done including recording Status.
+  //
+  Progress (100);
+
+  return Status;
+}
+
+/**
+  Returns information about the firmware package.
+
+  This function returns package information.
+
+  @param[in]  This                     A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
+  @param[out] PackageVersion           A version number that represents all the firmware images in the device.
+                                       The format is vendor specific and new version must have a greater value
+                                       than the old version. If PackageVersion is not supported, the value is
+                                       0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version
+                                       comparison is to be performed using PackageVersionName. A value of
+                                       0xFFFFFFFD indicates that package version update is in progress.
+  @param[out] PackageVersionName       A pointer to a pointer to a null-terminated string representing
+                                       the package version name. The buffer is allocated by this function with
+                                       AllocatePool(), and it is the caller's responsibility to free it with a
+                                       call to FreePool().
+  @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of
+                                       package version name. A value of 0 indicates the device does not support
+                                       update of package version name. Length is the number of Unicode characters,
+                                       including the terminating null character.
+  @param[out] AttributesSupported      Package attributes that are supported by this device. See 'Package Attribute
+                                       Definitions' for possible returned values of this parameter. A value of 1
+                                       indicates the attribute is supported and the current setting value is
+                                       indicated in AttributesSetting. A value of 0 indicates the attribute is not
+                                       supported and the current setting value in AttributesSetting is meaningless.
+  @param[out] AttributesSetting        Package attributes. See 'Package Attribute Definitions' for possible returned
+                                       values of this parameter
+
+  @retval EFI_SUCCESS                  The package information was successfully returned.
+  @retval EFI_UNSUPPORTED              The operation is not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+GetPackageInfo (
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  OUT UINT32                            *PackageVersion,
+  OUT CHAR16                            **PackageVersionName,
+  OUT UINT32                            *PackageVersionNameMaxLen,
+  OUT UINT64                            *AttributesSupported,
+  OUT UINT64                            *AttributesSetting
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Updates information about the firmware package.
+
+  This function updates package information.
+  This function returns EFI_UNSUPPORTED if the package information is not updatable.
+  VendorCode enables vendor to implement vendor-specific package information update policy.
+  Null if the caller did not specify this policy or use the default policy.
+
+  @param[in]  This               A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
+  @param[in]  Image              Points to the authentication image.
+                                 Null if authentication is not required.
+  @param[in]  ImageSize          Size of the authentication image in bytes.
+                                 0 if authentication is not required.
+  @param[in]  VendorCode         This enables vendor to implement vendor-specific firmware
+                                 image update policy.
+                                 Null indicates the caller did not specify this policy or use
+                                 the default policy.
+  @param[in]  PackageVersion     The new package version.
+  @param[in]  PackageVersionName A pointer to the new null-terminated Unicode string representing
+                                 the package version name.
+                                 The string length is equal to or less than the value returned in
+                                 PackageVersionNameMaxLen.
+
+  @retval EFI_SUCCESS            The device was successfully updated with the new package
+                                 information.
+  @retval EFI_INVALID_PARAMETER  The PackageVersionName length is longer than the value
+                                 returned in PackageVersionNameMaxLen.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_SECURITY_VIOLATIO  The operation could not be performed due to an authentication failure.
+
+**/
+EFI_STATUS
+EFIAPI
+SetPackageInfo (
+  IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN CONST VOID                        *Image,
+  IN UINTN                             ImageSize,
+  IN CONST VOID                        *VendorCode,
+  IN UINT32                            PackageVersion,
+  IN CONST CHAR16                      *PackageVersionName
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+VOID
+EFIAPI
+FmpDxeLockEventNotify (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  )
+{
+  EFI_STATUS  Status;
+
+  if (!mFmpDeviceLocked) {
+    if (LockFmpDeviceAtLockEventGuid ()) {
+      Status = FmpDeviceLock();
+      if (EFI_ERROR (Status)) {
+        if (Status != EFI_UNSUPPORTED) {
+          DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLock() returned error.  Status = %r\n", Status));
+        } else {
+          DEBUG ((DEBUG_WARN, "FmpDxe: FmpDeviceLock() returned error.  Status = %r\n", Status));
+        }
+      }
+      mFmpDeviceLocked = TRUE;
+    } else {
+      DEBUG ((DEBUG_VERBOSE, "FmpDxe: Not calling FmpDeviceLock() because mfg mode\n"));
+    }
+  }
+}
+
+/**
+  Function to install FMP instance.
+
+  @param[in]  Handle  The device handle to install a FMP instance on.
+
+  @retval  EFI_SUCCESS            FMP Installed
+  @retval  EFI_INVALID_PARAMETER  Handle was invalid
+  @retval  other                  Error installing FMP
+
+**/
+EFI_STATUS
+EFIAPI
+InstallFmpInstance (
+  IN EFI_HANDLE  Handle
+  )
+{
+  EFI_STATUS                                   Status;
+  EFI_FIRMWARE_MANAGEMENT_PROTOCOL             *Fmp;
+  EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL  *FmpProgress;
+
+  Status      = EFI_SUCCESS;
+  Fmp         = NULL;
+  FmpProgress = NULL;
+
+  //
+  // Only allow a single FMP Protocol instance to be installed
+  //
+  if (mFmpInstalled) {
+    return EFI_ALREADY_STARTED;
+  }
+
+  //
+  // Allocate FMP Protocol instance
+  //
+  Fmp = AllocateZeroPool (sizeof (EFI_FIRMWARE_MANAGEMENT_PROTOCOL));
+  if (Fmp == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to allocate memory for FMP Protocol instance.\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto cleanup;
+  }
+
+  //
+  // Allocate FMP Progress Protocol instance
+  //
+  FmpProgress = AllocateZeroPool (sizeof (EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL));
+  if (FmpProgress == NULL) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to allocate memory for FMP Progress Protocol instance.\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    FreePool (Fmp);
+    goto cleanup;
+  }
+
+  //
+  // Set up FMP Protocol function pointers
+  //
+  Fmp->GetImageInfo   = GetTheImageInfo;
+  Fmp->GetImage       = GetTheImage;
+  Fmp->SetImage       = SetTheImage;
+  Fmp->CheckImage     = CheckTheImage;
+  Fmp->GetPackageInfo = GetPackageInfo;
+  Fmp->SetPackageInfo = SetPackageInfo;
+
+  //
+  // Fill in FMP Progress Protocol fields
+  //
+  FmpProgress->ProgressBarColor.Raw = PcdGet32 (PcdFmpDeviceProgressColor);
+  FmpProgress->WatchdogSeconds      = PcdGet8 (PcdFmpDeviceProgressWatchdogTimeInSeconds);
+
+  //
+  // Install FMP Protocol and FMP Progress Protocol
+  //
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &Handle,
+                  &gEfiFirmwareManagementProtocolGuid,
+                  Fmp,
+                  &gEdkiiFirmwareManagementProgressProtocolGuid,
+                  FmpProgress,
+                  NULL
+                  );
+
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: FMP Protocol install error. Status = %r.\n", Status));
+    FreePool (Fmp);
+    goto cleanup;
+  }
+
+  DEBUG ((DEBUG_INFO, "FmpDxe: FMP Protocol Installed!\n"));
+  mFmpInstalled = TRUE;
+
+cleanup:
+
+  return Status;
+}
+
+/**
+  Main entry for this library.
+
+  @param  ImageHandle  Image handle this driver.
+  @param  SystemTable  Pointer to SystemTable.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDxeEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  VOID        *TestKeyBuffer;
+  UINTN       TestKeySize;
+  VOID        *PublicKeyData;
+  UINTN       PublicKeyDataLength;
+  UINT8       *PublicKeyDataXdr;
+  UINT8       *PublicKeyDataXdrEnd;
+  EFI_GUID    *LockGuid;
+
+  //
+  // Verify that a new FILE_GUID value have been provided in the <Defines>
+  // section of this module.  The FILE_GUID is the ESRT GUID that must be
+  // unique for each updatable firmware image.
+  //
+  if (CompareGuid (&mDefaultModuleFileGuid, &gEfiCallerIdGuid)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Use of default FILE_GUID detected.  FILE_GUID must be set to a unique value.\n"));
+    ASSERT (FALSE);
+    return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Attempt to read test key FFS file
+  //
+  Status = GetSectionFromAnyFv (
+             PcdGetPtr (PcdEdkiiPkcs7TestPublicKeyFileGuid),
+             EFI_SECTION_RAW,
+             0,
+             &TestKeyBuffer,
+             &TestKeySize
+             );
+  if (EFI_ERROR (Status)) {
+    //
+    // If test key FFS file not found then assume a test key is in use
+    //
+    PcdSetBoolS (PcdTestKeyUsed, TRUE);
+  } else {
+    //
+    // Make sure none of the keys in PcdFmpDevicePkcs7CertBufferXdr match the test key
+    //
+    PublicKeyDataXdr    = PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
+    PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr);
+
+    if (PublicKeyDataXdr != NULL && PublicKeyDataXdr != PublicKeyDataXdrEnd) {
+      //
+      // Try each key from PcdFmpDevicePkcs7CertBufferXdr
+      //
+      while (PublicKeyDataXdr < PublicKeyDataXdrEnd) {
+        if (PublicKeyDataXdr + sizeof (UINT32) > PublicKeyDataXdrEnd) {
+          //
+          // Key data extends beyond end of PCD
+          //
+          break;
+        }
+        //
+        // Read key length stored in big endian format
+        //
+        PublicKeyDataLength = SwapBytes32 (*(UINT32 *)(PublicKeyDataXdr));
+        //
+        // Point to the start of the key data
+        //
+        PublicKeyDataXdr += sizeof (UINT32);
+        if (PublicKeyDataXdr + PublicKeyDataLength > PublicKeyDataXdrEnd) {
+          //
+          // Key data extends beyond end of PCD
+          //
+          break;
+        }
+        PublicKeyData = PublicKeyDataXdr;
+        if ((sizeof (TestKeyBuffer) == PublicKeyDataLength) &&
+            (CompareMem (TestKeyBuffer, PublicKeyData, TestKeySize) == 0)) {
+          //
+          // Match found.  Set PCD to indicate that a test key is in use.
+          //
+          PcdSetBoolS (PcdTestKeyUsed, TRUE);
+          break;
+        }
+
+        PublicKeyDataXdr += PublicKeyDataLength;
+        PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
+      }
+    }
+    FreePool (TestKeyBuffer);
+  }
+
+  //
+  // Get the ImageIdName value for the EFI_FIRMWARE_IMAGE_DESCRIPTOR from a PCD.
+  //
+  mImageIdName = (CHAR16 *) PcdGetPtr (PcdFmpDeviceImageIdName);
+  if (PcdGetSize (PcdFmpDeviceImageIdName) <= 2 || mImageIdName[0] == 0) {
+    //
+    // PcdFmpDeviceImageIdName must be set to a non-empty Unicode string
+    //
+    ASSERT (FALSE);
+    DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib PcdFmpDeviceImageIdName is an empty string.\n"));
+  }
+
+  //
+  // Register with library the install function so if the library uses
+  // UEFI driver model/driver binding protocol it can install FMP on its device handle
+  // If library is simple lib that does not use driver binding then it should return
+  // unsupported and this will install the FMP instance on the ImageHandle
+  //
+  Status = RegisterFmpInstaller (InstallFmpInstance);
+  if (Status == EFI_UNSUPPORTED) {
+    DEBUG ((DEBUG_INFO, "FmpDxe: FmpDeviceLib registration returned EFI_UNSUPPORTED.  Installing single FMP instance.\n"));
+    Status = InstallFmpInstance (ImageHandle);
+  } else if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib registration returned %r.  No FMP installed.\n", Status));
+  } else {
+    DEBUG (
+      (DEBUG_INFO,
+      "FmpDxe: FmpDeviceLib registration returned EFI_SUCCESS.  Expect FMP to be installed during the BDS/Device connection phase.\n")
+      );
+  }
+
+  //
+  // If the boot mode isn't flash update then we must lock all vars.
+  // If it is flash update leave them unlocked as the system will not
+  // boot all the way in flash update mode
+  //
+  if (BOOT_ON_FLASH_UPDATE != GetBootModeHob ()) {
+    LockAllVars ();
+  }
+
+  //
+  // Register notify function to lock the FMP device.
+  // The lock event GUID is retrieved from PcdFmpDeviceLockEventGuid.
+  // If PcdFmpDeviceLockEventGuid is not the size of an EFI_GUID, then
+  // gEfiEndOfDxeEventGroupGuid is used.
+  //
+  LockGuid = &gEfiEndOfDxeEventGroupGuid;
+  if (PcdGetSize (PcdFmpDeviceLockEventGuid) == sizeof (EFI_GUID)) {
+    LockGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceLockEventGuid);
+  }
+  DEBUG ((DEBUG_INFO, "FmpDxe: Lock GUID: %g\n", LockGuid));
+
+  Status = gBS->CreateEventEx (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_CALLBACK,
+                  FmpDxeLockEventNotify,
+                  NULL,
+                  LockGuid,
+                  &mFmpDeviceLockEvent
+                  );
+
+  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to register for ready to boot.  Status = %r\n", Status));
+  }
+
+  return Status;
+}
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
new file mode 100644
index 0000000000..c8f485ddbc
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -0,0 +1,96 @@
+## @file
+#  Produces a Firmware Management Protocol that supports updates to a firmware
+#  image stored in a firmware device with platform and firmware device specific
+#  information provided through PCDs and libraries.
+#
+#  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  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]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = FmpDxe
+  MODULE_UNI_FILE                = FmpDxe.uni
+  FILE_GUID                      = 78EF0A56-1CF0-4535-B5DA-F6FD2F405A11
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = FmpDxeEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF ARM AARCH64
+#
+
+[Sources]
+  FmpDxe.c
+  VariableSupport.h
+  VariableSupport.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  SignedCapsulePkg/SignedCapsulePkg.dec
+  FmpDevicePkg/FmpDevicePkg.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  DebugLib
+  BaseLib
+  UefiBootServicesTableLib
+  UefiRuntimeServicesTableLib
+  UefiLib
+  MemoryAllocationLib
+  PrintLib
+  FmpDeviceLib
+  CapsuleUpdatePolicyLib
+  FmpPayloadHeaderLib
+  HobLib
+  FmpAuthenticationLib
+  DxeServicesLib
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+
+[Protocols]
+  gEfiFirmwareManagementProtocolGuid            ## PRODUCES
+  gEdkiiVariableLockProtocolGuid                ## SOMETIMES_CONSUMES
+  gEdkiiFirmwareManagementProgressProtocolGuid  ## PRODUCES
+
+[FeaturePcd]
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired  ## CONSUMES
+
+[Pcd]
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName                      ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion  ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid                    ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds    ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor                    ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr               ## CONSUMES
+  gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiPkcs7TestPublicKeyFileGuid    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed                            ## SOMETIMES_PRODUCES
+
+[Depex]
+  TRUE
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  FmpDxeExtra.uni
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.uni b/FmpDevicePkg/FmpDxe/FmpDxe.uni
new file mode 100644
index 0000000000..502ec0660d
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.uni
@@ -0,0 +1,20 @@
+// /** @file
+// Produces a Firmware Management Protocol that supports updates to a firmware
+// image stored in a firmware device with platform and firmware device specific
+// information provided through PCDs and libraries.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// 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.
+//
+// **/
+
+#string STR_MODULE_ABSTRACT             #language en-US "Produces a Firmware Management Protocol to support firmware updates"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Produces a Firmware Management Protocol that supports updates to a firmware image stored in a firmware device with platform and firmware device specific information provided through PCDs and libraries."
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeExtra.uni b/FmpDevicePkg/FmpDxe/FmpDxeExtra.uni
new file mode 100644
index 0000000000..8f3cc4367c
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/FmpDxeExtra.uni
@@ -0,0 +1,18 @@
+// /** @file
+// FmpDxe Localized Strings and Content
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// 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.
+//
+// **/
+
+#string STR_PROPERTIES_MODULE_NAME
+#language en-US
+"Firmware Management Protocol DXE DXE Driver"
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
new file mode 100644
index 0000000000..3ea4834948
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -0,0 +1,93 @@
+## @file
+#  Produces a Firmware Management Protocol that supports updates to a firmware
+#  image stored in a firmware device with platform and firmware device specific
+#  information provided through PCDs and libraries.
+#
+#  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  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]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = FmpDxeLib
+  MODULE_UNI_FILE                = FmpDxe.uni
+  FILE_GUID                      = 4B11717A-30B3-4122-8C69-8E0D5E141C32
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = NULL
+  CONSTRUCTOR                    = FmpDxeEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF ARM AARCH64
+#
+
+[Sources]
+  FmpDxe.c
+  VariableSupport.h
+  VariableSupport.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  SignedCapsulePkg/SignedCapsulePkg.dec
+  FmpDevicePkg/FmpDevicePkg.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  DebugLib
+  BaseLib
+  UefiBootServicesTableLib
+  UefiRuntimeServicesTableLib
+  UefiLib
+  MemoryAllocationLib
+  PrintLib
+  FmpDeviceLib
+  CapsuleUpdatePolicyLib
+  FmpPayloadHeaderLib
+  HobLib
+  FmpAuthenticationLib
+  DxeServicesLib
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+
+[Protocols]
+  gEfiFirmwareManagementProtocolGuid  ## PRODUCES
+  gEdkiiVariableLockProtocolGuid      ## SOMETIMES_CONSUMES
+
+[FeaturePcd]
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired  ## CONSUMES
+
+[Pcd]
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName                      ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion  ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid                    ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds    ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor                    ## CONSUMES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr               ## CONSUMES
+  gEfiSignedCapsulePkgTokenSpaceGuid.PcdEdkiiPkcs7TestPublicKeyFileGuid    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed                            ## SOMETIMES_PRODUCES
+
+[Depex]
+  TRUE
diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c
new file mode 100644
index 0000000000..c5ff094106
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/VariableSupport.c
@@ -0,0 +1,431 @@
+/**  @file
+  UEFI variable support functions for Firmware Management Protocol based
+  firmware updates.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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 <PiDxe.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Protocol/VariableLock.h>
+#include "VariableSupport.h"
+
+/**
+  Returns the value used to fill in the Version field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default version value
+  is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
+
+  @return  The version of the firmware image in the firmware device.
+
+**/
+UINT32
+GetVersionFromVariable (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      *Value;
+  UINTN       Size;
+  UINT32      Version;
+
+  Value = NULL;
+  Size = 0;
+  Version = DEFAULT_VERSION;
+
+  Status = GetVariable2 (VARNAME_VERSION, &gEfiCallerIdGuid, (VOID **)&Value, &Size);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "Failed to get the Version from variable.  Status = %r\n", Status));
+    return Version;
+  }
+
+  //
+  // No error from call
+  //
+  if (Size == sizeof (*Value)) {
+    //
+    // Successful read
+    //
+    Version = *Value;
+  } else {
+    //
+    // Return default since size was unknown
+    //
+    DEBUG ((DEBUG_ERROR, "Getting version Variable returned a size different than expected. Size = 0x%x\n", Size));
+  }
+
+  FreePool (Value);
+
+  return Version;
+}
+
+/**
+  Returns the 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.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default lowest
+  supported version value is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
+
+  @return  The lowest supported version of the firmware image in the firmware
+           device.
+
+**/
+UINT32
+GetLowestSupportedVersionFromVariable (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      *Value;
+  UINTN       Size;
+  UINT32      Version;
+
+  Value   = NULL;
+  Size    = 0;
+  Version = DEFAULT_LOWESTSUPPORTEDVERSION;
+
+  Status = GetVariable2 (VARNAME_LSV, &gEfiCallerIdGuid, (VOID **)&Value, &Size);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_WARN, "Warning: Failed to get the Lowest Supported Version from variable.  Status = %r\n", Status));
+    return Version;
+  }
+
+  //
+  // No error from call
+  //
+  if (Size == sizeof (*Value)) {
+    //
+    // Successful read
+    //
+    Version = *Value;
+  } else {
+    //
+    // Return default since size was unknown
+    //
+    DEBUG ((DEBUG_ERROR, "Getting LSV Variable returned a size different than expected. Size = 0x%x\n", Size));
+  }
+
+  FreePool (Value);
+
+  return Version;
+}
+
+/**
+  Returns the value used to fill in the LastAttemptStatus field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default last attempt
+  status value is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
+
+  @return  The last attempt status value for the most recent capsule update.
+
+**/
+UINT32
+GetLastAttemptStatusFromVariable (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      *Value;
+  UINTN       Size;
+  UINT32      LastAttemptStatus;
+
+  Value = NULL;
+  Size  = 0;
+  LastAttemptStatus     = DEFAULT_LASTATTEMPT;
+
+  Status = GetVariable2 (VARNAME_LASTATTEMPTSTATUS, &gEfiCallerIdGuid, (VOID **)&Value, &Size);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_WARN, "Warning: Failed to get the Last Attempt Status from variable.  Status = %r\n", Status));
+    return LastAttemptStatus;
+  }
+
+  //
+  // No error from call
+  //
+  if (Size == sizeof (*Value)) {
+    //
+    // Successful read
+    //
+    LastAttemptStatus = *Value;
+  } else {
+    //
+    // Return default since size was unknown
+    //
+    DEBUG (
+      (DEBUG_ERROR,
+      "Getting Last Attempt Status Variable returned a size different than expected. Size = 0x%x\n",
+      Size)
+      );
+  }
+
+  FreePool (Value);
+
+  return LastAttemptStatus;
+}
+
+/**
+  Returns the value used to fill in the LastAttemptVersion field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default last attempt
+  version value is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
+
+  @return  The last attempt version value for the most recent capsule update.
+
+**/
+UINT32
+GetLastAttemptVersionFromVariable (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      *Value;
+  UINTN       Size;
+  UINT32      Version;
+
+  Value   = NULL;
+  Size    = 0;
+  Version = DEFAULT_LASTATTEMPT;
+
+  Status = GetVariable2 (VARNAME_LASTATTEMPTVERSION, &gEfiCallerIdGuid, (VOID **)&Value, &Size);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_WARN, "Warning: Failed to get the Last Attempt Version from variable.  Status = %r\n", Status));
+    return Version;
+  }
+
+  //
+  // No error from call
+  //
+  if (Size == sizeof (*Value)) {
+    //
+    // Successful read
+    //
+    Version = *Value;
+  } else {
+    //
+    // Return default since size was unknown
+    //
+    DEBUG (
+      (DEBUG_ERROR,
+      "Getting Last Attempt Version variable returned a size different than expected. Size = 0x%x\n",
+      Size)
+      );
+  }
+
+  FreePool (Value);
+
+  return Version;
+}
+
+
+/**
+  Saves the version current of the firmware image in the firmware device to a
+  UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
+
+  @param[in] Version  The version of the firmware image in the firmware device.
+
+**/
+VOID
+SetVersionInVariable (
+   UINT32  Version
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Current;
+
+  Status = EFI_SUCCESS;
+
+  Current = GetVersionFromVariable();
+  if (Current != Version) {
+    Status = gRT->SetVariable (
+                    VARNAME_VERSION,
+                    &gEfiCallerIdGuid,
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                    sizeof (Version),
+                    &Version
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to set the Version into a variable.  Status = %r\n", Status));
+    }
+  } else {
+    DEBUG ((DEBUG_INFO, "Version variable doesn't need to update.  Same value as before.\n"));
+  }
+}
+
+/**
+  Saves the lowest supported version current of the firmware image in the
+  firmware device to a UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
+
+  @param[in] LowestSupported  The lowest supported version of the firmware image
+                              in the firmware device.
+
+**/
+VOID
+SetLowestSupportedVersionInVariable (
+   UINT32  LowestSupportedVersion
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Current;
+
+  Status = EFI_SUCCESS;
+
+  Current = GetLowestSupportedVersionFromVariable();
+  if (LowestSupportedVersion > Current) {
+    Status = gRT->SetVariable (
+                    VARNAME_LSV,
+                    &gEfiCallerIdGuid,
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                    sizeof (LowestSupportedVersion), &LowestSupportedVersion
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to set the LSV into a variable.  Status = %r\n", Status));
+    }
+  } else {
+    DEBUG ((DEBUG_INFO, "LSV variable doesn't need to update.  Same value as before.\n"));
+  }
+}
+
+/**
+  Saves the last attempt status value of the most recent FMP capsule update to a
+  UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
+
+  @param[in] LastAttemptStatus  The last attempt status of the most recent FMP
+                                capsule update.
+
+**/
+VOID
+SetLastAttemptStatusInVariable (
+   UINT32  LastAttemptStatus
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Current;
+
+  Status = EFI_SUCCESS;
+
+  Current = GetLastAttemptStatusFromVariable();
+  if (Current != LastAttemptStatus) {
+    Status = gRT->SetVariable (
+                    VARNAME_LASTATTEMPTSTATUS,
+                    &gEfiCallerIdGuid,
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                    sizeof (LastAttemptStatus),
+                    &LastAttemptStatus
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to set the LastAttemptStatus into a variable.  Status = %r\n", Status));
+    }
+  } else {
+    DEBUG ((DEBUG_INFO, "LastAttemptStatus variable doesn't need to update.  Same value as before.\n"));
+  }
+}
+
+/**
+  Saves the last attempt version value of the most recent FMP capsule update to
+  a UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
+
+  @param[in] LastAttemptVersion  The last attempt version value of the most
+                                 recent FMP capsule update.
+
+**/
+VOID
+SetLastAttemptVersionInVariable (
+   UINT32  LastAttemptVersion
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Current;
+
+  Status = EFI_SUCCESS;
+
+  Current = GetLastAttemptVersionFromVariable();
+  if (Current != LastAttemptVersion) {
+    Status = gRT->SetVariable (
+                    VARNAME_LASTATTEMPTVERSION,
+                    &gEfiCallerIdGuid,
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                    sizeof (LastAttemptVersion),
+                    &LastAttemptVersion
+                    );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to set the LastAttemptVersion into a variable.  Status = %r\n", Status));
+    }
+  } else {
+    DEBUG ((DEBUG_INFO, "LastAttemptVersion variable doesn't need to update.  Same value as before.\n"));
+  }
+}
+
+/**
+  Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently
+  executing module.
+
+**/
+VOID
+LockAllVars (
+  VOID
+  )
+{
+  EFI_STATUS                    Status;
+  EDKII_VARIABLE_LOCK_PROTOCOL  *Protocol;
+
+  Protocol = NULL;
+  Status = gBS->LocateProtocol (
+                  &gEdkiiVariableLockProtocolGuid,
+                  NULL,
+                  (VOID **)&Protocol
+                  );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "Failed to locate var lock protocol (%r).  Can't lock variables\n", Status));
+    return;
+  }
+  Status = Protocol->RequestToLock (Protocol, L"*", &gEfiCallerIdGuid);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "Failed to lock.  Status = %r\n", Status));
+  } else {
+    DEBUG ((DEBUG_INFO, "All variables are locked\n"));
+  }
+}
diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.h b/FmpDevicePkg/FmpDxe/VariableSupport.h
new file mode 100644
index 0000000000..675ffa11d2
--- /dev/null
+++ b/FmpDevicePkg/FmpDxe/VariableSupport.h
@@ -0,0 +1,180 @@
+/**  @file
+  UEFI variable support functions for Firmware Management Protocol based
+  firmware updates.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef __VARIABLE_SUPPORT_H__
+#define __VARIABLE_SUPPORT_H__
+
+#define DEFAULT_VERSION                 0x1
+#define DEFAULT_LOWESTSUPPORTEDVERSION  0x0
+#define DEFAULT_LASTATTEMPT             0x0
+
+#define VARNAME_VERSION                 L"FmpVersion"
+#define VARNAME_LSV                     L"FmpLsv"
+
+#define VARNAME_LASTATTEMPTSTATUS       L"LastAttemptStatus"
+#define VARNAME_LASTATTEMPTVERSION      L"LastAttemptVersion"
+
+/**
+  Returns the value used to fill in the Version field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default version value
+  is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
+
+  @return  The version of the firmware image in the firmware device.
+
+**/
+UINT32
+GetVersionFromVariable (
+  VOID
+  );
+
+/**
+  Returns the 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.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default lowest
+  supported version value is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
+
+  @return  The lowest supported version of the firmware image in the firmware
+           device.
+
+**/
+UINT32
+GetLowestSupportedVersionFromVariable (
+  VOID
+  );
+
+/**
+  Returns the value used to fill in the LastAttemptStatus field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default last attempt
+  status value is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
+
+  @return  The last attempt status value for the most recent capsule update.
+
+**/
+UINT32
+GetLastAttemptStatusFromVariable (
+  VOID
+  );
+
+/**
+  Returns the value used to fill in the LastAttemptVersion field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
+  service of the Firmware Management Protocol.  The value is read from a UEFI
+  variable.  If the UEFI variables does not exist, then a default last attempt
+  version value is returned.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
+
+  @return  The last attempt version value for the most recent capsule update.
+
+**/
+UINT32
+GetLastAttemptVersionFromVariable (
+  VOID
+  );
+
+/**
+  Saves the version current of the firmware image in the firmware device to a
+  UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
+
+  @param[in] Version  The version of the firmware image in the firmware device.
+
+**/
+VOID
+SetVersionInVariable (
+   UINT32  Version
+  );
+
+/**
+  Saves the lowest supported version current of the firmware image in the
+  firmware device to a UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
+
+  @param[in] LowestSupported  The lowest supported version of the firmware image
+                              in the firmware device.
+
+**/
+VOID
+SetLowestSupportedVersionInVariable (
+   UINT32  LowestSupportedVersion
+  );
+
+/**
+  Saves the last attempt status value of the most recent FMP capsule update to a
+  UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
+
+  @param[in] LastAttemptStatus  The last attempt status of the most recent FMP
+                                capsule update.
+
+**/
+VOID
+SetLastAttemptStatusInVariable (
+   UINT32  LastAttemptStatus
+  );
+
+/**
+  Saves the last attempt version value of the most recent FMP capsule update to
+  a UEFI variable.
+
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
+
+  @param[in] LastAttemptVersion  The last attempt version value of the most
+                                 recent FMP capsule update.
+
+**/
+VOID
+SetLastAttemptVersionInVariable (
+   UINT32  LastAttemptVersion
+  );
+
+/**
+  Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently
+  executing module.
+
+**/
+VOID
+LockAllVars (
+  VOID
+  );
+
+#endif
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC 4/4] FmpDevicePkg: Add DSC file to build all package components
  2018-04-04 21:28 [RFC 0/4] Add FmpDevicePkg Michael D Kinney
                   ` (2 preceding siblings ...)
  2018-04-04 21:28 ` [RFC 3/4] FmpDevicePkg: Add FmpDxe module Michael D Kinney
@ 2018-04-04 21:28 ` Michael D Kinney
  2018-04-04 23:29 ` [RFC 0/4] Add FmpDevicePkg Yao, Jiewen
  4 siblings, 0 replies; 9+ messages in thread
From: Michael D Kinney @ 2018-04-04 21:28 UTC (permalink / raw)
  To: edk2-devel; +Cc: Kinney, Michael D, Sean Brogan, Jiewen Yao

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch:

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

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

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 FmpDevicePkg/FmpDevicePkg.dsc | 119 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 119 insertions(+)
 create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc

diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc
new file mode 100644
index 0000000000..779b1ac243
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dsc
@@ -0,0 +1,119 @@
+## @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.<BR>
+# Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+##
+
+[Defines]
+  PLATFORM_NAME                  = FmpDevicePkg
+  PLATFORM_GUID                  = 0af3d540-27c6-11e8-828b-f8597177a00a
+  PLATFORM_VERSION               = 0.1
+  DSC_SPECIFICATION              = 0x00010005
+  OUTPUT_DIRECTORY               = Build/FmpDevicePkg
+  SUPPORTED_ARCHITECTURES        = IA32|IPF|X64|ARM|AARCH64
+  BUILD_TARGETS                  = DEBUG|RELEASE
+  SKUID_IDENTIFIER               = DEFAULT
+
+  #
+  # Define ESRT GUIDs for Firmware Management Protocol instances
+  #
+  DEFINE FMP_GRAPHICS_ESRT_GUID  = B461B3BD-E62A-4A71-841C-50BA4E500267
+  DEFINE FMP_TEXT_ESRT_GUID      = 226034C4-8B67-4536-8653-D6EE7CE5A316
+
+[LibraryClasses]
+  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+  UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
+  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  PostCodeLib|MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+
+  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+  FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
+
+  CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
+  FmpPayloadHeaderLib|FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
+  FmpDeviceLib|FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+
+[Components]
+  #
+  # Libraries
+  #
+  FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
+  FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
+  FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLibNull.inf
+  FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+
+  #
+  # Modules
+  #
+  FmpDevicePkg/FmpDxe/FmpDxe.inf {
+    <Defines>
+      #
+      # FILE_GUID is FMP ESRT GUID
+      #
+      FILE_GUID = $(FMP_GRAPHICS_ESRT_GUID)
+    <LibraryClasses>
+      DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
+  }
+
+  FmpDevicePkg/FmpDxe/FmpDxe.inf {
+    <Defines>
+      #
+      # FILE_GUID is used as ESRT GUID
+      #
+      FILE_GUID = $(FMP_TEXT_ESRT_GUID)
+    <LibraryClasses>
+      DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
+  }
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RFC 0/4] Add FmpDevicePkg
  2018-04-04 21:28 [RFC 0/4] Add FmpDevicePkg Michael D Kinney
                   ` (3 preceding siblings ...)
  2018-04-04 21:28 ` [RFC 4/4] FmpDevicePkg: Add DSC file to build all package components Michael D Kinney
@ 2018-04-04 23:29 ` Yao, Jiewen
  2018-04-05  0:28   ` Kinney, Michael D
  4 siblings, 1 reply; 9+ messages in thread
From: Yao, Jiewen @ 2018-04-04 23:29 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org

Hi Mike
It is great to see this feature. Thanks for doing this.

Some thought below:
1) Do we must add V1 as suffix for the FmpPayloadHeaderLib?
I think we can just use that FmpPayloadHeaderLib.
If we have second version, we can use FmpPayloadHeaderLibV2.

2) The check in GetFmpPayloadHeaderSize() seems weird.

  if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||

If we just want to add overflow check, I suggest we use below.
  if ((UINTN)FmpPayloadHeader > (MAX_ADDRESS - sizeof (FMP_PAYLOAD_HEADER)) ||

I think it is more readable.

3) For FmpDeviceLib, the interface definition seems not consistent.

Most of them return EFI_STATUS, such as:
EFI_STATUS
EFIAPI
FmpDeviceGetLowestSupportedVersion (
  OUT UINT32  *LowestSupportedVersion
  )

But some return data directly, such as:
CHAR16 *
EFIAPI
FmpDeviceGetVersionString (
  VOID
  )

Can we make them consistent to return EFI_STATUS for all? Such as
EFI_STATUS
EFIAPI
FmpDeviceGetVersionString (
  OUT CHAR16 **VersionString
  )

4) Do we need GetPackageVersion() and GetPackageVersionName() ?

5) I found FmpDxe driver returns unsupported for GetPackageInfo() and SetPackageInfo().
It means that an implementation cannot use FmpDxe driver as template, if it wants to support those 2.

Is there any design limitation ?

6) for variable set, I do not think we need get and compare.
I think variable driver already did that for us. The caller can just set the variable.

VOID
SetVersionInVariable (
   UINT32  Version
  )
{
  EFI_STATUS  Status;
  UINT32      Current;

  Status = EFI_SUCCESS;

  Current = GetVersionFromVariable();
  if (Current != Version) {
    Status = gRT->SetVariable (
                    VARNAME_VERSION,
                    &gEfiCallerIdGuid,
                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
                    sizeof (Version),
                    &Version
                    );

7) for LockAllVars(), I found it only happens in non flash_update boot mode.
I think we should also do in flash_update boot mode, after the capsule is processed.

Or there will be a hole, for the non-reset capsule.

  //
  // If the boot mode isn't flash update then we must lock all vars.
  // If it is flash update leave them unlocked as the system will not
  // boot all the way in flash update mode
  //
  if (BOOT_ON_FLASH_UPDATE != GetBootModeHob ()) {
    LockAllVars ();
  }

8) I am surprised that we support "*" as variable name. Will it lock all variables with gEfiCallerIdGuid?

Status = Protocol->RequestToLock (Protocol, L"*", &gEfiCallerIdGuid);


Thank you
Yao Jiewen


> -----Original Message-----
> From: Kinney, Michael D
> Sent: Thursday, April 5, 2018 5:29 AM
> To: edk2-devel@lists.01.org
> Cc: Sean Brogan <sean.brogan@microsoft.com>; Yao, Jiewen
> <jiewen.yao@intel.com>
> Subject: [RFC 0/4] Add FmpDevicePkg
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=922
> 
> Based on content from the following branch:
> 
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsu
> leUpdatePkg
> 
> Branch for review:
> 
> https://github.com/mdkinney/edk2/tree/Bug_922_FmpDevicePkg
> 
> This package provides an implementation of a Firmware Management Protocol
> instance that supports the update of firmware storage devices using UEFI
> Capsules.  The behavior of the Firmware Management Protocol instance is
> customized using libraries and PCDs.
> 
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Kinney, Michael D (4):
>   FmpDevicePkg: Add package, library classes, and PCDs
>   FmpDevicePkg: Add library instances
>   FmpDevicePkg: Add FmpDxe module
>   FmpDevicePkg: Add DSC file to build all package components
> 
>  FmpDevicePkg/FmpDevicePkg.dec                      |  126 ++
>  FmpDevicePkg/FmpDevicePkg.dsc                      |  119 ++
>  FmpDevicePkg/FmpDevicePkg.uni                      |   75 +
>  FmpDevicePkg/FmpDevicePkgExtra.uni                 |   18 +
>  FmpDevicePkg/FmpDxe/FmpDxe.c                       | 1533
> ++++++++++++++++++++
>  FmpDevicePkg/FmpDxe/FmpDxe.inf                     |   96 ++
>  FmpDevicePkg/FmpDxe/FmpDxe.uni                     |   20 +
>  FmpDevicePkg/FmpDxe/FmpDxeExtra.uni                |   18 +
>  FmpDevicePkg/FmpDxe/FmpDxeLib.inf                  |   93 ++
>  FmpDevicePkg/FmpDxe/VariableSupport.c              |  431 ++++++
>  FmpDevicePkg/FmpDxe/VariableSupport.h              |  180 +++
>  .../Include/Library/CapsuleUpdatePolicyLib.h       |  120 ++
>  FmpDevicePkg/Include/Library/FmpDeviceLib.h        |  385 +++++
>  FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h |  100 ++
>  .../CapsuleUpdatePolicyLibNull.c                   |  136 ++
>  .../CapsuleUpdatePolicyLibNull.inf                 |   45 +
>  .../CapsuleUpdatePolicyLibNull.uni                 |   17 +
>  .../Library/FmpDeviceLibNull/FmpDeviceLib.c        |  395 +++++
>  .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |   48 +
>  .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |   18 +
>  .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c    |  188 +++
>  .../FmpPayloadHeaderLibV1.inf                      |   48 +
>  .../FmpPayloadHeaderLibV1.uni                      |   21 +
>  23 files changed, 4230 insertions(+)
>  create mode 100644 FmpDevicePkg/FmpDevicePkg.dec
>  create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc
>  create mode 100644 FmpDevicePkg/FmpDevicePkg.uni
>  create mode 100644 FmpDevicePkg/FmpDevicePkgExtra.uni
>  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
>  create mode 100644 FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
>  create mode 100644 FmpDevicePkg/Include/Library/FmpDeviceLib.h
>  create mode 100644 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
>  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
> 
> --
> 2.14.2.windows.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC 0/4] Add FmpDevicePkg
  2018-04-04 23:29 ` [RFC 0/4] Add FmpDevicePkg Yao, Jiewen
@ 2018-04-05  0:28   ` Kinney, Michael D
  2018-04-08  9:16     ` Zeng, Star
  0 siblings, 1 reply; 9+ messages in thread
From: Kinney, Michael D @ 2018-04-05  0:28 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org

Hi Jiewen,

Responses below.  

A couple require some comments from Sean or Bret.

Mike

> -----Original Message-----
> From: Yao, Jiewen
> Sent: Wednesday, April 4, 2018 4:29 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>;
> edk2-devel@lists.01.org
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Subject: RE: [RFC 0/4] Add FmpDevicePkg
> 
> Hi Mike
> It is great to see this feature. Thanks for doing this.
> 
> Some thought below:
> 1) Do we must add V1 as suffix for the
> FmpPayloadHeaderLib?
> I think we can just use that FmpPayloadHeaderLib.
> If we have second version, we can use
> FmpPayloadHeaderLibV2.
> 

It is not a must, but since this library class is designed
to manage a versioned header structure with extensibility
in mind, I do not see anything wrong with V1 in the name.

In many cases the exiting use of a 2 suffix in the EDK II
is because the original one was not intending multiple
versions but an issue was discovered later that required
a new version. 

> 2) The check in GetFmpPayloadHeaderSize() seems weird.
> 
>   if ((UINTN)FmpPayloadHeader + sizeof
> (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
> 
> If we just want to add overflow check, I suggest we use
> below.
>   if ((UINTN)FmpPayloadHeader > (MAX_ADDRESS - sizeof
> (FMP_PAYLOAD_HEADER)) ||
> 
> I think it is more readable.
> 

Maybe we should use SafeIntLib service instead?


> 3) For FmpDeviceLib, the interface definition seems not
> consistent.
> 
> Most of them return EFI_STATUS, such as:
> EFI_STATUS
> EFIAPI
> FmpDeviceGetLowestSupportedVersion (
>   OUT UINT32  *LowestSupportedVersion
>   )
> 
> But some return data directly, such as:
> CHAR16 *
> EFIAPI
> FmpDeviceGetVersionString (
>   VOID
>   )
> 
> Can we make them consistent to return EFI_STATUS for
> all? Such as
> EFI_STATUS
> EFIAPI
> FmpDeviceGetVersionString (
>   OUT CHAR16 **VersionString
>   )
> 

I agree they are inconsistent.  These APIs are the same
as the ones from MS_UEFI GitHub branch and I did not change
the API design.  It appears that some of the APIs in 
the FmpDeviceLib are optimized for how they are used by the
FmpDxe component.

> 4) Do we need GetPackageVersion() and
> GetPackageVersionName() ?

No.

> 
> 5) I found FmpDxe driver returns unsupported for
> GetPackageInfo() and SetPackageInfo().
> It means that an implementation cannot use FmpDxe
> driver as template, if it wants to support those 2.
> 
> Is there any design limitation ?

Yes.  This simplified Firmware Management Protocol
Implementation does not support Get/Set PackageInfo().
The UEFI Specification allows these APIs to return
EFI_UNSUPPORTED, and for this firmware update use
case they are not required.  If a Firmware Management
Protocol implementation requires Get/Set PackageInfo()
then FmpDxe should not be used.

> 
> 6) for variable set, I do not think we need get and
> compare.
> I think variable driver already did that for us. The
> caller can just set the variable.
> 
> VOID
> SetVersionInVariable (
>    UINT32  Version
>   )
> {
>   EFI_STATUS  Status;
>   UINT32      Current;
> 
>   Status = EFI_SUCCESS;
> 
>   Current = GetVersionFromVariable();
>   if (Current != Version) {
>     Status = gRT->SetVariable (
>                     VARNAME_VERSION,
>                     &gEfiCallerIdGuid,
>                     EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
>                     sizeof (Version),
>                     &Version
>                     );
> 

Does the UEFI Specification require the compare on set?
If not, then is there any harm in doing this check? 


> 7) for LockAllVars(), I found it only happens in non
> flash_update boot mode.
> I think we should also do in flash_update boot mode,
> after the capsule is processed.
> 
> Or there will be a hole, for the non-reset capsule.
> 
>   //
>   // If the boot mode isn't flash update then we must
> lock all vars.
>   // If it is flash update leave them unlocked as the
> system will not
>   // boot all the way in flash update mode
>   //
>   if (BOOT_ON_FLASH_UPDATE != GetBootModeHob ()) {
>     LockAllVars ();
>   }
> 

That is a good point.  Maybe Sean had another use case in mind?

> 8) I am surprised that we support "*" as variable name.
> Will it lock all variables with gEfiCallerIdGuid?
> 
> Status = Protocol->RequestToLock (Protocol, L"*",
> &gEfiCallerIdGuid);
> 

I was equally surprised.  I thought it may be a special argument
to the EDK II specific lock protocol.  Maybe it is a feature
that was not included in the MS_UEFI branch.

> 
> Thank you
> Yao Jiewen
> 
> 
> > -----Original Message-----
> > From: Kinney, Michael D
> > Sent: Thursday, April 5, 2018 5:29 AM
> > To: edk2-devel@lists.01.org
> > Cc: Sean Brogan <sean.brogan@microsoft.com>; Yao,
> Jiewen
> > <jiewen.yao@intel.com>
> > Subject: [RFC 0/4] Add FmpDevicePkg
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=922
> >
> > Based on content from the following branch:
> >
> >
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsu
> leSupport/MsCapsu
> > leUpdatePkg
> >
> > Branch for review:
> >
> >
> https://github.com/mdkinney/edk2/tree/Bug_922_FmpDevice
> Pkg
> >
> > This package provides an implementation of a Firmware
> Management Protocol
> > instance that supports the update of firmware storage
> devices using UEFI
> > Capsules.  The behavior of the Firmware Management
> Protocol instance is
> > customized using libraries and PCDs.
> >
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> > Signed-off-by: Michael D Kinney
> <michael.d.kinney@intel.com>
> >
> > Kinney, Michael D (4):
> >   FmpDevicePkg: Add package, library classes, and
> PCDs
> >   FmpDevicePkg: Add library instances
> >   FmpDevicePkg: Add FmpDxe module
> >   FmpDevicePkg: Add DSC file to build all package
> components
> >
> >  FmpDevicePkg/FmpDevicePkg.dec                      |
> 126 ++
> >  FmpDevicePkg/FmpDevicePkg.dsc                      |
> 119 ++
> >  FmpDevicePkg/FmpDevicePkg.uni                      |
> 75 +
> >  FmpDevicePkg/FmpDevicePkgExtra.uni                 |
> 18 +
> >  FmpDevicePkg/FmpDxe/FmpDxe.c                       |
> 1533
> > ++++++++++++++++++++
> >  FmpDevicePkg/FmpDxe/FmpDxe.inf                     |
> 96 ++
> >  FmpDevicePkg/FmpDxe/FmpDxe.uni                     |
> 20 +
> >  FmpDevicePkg/FmpDxe/FmpDxeExtra.uni                |
> 18 +
> >  FmpDevicePkg/FmpDxe/FmpDxeLib.inf                  |
> 93 ++
> >  FmpDevicePkg/FmpDxe/VariableSupport.c              |
> 431 ++++++
> >  FmpDevicePkg/FmpDxe/VariableSupport.h              |
> 180 +++
> >  .../Include/Library/CapsuleUpdatePolicyLib.h       |
> 120 ++
> >  FmpDevicePkg/Include/Library/FmpDeviceLib.h        |
> 385 +++++
> >  FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h |
> 100 ++
> >  .../CapsuleUpdatePolicyLibNull.c                   |
> 136 ++
> >  .../CapsuleUpdatePolicyLibNull.inf                 |
> 45 +
> >  .../CapsuleUpdatePolicyLibNull.uni                 |
> 17 +
> >  .../Library/FmpDeviceLibNull/FmpDeviceLib.c        |
> 395 +++++
> >  .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |
> 48 +
> >  .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |
> 18 +
> >  .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c    |
> 188 +++
> >  .../FmpPayloadHeaderLibV1.inf                      |
> 48 +
> >  .../FmpPayloadHeaderLibV1.uni                      |
> 21 +
> >  23 files changed, 4230 insertions(+)
> >  create mode 100644 FmpDevicePkg/FmpDevicePkg.dec
> >  create mode 100644 FmpDevicePkg/FmpDevicePkg.dsc
> >  create mode 100644 FmpDevicePkg/FmpDevicePkg.uni
> >  create mode 100644
> FmpDevicePkg/FmpDevicePkgExtra.uni
> >  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
> >  create mode 100644
> FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
> >  create mode 100644
> FmpDevicePkg/Include/Library/FmpDeviceLib.h
> >  create mode 100644
> FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
> >  create mode 100644
> >
> FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule
> UpdatePolicyLibNull
> > .c
> >  create mode 100644
> >
> FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule
> UpdatePolicyLibNull
> > .inf
> >  create mode 100644
> >
> FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule
> UpdatePolicyLibNull
> > .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/FmpPayloadHe
> aderLib.c
> >  create mode 100644
> >
> FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe
> aderLibV1.inf
> >  create mode 100644
> >
> FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe
> aderLibV1.uni
> >
> > --
> > 2.14.2.windows.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC 0/4] Add FmpDevicePkg
  2018-04-05  0:28   ` Kinney, Michael D
@ 2018-04-08  9:16     ` Zeng, Star
  0 siblings, 0 replies; 9+ messages in thread
From: Zeng, Star @ 2018-04-08  9:16 UTC (permalink / raw)
  To: Kinney, Michael D, Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Zeng, Star

Curious about which tool to generate the FMP_PAYLOAD_HEADER?
BaseTools needs to be updated?


Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Kinney, Michael D
Sent: Thursday, April 5, 2018 8:29 AM
To: Yao, Jiewen <jiewen.yao@intel.com>; edk2-devel@lists.01.org
Subject: Re: [edk2] [RFC 0/4] Add FmpDevicePkg

Hi Jiewen,

Responses below.  

A couple require some comments from Sean or Bret.

Mike

> -----Original Message-----
> From: Yao, Jiewen
> Sent: Wednesday, April 4, 2018 4:29 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; 
> edk2-devel@lists.01.org
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Subject: RE: [RFC 0/4] Add FmpDevicePkg
> 
> Hi Mike
> It is great to see this feature. Thanks for doing this.
> 
> Some thought below:
> 1) Do we must add V1 as suffix for the FmpPayloadHeaderLib?
> I think we can just use that FmpPayloadHeaderLib.
> If we have second version, we can use
> FmpPayloadHeaderLibV2.
> 

It is not a must, but since this library class is designed to manage a versioned header structure with extensibility in mind, I do not see anything wrong with V1 in the name.

In many cases the exiting use of a 2 suffix in the EDK II is because the original one was not intending multiple versions but an issue was discovered later that required a new version. 

> 2) The check in GetFmpPayloadHeaderSize() seems weird.
> 
>   if ((UINTN)FmpPayloadHeader + sizeof
> (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
> 
> If we just want to add overflow check, I suggest we use below.
>   if ((UINTN)FmpPayloadHeader > (MAX_ADDRESS - sizeof
> (FMP_PAYLOAD_HEADER)) ||
> 
> I think it is more readable.
> 

Maybe we should use SafeIntLib service instead?


> 3) For FmpDeviceLib, the interface definition seems not consistent.
> 
> Most of them return EFI_STATUS, such as:
> EFI_STATUS
> EFIAPI
> FmpDeviceGetLowestSupportedVersion (
>   OUT UINT32  *LowestSupportedVersion
>   )
> 
> But some return data directly, such as:
> CHAR16 *
> EFIAPI
> FmpDeviceGetVersionString (
>   VOID
>   )
> 
> Can we make them consistent to return EFI_STATUS for all? Such as 
> EFI_STATUS EFIAPI FmpDeviceGetVersionString (
>   OUT CHAR16 **VersionString
>   )
> 

I agree they are inconsistent.  These APIs are the same as the ones from MS_UEFI GitHub branch and I did not change the API design.  It appears that some of the APIs in the FmpDeviceLib are optimized for how they are used by the FmpDxe component.

> 4) Do we need GetPackageVersion() and
> GetPackageVersionName() ?

No.

> 
> 5) I found FmpDxe driver returns unsupported for
> GetPackageInfo() and SetPackageInfo().
> It means that an implementation cannot use FmpDxe driver as template, 
> if it wants to support those 2.
> 
> Is there any design limitation ?

Yes.  This simplified Firmware Management Protocol Implementation does not support Get/Set PackageInfo().
The UEFI Specification allows these APIs to return EFI_UNSUPPORTED, and for this firmware update use case they are not required.  If a Firmware Management Protocol implementation requires Get/Set PackageInfo() then FmpDxe should not be used.

> 
> 6) for variable set, I do not think we need get and compare.
> I think variable driver already did that for us. The caller can just 
> set the variable.
> 
> VOID
> SetVersionInVariable (
>    UINT32  Version
>   )
> {
>   EFI_STATUS  Status;
>   UINT32      Current;
> 
>   Status = EFI_SUCCESS;
> 
>   Current = GetVersionFromVariable();
>   if (Current != Version) {
>     Status = gRT->SetVariable (
>                     VARNAME_VERSION,
>                     &gEfiCallerIdGuid,
>                     EFI_VARIABLE_NON_VOLATILE | 
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
>                     sizeof (Version),
>                     &Version
>                     );
> 

Does the UEFI Specification require the compare on set?
If not, then is there any harm in doing this check? 


> 7) for LockAllVars(), I found it only happens in non flash_update boot 
> mode.
> I think we should also do in flash_update boot mode, after the capsule 
> is processed.
> 
> Or there will be a hole, for the non-reset capsule.
> 
>   //
>   // If the boot mode isn't flash update then we must lock all vars.
>   // If it is flash update leave them unlocked as the system will not
>   // boot all the way in flash update mode
>   //
>   if (BOOT_ON_FLASH_UPDATE != GetBootModeHob ()) {
>     LockAllVars ();
>   }
> 

That is a good point.  Maybe Sean had another use case in mind?

> 8) I am surprised that we support "*" as variable name.
> Will it lock all variables with gEfiCallerIdGuid?
> 
> Status = Protocol->RequestToLock (Protocol, L"*", &gEfiCallerIdGuid);
> 

I was equally surprised.  I thought it may be a special argument to the EDK II specific lock protocol.  Maybe it is a feature that was not included in the MS_UEFI branch.

> 
> Thank you
> Yao Jiewen
> 
> 
> > -----Original Message-----
> > From: Kinney, Michael D
> > Sent: Thursday, April 5, 2018 5:29 AM
> > To: edk2-devel@lists.01.org
> > Cc: Sean Brogan <sean.brogan@microsoft.com>; Yao,
> Jiewen
> > <jiewen.yao@intel.com>
> > Subject: [RFC 0/4] Add FmpDevicePkg
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=922
> >
> > Based on content from the following branch:
> >
> >
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsu
> leSupport/MsCapsu
> > leUpdatePkg
> >
> > Branch for review:
> >
> >
> https://github.com/mdkinney/edk2/tree/Bug_922_FmpDevice
> Pkg
> >
> > This package provides an implementation of a Firmware
> Management Protocol
> > instance that supports the update of firmware storage
> devices using UEFI
> > Capsules.  The behavior of the Firmware Management
> Protocol instance is
> > customized using libraries and PCDs.
> >
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> > Signed-off-by: Michael D Kinney
> <michael.d.kinney@intel.com>
> >
> > Kinney, Michael D (4):
> >   FmpDevicePkg: Add package, library classes, and
> PCDs
> >   FmpDevicePkg: Add library instances
> >   FmpDevicePkg: Add FmpDxe module
> >   FmpDevicePkg: Add DSC file to build all package
> components
> >
> >  FmpDevicePkg/FmpDevicePkg.dec                      |
> 126 ++
> >  FmpDevicePkg/FmpDevicePkg.dsc                      |
> 119 ++
> >  FmpDevicePkg/FmpDevicePkg.uni                      |
> 75 +
> >  FmpDevicePkg/FmpDevicePkgExtra.uni                 |
> 18 +
> >  FmpDevicePkg/FmpDxe/FmpDxe.c                       |
> 1533
> > ++++++++++++++++++++
> >  FmpDevicePkg/FmpDxe/FmpDxe.inf                     |
> 96 ++
> >  FmpDevicePkg/FmpDxe/FmpDxe.uni                     |
> 20 +
> >  FmpDevicePkg/FmpDxe/FmpDxeExtra.uni                |
> 18 +
> >  FmpDevicePkg/FmpDxe/FmpDxeLib.inf                  |
> 93 ++
> >  FmpDevicePkg/FmpDxe/VariableSupport.c              |
> 431 ++++++
> >  FmpDevicePkg/FmpDxe/VariableSupport.h              |
> 180 +++
> >  .../Include/Library/CapsuleUpdatePolicyLib.h       |
> 120 ++
> >  FmpDevicePkg/Include/Library/FmpDeviceLib.h        |
> 385 +++++
> >  FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h |
> 100 ++
> >  .../CapsuleUpdatePolicyLibNull.c                   |
> 136 ++
> >  .../CapsuleUpdatePolicyLibNull.inf                 |
> 45 +
> >  .../CapsuleUpdatePolicyLibNull.uni                 |
> 17 +
> >  .../Library/FmpDeviceLibNull/FmpDeviceLib.c        |
> 395 +++++
> >  .../Library/FmpDeviceLibNull/FmpDeviceLibNull.inf  |
> 48 +
> >  .../Library/FmpDeviceLibNull/FmpDeviceLibNull.uni  |
> 18 +
> >  .../FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c    |
> 188 +++
> >  .../FmpPayloadHeaderLibV1.inf                      |
> 48 +
> >  .../FmpPayloadHeaderLibV1.uni                      |
> 21 +
> >  23 files changed, 4230 insertions(+)  create mode 100644 
> > FmpDevicePkg/FmpDevicePkg.dec  create mode 100644 
> > FmpDevicePkg/FmpDevicePkg.dsc  create mode 100644 
> > FmpDevicePkg/FmpDevicePkg.uni  create mode 100644
> FmpDevicePkg/FmpDevicePkgExtra.uni
> >  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
> >  create mode 100644
> FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
> >  create mode 100644
> FmpDevicePkg/Include/Library/FmpDeviceLib.h
> >  create mode 100644
> FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
> >  create mode 100644
> >
> FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule
> UpdatePolicyLibNull
> > .c
> >  create mode 100644
> >
> FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule
> UpdatePolicyLibNull
> > .inf
> >  create mode 100644
> >
> FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/Capsule
> UpdatePolicyLibNull
> > .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/FmpPayloadHe
> aderLib.c
> >  create mode 100644
> >
> FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe
> aderLibV1.inf
> >  create mode 100644
> >
> FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHe
> aderLibV1.uni
> >
> > --
> > 2.14.2.windows.3

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs
  2018-04-04 21:28 ` [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs Michael D Kinney
@ 2018-04-08  9:18   ` Zeng, Star
  0 siblings, 0 replies; 9+ messages in thread
From: Zeng, Star @ 2018-04-08  9:18 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org
  Cc: Kinney, Michael D, Yao, Jiewen, Zeng, Star

Since PcdFmpDeviceBuildTimeLowestSupportedVersion is defined to support only FixedAtBuild and PatchableInModule, it is definitely for build time.
Do we really need "BuildTime" keyword in the PCD name PcdFmpDeviceBuildTimeLowestSupportedVersion?


Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Michael D Kinney
Sent: Thursday, April 5, 2018 5:29 AM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
Subject: [edk2] [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch:

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

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

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

PCDs set per module
====================
* PcdFmpDeviceSystemResetRequired - Indicates if a full
  system reset is required before a firmware update to a
  firmware devices takes effect
* 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.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 FmpDevicePkg/FmpDevicePkg.dec                      | 126 +++++++
 FmpDevicePkg/FmpDevicePkg.uni                      |  75 ++++
 FmpDevicePkg/FmpDevicePkgExtra.uni                 |  18 +
 .../Include/Library/CapsuleUpdatePolicyLib.h       | 120 +++++++
 FmpDevicePkg/Include/Library/FmpDeviceLib.h        | 385 +++++++++++++++++++++
 FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h | 100 ++++++
 6 files changed, 824 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 0000000000..62fb98dbdb
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.dec
@@ -0,0 +1,126 @@
+## @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.<BR> # 
+Copyright (c) 2018, Intel Corporation. All rights reserved.<BR> # # 
+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]
+  DEC_SPECIFICATION = 0x00010005
+  PACKAGE_NAME      = FmpDevicePkg
+  PACKAGE_UNI_FILE  = FmpDevicePkg.uni
+  PACKAGE_GUID      = 080b5b4f-27c6-11e8-84d1-f8597177a00a
+  PACKAGE_VERSION   = 0.1
+
+[Includes]
+  Include
+
+[LibraryClasses]
+  ##  @libraryclass  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.
+  FmpPayloadHeaderLib|Include/Library/FmpPayloadHeaderLib.h
+
+  ##  @libraryclass  Provides platform policy services used during a capsule
+  #                  update.
+  CapsuleUpdatePolicyLib|Include/Library/CapsuleUpdatePolicyLib.h
+
+  ##  @libraryclass  Provides firmware device specific services to support
+  #                  updates of a firmware image stored in a firmware device.
+  FmpDeviceLib|Include/Library/FmpDeviceLib.h
+
+[Guids]
+  ## Firmware Management Protocol Device Package Token Space GUID
+  gFmpDevicePkgTokenSpaceGuid = { 0x40b2d964, 0xfe11, 0x40dc, { 0x82, 
+0x83, 0x2e, 0xfb, 0xda, 0x29, 0x53, 0x56 } }
+
+[PcdsFeatureFlag]
+  ## Indicates if a full system reset is required before a firmware 
+update to a
+  #  firmware devices takes effect.<BR><BR>
+  #   TRUE  - System reset is required.<BR>
+  #   FALSE - System reset is not required.<BR>
+  # @Prompt FMP Device System Reset Required.
+  
+gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceSystemResetRequired|TRUE|BOOLEA
+N|0x40000008
+
+[PcdsFixedAtBuild, PcdsPatchableInModule]
+  ## The color of the progress bar during a firmware update.  Each 
+firmware
+  #  device can set its own color.  The default color is white.<BR><BR>
+  #  Bits  7..0  - Red<BR>
+  #  Bits 15..8  - Green<BR>
+  #  Bits 23..16 - Blue<BR>
+  # @Prompt Firmware Device Progress Bar Color.
+  
+gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor|0x00FFFFFF|UINT32
+|0x40000004
+
+  ## 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.  An ImageIdName string must be provided for each firmware device.
+  #  The default value is an empty string.
+  # @Prompt Firmware Device ImageIdName string.
+  
+ gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L""|VOID*|0x400000
+ 07
+
+  ## 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.  This value is  #  only used if the firmware device does not 
+ provide a method to report the  #  lowest supported version value from 
+ the current firmware image and the  #  UEFI variable used to provide 
+ the lowest supported version value does not  #  exist.  The default value is 0.
+  # @Prompt Build Time Firmware Device Lowest Support Version.
+  
+ gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersio
+ n|0x0|UINT32|0x4000000C
+
+  ## The time in seconds to arm a watchdog timer during the update of a 
+ firmware  #  device.  The watchdog is re-armed each time the 
+ FmpDeviceLib calls the  #  Progress() function passed into 
+ FmpDeviceSetImage() function.  The  #  FmpDeviceLib calls Progress() 
+ to update the percent completion of a  #  firmware update.  If the 
+ watchdog timer expires, the system reboots.  A  #  value of 0 disables 
+ the watchdog timer.  The default value is 0 (watchdog  #  disabled).
+  # @Prompt Firmware Device Watchdog Time in Seconds.
+  
+ gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds|
+ 0x0|UINT8|0x4000000D
+
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+  ## One or more PKCS7 certificates used to verify a firmware device 
+capsule
+  #  update image.  Encoded using the Variable-Length Opaque Data 
+format of RFC
+  #  4506 External Data Representation Standard (XDR).  The default 
+value is
+  #  empty with 0 certificates.
+  # @Prompt One or more XDR encoded PKCS7 certificates used to verify firmware device capsule update images.
+  
+gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr|{0x0}|VOID*|
+0x4000000E
+
+  ## An event GUID that locks the firmware device when the event is signaled.
+  #  If this PCD is not a valid GUID value, then the firmware device is 
+ locked  #  when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is 
+ signaled.  The  #  default value is empty, so by default the firmware 
+ device is locked at the  #  end of the DXE phase.
+  # @Prompt Firmware Device Lock Event GUID.
+  
+ gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceLockEventGuid|{0}|VOID*|0x4000
+ 000F
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  FmpDevicePkgExtra.uni
diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni new file mode 100644 index 0000000000..ba3f6d64c2
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkg.uni
@@ -0,0 +1,75 @@
+// /** @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) 2018, Intel Corporation. All rights reserved.<BR> // 
+// This program and the accompanying materials are licensed and made 
+available under // the terms and conditions of the BSD License 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.
+//
+// **/
+
+#string STR_PACKAGE_ABSTRACT     #language en-US  "Firmware Management Protocol Software Development Kit"
+
+#string STR_PACKAGE_DESCRIPTION  #language en-US  "This package provides libraries that support the implementation of a module that produces the Firmware Management Protocol to support the update of a system firmware component."
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_PROMPT  #language en-US "FMP Device System Reset Required."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceSystemResetRequired_HELP    #language en-US "Indicates if a full system reset is required before a firmware update to a firmware device takes effect.<BR><BR>\n"
+                                                                                                "TRUE  - System reset is required.<BR>\n"
+                                                                                                "FALSE - System reset is not required.<BR>"
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressColor_PROMPT  #language en-US "Firmware Device Progress Bar Color."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressColor_HELP    #language en-US "The color of the progress bar during a firmware update.  Each firmware"
+                                                                                          "device can set its own color.  The default color is white.<BR><BR>\n"
+                                                                                          "Bits  7..0  - Red<BR>\n"
+                                                                                          "Bits 15..8  - Green<BR>\n"
+                                                                                          "Bits 23..16 - Blue<BR>\n"
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageIdName_PROMPT  #language en-US "Firmware Device ImageIdName string."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageIdName_HELP    #language en-US "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.  An ImageIdName string must be provided for each firmware device."
+                                                                                        "The default value is an empty string."
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceBuildTimeLowestSupportedVersion_PROMPT  #language en-US "Build Time Firmware Device Lowest Support Version."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceBuildTimeLowestSupportedVersion_HELP    #language en-US "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.  This value is"
+                                                                                                            "only used if the firmware device does not provide a method to report the"
+                                                                                                            "lowest supported version value from the current firmware image and the"
+                                                                                                            "UEFI variable used to provide the lowest supported version value does not"
+                                                                                                            "exist.  The default value is 0."
+
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressWatchdogTimeInSeconds_PROMPT  #language en-US "Firmware Device Watchdog Time in Seconds."
+#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceProgressWatchdogTimeInSeconds_HELP    #language en-US "Indicates the time in seconds to arm a watchdog timer during the update of"
+                                                                                                          "a firmware device.  The watchdog is re-armed each time the FmpDeviceLib"
+                                                                                                          "calls the Progress() function passed into FmpDeviceSetImage() function."
+                                                                                                          "The FmpDeviceLib calls Progress() to update the percent completion of a"
+                                                                                                          "firmware update.  If the watchdog timer expires, the system reboots.  A"
+                                                                                                          "value of 0 disables the watchdog timer.  The default value is 0 (watchdog"
+                                                                                                          "disabled)."
+
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT  #language en-US "One or more XDR encoded PKCS7 certificates used to verify firmware device capsule update images"
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP    #language en-US "Provides one or more PKCS7 certificates used to verify a firmware device"
+                                                                                                 "capsule update image.  This PCD is encoded using the Variable-Length Opaque"
+                                                                                                 "Data format of RFC 4506 External Data Representation Standard (XDR)."
+                                                                                                 "The default value is empty with 0 certificates."
+
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_PROMPT  #language en-US "Firmware Device Lock Event GUID."
+#string STR_gEfiSecurityPkgTokenSpaceGuid_PcdFmpDeviceLockEventGuid_HELP    #language en-US "An event GUID that locks the firmware device when the event is signaled."
+                                                                                            "If this PCD is not a valid GUID value, then the firmware device is locked"
+                                                                                            "when gEfiEndOfDxeEventGroupGuid (End of DXE Phase) is signaled.  The"
+                                                                                            "default value is empty, so by default the firmware device is locked at the"
+                                                                                            "end of the DXE phase."
+
+
diff --git a/FmpDevicePkg/FmpDevicePkgExtra.uni b/FmpDevicePkg/FmpDevicePkgExtra.uni
new file mode 100644
index 0000000000..fe49e8cd6c
--- /dev/null
+++ b/FmpDevicePkg/FmpDevicePkgExtra.uni
@@ -0,0 +1,18 @@
+// /** @file
+// Firmware Management Protocol Device Package Localized Strings and Content.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR> // 
+// This program and the accompanying materials are licensed and made 
+available under // the terms and conditions of the BSD License 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.
+//
+// **/
+
+#string STR_PROPERTIES_PACKAGE_NAME
+#language en-US
+"Firmware Management Protocol Device package"
diff --git a/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h b/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
new file mode 100644
index 0000000000..b38f212859
--- /dev/null
+++ b/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h
@@ -0,0 +1,120 @@
+/**  @file
+  Provides platform policy services used during a capsule update.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>  
+ Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef __CAPSULE_UPDATE_POLICY_LIB__
+#define __CAPSULE_UPDATE_POLICY_LIB__
+
+/**
+  Determine if the system power state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system power state supports a capsule
+                    update.  Returns FALSE if system power state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System power state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemPower (
+  OUT BOOLEAN  *Good
+  );
+
+/**
+  Determines if the system thermal state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system thermal state supports a capsule
+                    update.  Returns FALSE if system thermal state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System thermal state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemThermal (
+  IN OUT BOOLEAN  *Good
+  );
+
+/**
+  Determines if the system environment state supports a capsule update.
+
+  @param[out] Good  Returns TRUE if system environment state supports a capsule
+                    update.  Returns FALSE if system environment state does not
+                    support a capsule update.  Return value is only valid if
+                    return status is EFI_SUCCESS.
+
+  @retval EFI_SUCCESS            Good parameter has been updated with result.
+  @retval EFI_INVALID_PARAMETER  Good is NULL.
+  @retval EFI_DEVICE_ERROR       System environment state can not be determined.
+
+**/
+EFI_STATUS
+EFIAPI
+CheckSystemEnvironment (
+  IN OUT BOOLEAN  *Good
+  );
+
+/**
+  Determines if the Lowest Supported Version checks should be 
+performed.  The
+  expected result from this function is TRUE.  A platform can choose to 
+return
+  FALSE (e.g. during manufacturing or servicing) to allow a capsule 
+update to a
+  version below the current Lowest Supported Version.
+
+  @retval TRUE   Perform Lowest Support Version check.
+  @retval FALSE  Do not perform Lowest Support Version check.
+
+**/
+BOOLEAN
+EFIAPI
+CheckLowestSupportedVersion (
+  VOID
+  );
+
+/**
+  Determines if the FMP device should be locked when the event 
+specified by
+  PcdFmpDeviceLockEventGuid is signaled. The expected result from this 
+function
+  is TRUE so the FMP device is always locked.  A platform can choose to 
+return
+  FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.
+
+  @retval TRUE   Perform Lowest Support Version check.
+  @retval FALSE  Do not perform Lowest Support Version check.
+
+**/
+BOOLEAN
+EFIAPI
+LockFmpDeviceAtLockEventGuid (
+  VOID
+  );
+
+#endif
diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
new file mode 100644
index 0000000000..cdbe980183
--- /dev/null
+++ b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
@@ -0,0 +1,385 @@
+/**  @file
+  Provides firmware device specific services to support updates of a 
+firmware
+  image stored in a firmware device.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>  
+ Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef __FMP_DEVICE_LIB__
+#define __FMP_DEVICE_LIB__
+
+#include <Protocol/FirmwareManagement.h>
+
+/**
+  Callback function that installs a Firmware Management Protocol 
+instance onto
+  a handle.
+
+  @param[in]  Handle  The device handle to install a Firmware Management
+                      Protocol instance.
+
+  @retval  EFI_SUCCESS            A Firmware Management Protocol instance was
+                                  installed onto Handle.
+  @retval  EFI_INVALID_PARAMETER  Handle is invalid
+  @retval  other                  A Firmware Management Protocol instance could
+                                  not be installed onto Handle.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER)(
+  IN  EFI_HANDLE      Handle
+  );
+
+/**
+  Provide a function to install the Firmware Management Protocol 
+instance onto a
+  device handle when the device is managed by a driver that follows the 
+UEFI
+  Driver Model.  If the device is not managed by a driver that follows 
+the UEFI
+  Driver Model, then EFI_UNSUPPORTED is returned.
+
+  @param[in] FmpInstaller  Function that installs the Firmware Management
+                           Protocol.
+
+  @retval EFI_SUCCESS      The device is managed by a driver that follows the
+                           UEFI Driver Model.  FmpInstaller must be called on
+                           each Driver Binding Start().
+  @retval EFI_UNSUPPORTED  The device is not managed by a driver that follows
+                           the UEFI Driver Model.
+  @retval other            The Firmware Management Protocol for this firmware
+                           device is not installed.  The firmware device is
+                           still locked using FmpDeviceLock().
+
+**/
+EFI_STATUS
+EFIAPI
+RegisterFmpInstaller (
+  IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER  FmpInstaller
+  );
+
+/**
+  Returns the size, in bytes, of the firmware image currently stored in 
+the
+  firmware device.  This function is used to by the GetImage() and
+  GetImageInfo() services of the Firmware Management Protocol.  If the 
+image
+  size can not be determined from the firmware device, then 0 must be returned.
+
+  @return  The size, in bytes, of the firmware image current stored in the
+           firmware device.  Return 0 if the size can not be determined.
+
+**/
+UINTN
+EFIAPI
+FmpDeviceGetSize (
+  VOID
+  );
+
+/**
+  Returns the GUID value used to fill in the ImageTypeId field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the 
+GetImageInfo()
+  service of the Firmware Management Protocol.  If EFI_UNSUPPORTED is 
+returned,
+  then the ImageTypeId field is set to gEfiCallerIdGuid.  If 
+EFI_SUCCESS is
+  returned, then ImageTypeId is set to the Guid returned from this function.
+
+  @param[out] Guid  Double pointer to a GUID value that is updated to point to
+                    to a GUID value.  The GUID value is not allocated and must
+                    not be modified or freed by the caller.
+
+  @retval EFI_SUCCESS      EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set
+                           to the returned Guid value.
+  @retval EFI_UNSUPPORTED  EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set
+                           to gEfiCallerIdGuid.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetImageTypeIdGuidPtr (
+  OUT EFI_GUID  **Guid
+  );
+
+/**
+  Returns values used to fill in the AttributesSupported and 
+AttributesSettings
+  fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is 
+returned by the
+  GetImageInfo() service of the Firmware Management Protocol.  The 
+following
+  bit values from the Firmware Management Protocol may be combined:
+    IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
+    IMAGE_ATTRIBUTE_RESET_REQUIRED
+    IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
+    IMAGE_ATTRIBUTE_IN_USE
+    IMAGE_ATTRIBUTE_UEFI_IMAGE
+
+  @param[out] Supported  Attributes supported by this firmware device.
+  @param[out] Setting    Attributes settings for this firmware device.
+
+**/
+VOID
+EFIAPI
+FmpDeviceGetAttributes (
+  IN OUT UINT64  *Supported,
+  IN OUT UINT64  *Setting
+  );
+
+/**
+  Returns the 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.  If EFI_SUCCESS is 
+returned, then
+  the firmware device supports a method to report the 
+LowestSupportedVersion
+  value from the currently stored firmware image.  If the value can not 
+be
+  reported for the firmware image currently stored in the firmware 
+device, then
+  EFI_UNSUPPORTED must be returned.  EFI_DEVICE_ERROR is returned if an 
+error
+  occurs attempting to retrieve the LowestSupportedVersion value for 
+the
+  currently stored firmware image.
+
+  @note It is recommended that all firmware devices support a method to report
+        the LowestSupportedVersion value from the currently stored firmware
+        image.
+
+  @param[out] LowestSupportedVersion  LowestSupportedVersion value retrieved
+                                      from the currently stored firmware image.
+
+  @retval EFI_SUCCESS       The lowest supported version of currently stored
+                            firmware image was returned in LowestSupportedVersion.
+  @retval EFI_UNSUPPORTED   The firmware device does not support a method to
+                            report the lowest supported version of the currently
+                            stored firmware image.
+  @retval EFI_DEVICE_ERROR  An error occurred attempting to retrieve the lowest
+                            supported version of the currently stored firmware
+                            image.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetLowestSupportedVersion (
+  OUT UINT32  *LowestSupportedVersion
+  );
+
+/**
+  Returns the Null-terminated Unicode string that is used to fill in 
+the
+  VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that 
+is
+  returned by the GetImageInfo() service of the Firmware Management Protocol.
+  If the VersionName string can not be reported by the firmware image 
+currently
+  stored in the firmware device, then NULL must be returned.  
+Otherwise,
+  a Null-terminated Unicode string containing the VersioName is returned.
+  The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().
+
+  @note It is recommended that all firmware devices support a method to report
+        the VersionName string from the currently stored firmware image.
+
+  @retval NULL       The firmware device does not support a method to report the
+                     version string for the currently stored firmware image.
+  @retval NULL       An error occurred attempting to retrieve the version string
+                     for the currently stored firmware image.
+  @retval non NULL   A pointer to an allocated buffer containing the version
+                     string for the currently stored firmware image.
+
+**/
+CHAR16 *
+EFIAPI
+FmpDeviceGetVersionString (
+  VOID
+  );
+
+/**
+  Returns the value used to fill in the Version field of the
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the 
+GetImageInfo()
+  service of the Firmware Management Protocol.  If EFI_SUCCESS is 
+returned, then
+  the firmware device supports a method to report the Version value 
+from the
+  currently stored firmware image.  If the value can not be reported 
+for the
+  firmware image currently stored in the firmware device, then 
+EFI_UNSUPPORTED
+  must be returned.  EFI_DEVICE_ERROR is returned if an error occurs 
+attempting
+  to retrieve the LowestSupportedVersion value for the currently stored 
+firmware
+  image.
+
+  @note It is recommended that all firmware devices support a method to report
+        the Version value from the currently stored firmware image.
+
+  @param[out] Version  The version value retrieved from the currently stored
+                       firmware image.
+
+  @retval EFI_SUCCESS       The version of currently stored firmware image was
+                            returned in Version.
+  @retval EFI_UNSUPPORTED   The firmware device does not support a method to
+                            report the version of the currently stored firmware
+                            image.
+  @retval EFI_DEVICE_ERROR  An error occurred attempting to retrieve the version
+                            of the currently stored firmware image.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetVersion (
+  OUT UINT32  *Version
+  );
+
+/**
+  Returns a copy of the firmware image currently stored in the firmware device.
+
+  @note It is recommended that all firmware devices support a method to retrieve
+        a copy currently stored firmware image.  This can be used to support
+        features such as recovery and rollback.
+
+  @param[out]    Image      Pointer to a caller allocated buffer where the
+                            currently stored firmware image is copied to.
+  @param[in out] ImageSize  Pointer the size, in bytes, of the Image buffer.
+                            On return, points to the size, in bytes, of firmware
+                            image currently stored in the firmware device.
+
+  @retval EFI_SUCCESS            Image contains a copy of the firmware image
+                                 currently stored in the firmware device, and
+                                 ImageSize contains the size, in bytes, of the
+                                 firmware image currently stored in the
+                                 firmware device.
+  @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small
+                                 to hold the firmware image currently stored in
+                                 the firmware device. The buffer size required
+                                 is returned in ImageSize.
+  @retval EFI_INVALID_PARAMETER  The Image is NULL.
+  @retval EFI_INVALID_PARAMETER  The ImageSize is NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+  @retval EFI_DEVICE_ERROR       An error occurred attempting to retrieve the
+                                 firmware image currently stored in the firmware
+                                 device.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceGetImage (
+  IN OUT    VOID   *Image,
+  IN IN OUT UINTN  *ImageSize
+  );
+
+/**
+  Checks if a new firmware image is valid for the firmware device.  
+This
+  function allows firmware update operation to validate the firmware 
+image
+  before FmpDeviceSetImage() is called.
+
+  @param[in]  Image           Points to a new firmware image.
+  @param[in]  ImageSize       Size, in bytes, of a new firmware image.
+  @param[out] ImageUpdatable  Indicates if a new firmware image is valid for
+                              a firmware update to the firmware device.  The
+                              following values from the Firmware Management
+                              Protocol are supported:
+                                IMAGE_UPDATABLE_VALID
+                                IMAGE_UPDATABLE_INVALID
+                                IMAGE_UPDATABLE_INVALID_TYPE
+                                IMAGE_UPDATABLE_INVALID_OLD
+                                IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
+
+  @retval EFI_SUCCESS            The image was successfully checked.  Additional
+                                 status information is returned in
+                                 ImageUpdateable.
+  @retval EFI_INVALID_PARAMETER  Image is NULL.
+  @retval EFI_INVALID_PARAMETER  ImageUpdateable is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceCheckImage (
+  IN  CONST VOID  *Image,
+  IN  UINTN       ImageSize,
+  OUT UINT32      *ImageUpdateable
+  );
+
+/**
+  Updates a firmware device with a new firmware image.  This function 
+returns
+  EFI_UNSUPPORTED if the firmware image is not updatable.  If the 
+firmware image
+  is updatable, the function should perform the following minimal 
+validations
+  before proceeding to do the firmware image update.
+    - Validate that the image is a supported image for this firmware device.
+      Return EFI_ABORTED if the image is not supported.  Additional details
+      on why the image is not a supported image may be returned in AbortReason.
+    - Validate the data from VendorCode if is not NULL.  Firmware image
+      validation must be performed before VendorCode data validation.
+      VendorCode data is ignored or considered invalid if image validation
+      fails.  Return EFI_ABORTED if the VendorCode data is invalid.
+
+  VendorCode enables vendor to implement vendor-specific firmware image 
+ update  policy.  Null if the caller did not specify the policy or use 
+ the default  policy.  As an example, vendor can implement a policy to 
+ allow an option to  force a firmware image update when the abort 
+ reason is due to the new firmware  image version is older than the 
+ current firmware image version or bad image  checksum.  Sensitive 
+ operations such as those wiping the entire firmware image  and render 
+ the device to be non-functional should be encoded in the image  itself 
+ rather than passed with the VendorCode.  AbortReason enables vendor to  
+ have the option to provide a more detailed description of the abort reason to  the caller.
+
+  @param[in]  Image             Points to the new firmware image.
+  @param[in]  ImageSize         Size, in bytes, of the new firmware image.
+  @param[in]  VendorCode        This enables vendor to implement vendor-specific
+                                firmware image update policy.  NULL indicates
+                                the caller did not specify the policy or use the
+                                default policy.
+  @param[in]  Progress          A function used to report the progress of
+                                updating the firmware device with the new
+                                firmware image.
+  @param[in]  CapsuleFwVersion  The version of the new firmware image from the
+                                update capsule that provided the new firmware
+                                image.
+  @param[out] AbortReason       A pointer to a pointer to a Null-terminated
+                                Unicode string providing more details on an
+                                aborted operation. The buffer is allocated by
+                                this function with
+                                EFI_BOOT_SERVICES.AllocatePool().  It is the
+                                caller's responsibility to free this buffer with
+                                EFI_BOOT_SERVICES.FreePool().
+
+  @retval EFI_SUCCESS            The firmware device was successfully updated
+                                 with the new firmware image.
+  @retval EFI_ABORTED            The operation is aborted.  Additional details
+                                 are provided in AbortReason.
+  @retval EFI_INVALID_PARAMETER  The Image was NULL.
+  @retval EFI_UNSUPPORTED        The operation is not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceSetImage (
+  IN  CONST VOID                                     *Image,
+  IN  UINTN                                          ImageSize,
+  IN  CONST VOID                                     *VendorCode,       OPTIONAL
+  IN  EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,          OPTIONAL
+  IN  UINT32                                         CapsuleFwVersion,
+  OUT CHAR16                                         **AbortReason
+  );
+
+/**
+  Lock the firmware device that contains a firmware image.  Once a 
+firmware
+  device is locked, any attempts to modify the firmware image contents 
+in the
+  firmware device must fail.
+
+  @note It is recommended that all firmware devices support a lock method to
+        prevent modifications to a stored firmware image.
+
+  @note A firmware device lock mechanism is typically only cleared by a full
+        system reset (not just sleep state/low power mode).
+
+  @retval  EFI_SUCCESS      The firmware device was locked.
+  @retval  EFI_UNSUPPORTED  The firmware device does not support 
+ locking
+
+**/
+EFI_STATUS
+EFIAPI
+FmpDeviceLock (
+  VOID
+  );
+
+#endif
diff --git a/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h b/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
new file mode 100644
index 0000000000..cb5622e9ce
--- /dev/null
+++ b/FmpDevicePkg/Include/Library/FmpPayloadHeaderLib.h
@@ -0,0 +1,100 @@
+/**  @file
+  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.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>  
+ Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  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.
+
+**/
+
+#ifndef _FMP_PAYLOAD_HEADER_LIB_H__
+#define _FMP_PAYLOAD_HEADER_LIB_H__
+
+/**
+  Returns the FMP Payload Header size in bytes.
+
+  @param[in]  Header          FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize  Size of FMP payload
+  @param[out] Size            The size, in bytes, of the FMP Payload Header.
+
+  @retval EFI_SUCCESS            The firmware version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  Size is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderSize (
+  IN  CONST VOID   *Header,
+  IN  CONST UINTN  FmpPayloadSize,
+  OUT UINT32       *Size
+  );
+
+/**
+  Returns the version described in the FMP Payload Header.
+
+  @param[in]  Header          FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize  Size of FMP payload
+  @param[out] Version         The firmware version described in the FMP Payload
+                              Header.
+
+  @retval EFI_SUCCESS            The firmware version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  Version is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderVersion (
+  IN  CONST VOID   *Header,
+  IN  CONST UINTN  FmpPayloadSize,
+  OUT UINT32       *Version
+  );
+
+/**
+  Returns the lowest supported version described in the FMP Payload Header.
+
+  @param[in]  Header                  FMP Payload Header to evaluate
+  @param[in]  FmpPayloadSize          Size of FMP payload
+  @param[out] LowestSupportedVersion  The lowest supported version described in
+                                      the FMP Payload Header.
+
+  @retval EFI_SUCCESS            The lowest support version was returned.
+  @retval EFI_INVALID_PARAMETER  Header is NULL.
+  @retval EFI_INVALID_PARAMETER  LowestSupportedVersion is NULL.
+  @retval EFI_INVALID_PARAMETER  Header is not a valid FMP Payload Header.
+
+**/
+EFI_STATUS
+EFIAPI
+GetFmpPayloadHeaderLowestSupportedVersion (
+  IN     CONST VOID   *Header,
+  IN     CONST UINTN  FmpPayloadSize,
+  IN OUT UINT32       *LowestSupportedVersion
+  );
+
+#endif
--
2.14.2.windows.3

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-04-08  9:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-04 21:28 [RFC 0/4] Add FmpDevicePkg Michael D Kinney
2018-04-04 21:28 ` [RFC 1/4] FmpDevicePkg: Add package, library classes, and PCDs Michael D Kinney
2018-04-08  9:18   ` Zeng, Star
2018-04-04 21:28 ` [RFC 2/4] FmpDevicePkg: Add library instances Michael D Kinney
2018-04-04 21:28 ` [RFC 3/4] FmpDevicePkg: Add FmpDxe module Michael D Kinney
2018-04-04 21:28 ` [RFC 4/4] FmpDevicePkg: Add DSC file to build all package components Michael D Kinney
2018-04-04 23:29 ` [RFC 0/4] Add FmpDevicePkg Yao, Jiewen
2018-04-05  0:28   ` Kinney, Michael D
2018-04-08  9:16     ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox