]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h
IntelFrameworkModulePkg: Add UpdateDriverDxe driver
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / FirmwareVolume / UpdateDriverDxe / UpdateDriver.h
diff --git a/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h b/IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h
new file mode 100644 (file)
index 0000000..9fd00b3
--- /dev/null
@@ -0,0 +1,218 @@
+/** @file\r
+  Common defines and definitions for a component update driver.\r
+\r
+  Copyright (c) 2002 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions\r
+  of the BSD License which accompanies this distribution.  The\r
+  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
+#ifndef _EFI_UPDATE_DRIVER_H_\r
+#define _EFI_UPDATE_DRIVER_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/LoadedImage.h>\r
+#include <Guid/Capsule.h>\r
+#include <Protocol/FaultTolerantWrite.h>\r
+#include <Protocol/FirmwareVolumeBlock.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+//\r
+// {283FA2EE-532C-484d-9383-9F93B36F0B7E}\r
+//\r
+#define EFI_UPDATE_DATA_FILE_GUID \\r
+ { 0x283fa2ee, 0x532c, 0x484d, { 0x93, 0x83, 0x9f, 0x93, 0xb3, 0x6f, 0xb, 0x7e } }\r
+\r
+extern EFI_HII_HANDLE gHiiHandle;\r
+\r
+typedef enum {\r
+  UpdateWholeFV = 0,              // 0, update whole FV\r
+  UpdateFvFile,                   // 1, update a set of FV files asynchronously\r
+  UpdateFvRange,                  // 2, update part of FV or flash\r
+  UpdateOperationMaximum          // 3\r
+} UPDATE_OPERATION_TYPE;\r
+\r
+typedef struct {\r
+  UINTN                           Index;\r
+  UPDATE_OPERATION_TYPE           UpdateType;\r
+  EFI_DEVICE_PATH_PROTOCOL        DevicePath;\r
+  EFI_PHYSICAL_ADDRESS            BaseAddress;\r
+  EFI_GUID                        FileGuid;\r
+  UINTN                           Length;\r
+  BOOLEAN                         FaultTolerant;\r
+} UPDATE_CONFIG_DATA;\r
+\r
+typedef struct _SECTION_ITEM SECTION_ITEM;\r
+struct _SECTION_ITEM {\r
+  CHAR8                           *ptrSection;\r
+  UINTN                           SecNameLen;\r
+  CHAR8                           *ptrEntry;\r
+  CHAR8                           *ptrValue;\r
+  SECTION_ITEM                    *ptrNext;\r
+};\r
+\r
+typedef struct _COMMENT_LINE COMMENT_LINE;\r
+struct _COMMENT_LINE {\r
+  CHAR8                           *ptrComment;\r
+  COMMENT_LINE                    *ptrNext;\r
+};\r
+\r
+typedef struct {\r
+  EFI_GUID                        FileGuid;\r
+} UPDATE_PRIVATE_DATA;\r
+\r
+#define MAX_LINE_LENGTH           512\r
+#define EFI_D_UPDATE              EFI_D_ERROR\r
+\r
+#define MIN_ALIGNMENT_SIZE        4\r
+#define ALIGN_SIZE(a)   ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
+\r
+/**\r
+  Parse Config data file to get the updated data array.\r
+\r
+  @param DataBuffer      Config raw file buffer.\r
+  @param BufferSize      Size of raw buffer.\r
+  @param NumOfUpdates    Pointer to the number of update data.\r
+  @param UpdateArray     Pointer to the config of update data.\r
+\r
+  @retval EFI_NOT_FOUND         No config data is found.\r
+  @retval EFI_OUT_OF_RESOURCES  No enough memory is allocated.\r
+  @retval EFI_SUCCESS           Parse the config file successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+ParseUpdateDataFile (\r
+  IN      UINT8                         *DataBuffer,\r
+  IN      UINTN                         BufferSize,\r
+  IN OUT  UINTN                         *NumOfUpdates,\r
+  IN OUT  UPDATE_CONFIG_DATA            **UpdateArray\r
+  );\r
+\r
+/**\r
+  Update the whole FV image, and reinsall FVB protocol for the updated FV image.\r
+\r
+  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
+  @param FvbProtocol     FVB protocol.\r
+  @param ConfigData      Config data on updating driver.\r
+  @param ImageBuffer     Image buffer to be updated.\r
+  @param ImageSize       Image size.\r
+\r
+  @retval EFI_INVALID_PARAMETER  Update type is not UpdateWholeFV.\r
+                                 Or Image size is not same to the size of whole FV.\r
+  @retval EFI_OUT_OF_RESOURCES   No enoug memory is allocated.\r
+  @retval EFI_SUCCESS            FV image is updated, and its FVB protocol is reinstalled.\r
+\r
+**/\r
+EFI_STATUS\r
+PerformUpdateOnWholeFv (\r
+  IN EFI_HANDLE                         FvbHandle,\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
+  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
+  IN UINT8                              *ImageBuffer,\r
+  IN UINTN                              ImageSize\r
+  );\r
+\r
+/**\r
+  Update certain file in the FV.\r
+\r
+  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
+  @param FvbProtocol     FVB protocol.\r
+  @param ConfigData      Config data on updating driver.\r
+  @param ImageBuffer     Image buffer to be updated.\r
+  @param ImageSize       Image size.\r
+  @param FileType        FFS file type.\r
+  @param FileAttributes  FFS file attribute\r
+\r
+  @retval EFI_INVALID_PARAMETER  Update type is not UpdateFvFile.\r
+                                 Or Image size is not same to the size of whole FV.\r
+  @retval EFI_UNSUPPORTED        PEIM FFS is unsupported to be updated.\r
+  @retval EFI_SUCCESS            The FFS file is added into FV.\r
+\r
+**/\r
+EFI_STATUS\r
+PerformUpdateOnFvFile (\r
+  IN EFI_HANDLE                         FvbHandle,\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
+  IN UPDATE_CONFIG_DATA                 *ConfigData,\r
+  IN UINT8                              *ImageBuffer,\r
+  IN UINTN                              ImageSize,\r
+  IN EFI_FV_FILETYPE                    FileType,\r
+  IN EFI_FV_FILE_ATTRIBUTES             FileAttributes\r
+  );\r
+\r
+/**\r
+  Update the buffer into flash area in fault tolerant write method.\r
+\r
+  @param ImageBuffer     Image buffer to be updated.\r
+  @param SizeLeft        Size of the image buffer.\r
+  @param UpdatedSize     Size of the updated buffer.\r
+  @param ConfigData      Config data on updating driver.\r
+  @param FlashAddress    Flash address to be updated as start address.\r
+  @param FvbProtocol     FVB protocol.\r
+  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
+\r
+  @retval EFI_SUCCESS            Buffer data is updated into flash.\r
+  @retval EFI_INVALID_PARAMETER  Base flash address is not in FVB flash area.\r
+  @retval EFI_NOT_FOUND          FTW protocol doesn't exist.\r
+  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
+  @retval EFI_ABORTED            Error happen when update flash area.\r
+\r
+**/\r
+EFI_STATUS\r
+FaultTolerantUpdateOnPartFv (\r
+  IN       UINT8                         *ImageBuffer,\r
+  IN       UINTN                         SizeLeft,\r
+  IN OUT   UINTN                         *UpdatedSize,\r
+  IN       UPDATE_CONFIG_DATA            *ConfigData,\r
+  IN       EFI_PHYSICAL_ADDRESS          FlashAddress,\r
+  IN       EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
+  IN       EFI_HANDLE                    FvbHandle\r
+  );\r
+\r
+/**\r
+  Directly update the buffer into flash area without fault tolerant write method.\r
+\r
+  @param ImageBuffer     Image buffer to be updated.\r
+  @param SizeLeft        Size of the image buffer.\r
+  @param UpdatedSize     Size of the updated buffer.\r
+  @param FlashAddress    Flash address to be updated as start address.\r
+  @param FvbProtocol     FVB protocol.\r
+  @param FvbHandle       Handle of FVB protocol for the updated flash range.\r
+\r
+  @retval EFI_SUCCESS            Buffer data is updated into flash.\r
+  @retval EFI_INVALID_PARAMETER  Base flash address is not in FVB flash area.\r
+  @retval EFI_OUT_OF_RESOURCES   No enough backup space.\r
+\r
+**/\r
+EFI_STATUS\r
+NonFaultTolerantUpdateOnPartFv (\r
+  IN      UINT8                         *ImageBuffer,\r
+  IN      UINTN                         SizeLeft,\r
+  IN OUT  UINTN                         *UpdatedSize,\r
+  IN      EFI_PHYSICAL_ADDRESS          FlashAddress,\r
+  IN      EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r
+  IN      EFI_HANDLE                    FvbHandle\r
+  );\r
+\r
+#endif\r