]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeFmp.c
IntelFrameworkModulePkg KbDxe: Execute key notify func at TPL_CALLBACK
[mirror_edk2.git] / UefiCpuPkg / Feature / Capsule / MicrocodeUpdateDxe / MicrocodeFmp.c
1 /** @file
2 Produce FMP instance for Microcode.
3
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "MicrocodeUpdate.h"
16
17 //
18 // MicrocodeFmp driver private data
19 //
20 MICROCODE_FMP_PRIVATE_DATA *mMicrocodeFmpPrivate = NULL;
21
22 EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = {
23 FmpGetImageInfo,
24 FmpGetImage,
25 FmpSetImage,
26 FmpCheckImage,
27 FmpGetPackageInfo,
28 FmpSetPackageInfo
29 };
30
31 /**
32 Initialize Microcode Descriptor.
33
34 @param[in] MicrocodeFmpPrivate private data structure to be initialized.
35
36 @return EFI_SUCCESS Microcode Descriptor is initialized.
37 **/
38 EFI_STATUS
39 InitializeMicrocodeDescriptor (
40 IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate
41 );
42
43 /**
44 Returns information about the current firmware image(s) of the device.
45
46 This function allows a copy of the current firmware image to be created and saved.
47 The saved copy could later been used, for example, in firmware image recovery or rollback.
48
49 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
50 @param[in, out] ImageInfoSize A pointer to the size, in bytes, of the ImageInfo buffer.
51 On input, this is the size of the buffer allocated by the caller.
52 On output, it is the size of the buffer returned by the firmware
53 if the buffer was large enough, or the size of the buffer needed
54 to contain the image(s) information if the buffer was too small.
55 @param[in, out] ImageInfo A pointer to the buffer in which firmware places the current image(s)
56 information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
57 @param[out] DescriptorVersion A pointer to the location in which firmware returns the version number
58 associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR.
59 @param[out] DescriptorCount A pointer to the location in which firmware returns the number of
60 descriptors or firmware images within this device.
61 @param[out] DescriptorSize A pointer to the location in which firmware returns the size, in bytes,
62 of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR.
63 @param[out] PackageVersion A version number that represents all the firmware images in the device.
64 The format is vendor specific and new version must have a greater value
65 than the old version. If PackageVersion is not supported, the value is
66 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison
67 is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates
68 that package version update is in progress.
69 @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing the
70 package version name. The buffer is allocated by this function with
71 AllocatePool(), and it is the caller's responsibility to free it with a call
72 to FreePool().
73
74 @retval EFI_SUCCESS The device was successfully updated with the new image.
75 @retval EFI_BUFFER_TOO_SMALL The ImageInfo buffer was too small. The current buffer size
76 needed to hold the image(s) information is returned in ImageInfoSize.
77 @retval EFI_INVALID_PARAMETER ImageInfoSize is NULL.
78 @retval EFI_DEVICE_ERROR Valid information could not be returned. Possible corrupted image.
79
80 **/
81 EFI_STATUS
82 EFIAPI
83 FmpGetImageInfo (
84 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
85 IN OUT UINTN *ImageInfoSize,
86 IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
87 OUT UINT32 *DescriptorVersion,
88 OUT UINT8 *DescriptorCount,
89 OUT UINTN *DescriptorSize,
90 OUT UINT32 *PackageVersion,
91 OUT CHAR16 **PackageVersionName
92 )
93 {
94 MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate;
95 UINTN Index;
96
97 MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This);
98
99 if(ImageInfoSize == NULL) {
100 return EFI_INVALID_PARAMETER;
101 }
102
103 if (*ImageInfoSize < sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount) {
104 *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount;
105 return EFI_BUFFER_TOO_SMALL;
106 }
107
108 if (ImageInfo == NULL ||
109 DescriptorVersion == NULL ||
110 DescriptorCount == NULL ||
111 DescriptorSize == NULL ||
112 PackageVersion == NULL ||
113 PackageVersionName == NULL) {
114 return EFI_INVALID_PARAMETER;
115 }
116
117 *ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount;
118 *DescriptorSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR);
119 *DescriptorCount = MicrocodeFmpPrivate->DescriptorCount;
120 *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
121
122 //
123 // supports 1 ImageInfo descriptor
124 //
125 CopyMem(&ImageInfo[0], MicrocodeFmpPrivate->ImageDescriptor, sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * MicrocodeFmpPrivate->DescriptorCount);
126 for (Index = 0; Index < MicrocodeFmpPrivate->DescriptorCount; Index++) {
127 if ((ImageInfo[Index].AttributesSetting & IMAGE_ATTRIBUTE_IN_USE) != 0) {
128 ImageInfo[Index].LastAttemptVersion = MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion;
129 ImageInfo[Index].LastAttemptStatus = MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus;
130 }
131 }
132
133 //
134 // package version
135 //
136 *PackageVersion = MicrocodeFmpPrivate->PackageVersion;
137 if (MicrocodeFmpPrivate->PackageVersionName != NULL) {
138 *PackageVersionName = AllocateCopyPool(StrSize(MicrocodeFmpPrivate->PackageVersionName), MicrocodeFmpPrivate->PackageVersionName);
139 }
140
141 return EFI_SUCCESS;
142 }
143
144 /**
145 Retrieves a copy of the current firmware image of the device.
146
147 This function allows a copy of the current firmware image to be created and saved.
148 The saved copy could later been used, for example, in firmware image recovery or rollback.
149
150 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
151 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.
152 The number is between 1 and DescriptorCount.
153 @param[in,out] Image Points to the buffer where the current image is copied to.
154 @param[in,out] ImageSize On entry, points to the size of the buffer pointed to by Image, in bytes.
155 On return, points to the length of the image, in bytes.
156
157 @retval EFI_SUCCESS The device was successfully updated with the new image.
158 @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to hold the
159 image. The current buffer size needed to hold the image is returned
160 in ImageSize.
161 @retval EFI_INVALID_PARAMETER The Image was NULL.
162 @retval EFI_NOT_FOUND The current image is not copied to the buffer.
163 @retval EFI_UNSUPPORTED The operation is not supported.
164 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
165
166 **/
167 EFI_STATUS
168 EFIAPI
169 FmpGetImage (
170 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
171 IN UINT8 ImageIndex,
172 IN OUT VOID *Image,
173 IN OUT UINTN *ImageSize
174 )
175 {
176 MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate;
177 EFI_STATUS Status;
178
179 if (Image == NULL || ImageSize == NULL) {
180 return EFI_INVALID_PARAMETER;
181 }
182
183 MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This);
184
185 if (ImageIndex == 0 || ImageIndex > MicrocodeFmpPrivate->DescriptorCount || ImageSize == NULL || Image == NULL) {
186 return EFI_INVALID_PARAMETER;
187 }
188
189 Status = MicrocodeRead(ImageIndex, (VOID *)Image, ImageSize);
190 return Status;
191 }
192
193 /**
194 Updates the firmware image of the device.
195
196 This function updates the hardware with the new firmware image.
197 This function returns EFI_UNSUPPORTED if the firmware image is not updatable.
198 If the firmware image is updatable, the function should perform the following minimal validations
199 before proceeding to do the firmware image update.
200 - Validate the image authentication if image has attribute
201 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns
202 EFI_SECURITY_VIOLATION if the validation fails.
203 - Validate the image is a supported image for this device. The function returns EFI_ABORTED if
204 the image is unsupported. The function can optionally provide more detailed information on
205 why the image is not a supported image.
206 - Validate the data from VendorCode if not null. Image validation must be performed before
207 VendorCode data validation. VendorCode data is ignored or considered invalid if image
208 validation failed. The function returns EFI_ABORTED if the data is invalid.
209
210 VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if
211 the caller did not specify the policy or use the default policy. As an example, vendor can implement
212 a policy to allow an option to force a firmware image update when the abort reason is due to the new
213 firmware image version is older than the current firmware image version or bad image checksum.
214 Sensitive operations such as those wiping the entire firmware image and render the device to be
215 non-functional should be encoded in the image itself rather than passed with the VendorCode.
216 AbortReason enables vendor to have the option to provide a more detailed description of the abort
217 reason to the caller.
218
219 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
220 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.
221 The number is between 1 and DescriptorCount.
222 @param[in] Image Points to the new image.
223 @param[in] ImageSize Size of the new image in bytes.
224 @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy.
225 Null indicates the caller did not specify the policy or use the default policy.
226 @param[in] Progress A function used by the driver to report the progress of the firmware update.
227 @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more
228 details for the aborted operation. The buffer is allocated by this function
229 with AllocatePool(), and it is the caller's responsibility to free it with a
230 call to FreePool().
231
232 @retval EFI_SUCCESS The device was successfully updated with the new image.
233 @retval EFI_ABORTED The operation is aborted.
234 @retval EFI_INVALID_PARAMETER The Image was NULL.
235 @retval EFI_UNSUPPORTED The operation is not supported.
236 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
237
238 **/
239 EFI_STATUS
240 EFIAPI
241 FmpSetImage (
242 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
243 IN UINT8 ImageIndex,
244 IN CONST VOID *Image,
245 IN UINTN ImageSize,
246 IN CONST VOID *VendorCode,
247 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
248 OUT CHAR16 **AbortReason
249 )
250 {
251 EFI_STATUS Status;
252 EFI_STATUS VarStatus;
253 MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate;
254
255 if (Image == NULL || AbortReason == NULL) {
256 return EFI_INVALID_PARAMETER;
257 }
258
259 MicrocodeFmpPrivate = MICROCODE_FMP_PRIVATE_DATA_FROM_FMP(This);
260 *AbortReason = NULL;
261
262 if (ImageIndex == 0 || ImageIndex > MicrocodeFmpPrivate->DescriptorCount || Image == NULL) {
263 return EFI_INVALID_PARAMETER;
264 }
265
266 Status = MicrocodeWrite(ImageIndex, (VOID *)Image, ImageSize, &MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, &MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus, AbortReason);
267 DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus));
268 VarStatus = gRT->SetVariable(
269 MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME,
270 &gEfiCallerIdGuid,
271 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
272 sizeof(MicrocodeFmpPrivate->LastAttempt),
273 &MicrocodeFmpPrivate->LastAttempt
274 );
275 DEBUG((DEBUG_INFO, "SetLastAttemp - %r\n", VarStatus));
276
277 if (!EFI_ERROR(Status)) {
278 InitializeMicrocodeDescriptor(MicrocodeFmpPrivate);
279 }
280
281 return Status;
282 }
283
284 /**
285 Checks if the firmware image is valid for the device.
286
287 This function allows firmware update application to validate the firmware image without
288 invoking the SetImage() first.
289
290 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
291 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.
292 The number is between 1 and DescriptorCount.
293 @param[in] Image Points to the new image.
294 @param[in] ImageSize Size of the new image in bytes.
295 @param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides,
296 if available, additional information if the image is invalid.
297
298 @retval EFI_SUCCESS The image was successfully checked.
299 @retval EFI_INVALID_PARAMETER The Image was NULL.
300 @retval EFI_UNSUPPORTED The operation is not supported.
301 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
302
303 **/
304 EFI_STATUS
305 EFIAPI
306 FmpCheckImage (
307 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
308 IN UINT8 ImageIndex,
309 IN CONST VOID *Image,
310 IN UINTN ImageSize,
311 OUT UINT32 *ImageUpdatable
312 )
313 {
314 return EFI_UNSUPPORTED;
315 }
316
317 /**
318 Returns information about the firmware package.
319
320 This function returns package information.
321
322 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
323 @param[out] PackageVersion A version number that represents all the firmware images in the device.
324 The format is vendor specific and new version must have a greater value
325 than the old version. If PackageVersion is not supported, the value is
326 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version
327 comparison is to be performed using PackageVersionName. A value of
328 0xFFFFFFFD indicates that package version update is in progress.
329 @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing
330 the package version name. The buffer is allocated by this function with
331 AllocatePool(), and it is the caller's responsibility to free it with a
332 call to FreePool().
333 @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of
334 package version name. A value of 0 indicates the device does not support
335 update of package version name. Length is the number of Unicode characters,
336 including the terminating null character.
337 @param[out] AttributesSupported Package attributes that are supported by this device. See 'Package Attribute
338 Definitions' for possible returned values of this parameter. A value of 1
339 indicates the attribute is supported and the current setting value is
340 indicated in AttributesSetting. A value of 0 indicates the attribute is not
341 supported and the current setting value in AttributesSetting is meaningless.
342 @param[out] AttributesSetting Package attributes. See 'Package Attribute Definitions' for possible returned
343 values of this parameter
344
345 @retval EFI_SUCCESS The package information was successfully returned.
346 @retval EFI_UNSUPPORTED The operation is not supported.
347
348 **/
349 EFI_STATUS
350 EFIAPI
351 FmpGetPackageInfo (
352 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
353 OUT UINT32 *PackageVersion,
354 OUT CHAR16 **PackageVersionName,
355 OUT UINT32 *PackageVersionNameMaxLen,
356 OUT UINT64 *AttributesSupported,
357 OUT UINT64 *AttributesSetting
358 )
359 {
360 return EFI_UNSUPPORTED;
361 }
362
363 /**
364 Updates information about the firmware package.
365
366 This function updates package information.
367 This function returns EFI_UNSUPPORTED if the package information is not updatable.
368 VendorCode enables vendor to implement vendor-specific package information update policy.
369 Null if the caller did not specify this policy or use the default policy.
370
371 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
372 @param[in] Image Points to the authentication image.
373 Null if authentication is not required.
374 @param[in] ImageSize Size of the authentication image in bytes.
375 0 if authentication is not required.
376 @param[in] VendorCode This enables vendor to implement vendor-specific firmware
377 image update policy.
378 Null indicates the caller did not specify this policy or use
379 the default policy.
380 @param[in] PackageVersion The new package version.
381 @param[in] PackageVersionName A pointer to the new null-terminated Unicode string representing
382 the package version name.
383 The string length is equal to or less than the value returned in
384 PackageVersionNameMaxLen.
385
386 @retval EFI_SUCCESS The device was successfully updated with the new package
387 information.
388 @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value
389 returned in PackageVersionNameMaxLen.
390 @retval EFI_UNSUPPORTED The operation is not supported.
391 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
392
393 **/
394 EFI_STATUS
395 EFIAPI
396 FmpSetPackageInfo (
397 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
398 IN CONST VOID *Image,
399 IN UINTN ImageSize,
400 IN CONST VOID *VendorCode,
401 IN UINT32 PackageVersion,
402 IN CONST CHAR16 *PackageVersionName
403 )
404 {
405 return EFI_UNSUPPORTED;
406 }
407
408 /**
409 Initialize Microcode Descriptor.
410
411 @param[in] MicrocodeFmpPrivate private data structure to be initialized.
412
413 @return EFI_SUCCESS Microcode Descriptor is initialized.
414 **/
415 EFI_STATUS
416 InitializeMicrocodeDescriptor (
417 IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate
418 )
419 {
420 UINT8 CurrentMicrocodeCount;
421
422 CurrentMicrocodeCount = (UINT8)GetMicrocodeInfo(NULL, 0);
423
424 if (CurrentMicrocodeCount > MicrocodeFmpPrivate->DescriptorCount) {
425 if (MicrocodeFmpPrivate->ImageDescriptor != NULL) {
426 FreePool(MicrocodeFmpPrivate->ImageDescriptor);
427 MicrocodeFmpPrivate->ImageDescriptor = NULL;
428 }
429 } else {
430 ZeroMem(MicrocodeFmpPrivate->ImageDescriptor, MicrocodeFmpPrivate->DescriptorCount * sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR));
431 }
432
433 MicrocodeFmpPrivate->DescriptorCount = CurrentMicrocodeCount;
434
435 if (MicrocodeFmpPrivate->ImageDescriptor == NULL) {
436 MicrocodeFmpPrivate->ImageDescriptor = AllocateZeroPool(MicrocodeFmpPrivate->DescriptorCount * sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR));
437 if (MicrocodeFmpPrivate->ImageDescriptor == NULL) {
438 return EFI_OUT_OF_RESOURCES;
439 }
440 }
441
442 CurrentMicrocodeCount = (UINT8)GetMicrocodeInfo(MicrocodeFmpPrivate->ImageDescriptor, MicrocodeFmpPrivate->DescriptorCount);
443 ASSERT(CurrentMicrocodeCount == MicrocodeFmpPrivate->DescriptorCount);
444
445 return EFI_SUCCESS;
446 }
447
448 /**
449 Initialize MicrocodeFmpDriver private data structure.
450
451 @param[in] MicrocodeFmpPrivate private data structure to be initialized.
452
453 @return EFI_SUCCESS private data is initialized.
454 **/
455 EFI_STATUS
456 InitializePrivateData (
457 IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate
458 )
459 {
460 EFI_STATUS Status;
461 EFI_STATUS VarStatus;
462 UINTN VarSize;
463
464 MicrocodeFmpPrivate->Signature = MICROCODE_FMP_PRIVATE_DATA_SIGNATURE;
465 MicrocodeFmpPrivate->Handle = NULL;
466 CopyMem(&MicrocodeFmpPrivate->Fmp, &mFirmwareManagementProtocol, sizeof(EFI_FIRMWARE_MANAGEMENT_PROTOCOL));
467
468 MicrocodeFmpPrivate->PackageVersion = 0x1;
469 MicrocodeFmpPrivate->PackageVersionName = L"Microcode";
470
471 MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion = 0x0;
472 MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus = 0x0;
473 VarSize = sizeof(MicrocodeFmpPrivate->LastAttempt);
474 VarStatus = gRT->GetVariable(
475 MICROCODE_FMP_LAST_ATTEMPT_VARIABLE_NAME,
476 &gEfiCallerIdGuid,
477 NULL,
478 &VarSize,
479 &MicrocodeFmpPrivate->LastAttempt
480 );
481 DEBUG((DEBUG_INFO, "GetLastAttemp - %r\n", VarStatus));
482 DEBUG((DEBUG_INFO, "GetLastAttemp Version - 0x%x, State - 0x%x\n", MicrocodeFmpPrivate->LastAttempt.LastAttemptVersion, MicrocodeFmpPrivate->LastAttempt.LastAttemptStatus));
483
484 Status = InitializeMicrocodeDescriptor(MicrocodeFmpPrivate);
485
486 return Status;
487 }
488
489 /**
490 Microcode FMP module entrypoint
491
492 @param[in] ImageHandle The firmware allocated handle for the EFI image.
493 @param[in] SystemTable A pointer to the EFI System Table.
494
495 @return EFI_SUCCESS Microcode FMP module is initialized.
496 **/
497 EFI_STATUS
498 EFIAPI
499 MicrocodeFmpMain (
500 IN EFI_HANDLE ImageHandle,
501 IN EFI_SYSTEM_TABLE *SystemTable
502 )
503 {
504 EFI_STATUS Status;
505
506 //
507 // Initialize MicrocodeFmpPrivateData
508 //
509 mMicrocodeFmpPrivate = AllocateZeroPool (sizeof(MICROCODE_FMP_PRIVATE_DATA));
510 if (mMicrocodeFmpPrivate == NULL) {
511 return EFI_OUT_OF_RESOURCES;
512 }
513
514 Status = InitializePrivateData(mMicrocodeFmpPrivate);
515 if (EFI_ERROR(Status)) {
516 FreePool(mMicrocodeFmpPrivate);
517 mMicrocodeFmpPrivate = NULL;
518 return Status;
519 }
520
521 //
522 // Install FMP protocol.
523 //
524 Status = gBS->InstallProtocolInterface (
525 &mMicrocodeFmpPrivate->Handle,
526 &gEfiFirmwareManagementProtocolGuid,
527 EFI_NATIVE_INTERFACE,
528 &mMicrocodeFmpPrivate->Fmp
529 );
530 if (EFI_ERROR (Status)) {
531 FreePool(mMicrocodeFmpPrivate);
532 mMicrocodeFmpPrivate = NULL;
533 return Status;
534 }
535
536 return Status;
537 }