]>
Commit | Line | Data |
---|---|---|
b2824a8e | 1 | /** @file\r |
2 | Common defines and definitions for a component update driver.\r | |
3 | \r | |
4 | Copyright (c) 2002 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
c0a00b14 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
b2824a8e | 7 | \r |
8 | **/\r | |
9 | \r | |
10 | #ifndef _EFI_UPDATE_DRIVER_H_\r | |
11 | #define _EFI_UPDATE_DRIVER_H_\r | |
12 | \r | |
13 | #include <PiDxe.h>\r | |
14 | \r | |
15 | #include <Protocol/LoadedImage.h>\r | |
16 | #include <Guid/Capsule.h>\r | |
e24fc103 | 17 | #include <Guid/CapsuleDataFile.h>\r |
b2824a8e | 18 | #include <Protocol/FaultTolerantWrite.h>\r |
19 | #include <Protocol/FirmwareVolumeBlock.h>\r | |
20 | #include <Protocol/FirmwareVolume2.h>\r | |
21 | \r | |
22 | #include <Library/BaseLib.h>\r | |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/BaseMemoryLib.h>\r | |
25 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
26 | #include <Library/UefiDriverEntryPoint.h>\r | |
27 | #include <Library/UefiBootServicesTableLib.h>\r | |
28 | #include <Library/UefiLib.h>\r | |
29 | #include <Library/MemoryAllocationLib.h>\r | |
30 | #include <Library/DxeServicesTableLib.h>\r | |
31 | #include <Library/HiiLib.h>\r | |
32 | #include <Library/PrintLib.h>\r | |
33 | #include <Library/DevicePathLib.h>\r | |
34 | \r | |
b2824a8e | 35 | extern EFI_HII_HANDLE gHiiHandle;\r |
36 | \r | |
37 | typedef enum {\r | |
38 | UpdateWholeFV = 0, // 0, update whole FV\r | |
39 | UpdateFvFile, // 1, update a set of FV files asynchronously\r | |
40 | UpdateFvRange, // 2, update part of FV or flash\r | |
41 | UpdateOperationMaximum // 3\r | |
42 | } UPDATE_OPERATION_TYPE;\r | |
43 | \r | |
44 | typedef struct {\r | |
45 | UINTN Index;\r | |
46 | UPDATE_OPERATION_TYPE UpdateType;\r | |
47 | EFI_DEVICE_PATH_PROTOCOL DevicePath;\r | |
48 | EFI_PHYSICAL_ADDRESS BaseAddress;\r | |
49 | EFI_GUID FileGuid;\r | |
50 | UINTN Length;\r | |
51 | BOOLEAN FaultTolerant;\r | |
52 | } UPDATE_CONFIG_DATA;\r | |
53 | \r | |
54 | typedef struct _SECTION_ITEM SECTION_ITEM;\r | |
55 | struct _SECTION_ITEM {\r | |
56 | CHAR8 *ptrSection;\r | |
57 | UINTN SecNameLen;\r | |
58 | CHAR8 *ptrEntry;\r | |
59 | CHAR8 *ptrValue;\r | |
60 | SECTION_ITEM *ptrNext;\r | |
61 | };\r | |
62 | \r | |
63 | typedef struct _COMMENT_LINE COMMENT_LINE;\r | |
64 | struct _COMMENT_LINE {\r | |
65 | CHAR8 *ptrComment;\r | |
66 | COMMENT_LINE *ptrNext;\r | |
67 | };\r | |
68 | \r | |
69 | typedef struct {\r | |
70 | EFI_GUID FileGuid;\r | |
71 | } UPDATE_PRIVATE_DATA;\r | |
72 | \r | |
73 | #define MAX_LINE_LENGTH 512\r | |
74 | #define EFI_D_UPDATE EFI_D_ERROR\r | |
75 | \r | |
76 | #define MIN_ALIGNMENT_SIZE 4\r | |
77 | #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r | |
78 | \r | |
79 | /**\r | |
80 | Parse Config data file to get the updated data array.\r | |
81 | \r | |
82 | @param DataBuffer Config raw file buffer.\r | |
83 | @param BufferSize Size of raw buffer.\r | |
84 | @param NumOfUpdates Pointer to the number of update data.\r | |
85 | @param UpdateArray Pointer to the config of update data.\r | |
86 | \r | |
87 | @retval EFI_NOT_FOUND No config data is found.\r | |
88 | @retval EFI_OUT_OF_RESOURCES No enough memory is allocated.\r | |
89 | @retval EFI_SUCCESS Parse the config file successfully.\r | |
90 | \r | |
91 | **/\r | |
92 | EFI_STATUS\r | |
93 | ParseUpdateDataFile (\r | |
94 | IN UINT8 *DataBuffer,\r | |
95 | IN UINTN BufferSize,\r | |
96 | IN OUT UINTN *NumOfUpdates,\r | |
97 | IN OUT UPDATE_CONFIG_DATA **UpdateArray\r | |
98 | );\r | |
99 | \r | |
100 | /**\r | |
101 | Update the whole FV image, and reinsall FVB protocol for the updated FV image.\r | |
102 | \r | |
103 | @param FvbHandle Handle of FVB protocol for the updated flash range.\r | |
104 | @param FvbProtocol FVB protocol.\r | |
105 | @param ConfigData Config data on updating driver.\r | |
106 | @param ImageBuffer Image buffer to be updated.\r | |
107 | @param ImageSize Image size.\r | |
108 | \r | |
109 | @retval EFI_INVALID_PARAMETER Update type is not UpdateWholeFV.\r | |
110 | Or Image size is not same to the size of whole FV.\r | |
111 | @retval EFI_OUT_OF_RESOURCES No enoug memory is allocated.\r | |
112 | @retval EFI_SUCCESS FV image is updated, and its FVB protocol is reinstalled.\r | |
113 | \r | |
114 | **/\r | |
115 | EFI_STATUS\r | |
116 | PerformUpdateOnWholeFv (\r | |
117 | IN EFI_HANDLE FvbHandle,\r | |
118 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r | |
119 | IN UPDATE_CONFIG_DATA *ConfigData,\r | |
120 | IN UINT8 *ImageBuffer,\r | |
121 | IN UINTN ImageSize\r | |
122 | );\r | |
123 | \r | |
124 | /**\r | |
125 | Update certain file in the FV.\r | |
126 | \r | |
127 | @param FvbHandle Handle of FVB protocol for the updated flash range.\r | |
128 | @param FvbProtocol FVB protocol.\r | |
129 | @param ConfigData Config data on updating driver.\r | |
130 | @param ImageBuffer Image buffer to be updated.\r | |
131 | @param ImageSize Image size.\r | |
132 | @param FileType FFS file type.\r | |
133 | @param FileAttributes FFS file attribute\r | |
134 | \r | |
135 | @retval EFI_INVALID_PARAMETER Update type is not UpdateFvFile.\r | |
136 | Or Image size is not same to the size of whole FV.\r | |
137 | @retval EFI_UNSUPPORTED PEIM FFS is unsupported to be updated.\r | |
138 | @retval EFI_SUCCESS The FFS file is added into FV.\r | |
139 | \r | |
140 | **/\r | |
141 | EFI_STATUS\r | |
142 | PerformUpdateOnFvFile (\r | |
143 | IN EFI_HANDLE FvbHandle,\r | |
144 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r | |
145 | IN UPDATE_CONFIG_DATA *ConfigData,\r | |
146 | IN UINT8 *ImageBuffer,\r | |
147 | IN UINTN ImageSize,\r | |
148 | IN EFI_FV_FILETYPE FileType,\r | |
149 | IN EFI_FV_FILE_ATTRIBUTES FileAttributes\r | |
150 | );\r | |
151 | \r | |
152 | /**\r | |
153 | Update the buffer into flash area in fault tolerant write method.\r | |
154 | \r | |
155 | @param ImageBuffer Image buffer to be updated.\r | |
156 | @param SizeLeft Size of the image buffer.\r | |
157 | @param UpdatedSize Size of the updated buffer.\r | |
158 | @param ConfigData Config data on updating driver.\r | |
159 | @param FlashAddress Flash address to be updated as start address.\r | |
160 | @param FvbProtocol FVB protocol.\r | |
161 | @param FvbHandle Handle of FVB protocol for the updated flash range.\r | |
162 | \r | |
163 | @retval EFI_SUCCESS Buffer data is updated into flash.\r | |
164 | @retval EFI_INVALID_PARAMETER Base flash address is not in FVB flash area.\r | |
165 | @retval EFI_NOT_FOUND FTW protocol doesn't exist.\r | |
166 | @retval EFI_OUT_OF_RESOURCES No enough backup space.\r | |
167 | @retval EFI_ABORTED Error happen when update flash area.\r | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | FaultTolerantUpdateOnPartFv (\r | |
172 | IN UINT8 *ImageBuffer,\r | |
173 | IN UINTN SizeLeft,\r | |
174 | IN OUT UINTN *UpdatedSize,\r | |
175 | IN UPDATE_CONFIG_DATA *ConfigData,\r | |
176 | IN EFI_PHYSICAL_ADDRESS FlashAddress,\r | |
177 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r | |
178 | IN EFI_HANDLE FvbHandle\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | Directly update the buffer into flash area without fault tolerant write method.\r | |
183 | \r | |
184 | @param ImageBuffer Image buffer to be updated.\r | |
185 | @param SizeLeft Size of the image buffer.\r | |
186 | @param UpdatedSize Size of the updated buffer.\r | |
187 | @param FlashAddress Flash address to be updated as start address.\r | |
188 | @param FvbProtocol FVB protocol.\r | |
189 | @param FvbHandle Handle of FVB protocol for the updated flash range.\r | |
190 | \r | |
191 | @retval EFI_SUCCESS Buffer data is updated into flash.\r | |
192 | @retval EFI_INVALID_PARAMETER Base flash address is not in FVB flash area.\r | |
193 | @retval EFI_OUT_OF_RESOURCES No enough backup space.\r | |
194 | \r | |
195 | **/\r | |
196 | EFI_STATUS\r | |
197 | NonFaultTolerantUpdateOnPartFv (\r | |
198 | IN UINT8 *ImageBuffer,\r | |
199 | IN UINTN SizeLeft,\r | |
200 | IN OUT UINTN *UpdatedSize,\r | |
201 | IN EFI_PHYSICAL_ADDRESS FlashAddress,\r | |
202 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol,\r | |
203 | IN EFI_HANDLE FvbHandle\r | |
204 | );\r | |
205 | \r | |
206 | #endif\r |