]> git.proxmox.com Git - mirror_edk2.git/blame - SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
SignedCapsulePkg Universal: Init local variables before using them
[mirror_edk2.git] / SignedCapsulePkg / Universal / SystemFirmwareUpdate / SystemFirmwareUpdateDxe.c
CommitLineData
f6f91d38
JY
1/** @file\r
2 SetImage instance to update system firmware.\r
3\r
4 Caution: This module requires additional review when modified.\r
5 This module will have external input - capsule image.\r
6 This external input must be validated carefully to avoid security issue like\r
7 buffer overflow, integer overflow.\r
8\r
9 FmpSetImage() will receive untrusted input and do basic validation.\r
10\r
11 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
12 This program and the accompanying materials\r
13 are licensed and made available under the terms and conditions of the BSD License\r
14 which accompanies this distribution. The full text of the license may be found at\r
15 http://opensource.org/licenses/bsd-license.php\r
16\r
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
19\r
20**/\r
21\r
22#include "SystemFirmwareDxe.h"\r
23\r
24//\r
25// SystemFmp driver private data\r
26//\r
27SYSTEM_FMP_PRIVATE_DATA *mSystemFmpPrivate = NULL;\r
28\r
29EFI_GUID mCurrentImageTypeId;\r
30\r
31BOOLEAN mNvRamUpdated = FALSE;\r
32\r
33/**\r
34 Parse Config data file to get the updated data array.\r
35\r
36 @param[in] DataBuffer Config raw file buffer.\r
37 @param[in] BufferSize Size of raw buffer.\r
38 @param[in, out] ConfigHeader Pointer to the config header.\r
39 @param[in, out] UpdateArray Pointer to the config of update data.\r
40\r
41 @retval EFI_NOT_FOUND No config data is found.\r
42 @retval EFI_OUT_OF_RESOURCES No enough memory is allocated.\r
43 @retval EFI_SUCCESS Parse the config file successfully.\r
44\r
45**/\r
46EFI_STATUS\r
47ParseUpdateDataFile (\r
48 IN UINT8 *DataBuffer,\r
49 IN UINTN BufferSize,\r
50 IN OUT CONFIG_HEADER *ConfigHeader,\r
51 IN OUT UPDATE_CONFIG_DATA **UpdateArray\r
52 );\r
53\r
54/**\r
55 Update System Firmware image component.\r
56\r
57 @param[in] SystemFirmwareImage Points to the System Firmware image.\r
58 @param[in] SystemFirmwareImageSize The length of the System Firmware image in bytes.\r
59 @param[in] ConfigData Points to the component configuration structure.\r
60 @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
61 @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
62\r
63 @retval EFI_SUCCESS The System Firmware image is updated.\r
64 @retval EFI_WRITE_PROTECTED The flash device is read only.\r
65**/\r
66EFI_STATUS\r
67PerformUpdate (\r
68 IN VOID *SystemFirmwareImage,\r
69 IN UINTN SystemFirmwareImageSize,\r
70 IN UPDATE_CONFIG_DATA *ConfigData,\r
71 OUT UINT32 *LastAttemptVersion,\r
72 OUT UINT32 *LastAttemptStatus\r
73 )\r
74{\r
75 EFI_STATUS Status;\r
76\r
77 DEBUG((DEBUG_INFO, "PlatformUpdate:"));\r
78 DEBUG((DEBUG_INFO, " BaseAddress - 0x%lx,", ConfigData->BaseAddress));\r
79 DEBUG((DEBUG_INFO, " ImageOffset - 0x%x,", ConfigData->ImageOffset));\r
80 DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ConfigData->Length));\r
81 Status = PerformFlashWrite (\r
82 ConfigData->FirmwareType,\r
83 ConfigData->BaseAddress,\r
84 ConfigData->AddressType,\r
85 (VOID *)((UINTN)SystemFirmwareImage + (UINTN)ConfigData->ImageOffset),\r
86 ConfigData->Length\r
87 );\r
88 if (!EFI_ERROR(Status)) {\r
89 *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;\r
90 if (ConfigData->FirmwareType == PlatformFirmwareTypeNvRam) {\r
91 mNvRamUpdated = TRUE;\r
92 }\r
93 } else {\r
94 *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
95 }\r
96 return Status;\r
97}\r
98\r
99/**\r
100 Update System Firmware image.\r
101\r
102 @param[in] SystemFirmwareImage Points to the System Firmware image.\r
103 @param[in] SystemFirmwareImageSize The length of the System Firmware image in bytes.\r
104 @param[in] ConfigImage Points to the config file image.\r
105 @param[in] ConfigImageSize The length of the config file image in bytes.\r
106 @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
107 @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
108\r
109 @retval EFI_SUCCESS The System Firmware image is updated.\r
110 @retval EFI_WRITE_PROTECTED The flash device is read only.\r
111**/\r
112EFI_STATUS\r
113UpdateImage (\r
114 IN VOID *SystemFirmwareImage,\r
115 IN UINTN SystemFirmwareImageSize,\r
116 IN VOID *ConfigImage,\r
117 IN UINTN ConfigImageSize,\r
118 OUT UINT32 *LastAttemptVersion,\r
119 OUT UINT32 *LastAttemptStatus\r
120 )\r
121{\r
122 EFI_STATUS Status;\r
123 UPDATE_CONFIG_DATA *ConfigData;\r
124 UPDATE_CONFIG_DATA *UpdateConfigData;\r
125 CONFIG_HEADER ConfigHeader;\r
126 UINTN Index;\r
127\r
128 if (ConfigImage == NULL) {\r
129 DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):"));\r
130 DEBUG((DEBUG_INFO, " BaseAddress - 0x%x,", 0));\r
131 DEBUG((DEBUG_INFO, " Length - 0x%x\n", SystemFirmwareImageSize));\r
132 // ASSUME the whole System Firmware include NVRAM region.\r
133 Status = PerformFlashWrite (\r
134 PlatformFirmwareTypeNvRam,\r
135 0,\r
136 FlashAddressTypeRelativeAddress,\r
137 SystemFirmwareImage,\r
138 SystemFirmwareImageSize\r
139 );\r
140 if (!EFI_ERROR(Status)) {\r
141 *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;\r
142 mNvRamUpdated = TRUE;\r
143 } else {\r
144 *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
145 }\r
146 return Status;\r
147 }\r
148\r
149 DEBUG((DEBUG_INFO, "PlatformUpdate (With Config):\n"));\r
150 ConfigData = NULL;\r
151 ZeroMem (&ConfigHeader, sizeof(ConfigHeader));\r
152 Status = ParseUpdateDataFile (\r
153 ConfigImage,\r
154 ConfigImageSize,\r
155 &ConfigHeader,\r
156 &ConfigData\r
157 );\r
158 DEBUG((DEBUG_INFO, "ParseUpdateDataFile - %r\n", Status));\r
159 if (EFI_ERROR(Status)) {\r
160 *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
161 return EFI_INVALID_PARAMETER;\r
162 }\r
163 DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));\r
164 DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));\r
165\r
166 Index = 0;\r
167 UpdateConfigData = ConfigData;\r
168 while (Index < ConfigHeader.NumOfUpdates) {\r
169 if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {\r
170 DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));\r
171 Status = PerformUpdate (\r
172 SystemFirmwareImage,\r
173 SystemFirmwareImageSize,\r
174 UpdateConfigData,\r
175 LastAttemptVersion,\r
176 LastAttemptStatus\r
177 );\r
178 //\r
179 // Shall updates be serialized so that if an update is not successfully completed,\r
180 // the remaining updates won't be performed.\r
181 //\r
182 if (EFI_ERROR (Status)) {\r
183 break;\r
184 }\r
185 } else {\r
186 DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));\r
187 }\r
188\r
189 Index++;\r
190 UpdateConfigData++;\r
191 }\r
192\r
193 return Status;\r
194}\r
195\r
196/**\r
197 Authenticate and update System Firmware image.\r
198\r
199 Caution: This function may receive untrusted input.\r
200\r
201 @param[in] Image The EDKII system FMP capsule image.\r
202 @param[in] ImageSize The size of the EDKII system FMP capsule image in bytes.\r
203 @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
204 @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
205\r
206 @retval EFI_SUCCESS EDKII system FMP capsule passes authentication and the System Firmware image is updated.\r
207 @retval EFI_SECURITY_VIOLATION EDKII system FMP capsule fails authentication and the System Firmware image is not updated.\r
208 @retval EFI_WRITE_PROTECTED The flash device is read only.\r
209**/\r
210EFI_STATUS\r
211SystemFirmwareAuthenticatedUpdate (\r
212 IN VOID *Image,\r
213 IN UINTN ImageSize,\r
214 OUT UINT32 *LastAttemptVersion,\r
215 OUT UINT32 *LastAttemptStatus\r
216 )\r
217{\r
218 EFI_STATUS Status;\r
219 VOID *SystemFirmwareImage;\r
220 UINTN SystemFirmwareImageSize;\r
221 VOID *ConfigImage;\r
222 UINTN ConfigImageSize;\r
223 VOID *AuthenticatedImage;\r
224 UINTN AuthenticatedImageSize;\r
225\r
8b66342c
HW
226 AuthenticatedImage = NULL;\r
227 AuthenticatedImageSize = 0;\r
228\r
f6f91d38
JY
229 DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticatedUpdate...\n"));\r
230\r
231 Status = CapsuleAuthenticateSystemFirmware(Image, ImageSize, FALSE, LastAttemptVersion, LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);\r
232 if (EFI_ERROR(Status)) {\r
233 DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticateImage - %r\n", Status));\r
234 return Status;\r
235 }\r
236\r
237 DEBUG((DEBUG_INFO, "ExtractSystemFirmwareImage ...\n"));\r
238 ExtractSystemFirmwareImage(AuthenticatedImage, AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);\r
239 DEBUG((DEBUG_INFO, "ExtractConfigImage ...\n"));\r
240 ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);\r
241\r
242 DEBUG((DEBUG_INFO, "UpdateImage ...\n"));\r
243 Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus);\r
244 if (EFI_ERROR(Status)) {\r
245 DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status));\r
246 return Status;\r
247 }\r
248\r
249 DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticatedUpdate Done\n"));\r
250\r
251 return EFI_SUCCESS;\r
252}\r
253\r
254/**\r
255\r
256 This code finds variable in storage blocks (Volatile or Non-Volatile).\r
257\r
258 @param[in] VariableName Name of Variable to be found.\r
259 @param[in] VendorGuid Variable vendor GUID.\r
260 @param[out] Attributes Attribute value of the variable found.\r
261 @param[in, out] DataSize Size of Data found. If size is less than the\r
262 data, this value contains the required size.\r
263 @param[out] Data Data pointer.\r
264\r
265 @return EFI_INVALID_PARAMETER Invalid parameter.\r
266 @return EFI_SUCCESS Find the specified variable.\r
267 @return EFI_NOT_FOUND Not found.\r
268 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r
269\r
270**/\r
271EFI_STATUS\r
272EFIAPI\r
273GetVariableHook (\r
274 IN CHAR16 *VariableName,\r
275 IN EFI_GUID *VendorGuid,\r
276 OUT UINT32 *Attributes OPTIONAL,\r
277 IN OUT UINTN *DataSize,\r
278 OUT VOID *Data\r
279 )\r
280{\r
281 DEBUG((DEBUG_INFO, "GetVariableHook - %S, %g\n", VariableName, VendorGuid));\r
282 return EFI_NOT_AVAILABLE_YET;\r
283}\r
284\r
285/**\r
286\r
287 This code Finds the Next available variable.\r
288\r
289 @param[in, out] VariableNameSize Size of the variable name.\r
290 @param[in, out] VariableName Pointer to variable name.\r
291 @param[in, out] VendorGuid Variable Vendor Guid.\r
292\r
293 @return EFI_INVALID_PARAMETER Invalid parameter.\r
294 @return EFI_SUCCESS Find the specified variable.\r
295 @return EFI_NOT_FOUND Not found.\r
296 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r
297\r
298**/\r
299EFI_STATUS\r
300EFIAPI\r
301GetNextVariableNameHook (\r
302 IN OUT UINTN *VariableNameSize,\r
303 IN OUT CHAR16 *VariableName,\r
304 IN OUT EFI_GUID *VendorGuid\r
305 )\r
306{\r
307 DEBUG((DEBUG_INFO, "GetNextVariableNameHook - %S, %g\n", VariableName, VendorGuid));\r
308 return EFI_NOT_AVAILABLE_YET;\r
309}\r
310\r
311/**\r
312\r
313 This code sets variable in storage blocks (Volatile or Non-Volatile).\r
314\r
315 @param[in] VariableName Name of Variable to be found.\r
316 @param[in] VendorGuid Variable vendor GUID.\r
317 @param[in] Attributes Attribute value of the variable found\r
318 @param[in] DataSize Size of Data found. If size is less than the\r
319 data, this value contains the required size.\r
320 @param[in] Data Data pointer.\r
321\r
322 @return EFI_INVALID_PARAMETER Invalid parameter.\r
323 @return EFI_SUCCESS Set successfully.\r
324 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.\r
325 @return EFI_NOT_FOUND Not found.\r
326 @return EFI_WRITE_PROTECTED Variable is read-only.\r
327\r
328**/\r
329EFI_STATUS\r
330EFIAPI\r
331SetVariableHook (\r
332 IN CHAR16 *VariableName,\r
333 IN EFI_GUID *VendorGuid,\r
334 IN UINT32 Attributes,\r
335 IN UINTN DataSize,\r
336 IN VOID *Data\r
337 )\r
338{\r
339 DEBUG((DEBUG_INFO, "SetVariableHook - %S, %g, 0x%x (0x%x)\n", VariableName, VendorGuid, Attributes, DataSize));\r
340 return EFI_NOT_AVAILABLE_YET;\r
341}\r
342\r
343/**\r
344\r
345 This code returns information about the EFI variables.\r
346\r
347 @param[in] Attributes Attributes bitmask to specify the type of variables\r
348 on which to return information.\r
349 @param[out] MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r
350 for the EFI variables associated with the attributes specified.\r
351 @param[out] RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r
352 for EFI variables associated with the attributes specified.\r
353 @param[out] MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r
354 associated with the attributes specified.\r
355\r
356 @return EFI_SUCCESS Query successfully.\r
357\r
358**/\r
359EFI_STATUS\r
360EFIAPI\r
361QueryVariableInfoHook (\r
362 IN UINT32 Attributes,\r
363 OUT UINT64 *MaximumVariableStorageSize,\r
364 OUT UINT64 *RemainingVariableStorageSize,\r
365 OUT UINT64 *MaximumVariableSize\r
366 )\r
367{\r
368 DEBUG((DEBUG_INFO, "QueryVariableInfoHook - 0x%x\n", Attributes));\r
369 return EFI_NOT_AVAILABLE_YET;\r
370}\r
371\r
372/**\r
373 Updates the firmware image of the device.\r
374\r
375 This function updates the hardware with the new firmware image.\r
376 This function returns EFI_UNSUPPORTED if the firmware image is not updatable.\r
377 If the firmware image is updatable, the function should perform the following minimal validations\r
378 before proceeding to do the firmware image update.\r
379 - Validate the image authentication if image has attribute\r
380 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns\r
381 EFI_SECURITY_VIOLATION if the validation fails.\r
382 - Validate the image is a supported image for this device. The function returns EFI_ABORTED if\r
383 the image is unsupported. The function can optionally provide more detailed information on\r
384 why the image is not a supported image.\r
385 - Validate the data from VendorCode if not null. Image validation must be performed before\r
386 VendorCode data validation. VendorCode data is ignored or considered invalid if image\r
387 validation failed. The function returns EFI_ABORTED if the data is invalid.\r
388\r
389 VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if\r
390 the caller did not specify the policy or use the default policy. As an example, vendor can implement\r
391 a policy to allow an option to force a firmware image update when the abort reason is due to the new\r
392 firmware image version is older than the current firmware image version or bad image checksum.\r
393 Sensitive operations such as those wiping the entire firmware image and render the device to be\r
394 non-functional should be encoded in the image itself rather than passed with the VendorCode.\r
395 AbortReason enables vendor to have the option to provide a more detailed description of the abort\r
396 reason to the caller.\r
397\r
398 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.\r
399 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.\r
400 The number is between 1 and DescriptorCount.\r
401 @param[in] Image Points to the new image.\r
402 @param[in] ImageSize Size of the new image in bytes.\r
403 @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy.\r
404 Null indicates the caller did not specify the policy or use the default policy.\r
405 @param[in] Progress A function used by the driver to report the progress of the firmware update.\r
406 @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more\r
407 details for the aborted operation. The buffer is allocated by this function\r
408 with AllocatePool(), and it is the caller's responsibility to free it with a\r
409 call to FreePool().\r
410\r
411 @retval EFI_SUCCESS The device was successfully updated with the new image.\r
412 @retval EFI_ABORTED The operation is aborted.\r
413 @retval EFI_INVALID_PARAMETER The Image was NULL.\r
414 @retval EFI_UNSUPPORTED The operation is not supported.\r
415 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.\r
416\r
417**/\r
418EFI_STATUS\r
419EFIAPI\r
420FmpSetImage (\r
421 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,\r
422 IN UINT8 ImageIndex,\r
423 IN CONST VOID *Image,\r
424 IN UINTN ImageSize,\r
425 IN CONST VOID *VendorCode,\r
426 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,\r
427 OUT CHAR16 **AbortReason\r
428 )\r
429{\r
430 EFI_STATUS Status;\r
431 EFI_STATUS VarStatus;\r
432 SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;\r
433\r
434 if (Image == NULL || ImageSize == 0 || AbortReason == NULL) {\r
435 return EFI_INVALID_PARAMETER;\r
436 }\r
437\r
438 SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP(This);\r
439 *AbortReason = NULL;\r
440\r
441 if (ImageIndex == 0 || ImageIndex > SystemFmpPrivate->DescriptorCount) {\r
442 return EFI_INVALID_PARAMETER;\r
443 }\r
444\r
445 Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);\r
446 DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));\r
447\r
448 //\r
449 // If NVRAM is updated, we should no longer touch variable services, because\r
450 // the current variable driver may not manage the new NVRAM region.\r
451 //\r
452 if (mNvRamUpdated) {\r
453 DEBUG ((DEBUG_INFO, "NvRamUpdated, Update Variable Serivces\n"));\r
454 gRT->GetVariable = GetVariableHook;\r
455 gRT->GetNextVariableName = GetNextVariableNameHook;\r
456 gRT->SetVariable = SetVariableHook;\r
457 gRT->QueryVariableInfo = QueryVariableInfoHook;\r
458\r
459 gRT->Hdr.CRC32 = 0;\r
460 gBS->CalculateCrc32 (\r
461 (UINT8 *) &gRT->Hdr,\r
462 gRT->Hdr.HeaderSize,\r
463 &gRT->Hdr.CRC32\r
464 );\r
465 }\r
466\r
467 VarStatus = gRT->SetVariable(\r
468 SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,\r
469 &gSystemFmpLastAttemptVariableGuid,\r
470 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
471 sizeof(SystemFmpPrivate->LastAttempt),\r
472 &SystemFmpPrivate->LastAttempt\r
473 );\r
474 DEBUG((DEBUG_INFO, "SetLastAttemp - %r\n", VarStatus));\r
475\r
476 return Status;\r
477}\r
478\r
479/**\r
480 System FMP module entrypoint\r
481\r
482 @param ImageHandle The firmware allocated handle for the EFI image.\r
483 @param SystemTable A pointer to the EFI System Table.\r
484\r
485 @return EFI_SUCCESS System FMP module is initialized.\r
486**/\r
487EFI_STATUS\r
488EFIAPI\r
489SystemFirmwareUpdateMainDxe (\r
490 IN EFI_HANDLE ImageHandle,\r
491 IN EFI_SYSTEM_TABLE *SystemTable\r
492 )\r
493{\r
494 EFI_STATUS Status;\r
495\r
496 //\r
497 // Initialize SystemFmpPrivateData\r
498 //\r
499 mSystemFmpPrivate = AllocateZeroPool (sizeof(SYSTEM_FMP_PRIVATE_DATA));\r
500 if (mSystemFmpPrivate == NULL) {\r
501 return EFI_OUT_OF_RESOURCES;\r
502 }\r
503\r
504 Status = InitializePrivateData(mSystemFmpPrivate);\r
505 if (EFI_ERROR(Status)) {\r
506 FreePool(mSystemFmpPrivate);\r
507 mSystemFmpPrivate = NULL;\r
508 return Status;\r
509 }\r
510\r
511 //\r
512 // Install FMP protocol.\r
513 //\r
514 Status = gBS->InstallMultipleProtocolInterfaces (\r
515 &mSystemFmpPrivate->Handle,\r
516 &gEfiFirmwareManagementProtocolGuid,\r
517 &mSystemFmpPrivate->Fmp,\r
518 &gSystemFmpProtocolGuid,\r
519 &mSystemFmpPrivate->Fmp,\r
520 NULL\r
521 );\r
522 if (EFI_ERROR (Status)) {\r
523 FreePool(mSystemFmpPrivate);\r
524 mSystemFmpPrivate = NULL;\r
525 return Status;\r
526 }\r
527\r
528 return Status;\r
529}\r