SystemBiosUpdate supports udpate system BIOS via UEFI FMP capsule.

SystemBiosReportDxe.inf can be included in system BIOS. It is a lightweight
FMP protocol implementation and it only reports FMP information, so that
ESRT table can report the system firmware information. It does not support
SetImage().

SystemBiosUpdateDxe.inf can be included in EDKII system capsule image.
It is a full feature FMP protocol implementation and supports SetImage().
It can be used to update the system firmware.
SystemBiosUpdateDxe.inf can also be included in system BIOS.
If so SystemBiosReportDxe.inf is not needed.

SystemBiosUpdateDxe SetImage() will perform the FMP authentication and
version check. If and only if the FMP authentication passes, and new
EDKII system capsule version is no less than current BIOS
LowestSupportedVersion, the system firmware will be udpated.

Cc: Feng Tian <feng.t...@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Cc: Chao Zhang <chao.b.zh...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen....@intel.com>
---
 MdeModulePkg/Universal/SystemBiosUpdate/ParseConfigProfile.c          | 219 
+++++++++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosDxe.h               | 393 
++++++++++++++++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainDxe.c           | 484 
++++++++++++++++++++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImage.c      | 453 
++++++++++++++++++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImageDummy.c |  90 
++++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.inf       |  66 +++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.uni       |  21 +
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxeExtra.uni  |  20 +
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.inf       |  70 +++
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.uni       |  21 +
 MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxeExtra.uni  |  20 +
 11 files changed, 1857 insertions(+)

diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/ParseConfigProfile.c 
b/MdeModulePkg/Universal/SystemBiosUpdate/ParseConfigProfile.c
new file mode 100644
index 0000000..365b8c5
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/ParseConfigProfile.c
@@ -0,0 +1,219 @@
+/** @file
+  Parse the INI configuration file and pass the information to the update 
driver
+  so that the driver can perform update accordingly.
+
+  Copyright (c) 2016, 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.
+
+**/
+
+#include "SystemBiosDxe.h"
+#include <Library/IniParsingLib.h>
+#include <Library/PrintLib.h>
+
+#define MAX_LINE_LENGTH           512
+
+/**
+  Parse Config data file to get the updated data array.
+
+  @param DataBuffer      Config raw file buffer.
+  @param BufferSize      Size of raw buffer.
+  @param ConfigHeader    Pointer to the config header.
+  @param UpdateArray     Pointer to the config of update data.
+
+  @retval EFI_NOT_FOUND         No config data is found.
+  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.
+  @retval EFI_SUCCESS           Parse the config file successfully.
+
+**/
+EFI_STATUS
+ParseUpdateDataFile (
+  IN      UINT8                         *DataBuffer,
+  IN      UINTN                         BufferSize,
+  IN OUT  CONFIG_HEADER                 *ConfigHeader,
+  IN OUT  UPDATE_CONFIG_DATA            **UpdateArray
+  )
+{
+  EFI_STATUS                            Status;
+  CHAR8                                 *SectionName;
+  CHAR8                                 Entry[MAX_LINE_LENGTH];
+  UINTN                                 Num;
+  UINT64                                Num64;
+  UINTN                                 Index;
+  EFI_GUID                              FileGuid;
+  VOID                                  *Context;
+
+  //
+  // First process the data buffer and get all sections and entries
+  //
+  Context = OpenDataFile(DataBuffer, BufferSize);
+  if (Context == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Now get NumOfUpdate
+  //
+  Status = GetDecimalUintnFromDataFile(
+             Context,
+             "Head",
+             "NumOfUpdate",
+             &Num
+             );
+  if (EFI_ERROR(Status) || (Num == 0)) {
+    CloseDataFile(Context);
+    return EFI_NOT_FOUND;
+  }
+
+  ConfigHeader->NumOfUpdates = Num;
+  *UpdateArray = AllocateZeroPool ((sizeof (UPDATE_CONFIG_DATA) * Num));
+  if (*UpdateArray == NULL) {
+    CloseDataFile(Context);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  for (Index = 0 ; Index < ConfigHeader->NumOfUpdates ; Index++) {
+    //
+    // Get the section name of each update
+    //
+    AsciiStrCpyS (Entry, MAX_LINE_LENGTH, "Update");
+    AsciiValueToString(Entry + AsciiStrLen(Entry), 0, Index, 0);
+    Status = GetStringFromDataFile(
+               Context,
+               "Head",
+               Entry,
+               &SectionName
+               );
+    if (EFI_ERROR(Status) || (SectionName == NULL)) {
+      CloseDataFile(Context);
+      return EFI_NOT_FOUND;
+    }
+
+    //
+    // The section name of this update has been found.
+    // Now looks for all the config data of this update
+    //
+    (*UpdateArray)[Index].Index = Index;
+
+    //
+    // ImageTypeId
+    //
+    Status = GetGuidFromDataFile(
+               Context,
+               SectionName,
+               "ImageTypeId",
+               &FileGuid
+               );
+    if (EFI_ERROR(Status)) {
+      ZeroMem(&((*UpdateArray)[Index].ImageTypeId), sizeof(EFI_GUID));
+    } else {
+      CopyGuid(&((*UpdateArray)[Index].ImageTypeId), &FileGuid);
+    }
+
+    //
+    // FirmwareType
+    //
+    Status = GetDecimalUintnFromDataFile(
+               Context,
+               SectionName,
+               "FirmwareType",
+               &Num
+               );
+    if (EFI_ERROR(Status)) {
+      Num = PlatformFirmwareTypeBios;
+    }
+    (*UpdateArray)[Index].FirmwareType = (PLATFORM_FIRMWARE_TYPE) Num;
+
+    //
+    // AddressType
+    //
+    Status = GetDecimalUintnFromDataFile(
+               Context,
+               SectionName,
+               "AddressType",
+               &Num
+               );
+    if (EFI_ERROR(Status)) {
+      CloseDataFile(Context);
+      return EFI_NOT_FOUND;
+    }
+    (*UpdateArray)[Index].AddressType = (FLASH_ADDRESS_TYPE) Num;
+
+    //
+    // BaseAddress
+    //
+    Status = GetHexUint64FromDataFile(
+               Context,
+               SectionName,
+               "BaseAddress",
+               &Num64
+               );
+    if (EFI_ERROR(Status)) {
+      CloseDataFile(Context);
+      return EFI_NOT_FOUND;
+    }
+    (*UpdateArray)[Index].BaseAddress = (EFI_PHYSICAL_ADDRESS) Num64;
+
+    //
+    // FileBuid
+    //
+    Status = GetGuidFromDataFile(
+               Context,
+               SectionName,
+               "FileGuid",
+               &FileGuid
+               );
+    if (EFI_ERROR(Status)) {
+      CloseDataFile(Context);
+      return EFI_NOT_FOUND;
+    }
+
+    CopyGuid(&((*UpdateArray)[Index].FileGuid), &FileGuid);
+
+    //
+    // Length
+    //
+    Status = GetHexUintnFromDataFile(
+               Context,
+               SectionName,
+               "Length",
+               &Num
+               );
+    if (EFI_ERROR(Status)) {
+      CloseDataFile(Context);
+      return EFI_NOT_FOUND;
+    }
+    (*UpdateArray)[Index].Length = (UINTN) Num;
+
+    //
+    // ImageOffset
+    //
+    Status = GetHexUintnFromDataFile(
+               Context,
+               SectionName,
+               "ImageOffset",
+               &Num
+               );
+    if (EFI_ERROR(Status)) {
+      CloseDataFile(Context);
+      return EFI_NOT_FOUND;
+    }
+    (*UpdateArray)[Index].ImageOffset = (UINTN) Num;
+  }
+
+  //
+  // Now all configuration data got. Free those temporary buffers
+  //
+  CloseDataFile(Context);
+
+  return EFI_SUCCESS;
+}
+
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosDxe.h 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosDxe.h
new file mode 100644
index 0000000..ce4cbd0
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosDxe.h
@@ -0,0 +1,393 @@
+/** @file
+  System BIOS update header file.
+
+  Copyright (c) 2016, 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.
+
+**/
+
+#ifndef _SYSTEM_BIOS_UPDATE_H_
+#define _SYSTEM_BIOS_UPDATE_H_
+
+#include <PiDxe.h>
+
+#include <Guid/SystemResourceTable.h>
+#include <Guid/FirmwareContentsSigned.h>
+#include <Guid/WinCertificate.h>
+#include <Guid/EdkiiSystemFmpCapsule.h>
+
+#include <Protocol/FirmwareManagement.h>
+#include <Protocol/FirmwareVolumeBlock.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/DevicePathLib.h>
+#include <Library/HobLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/PlatformFlashAccessLib.h>
+#include <Library/EdkiiSystemCapsuleLib.h>
+
+typedef struct {
+  UINT32 LastAttemptVersion;
+  UINT32 LastAttemptStatus;
+} SYSTEM_FMP_LAST_ATTEMPT_VARIABLE;
+
+#define SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME  L"SystemLastAttempVar"
+
+#define SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID {0x2f564d6f, 0xcc2c, 0x4838, { 
0xb9, 0xa8, 0xbe, 0x59, 0x48, 0xb0, 0x3d, 0x59 }}
+
+#define BIOS_FMP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32('B', 'I', 'O', 'F')
+
+//
+// BIOS FMP private data structure.
+//
+
+struct _BIOS_FMP_PRIVATE_DATA {
+  UINT32                                          Signature;
+  EFI_FIRMWARE_MANAGEMENT_PROTOCOL                Fmp;
+  EFI_HANDLE                                      Handle;
+  UINT8                                           DescriptorCount;
+  EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR          *ImageDescriptor;
+  SYSTEM_FMP_LAST_ATTEMPT_VARIABLE                LastAttempt;
+};
+
+typedef struct _BIOS_FMP_PRIVATE_DATA  BIOS_FMP_PRIVATE_DATA;
+
+/**
+  Returns a pointer to the BIOS_FMP_PRIVATE_DATA structure from the input a as 
Fmp.
+
+  If the signatures matches, then a pointer to the data structure that contains
+  a specified field of that data structure is returned.
+
+  @param  a              Pointer to the field specified by ServiceBinding 
within
+                         a data structure of type BIOS_FMP_PRIVATE_DATA.
+
+**/
+#define BIOS_FMP_PRIVATE_DATA_FROM_FMP(a) \
+  CR ( \
+  (a), \
+  BIOS_FMP_PRIVATE_DATA, \
+  Fmp, \
+  BIOS_FMP_PRIVATE_DATA_SIGNATURE \
+  )
+
+
+//
+// Update data
+//
+
+typedef struct {
+  UINTN                           NumOfUpdates;
+} CONFIG_HEADER;
+
+typedef struct {
+  UINTN                           Index;
+  EFI_GUID                        ImageTypeId;
+  PLATFORM_FIRMWARE_TYPE          FirmwareType;
+  FLASH_ADDRESS_TYPE              AddressType;
+  EFI_GUID                        FileGuid;
+  EFI_PHYSICAL_ADDRESS            BaseAddress;
+  UINTN                           Length;
+  UINTN                           ImageOffset;
+} UPDATE_CONFIG_DATA;
+
+//
+// System Firmware Update SMM Communication
+//
+
+#define SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_FUNCTION_SET_IMAGE 1
+
+typedef struct {
+  UINTN       Function;
+  EFI_STATUS  ReturnStatus;
+//UINT8       Data[];
+} SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_HEAD;
+
+#define  ABORT_REASON_MAX_SIZE              0x40  // UnicodeStringSize 
including final L'\0'
+
+#define  CAPSULE_IMAGE_ADDITIONAL_MAX_SIZE  (0x20020 + 0xA0000) // Addtional 
size for Capsule Header, FV block alignment + DispatchImage.
+
+typedef struct {
+  UINT8       ImageIndex;
+  UINTN       ImageSize;
+  UINTN       AbortReasonSize;
+  UINT32      LastAttemptVersion;
+  UINT32      LastAttemptStatus;
+//UINT8       Data[AbortReasonMaxSize + ImageSize];
+} SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_SET_IMAGE;
+
+
+/**
+  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
+FmpGetImageInfo(
+  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
+  );
+
+/**
+  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[in,out] Image           Points to the buffer where the current image 
is copied to.
+  @param[in,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
+FmpGetImage(
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN  UINT8                             ImageIndex,
+  IN  OUT  VOID                         *Image,
+  IN  OUT  UINTN                        *ImageSize
+  );
+
+/**
+  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
+FmpSetImage(
+  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
+  );
+
+/**
+  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
+FmpCheckImage(
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN  UINT8                             ImageIndex,
+  IN  CONST VOID                        *Image,
+  IN  UINTN                             ImageSize,
+  OUT UINT32                            *ImageUpdatable
+  );
+
+/**
+  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
+FmpGetPackageInfo(
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+  OUT UINT32                           *PackageVersion,
+  OUT CHAR16                           **PackageVersionName,
+  OUT UINT32                           *PackageVersionNameMaxLen,
+  OUT UINT64                           *AttributesSupported,
+  OUT UINT64                           *AttributesSetting
+  );
+
+/**
+  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
+FmpSetPackageInfo(
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL   *This,
+  IN  CONST VOID                         *Image,
+  IN  UINTN                              ImageSize,
+  IN  CONST VOID                         *VendorCode,
+  IN  UINT32                             PackageVersion,
+  IN  CONST CHAR16                       *PackageVersionName
+  );
+
+extern EFI_GUID gSystemFmpLastAttemptVariableGuid;
+extern EFI_GUID mCurrentImageTypeId;
+
+#endif
+
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainDxe.c 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainDxe.c
new file mode 100644
index 0000000..d3c2aeb
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainDxe.c
@@ -0,0 +1,484 @@
+/** @file
+  Produce FMP instance for system firmware.
+
+  Copyright (c) 2016, 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.
+
+**/
+
+#include "SystemBiosDxe.h"
+
+EFI_GUID gSystemFmpLastAttemptVariableGuid = 
SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID;
+
+//
+// BiosFmp driver private data
+//
+BIOS_FMP_PRIVATE_DATA *mBiosFmpPrivate = NULL;
+
+EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = {
+  FmpGetImageInfo,
+  FmpGetImage,
+  FmpSetImage,
+  FmpCheckImage,
+  FmpGetPackageInfo,
+  FmpSetPackageInfo
+};
+
+/**
+  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
+FmpGetImageInfo (
+  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
+  )
+{
+  BIOS_FMP_PRIVATE_DATA                  *BiosFmpPrivate;
+  EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor;
+
+  BiosFmpPrivate = BIOS_FMP_PRIVATE_DATA_FROM_FMP(This);
+
+  if(ImageInfoSize == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (*ImageInfoSize < sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * 
BiosFmpPrivate->DescriptorCount) {
+    *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * 
BiosFmpPrivate->DescriptorCount;
+    return EFI_BUFFER_TOO_SMALL;
+  }
+
+  if (ImageInfo == NULL ||
+      DescriptorVersion == NULL ||
+      DescriptorCount == NULL ||
+      DescriptorSize == NULL ||
+      PackageVersion == NULL ||
+      PackageVersionName == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *ImageInfoSize      = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * 
BiosFmpPrivate->DescriptorCount;
+  *DescriptorSize     = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR);
+  *DescriptorCount    = BiosFmpPrivate->DescriptorCount;
+  *DescriptorVersion  = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
+
+  //
+  // supports 1 ImageInfo descriptor
+  //
+  ImageDescriptor = BiosFmpPrivate->ImageDescriptor;
+  ImageInfo->ImageIndex = ImageDescriptor->ImageIndex;
+  CopyGuid (&ImageInfo->ImageTypeId, &ImageDescriptor->ImageTypeId);
+  ImageInfo->ImageId = ImageDescriptor->ImageId;
+  if (ImageDescriptor->ImageIdNameStringOffset != 0) {
+    ImageInfo->ImageIdName = (CHAR16 *)((UINTN)ImageDescriptor + 
ImageDescriptor->ImageIdNameStringOffset);
+  } else {
+    ImageInfo->ImageIdName = NULL;
+  }
+  ImageInfo->Version = ImageDescriptor->Version;
+  if (ImageDescriptor->VersionNameStringOffset != 0) {
+    ImageInfo->VersionName = (CHAR16 *)((UINTN)ImageDescriptor + 
ImageDescriptor->VersionNameStringOffset);
+  } else {
+    ImageInfo->VersionName = NULL;
+  }
+  ImageInfo->Size = (UINTN)ImageDescriptor->Size;
+  ImageInfo->AttributesSupported = ImageDescriptor->AttributesSupported;
+  ImageInfo->AttributesSetting = ImageDescriptor->AttributesSetting;
+  ImageInfo->Compatibilities = ImageDescriptor->Compatibilities;
+  ImageInfo->LowestSupportedImageVersion = 
ImageDescriptor->LowestSupportedImageVersion;
+  ImageInfo->LastAttemptVersion = 
BiosFmpPrivate->LastAttempt.LastAttemptVersion;
+  ImageInfo->LastAttemptStatus = BiosFmpPrivate->LastAttempt.LastAttemptStatus;
+  ImageInfo->HardwareInstance = ImageDescriptor->HardwareInstance;
+
+  //
+  // package version
+  //
+  *PackageVersion = ImageDescriptor->PackageVersion;
+  if (ImageDescriptor->PackageVersionNameStringOffset != 0) {
+    *PackageVersionName = (VOID *)((UINTN)ImageDescriptor + 
ImageDescriptor->PackageVersionNameStringOffset);
+    *PackageVersionName = AllocateCopyPool(StrSize(*PackageVersionName), 
*PackageVersionName);
+  } else {
+    *PackageVersionName = NULL;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  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[in,out] Image           Points to the buffer where the current image 
is copied to.
+  @param[in,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
+FmpGetImage(
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN  UINT8                             ImageIndex,
+  IN  OUT  VOID                         *Image,
+  IN  OUT  UINTN                        *ImageSize
+  )
+{
+  BIOS_FMP_PRIVATE_DATA *BiosFmpPrivate;
+
+  if (Image == NULL || ImageSize == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  BiosFmpPrivate = BIOS_FMP_PRIVATE_DATA_FROM_FMP(This);
+
+  if (ImageIndex == 0 || ImageIndex > BiosFmpPrivate->DescriptorCount || 
ImageSize == NULL || Image == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  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
+FmpCheckImage(
+  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
+  IN  UINT8                             ImageIndex,
+  IN  CONST VOID                        *Image,
+  IN  UINTN                             ImageSize,
+  OUT UINT32                            *ImageUpdatable
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  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
+FmpGetPackageInfo(
+  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
+FmpSetPackageInfo(
+  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;
+}
+
+/**
+  Initialize BiosFmpDriver private data structure.
+
+  @param BiosFmpPrivate  private data structure to be initialized.
+
+  @return EFI_SUCCESS private data is initialized.
+**/
+EFI_STATUS
+InitializePrivateData(
+  IN BIOS_FMP_PRIVATE_DATA *BiosFmpPrivate
+  )
+{
+  EFI_STATUS       VarStatus;
+  UINTN            VarSize;
+
+  BiosFmpPrivate->Signature       = BIOS_FMP_PRIVATE_DATA_SIGNATURE;
+  BiosFmpPrivate->Handle          = NULL;
+  BiosFmpPrivate->DescriptorCount = 1;
+  CopyMem(&BiosFmpPrivate->Fmp, &mFirmwareManagementProtocol, 
sizeof(EFI_FIRMWARE_MANAGEMENT_PROTOCOL));
+
+  BiosFmpPrivate->ImageDescriptor = 
PcdGetPtr(PcdEdkiiSystemFirmwareImageDescriptor);
+
+  BiosFmpPrivate->LastAttempt.LastAttemptVersion = 0x0;
+  BiosFmpPrivate->LastAttempt.LastAttemptStatus = 0x0;
+  VarSize = sizeof(BiosFmpPrivate->LastAttempt);
+  VarStatus = gRT->GetVariable(
+                     SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
+                     &gSystemFmpLastAttemptVariableGuid,
+                     NULL,
+                     &VarSize,
+                     &BiosFmpPrivate->LastAttempt
+                     );
+  DEBUG((EFI_D_INFO, "GetLastAttemp - %r\n", VarStatus));
+  DEBUG((EFI_D_INFO, "GetLastAttemp Version - 0x%x, State - 0x%x\n", 
BiosFmpPrivate->LastAttempt.LastAttemptVersion, 
BiosFmpPrivate->LastAttempt.LastAttemptStatus));
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo.
+
+  @param[in] FmpImageInfo A pointer to EFI_FIRMWARE_IMAGE_DESCRIPTOR
+
+  @retval TRUE  It is a system FMP.
+  @retval FALSE It is a device FMP.
+**/
+BOOLEAN
+IsSystemFmp(
+  IN EFI_FIRMWARE_IMAGE_DESCRIPTOR   *FmpImageInfo
+  )
+{
+  GUID      *Guid;
+  UINTN     Count;
+  UINTN     Index;
+
+  Guid = PcdGetPtr(PcdEdkiiSystemFmpCapsuleImageTypeIdGuid);
+  Count = PcdGetSize(PcdEdkiiSystemFmpCapsuleImageTypeIdGuid) / sizeof(GUID);
+
+  for (Index = 0; Index < Count; Index++, Guid++) {
+    if (CompareGuid(&FmpImageInfo->ImageTypeId, Guid)) {
+      return TRUE;
+    }
+  }
+
+  return FALSE;
+}
+
+/**
+  System BIOS FMP module entrypoint
+
+  @param  ImageHandle       The firmware allocated handle for the EFI image.
+  @param  SystemTable       A pointer to the EFI System Table.
+
+  @return EFI_SUCCESS System BIOS FMP module is initialized.
+**/
+EFI_STATUS
+EFIAPI
+BiosUpdateMainDxe(
+  IN EFI_HANDLE                         ImageHandle,
+  IN EFI_SYSTEM_TABLE                   *SystemTable
+  )
+{
+  EFI_STATUS                                      Status;
+  EFI_FIRMWARE_MANAGEMENT_PROTOCOL                *Fmp;
+  UINTN                                           NoHandles;
+  EFI_HANDLE                                      *HandleBuffer;
+  UINTN                                           Index;
+  EFI_FIRMWARE_IMAGE_DESCRIPTOR                   *FmpImageInfo;
+  UINTN                                           ImageInfoSize;
+  UINT32                                          DescriptorVersion;
+  UINT8                                           DescriptorCount;
+  UINTN                                           DescriptorSize;
+  UINT32                                          PackageVersion;
+  CHAR16                                          *PackageVersionName;
+
+  //
+  // Make sure only one instance in system
+  //
+  Status = gBS->LocateHandleBuffer(ByProtocol, 
&gEfiFirmwareManagementProtocolGuid, NULL, &NoHandles, &HandleBuffer);
+  if (!EFI_ERROR(Status)) {
+    for (Index = 0; Index < NoHandles; Index++) {
+      Status = gBS->HandleProtocol(HandleBuffer[Index], 
&gEfiFirmwareManagementProtocolGuid, (VOID **)&Fmp);
+      if (EFI_ERROR(Status)) {
+        continue;
+      }
+      ImageInfoSize = 0;
+      Status = Fmp->GetImageInfo (Fmp, &ImageInfoSize, NULL, NULL, NULL, NULL, 
NULL, NULL);
+      if (Status == EFI_BUFFER_TOO_SMALL) {
+        FmpImageInfo = AllocateZeroPool(ImageInfoSize);
+        if (FmpImageInfo == NULL) {
+          return EFI_OUT_OF_RESOURCES;
+        }
+      } else {
+        continue;
+      }
+      Status = Fmp->GetImageInfo (Fmp, &ImageInfoSize, FmpImageInfo, 
&DescriptorVersion, &DescriptorCount, &DescriptorSize, &PackageVersion, 
&PackageVersionName);
+      if (!IsSystemFmp(FmpImageInfo)) {
+        FreePool(FmpImageInfo);
+        continue;
+      }
+      FreePool(FmpImageInfo);
+      Status = gBS->UninstallProtocolInterface(HandleBuffer[Index], 
&gEfiFirmwareManagementProtocolGuid, Fmp);
+      if (EFI_ERROR(Status)) {
+        DEBUG((EFI_D_ERROR, "Fail to uninstall Fmp - 0x%x\n"));
+      }
+    }
+    FreePool(HandleBuffer);
+  }
+
+  //
+  // Initialize BiosFmpPrivateData
+  //
+  mBiosFmpPrivate = AllocateZeroPool (sizeof(BIOS_FMP_PRIVATE_DATA));
+  if (mBiosFmpPrivate == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Status = InitializePrivateData(mBiosFmpPrivate);
+  if (EFI_ERROR(Status)) {
+    FreePool(mBiosFmpPrivate);
+    mBiosFmpPrivate = NULL;
+    return Status;
+  }
+
+  //
+  // Install FMP protocol.
+  //
+  Status = gBS->InstallProtocolInterface (
+                  &mBiosFmpPrivate->Handle,
+                  &gEfiFirmwareManagementProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  &mBiosFmpPrivate->Fmp
+                  );
+  if (EFI_ERROR (Status)) {
+    FreePool(mBiosFmpPrivate);
+    mBiosFmpPrivate = NULL;
+    return Status;
+  }
+
+  return Status;
+}
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImage.c 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImage.c
new file mode 100644
index 0000000..a5cf77c
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImage.c
@@ -0,0 +1,453 @@
+/** @file
+  SetImage instance to update system firmware.
+
+  Caution: This module requires additional review when modified.
+  This module will have external input - capsule image.
+  This external input must be validated carefully to avoid security issue like
+  buffer overflow, integer overflow.
+
+  FmpSetImage() will receive untrusted input and do basic validation.
+
+  Copyright (c) 2016, 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.
+
+**/
+
+#include "SystemBiosDxe.h"
+
+EFI_GUID mCurrentImageTypeId;
+
+BOOLEAN  mNvRamUpdated = FALSE;
+
+/**
+  Parse Config data file to get the updated data array.
+
+  @param DataBuffer      Config raw file buffer.
+  @param BufferSize      Size of raw buffer.
+  @param ConfigHeader    Pointer to the config header.
+  @param UpdateArray     Pointer to the config of update data.
+
+  @retval EFI_NOT_FOUND         No config data is found.
+  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.
+  @retval EFI_SUCCESS           Parse the config file successfully.
+
+**/
+EFI_STATUS
+ParseUpdateDataFile(
+  IN      UINT8                         *DataBuffer,
+  IN      UINTN                         BufferSize,
+  IN OUT  CONFIG_HEADER                 *ConfigHeader,
+  IN OUT  UPDATE_CONFIG_DATA            **UpdateArray
+  );
+
+/**
+  Update BIOS image component.
+
+  @param[in]  BiosImage         Points to the BIOS image.
+  @param[in]  BiosImageSize     The length of the BIOS image in bytes.
+  @param[in]  ConfigData         Points to the component configuration 
structure.
+  @param[out] LastAttemptVersion The last attempt version, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[out] LastAttemptStatus  The last attempt status, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             The BIOS image is updated.
+  @retval EFI_WRITE_PROTECTED     The flash device is read only.
+**/
+EFI_STATUS
+PerformUpdate (
+  IN VOID                         *BiosImage,
+  IN UINTN                        BiosImageSize,
+  IN UPDATE_CONFIG_DATA           *ConfigData,
+  OUT UINT32                      *LastAttemptVersion,
+  OUT UINT32                      *LastAttemptStatus
+  )
+{
+  EFI_STATUS                   Status;
+
+  DEBUG((EFI_D_INFO, "PlatformUpdate:"));
+  DEBUG((EFI_D_INFO, "  BaseAddress - 0x%lx,", ConfigData->BaseAddress));
+  DEBUG((EFI_D_INFO, "  ImageOffset - 0x%x,", ConfigData->ImageOffset));
+  DEBUG((EFI_D_INFO, "  Legnth - 0x%x\n", ConfigData->Length));
+  Status = PerformFlashWrite (
+             ConfigData->FirmwareType,
+             ConfigData->BaseAddress,
+             ConfigData->AddressType,
+             (VOID *)((UINTN)BiosImage + (UINTN)ConfigData->ImageOffset),
+             ConfigData->Length
+             );
+  if (!EFI_ERROR(Status)) {
+    *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+    if (ConfigData->FirmwareType == PlatformFirmwareTypeNvRam) {
+      mNvRamUpdated = TRUE;
+    }
+  } else {
+    *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+  }
+  return Status;
+}
+
+/**
+  Update BIOS image.
+
+  @param[in]  BiosImage         Points to the BIOS image.
+  @param[in]  BiosImageSize     The length of the BIOS image in bytes.
+  @param[in]  ConfigImage       Points to the config file image.
+  @param[in]  ConfigImageSize   The length of the config file image in bytes.
+  @param[out] LastAttemptVersion The last attempt version, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[out] LastAttemptStatus  The last attempt status, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             The BIOS image is updated.
+  @retval EFI_WRITE_PROTECTED     The flash device is read only.
+**/
+EFI_STATUS
+UpdateImage(
+  IN VOID                         *BiosImage,
+  IN UINTN                        BiosImageSize,
+  IN VOID                         *ConfigImage,
+  IN UINTN                        ConfigImageSize,
+  OUT UINT32                      *LastAttemptVersion,
+  OUT UINT32                      *LastAttemptStatus
+  )
+{
+  EFI_STATUS                            Status;
+  UPDATE_CONFIG_DATA                    *ConfigData;
+  UPDATE_CONFIG_DATA                    *UpdateConfigData;
+  CONFIG_HEADER                         ConfigHeader;
+  UINTN                                 Index;
+
+  if (ConfigImage == NULL) {
+    DEBUG((EFI_D_INFO, "PlatformUpdate (NoConfig):"));
+    DEBUG((EFI_D_INFO, "  BaseAddress - 0x%x,", 0));
+    DEBUG((EFI_D_INFO, "  Length - 0x%x\n", BiosImageSize));
+    // ASSUME the whole BIOS include NVRAM region.
+    Status = PerformFlashWrite (
+               PlatformFirmwareTypeNvRam,
+               0,
+               FlashAddressTypeRelativeAddress,
+               BiosImage,
+               BiosImageSize
+               );
+    if (!EFI_ERROR(Status)) {
+      *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+      mNvRamUpdated = TRUE;
+    } else {
+      *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+    }
+    return Status;
+  }
+
+  ConfigData        = NULL;
+  ZeroMem (&ConfigHeader, sizeof(ConfigHeader));
+  Status            = ParseUpdateDataFile (
+                        ConfigImage,
+                        ConfigImageSize,
+                        &ConfigHeader,
+                        &ConfigData
+                        );
+
+  Index = 0;
+  UpdateConfigData = ConfigData;
+  while (Index < ConfigHeader.NumOfUpdates) {
+    if (IsZeroGuid(&UpdateConfigData->ImageTypeId) || 
CompareGuid(&UpdateConfigData->ImageTypeId, &mCurrentImageTypeId)) {
+      Status = PerformUpdate (
+                 BiosImage,
+                 BiosImageSize,
+                 UpdateConfigData,
+                 LastAttemptVersion,
+                 LastAttemptStatus
+                 );
+      //
+      // Shall updates be serialized so that if an update is not successfully 
completed,
+      // the remaining updates won't be performed.
+      //
+      if (EFI_ERROR (Status)) {
+        break;
+      }
+    }
+
+    Index++;
+    UpdateConfigData++;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Authenticate and update BIOS image.
+
+  @param[in]  Image              The EDKII system FMP capsule image.
+  @param[in]  ImageSize          The size of the EDKII system FMP capsule 
image in bytes.
+  @param[out] LastAttemptVersion The last attempt version, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+  @param[out] LastAttemptStatus  The last attempt status, which will be 
recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             EDKII system FMP capsule passes 
authentication and the BIOS image is updated.
+  @retval EFI_SECURITY_VIOLATION  EDKII system FMP capsule fails 
authentication and the BIOS image is not updated.
+  @retval EFI_WRITE_PROTECTED     The flash device is read only.
+**/
+EFI_STATUS
+BiosAuthenticatedUpdate(
+  IN VOID                         *Image,
+  IN UINTN                        ImageSize,
+  OUT UINT32                      *LastAttemptVersion,
+  OUT UINT32                      *LastAttemptStatus
+  )
+{
+  EFI_STATUS                  Status;
+  VOID                        *BiosImage;
+  UINTN                       BiosImageSize;
+  VOID                        *ConfigImage;
+  UINTN                       ConfigImageSize;
+  VOID                        *AuthenticatedImage;
+  UINTN                       AuthenticatedImageSize;
+
+  DEBUG((EFI_D_INFO, "BiosAuthenticatedUpdate...\n"));
+
+  Status = CapsuleAuthenticateSystemFirmware(Image, ImageSize, FALSE, 
LastAttemptVersion, LastAttemptStatus, &AuthenticatedImage, 
&AuthenticatedImageSize);
+  if (EFI_ERROR(Status)) {
+    DEBUG((EFI_D_INFO, "BiosAuthenticateImage - %r\n", Status));
+    return Status;
+  }
+
+  ExtractSystemFirmwareImage(AuthenticatedImage, AuthenticatedImageSize, 
&BiosImage, &BiosImageSize);
+  ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, 
&ConfigImageSize);
+
+  Status = UpdateImage(BiosImage, BiosImageSize, ConfigImage, ConfigImageSize, 
LastAttemptVersion, LastAttemptStatus);
+  if (EFI_ERROR(Status)) {
+    DEBUG((EFI_D_INFO, "UpdateImage - %r\n", Status));
+    return Status;
+  }
+
+  DEBUG((EFI_D_INFO, "BiosAuthenticatedUpdate Done\n"));
+
+  return EFI_SUCCESS;
+}
+
+/**
+
+  This code finds variable in storage blocks (Volatile or Non-Volatile).
+
+  @param VariableName               Name of Variable to be found.
+  @param VendorGuid                 Variable vendor GUID.
+  @param Attributes                 Attribute value of the variable found.
+  @param DataSize                   Size of Data found. If size is less than 
the
+                                    data, this value contains the required 
size.
+  @param Data                       Data pointer.
+
+  @return EFI_INVALID_PARAMETER     Invalid parameter.
+  @return EFI_SUCCESS               Find the specified variable.
+  @return EFI_NOT_FOUND             Not found.
+  @return EFI_BUFFER_TO_SMALL       DataSize is too small for the result.
+
+**/
+EFI_STATUS
+EFIAPI
+GetVariableHook (
+  IN      CHAR16            *VariableName,
+  IN      EFI_GUID          *VendorGuid,
+  OUT     UINT32            *Attributes OPTIONAL,
+  IN OUT  UINTN             *DataSize,
+  OUT     VOID              *Data
+  )
+{
+  DEBUG((EFI_D_INFO, "GetVariableHook - %S, %g\n", VariableName, VendorGuid));
+  return EFI_NOT_AVAILABLE_YET;
+}
+
+/**
+
+  This code Finds the Next available variable.
+
+  @param VariableNameSize           Size of the variable name.
+  @param VariableName               Pointer to variable name.
+  @param VendorGuid                 Variable Vendor Guid.
+
+  @return EFI_INVALID_PARAMETER     Invalid parameter.
+  @return EFI_SUCCESS               Find the specified variable.
+  @return EFI_NOT_FOUND             Not found.
+  @return EFI_BUFFER_TO_SMALL       DataSize is too small for the result.
+
+**/
+EFI_STATUS
+EFIAPI
+GetNextVariableNameHook (
+  IN OUT  UINTN             *VariableNameSize,
+  IN OUT  CHAR16            *VariableName,
+  IN OUT  EFI_GUID          *VendorGuid
+  )
+{
+  DEBUG((EFI_D_INFO, "GetNextVariableNameHook - %S, %g\n", VariableName, 
VendorGuid));
+  return EFI_NOT_AVAILABLE_YET;
+}
+
+/**
+
+  This code sets variable in storage blocks (Volatile or Non-Volatile).
+
+  @param VariableName                     Name of Variable to be found.
+  @param VendorGuid                       Variable vendor GUID.
+  @param Attributes                       Attribute value of the variable found
+  @param DataSize                         Size of Data found. If size is less 
than the
+                                          data, this value contains the 
required size.
+  @param Data                             Data pointer.
+
+  @return EFI_INVALID_PARAMETER           Invalid parameter.
+  @return EFI_SUCCESS                     Set successfully.
+  @return EFI_OUT_OF_RESOURCES            Resource not enough to set variable.
+  @return EFI_NOT_FOUND                   Not found.
+  @return EFI_WRITE_PROTECTED             Variable is read-only.
+
+**/
+EFI_STATUS
+EFIAPI
+SetVariableHook (
+  IN CHAR16                  *VariableName,
+  IN EFI_GUID                *VendorGuid,
+  IN UINT32                  Attributes,
+  IN UINTN                   DataSize,
+  IN VOID                    *Data
+  )
+{
+  DEBUG((EFI_D_INFO, "SetVariableHook - %S, %g, 0x%x (0x%x)\n", VariableName, 
VendorGuid, Attributes, DataSize));
+  return EFI_NOT_AVAILABLE_YET;
+}
+
+/**
+
+  This code returns information about the EFI variables.
+
+  @param Attributes                     Attributes bitmask to specify the type 
of variables
+                                        on which to return information.
+  @param MaximumVariableStorageSize     Pointer to the maximum size of the 
storage space available
+                                        for the EFI variables associated with 
the attributes specified.
+  @param RemainingVariableStorageSize   Pointer to the remaining size of the 
storage space available
+                                        for EFI variables associated with the 
attributes specified.
+  @param MaximumVariableSize            Pointer to the maximum size of an 
individual EFI variables
+                                        associated with the attributes 
specified.
+
+  @return EFI_SUCCESS                   Query successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+QueryVariableInfoHook (
+  IN  UINT32                 Attributes,
+  OUT UINT64                 *MaximumVariableStorageSize,
+  OUT UINT64                 *RemainingVariableStorageSize,
+  OUT UINT64                 *MaximumVariableSize
+  )
+{
+  DEBUG((EFI_D_INFO, "QueryVariableInfoHook - 0x%x\n", Attributes));
+  return EFI_NOT_AVAILABLE_YET;
+}
+
+/**
+  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
+FmpSetImage(
+  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;
+  EFI_STATUS              VarStatus;
+  BIOS_FMP_PRIVATE_DATA   *BiosFmpPrivate;
+
+  if (Image == NULL || AbortReason == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  BiosFmpPrivate = BIOS_FMP_PRIVATE_DATA_FROM_FMP(This);
+  *AbortReason     = NULL;
+
+  if (ImageIndex == 0 || ImageIndex > BiosFmpPrivate->DescriptorCount || Image 
== NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = BiosAuthenticatedUpdate((VOID *)Image, ImageSize, 
&BiosFmpPrivate->LastAttempt.LastAttemptVersion, 
&BiosFmpPrivate->LastAttempt.LastAttemptStatus);
+  DEBUG((EFI_D_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", 
BiosFmpPrivate->LastAttempt.LastAttemptVersion, 
BiosFmpPrivate->LastAttempt.LastAttemptStatus));
+
+  //
+  // If NVRAM is updated, we should no longer touch variable services, because
+  // the current variable driver may not manage the new NVRAM region.
+  //
+  if (mNvRamUpdated) {
+    DEBUG ((EFI_D_INFO, "NvRamUpdated, Update Variable Serivces\n"));
+    gRT->GetVariable         = GetVariableHook;
+    gRT->GetNextVariableName = GetNextVariableNameHook;
+    gRT->SetVariable         = SetVariableHook;
+    gRT->QueryVariableInfo   = QueryVariableInfoHook;
+
+    gRT->Hdr.CRC32 = 0;
+    gBS->CalculateCrc32 (
+          (UINT8 *) &gRT->Hdr,
+          gRT->Hdr.HeaderSize,
+          &gRT->Hdr.CRC32
+          );
+  }
+
+  VarStatus = gRT->SetVariable(
+                     SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
+                     &gSystemFmpLastAttemptVariableGuid,
+                     EFI_VARIABLE_NON_VOLATILE | 
EFI_VARIABLE_BOOTSERVICE_ACCESS,
+                     sizeof(BiosFmpPrivate->LastAttempt),
+                     &BiosFmpPrivate->LastAttempt
+                     );
+  DEBUG((EFI_D_INFO, "SetLastAttemp - %r\n", VarStatus));
+
+  return Status;
+}
diff --git 
a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImageDummy.c 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImageDummy.c
new file mode 100644
index 0000000..3a28f7f
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosMainSetImageDummy.c
@@ -0,0 +1,90 @@
+/** @file
+  Dummy SetImage instance.
+
+  Copyright (c) 2016, 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.
+
+**/
+
+#include "SystemBiosDxe.h"
+
+/**
+  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
+FmpSetImage(
+  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
+  )
+{
+  BIOS_FMP_PRIVATE_DATA   *BiosFmpPrivate;
+
+  if (Image == NULL || AbortReason == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  BiosFmpPrivate = BIOS_FMP_PRIVATE_DATA_FROM_FMP(This);
+  *AbortReason     = NULL;
+
+  if (ImageIndex == 0 || ImageIndex > BiosFmpPrivate->DescriptorCount || Image 
== NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  return EFI_UNSUPPORTED;
+}
+
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.inf 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.inf
new file mode 100644
index 0000000..9cda2ee
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.inf
@@ -0,0 +1,66 @@
+## @file
+# SystemBios FMP report driver.
+#
+# Produce FMP instance to report system firmware EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+#
+#  Copyright (c) 2016, 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.
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SystemBiosReportDxe
+  MODULE_UNI_FILE                = SystemBiosReportDxe.uni
+  FILE_GUID                      = BC1A046C-7DBD-41F2-94E5-D7595554CAF4
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = BiosUpdateMainDxe
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES           = X64
+#
+
+[Sources]
+  SystemBiosMainDxe.c
+  SystemBiosMainSetImageDummy.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  UefiLib
+  BaseMemoryLib
+  DebugLib
+  PcdLib
+  MemoryAllocationLib
+  UefiBootServicesTableLib
+  HobLib
+  UefiRuntimeServicesTableLib
+  UefiDriverEntryPoint
+  DxeServicesLib
+  PrintLib
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiSystemFmpCapsuleImageTypeIdGuid  ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor
+
+[Protocols]
+  gEfiFirmwareManagementProtocolGuid
+
+[Depex]
+  gEfiVariableArchProtocolGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  SystemBiosReportDxeExtra.uni
+
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.uni 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.uni
new file mode 100644
index 0000000..7d6fb22
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxe.uni
@@ -0,0 +1,21 @@
+// /** @file
+// SystemBios FMP report driver.
+//
+// Produce FMP instance to report system firmware 
EFI_FIRMWARE_IMAGE_DESCRIPTOR.
+//
+// Copyright (c) 2016, 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 "SystemBios FMP report 
driver."
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Produce FMP instance 
to report system firmware EFI_FIRMWARE_IMAGE_DESCRIPTOR."
diff --git 
a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxeExtra.uni 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxeExtra.uni
new file mode 100644
index 0000000..8eb2009
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosReportDxeExtra.uni
@@ -0,0 +1,20 @@
+// /** @file
+// SystemBiosReportDxe Localized Strings and Content
+//
+// Copyright (c) 2016, 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
+"SystemBiosReport DXE Driver"
+
+
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.inf 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.inf
new file mode 100644
index 0000000..9e65641
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.inf
@@ -0,0 +1,70 @@
+## @file
+# SystemBios FMP update driver.
+#
+# Produce FMP instance to update system firmware.
+#
+#  Copyright (c) 2016, 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.
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SystemBiosUpdateDxe
+  MODULE_UNI_FILE                = SystemBiosUpdateDxe.uni
+  FILE_GUID                      = 0A2FBD15-1C25-407E-8915-60C5652BC2AA
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = BiosUpdateMainDxe
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES           = X64
+#
+
+[Sources]
+  SystemBiosMainDxe.c
+  SystemBiosMainSetImage.c
+  ParseConfigProfile.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  UefiLib
+  BaseMemoryLib
+  DebugLib
+  PcdLib
+  MemoryAllocationLib
+  UefiBootServicesTableLib
+  HobLib
+  UefiRuntimeServicesTableLib
+  UefiDriverEntryPoint
+  DxeServicesLib
+  EdkiiSystemCapsuleLib
+  PlatformFlashAccessLib
+  IniParsingLib
+  PrintLib
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiSystemFmpCapsuleImageTypeIdGuid  ## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiSystemFirmwareImageDescriptor
+
+[Protocols]
+  gEfiFirmwareManagementProtocolGuid
+
+[Depex]
+  gEfiVariableArchProtocolGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+  SystemBiosUpdateDxeExtra.uni
+
diff --git a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.uni 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.uni
new file mode 100644
index 0000000..39ae0e6
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxe.uni
@@ -0,0 +1,21 @@
+// /** @file
+// SystemBios FMP update driver.
+//
+// Produce FMP instance to update system firmware.
+//
+// Copyright (c) 2016, 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 "SystemBios FMP update 
driver."
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Produce FMP instance 
to update system firmware."
diff --git 
a/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxeExtra.uni 
b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxeExtra.uni
new file mode 100644
index 0000000..0ec28bc
--- /dev/null
+++ b/MdeModulePkg/Universal/SystemBiosUpdate/SystemBiosUpdateDxeExtra.uni
@@ -0,0 +1,20 @@
+// /** @file
+// SystemBiosUpdateDxe Localized Strings and Content
+//
+// Copyright (c) 2016, 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
+"SystemBiosUpdate DXE Driver"
+
+
-- 
2.7.4.windows.1

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

Reply via email to