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