2 Common defines and definitions for a component update driver.
4 Copyright (c) 2002 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _EFI_UPDATE_DRIVER_H_
18 #define _EFI_UPDATE_DRIVER_H_
22 #include <Protocol/LoadedImage.h>
23 #include <Guid/Capsule.h>
24 #include <Protocol/FaultTolerantWrite.h>
25 #include <Protocol/FirmwareVolumeBlock.h>
26 #include <Protocol/FirmwareVolume2.h>
28 #include <Library/BaseLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/UefiRuntimeServicesTableLib.h>
32 #include <Library/UefiDriverEntryPoint.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/UefiLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/DxeServicesTableLib.h>
37 #include <Library/HiiLib.h>
38 #include <Library/PrintLib.h>
39 #include <Library/DevicePathLib.h>
42 // {283FA2EE-532C-484d-9383-9F93B36F0B7E}
44 #define EFI_UPDATE_DATA_FILE_GUID \
45 { 0x283fa2ee, 0x532c, 0x484d, { 0x93, 0x83, 0x9f, 0x93, 0xb3, 0x6f, 0xb, 0x7e } }
47 extern EFI_HII_HANDLE gHiiHandle
;
50 UpdateWholeFV
= 0, // 0, update whole FV
51 UpdateFvFile
, // 1, update a set of FV files asynchronously
52 UpdateFvRange
, // 2, update part of FV or flash
53 UpdateOperationMaximum
// 3
54 } UPDATE_OPERATION_TYPE
;
58 UPDATE_OPERATION_TYPE UpdateType
;
59 EFI_DEVICE_PATH_PROTOCOL DevicePath
;
60 EFI_PHYSICAL_ADDRESS BaseAddress
;
63 BOOLEAN FaultTolerant
;
66 typedef struct _SECTION_ITEM SECTION_ITEM
;
67 struct _SECTION_ITEM
{
72 SECTION_ITEM
*ptrNext
;
75 typedef struct _COMMENT_LINE COMMENT_LINE
;
76 struct _COMMENT_LINE
{
78 COMMENT_LINE
*ptrNext
;
83 } UPDATE_PRIVATE_DATA
;
85 #define MAX_LINE_LENGTH 512
86 #define EFI_D_UPDATE EFI_D_ERROR
88 #define MIN_ALIGNMENT_SIZE 4
89 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
92 Parse Config data file to get the updated data array.
94 @param DataBuffer Config raw file buffer.
95 @param BufferSize Size of raw buffer.
96 @param NumOfUpdates Pointer to the number of update data.
97 @param UpdateArray Pointer to the config of update data.
99 @retval EFI_NOT_FOUND No config data is found.
100 @retval EFI_OUT_OF_RESOURCES No enough memory is allocated.
101 @retval EFI_SUCCESS Parse the config file successfully.
105 ParseUpdateDataFile (
106 IN UINT8
*DataBuffer
,
108 IN OUT UINTN
*NumOfUpdates
,
109 IN OUT UPDATE_CONFIG_DATA
**UpdateArray
113 Update the whole FV image, and reinsall FVB protocol for the updated FV image.
115 @param FvbHandle Handle of FVB protocol for the updated flash range.
116 @param FvbProtocol FVB protocol.
117 @param ConfigData Config data on updating driver.
118 @param ImageBuffer Image buffer to be updated.
119 @param ImageSize Image size.
121 @retval EFI_INVALID_PARAMETER Update type is not UpdateWholeFV.
122 Or Image size is not same to the size of whole FV.
123 @retval EFI_OUT_OF_RESOURCES No enoug memory is allocated.
124 @retval EFI_SUCCESS FV image is updated, and its FVB protocol is reinstalled.
128 PerformUpdateOnWholeFv (
129 IN EFI_HANDLE FvbHandle
,
130 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
131 IN UPDATE_CONFIG_DATA
*ConfigData
,
132 IN UINT8
*ImageBuffer
,
137 Update certain file in the FV.
139 @param FvbHandle Handle of FVB protocol for the updated flash range.
140 @param FvbProtocol FVB protocol.
141 @param ConfigData Config data on updating driver.
142 @param ImageBuffer Image buffer to be updated.
143 @param ImageSize Image size.
144 @param FileType FFS file type.
145 @param FileAttributes FFS file attribute
147 @retval EFI_INVALID_PARAMETER Update type is not UpdateFvFile.
148 Or Image size is not same to the size of whole FV.
149 @retval EFI_UNSUPPORTED PEIM FFS is unsupported to be updated.
150 @retval EFI_SUCCESS The FFS file is added into FV.
154 PerformUpdateOnFvFile (
155 IN EFI_HANDLE FvbHandle
,
156 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
157 IN UPDATE_CONFIG_DATA
*ConfigData
,
158 IN UINT8
*ImageBuffer
,
160 IN EFI_FV_FILETYPE FileType
,
161 IN EFI_FV_FILE_ATTRIBUTES FileAttributes
165 Update the buffer into flash area in fault tolerant write method.
167 @param ImageBuffer Image buffer to be updated.
168 @param SizeLeft Size of the image buffer.
169 @param UpdatedSize Size of the updated buffer.
170 @param ConfigData Config data on updating driver.
171 @param FlashAddress Flash address to be updated as start address.
172 @param FvbProtocol FVB protocol.
173 @param FvbHandle Handle of FVB protocol for the updated flash range.
175 @retval EFI_SUCCESS Buffer data is updated into flash.
176 @retval EFI_INVALID_PARAMETER Base flash address is not in FVB flash area.
177 @retval EFI_NOT_FOUND FTW protocol doesn't exist.
178 @retval EFI_OUT_OF_RESOURCES No enough backup space.
179 @retval EFI_ABORTED Error happen when update flash area.
183 FaultTolerantUpdateOnPartFv (
184 IN UINT8
*ImageBuffer
,
186 IN OUT UINTN
*UpdatedSize
,
187 IN UPDATE_CONFIG_DATA
*ConfigData
,
188 IN EFI_PHYSICAL_ADDRESS FlashAddress
,
189 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
190 IN EFI_HANDLE FvbHandle
194 Directly update the buffer into flash area without fault tolerant write method.
196 @param ImageBuffer Image buffer to be updated.
197 @param SizeLeft Size of the image buffer.
198 @param UpdatedSize Size of the updated buffer.
199 @param FlashAddress Flash address to be updated as start address.
200 @param FvbProtocol FVB protocol.
201 @param FvbHandle Handle of FVB protocol for the updated flash range.
203 @retval EFI_SUCCESS Buffer data is updated into flash.
204 @retval EFI_INVALID_PARAMETER Base flash address is not in FVB flash area.
205 @retval EFI_OUT_OF_RESOURCES No enough backup space.
209 NonFaultTolerantUpdateOnPartFv (
210 IN UINT8
*ImageBuffer
,
212 IN OUT UINTN
*UpdatedSize
,
213 IN EFI_PHYSICAL_ADDRESS FlashAddress
,
214 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
215 IN EFI_HANDLE FvbHandle