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 <Guid/CapsuleDataFile.h>
25 #include <Protocol/FaultTolerantWrite.h>
26 #include <Protocol/FirmwareVolumeBlock.h>
27 #include <Protocol/FirmwareVolume2.h>
29 #include <Library/BaseLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/UefiRuntimeServicesTableLib.h>
33 #include <Library/UefiDriverEntryPoint.h>
34 #include <Library/UefiBootServicesTableLib.h>
35 #include <Library/UefiLib.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/DxeServicesTableLib.h>
38 #include <Library/HiiLib.h>
39 #include <Library/PrintLib.h>
40 #include <Library/DevicePathLib.h>
42 extern EFI_HII_HANDLE gHiiHandle
;
45 UpdateWholeFV
= 0, // 0, update whole FV
46 UpdateFvFile
, // 1, update a set of FV files asynchronously
47 UpdateFvRange
, // 2, update part of FV or flash
48 UpdateOperationMaximum
// 3
49 } UPDATE_OPERATION_TYPE
;
53 UPDATE_OPERATION_TYPE UpdateType
;
54 EFI_DEVICE_PATH_PROTOCOL DevicePath
;
55 EFI_PHYSICAL_ADDRESS BaseAddress
;
58 BOOLEAN FaultTolerant
;
61 typedef struct _SECTION_ITEM SECTION_ITEM
;
62 struct _SECTION_ITEM
{
67 SECTION_ITEM
*ptrNext
;
70 typedef struct _COMMENT_LINE COMMENT_LINE
;
71 struct _COMMENT_LINE
{
73 COMMENT_LINE
*ptrNext
;
78 } UPDATE_PRIVATE_DATA
;
80 #define MAX_LINE_LENGTH 512
81 #define EFI_D_UPDATE EFI_D_ERROR
83 #define MIN_ALIGNMENT_SIZE 4
84 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
87 Parse Config data file to get the updated data array.
89 @param DataBuffer Config raw file buffer.
90 @param BufferSize Size of raw buffer.
91 @param NumOfUpdates Pointer to the number of update data.
92 @param UpdateArray Pointer to the config of update data.
94 @retval EFI_NOT_FOUND No config data is found.
95 @retval EFI_OUT_OF_RESOURCES No enough memory is allocated.
96 @retval EFI_SUCCESS Parse the config file successfully.
100 ParseUpdateDataFile (
101 IN UINT8
*DataBuffer
,
103 IN OUT UINTN
*NumOfUpdates
,
104 IN OUT UPDATE_CONFIG_DATA
**UpdateArray
108 Update the whole FV image, and reinsall FVB protocol for the updated FV image.
110 @param FvbHandle Handle of FVB protocol for the updated flash range.
111 @param FvbProtocol FVB protocol.
112 @param ConfigData Config data on updating driver.
113 @param ImageBuffer Image buffer to be updated.
114 @param ImageSize Image size.
116 @retval EFI_INVALID_PARAMETER Update type is not UpdateWholeFV.
117 Or Image size is not same to the size of whole FV.
118 @retval EFI_OUT_OF_RESOURCES No enoug memory is allocated.
119 @retval EFI_SUCCESS FV image is updated, and its FVB protocol is reinstalled.
123 PerformUpdateOnWholeFv (
124 IN EFI_HANDLE FvbHandle
,
125 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
126 IN UPDATE_CONFIG_DATA
*ConfigData
,
127 IN UINT8
*ImageBuffer
,
132 Update certain file in the FV.
134 @param FvbHandle Handle of FVB protocol for the updated flash range.
135 @param FvbProtocol FVB protocol.
136 @param ConfigData Config data on updating driver.
137 @param ImageBuffer Image buffer to be updated.
138 @param ImageSize Image size.
139 @param FileType FFS file type.
140 @param FileAttributes FFS file attribute
142 @retval EFI_INVALID_PARAMETER Update type is not UpdateFvFile.
143 Or Image size is not same to the size of whole FV.
144 @retval EFI_UNSUPPORTED PEIM FFS is unsupported to be updated.
145 @retval EFI_SUCCESS The FFS file is added into FV.
149 PerformUpdateOnFvFile (
150 IN EFI_HANDLE FvbHandle
,
151 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
152 IN UPDATE_CONFIG_DATA
*ConfigData
,
153 IN UINT8
*ImageBuffer
,
155 IN EFI_FV_FILETYPE FileType
,
156 IN EFI_FV_FILE_ATTRIBUTES FileAttributes
160 Update the buffer into flash area in fault tolerant write method.
162 @param ImageBuffer Image buffer to be updated.
163 @param SizeLeft Size of the image buffer.
164 @param UpdatedSize Size of the updated buffer.
165 @param ConfigData Config data on updating driver.
166 @param FlashAddress Flash address to be updated as start address.
167 @param FvbProtocol FVB protocol.
168 @param FvbHandle Handle of FVB protocol for the updated flash range.
170 @retval EFI_SUCCESS Buffer data is updated into flash.
171 @retval EFI_INVALID_PARAMETER Base flash address is not in FVB flash area.
172 @retval EFI_NOT_FOUND FTW protocol doesn't exist.
173 @retval EFI_OUT_OF_RESOURCES No enough backup space.
174 @retval EFI_ABORTED Error happen when update flash area.
178 FaultTolerantUpdateOnPartFv (
179 IN UINT8
*ImageBuffer
,
181 IN OUT UINTN
*UpdatedSize
,
182 IN UPDATE_CONFIG_DATA
*ConfigData
,
183 IN EFI_PHYSICAL_ADDRESS FlashAddress
,
184 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
185 IN EFI_HANDLE FvbHandle
189 Directly update the buffer into flash area without fault tolerant write method.
191 @param ImageBuffer Image buffer to be updated.
192 @param SizeLeft Size of the image buffer.
193 @param UpdatedSize Size of the updated buffer.
194 @param FlashAddress Flash address to be updated as start address.
195 @param FvbProtocol FVB protocol.
196 @param FvbHandle Handle of FVB protocol for the updated flash range.
198 @retval EFI_SUCCESS Buffer data is updated into flash.
199 @retval EFI_INVALID_PARAMETER Base flash address is not in FVB flash area.
200 @retval EFI_OUT_OF_RESOURCES No enough backup space.
204 NonFaultTolerantUpdateOnPartFv (
205 IN UINT8
*ImageBuffer
,
207 IN OUT UINTN
*UpdatedSize
,
208 IN EFI_PHYSICAL_ADDRESS FlashAddress
,
209 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*FvbProtocol
,
210 IN EFI_HANDLE FvbHandle