]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h
IntelFrameworkModulePkg: Add UpdateDriverDxe driver
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / FirmwareVolume / UpdateDriverDxe / UpdateDriver.h
1 /** @file
2 Common defines and definitions for a component update driver.
3
4 Copyright (c) 2002 - 2010, Intel Corporation. All rights reserved.<BR>
5
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
11
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.
14
15 **/
16
17 #ifndef _EFI_UPDATE_DRIVER_H_
18 #define _EFI_UPDATE_DRIVER_H_
19
20 #include <PiDxe.h>
21
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>
27
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>
40
41 //
42 // {283FA2EE-532C-484d-9383-9F93B36F0B7E}
43 //
44 #define EFI_UPDATE_DATA_FILE_GUID \
45 { 0x283fa2ee, 0x532c, 0x484d, { 0x93, 0x83, 0x9f, 0x93, 0xb3, 0x6f, 0xb, 0x7e } }
46
47 extern EFI_HII_HANDLE gHiiHandle;
48
49 typedef enum {
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;
55
56 typedef struct {
57 UINTN Index;
58 UPDATE_OPERATION_TYPE UpdateType;
59 EFI_DEVICE_PATH_PROTOCOL DevicePath;
60 EFI_PHYSICAL_ADDRESS BaseAddress;
61 EFI_GUID FileGuid;
62 UINTN Length;
63 BOOLEAN FaultTolerant;
64 } UPDATE_CONFIG_DATA;
65
66 typedef struct _SECTION_ITEM SECTION_ITEM;
67 struct _SECTION_ITEM {
68 CHAR8 *ptrSection;
69 UINTN SecNameLen;
70 CHAR8 *ptrEntry;
71 CHAR8 *ptrValue;
72 SECTION_ITEM *ptrNext;
73 };
74
75 typedef struct _COMMENT_LINE COMMENT_LINE;
76 struct _COMMENT_LINE {
77 CHAR8 *ptrComment;
78 COMMENT_LINE *ptrNext;
79 };
80
81 typedef struct {
82 EFI_GUID FileGuid;
83 } UPDATE_PRIVATE_DATA;
84
85 #define MAX_LINE_LENGTH 512
86 #define EFI_D_UPDATE EFI_D_ERROR
87
88 #define MIN_ALIGNMENT_SIZE 4
89 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
90
91 /**
92 Parse Config data file to get the updated data array.
93
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.
98
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.
102
103 **/
104 EFI_STATUS
105 ParseUpdateDataFile (
106 IN UINT8 *DataBuffer,
107 IN UINTN BufferSize,
108 IN OUT UINTN *NumOfUpdates,
109 IN OUT UPDATE_CONFIG_DATA **UpdateArray
110 );
111
112 /**
113 Update the whole FV image, and reinsall FVB protocol for the updated FV image.
114
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.
120
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.
125
126 **/
127 EFI_STATUS
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,
133 IN UINTN ImageSize
134 );
135
136 /**
137 Update certain file in the FV.
138
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
146
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.
151
152 **/
153 EFI_STATUS
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,
159 IN UINTN ImageSize,
160 IN EFI_FV_FILETYPE FileType,
161 IN EFI_FV_FILE_ATTRIBUTES FileAttributes
162 );
163
164 /**
165 Update the buffer into flash area in fault tolerant write method.
166
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.
174
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.
180
181 **/
182 EFI_STATUS
183 FaultTolerantUpdateOnPartFv (
184 IN UINT8 *ImageBuffer,
185 IN UINTN SizeLeft,
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
191 );
192
193 /**
194 Directly update the buffer into flash area without fault tolerant write method.
195
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.
202
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.
206
207 **/
208 EFI_STATUS
209 NonFaultTolerantUpdateOnPartFv (
210 IN UINT8 *ImageBuffer,
211 IN UINTN SizeLeft,
212 IN OUT UINTN *UpdatedSize,
213 IN EFI_PHYSICAL_ADDRESS FlashAddress,
214 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,
215 IN EFI_HANDLE FvbHandle
216 );
217
218 #endif