]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/FirmwareVolume/UpdateDriverDxe/UpdateDriver.h
Clean up the private GUID definition in module Level.
[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 <Guid/CapsuleDataFile.h>
25 #include <Protocol/FaultTolerantWrite.h>
26 #include <Protocol/FirmwareVolumeBlock.h>
27 #include <Protocol/FirmwareVolume2.h>
28
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>
41
42 extern EFI_HII_HANDLE gHiiHandle;
43
44 typedef enum {
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;
50
51 typedef struct {
52 UINTN Index;
53 UPDATE_OPERATION_TYPE UpdateType;
54 EFI_DEVICE_PATH_PROTOCOL DevicePath;
55 EFI_PHYSICAL_ADDRESS BaseAddress;
56 EFI_GUID FileGuid;
57 UINTN Length;
58 BOOLEAN FaultTolerant;
59 } UPDATE_CONFIG_DATA;
60
61 typedef struct _SECTION_ITEM SECTION_ITEM;
62 struct _SECTION_ITEM {
63 CHAR8 *ptrSection;
64 UINTN SecNameLen;
65 CHAR8 *ptrEntry;
66 CHAR8 *ptrValue;
67 SECTION_ITEM *ptrNext;
68 };
69
70 typedef struct _COMMENT_LINE COMMENT_LINE;
71 struct _COMMENT_LINE {
72 CHAR8 *ptrComment;
73 COMMENT_LINE *ptrNext;
74 };
75
76 typedef struct {
77 EFI_GUID FileGuid;
78 } UPDATE_PRIVATE_DATA;
79
80 #define MAX_LINE_LENGTH 512
81 #define EFI_D_UPDATE EFI_D_ERROR
82
83 #define MIN_ALIGNMENT_SIZE 4
84 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
85
86 /**
87 Parse Config data file to get the updated data array.
88
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.
93
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.
97
98 **/
99 EFI_STATUS
100 ParseUpdateDataFile (
101 IN UINT8 *DataBuffer,
102 IN UINTN BufferSize,
103 IN OUT UINTN *NumOfUpdates,
104 IN OUT UPDATE_CONFIG_DATA **UpdateArray
105 );
106
107 /**
108 Update the whole FV image, and reinsall FVB protocol for the updated FV image.
109
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.
115
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.
120
121 **/
122 EFI_STATUS
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,
128 IN UINTN ImageSize
129 );
130
131 /**
132 Update certain file in the FV.
133
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
141
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.
146
147 **/
148 EFI_STATUS
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,
154 IN UINTN ImageSize,
155 IN EFI_FV_FILETYPE FileType,
156 IN EFI_FV_FILE_ATTRIBUTES FileAttributes
157 );
158
159 /**
160 Update the buffer into flash area in fault tolerant write method.
161
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.
169
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.
175
176 **/
177 EFI_STATUS
178 FaultTolerantUpdateOnPartFv (
179 IN UINT8 *ImageBuffer,
180 IN UINTN SizeLeft,
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
186 );
187
188 /**
189 Directly update the buffer into flash area without fault tolerant write method.
190
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.
197
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.
201
202 **/
203 EFI_STATUS
204 NonFaultTolerantUpdateOnPartFv (
205 IN UINT8 *ImageBuffer,
206 IN UINTN SizeLeft,
207 IN OUT UINTN *UpdatedSize,
208 IN EFI_PHYSICAL_ADDRESS FlashAddress,
209 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,
210 IN EFI_HANDLE FvbHandle
211 );
212
213 #endif