]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 3 Jan 2019 18:28:23 +0000 (19:28 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 16 Jan 2019 19:10:51 +0000 (20:10 +0100)
Implement a new version of the fault tolerant write driver that can
be used in the context of a standalone MM implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c [new file with mode: 0644]
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf [new file with mode: 0644]

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
new file mode 100644 (file)
index 0000000..8a4ea5b
--- /dev/null
@@ -0,0 +1,96 @@
+/** @file\r
+\r
+  Parts of the SMM/MM implementation that are specific to standalone MM\r
+\r
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Library/SmmMemLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include "FaultTolerantWrite.h"\r
+#include "FaultTolerantWriteSmmCommon.h"\r
+\r
+/**\r
+  This function checks if the buffer is valid per processor architecture and\r
+  does not overlap with SMRAM.\r
+\r
+  @param Buffer The buffer start address to be checked.\r
+  @param Length The buffer length to be checked.\r
+\r
+  @retval TRUE  This buffer is valid per processor architecture and does not\r
+                overlap with SMRAM.\r
+  @retval FALSE This buffer is not valid per processor architecture or overlaps\r
+                with SMRAM.\r
+**/\r
+BOOLEAN\r
+FtwSmmIsBufferOutsideSmmValid (\r
+  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
+  IN UINT64                Length\r
+  )\r
+{\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Internal implementation of CRC32. Depending on the execution context\r
+  (standalone SMM or DXE vs standalone MM), this function is implemented\r
+  via a call to the CalculateCrc32 () boot service, or via a library\r
+  call.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is to be computed.\r
+  @param[in]  Length       The number of bytes in the buffer Data.\r
+\r
+  @retval Crc32            The 32-bit CRC was computed for the data buffer.\r
+\r
+**/\r
+UINT32\r
+FtwCalculateCrc32 (\r
+  IN  VOID                         *Buffer,\r
+  IN  UINTN                        Length\r
+  )\r
+{\r
+  return CalculateCrc32 (Buffer, Length);\r
+}\r
+\r
+/**\r
+  Notify the system that the SMM FTW driver is ready\r
+**/\r
+VOID\r
+FtwNotifySmmReady (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  This function is the entry point of the Fault Tolerant Write driver.\r
+\r
+  @param[in] ImageHandle        A handle for the image that is initializing this driver\r
+  @param[in] MmSystemTable      A pointer to the MM system table\r
+\r
+  @retval EFI_SUCCESS           The initialization finished successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  Allocate memory error\r
+  @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StandaloneMmFaultTolerantWriteInitialize (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable\r
+  )\r
+{\r
+  return MmFaultTolerantWriteInitialize ();\r
+}\r
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
new file mode 100644 (file)
index 0000000..c667d4c
--- /dev/null
@@ -0,0 +1,90 @@
+ ## @file\r
+#   Fault Tolerant Write Smm Driver.\r
+#\r
+#   This driver installs SMM Fault Tolerant Write (FTW) protocol, which provides fault\r
+#   tolerant write capability in SMM environment for block devices. Its implementation\r
+#   depends on the full functionality SMM FVB protocol that support read, write/erase\r
+#   flash access.\r
+#\r
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001001B\r
+  BASE_NAME                      = FaultTolerantWriteStandaloneMm\r
+  FILE_GUID                      = 3aade4ec-63cc-4a48-a928-5a374dd463eb\r
+  MODULE_TYPE                    = MM_STANDALONE\r
+  VERSION_STRING                 = 1.0\r
+  PI_SPECIFICATION_VERSION       = 0x00010032\r
+  ENTRY_POINT                    = StandaloneMmFaultTolerantWriteInitialize\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64\r
+#\r
+\r
+[Sources]\r
+  FtwMisc.c\r
+  UpdateWorkingBlock.c\r
+  FaultTolerantWrite.c\r
+  FaultTolerantWriteStandaloneMm.c\r
+  FaultTolerantWriteSmm.c\r
+  FaultTolerantWrite.h\r
+  FaultTolerantWriteSmmCommon.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  StandaloneMmPkg/StandaloneMmPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  MemoryAllocationLib\r
+  MmServicesTableLib\r
+  PcdLib\r
+  ReportStatusCodeLib\r
+  StandaloneMmDriverEntryPoint\r
+\r
+[Guids]\r
+  #\r
+  # Signature in EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER\r
+  #\r
+  ## CONSUMES           ## GUID\r
+  ## PRODUCES           ## GUID\r
+  gEdkiiWorkingBlockSignatureGuid\r
+\r
+[Protocols]\r
+  gEfiSmmSwapAddressRangeProtocolGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable  ## SOMETIMES_CONSUMES\r
+  ## NOTIFY\r
+  ## CONSUMES\r
+  gEfiSmmFirmwareVolumeBlockProtocolGuid\r
+  ## PRODUCES\r
+  ## UNDEFINED # SmiHandlerRegister\r
+  gEfiSmmFaultTolerantWriteProtocolGuid\r
+  gEfiMmEndOfDxeProtocolGuid                       ## CONSUMES\r
+\r
+[FeaturePcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable    ## CONSUMES\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase    ## SOMETIMES_CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64  ## CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize    ## CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase      ## SOMETIMES_CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64    ## CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize      ## CONSUMES\r
+\r
+[Depex]\r
+  TRUE\r