1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
|
/**
Copyright (c) 2016, Microsoft Corporation. All rights reserved.
Copyright (c) 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiDxe.h>
#include <Library/FmpDeviceLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PlatformFlashAccessLib.h>
//#include <Protocol/FirmwareManagement.h>
//#include <Guid/SystemResourceTable.h>
typedef struct {
PLATFORM_FIRMWARE_TYPE FirmwareType;
FLASH_ADDRESS_TYPE AddressType;
EFI_PHYSICAL_ADDRESS BaseAddress;
UINTN Length;
UINTN ImageOffset;
} UPDATE_CONFIG_DATA;
UPDATE_CONFIG_DATA mUpdateConfigData[] = {
{ PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00400000, 0x00040000, 0x00400000 },
{ PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x004C0000, 0x00050000, 0x004C0000 },
{ PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00510000, 0x00210000, 0x00510000 },
{ PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00720000, 0x00070000, 0x00720000 },
{ PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00790000, 0x00070000, 0x00790000 }
};
/**
Used to pass the FMP install function to this lib. This allows the library to
have control of the handle that the FMP instance is installed on. This allows
the library to use DriverBinding protocol model to locate its device(s) in the
system.
@param[in] Func Function pointer to FMP install function.
@retval EFI_SUCCESS Library has saved function pointer and will call
function pointer on each DriverBinding Start.
@retval EFI_UNSUPPORTED Library doesn't use driver binding and only supports
a single instance.
@retval other error Error occurred. Don't install FMP
**/
EFI_STATUS
EFIAPI
RegisterFmpInstaller (
IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER Func
)
{
//
// This is a system firmware update that does not use Driver Binding Protocol
//
return EFI_UNSUPPORTED;
}
/**
Provide a function to uninstall the Firmware Management Protocol instance from a
device handle when the device is managed by a driver that follows the UEFI
Driver Model. If the device is not managed by a driver that follows the UEFI
Driver Model, then EFI_UNSUPPORTED is returned.
@param[in] FmpUninstaller Function that installs the Firmware Management
Protocol.
@retval EFI_SUCCESS The device is managed by a driver that follows the
UEFI Driver Model. FmpUinstaller must be called on
each Driver Binding Stop().
@retval EFI_UNSUPPORTED The device is not managed by a driver that follows
the UEFI Driver Model.
@retval other The Firmware Management Protocol for this firmware
device is not installed. The firmware device is
still locked using FmpDeviceLock().
**/
EFI_STATUS
EFIAPI
RegisterFmpUninstaller (
IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER FmpUninstaller
)
{
//
// This is a system firmware update that does not use Driver Binding Protocol
//
return EFI_UNSUPPORTED;
}
/**
Set the device context for the FmpDeviceLib services when the device is
managed by a driver that follows the UEFI Driver Model. If the device is not
managed by a driver that follows the UEFI Driver Model, then EFI_UNSUPPORTED
is returned. Once a device context is set, the FmpDeviceLib services
operate on the currently set device context.
@param[in] Handle Device handle for the FmpDeviceLib services.
If Handle is NULL, then Context is freed.
@param[in, out] Context Device context for the FmpDeviceLib services.
If Context is NULL, then a new context is allocated
for Handle and the current device context is set and
returned in Context. If Context is not NULL, then
the current device context is set.
@retval EFI_SUCCESS The device is managed by a driver that follows the
UEFI Driver Model.
@retval EFI_UNSUPPORTED The device is not managed by a driver that follows
the UEFI Driver Model.
@retval other The Firmware Management Protocol for this firmware
device is not installed. The firmware device is
still locked using FmpDeviceLock().
**/
EFI_STATUS
EFIAPI
FmpDeviceSetContext (
IN EFI_HANDLE Handle,
IN OUT VOID **Context
)
{
//
// This is a system firmware update that does not use Driver Binding Protocol
//
return EFI_UNSUPPORTED;
}
/**
Returns the size, in bytes, of the firmware image currently stored in the
firmware device. This function is used to by the GetImage() and
GetImageInfo() services of the Firmware Management Protocol. If the image
size can not be determined from the firmware device, then 0 must be returned.
@param[out] Size Pointer to the size, in bytes, of the firmware image
currently stored in the firmware device.
@retval EFI_SUCCESS The size of the firmware image currently
stored in the firmware device was returned.
@retval EFI_INVALID_PARAMETER Size is NULL.
@retval EFI_UNSUPPORTED The firmware device does not support reporting
the size of the currently stored firmware image.
@retval EFI_DEVICE_ERROR An error occured attempting to determine the
size of the firmware image currently stored in
in the firmware device.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetSize (
IN UINTN *Size
)
{
if (Size == NULL) {
return EFI_INVALID_PARAMETER;
}
*Size = PcdGet32 (PcdBiosRomSize);
return EFI_SUCCESS;
}
/**
Used to return a library supplied guid that will be the ImageTypeId guid of
the FMP descriptor. This is optional but can be used if at runtime the guid
needs to be determined.
@param[out] Guid Double Guid Ptr that will be updated to point to guid.
This should be from static memory and will not be freed.
@return EFI_UNSUPPORTED Library instance doesn't need dynamic guid.
@return Error Any error will cause the wrapper to use the GUID
defined by PCD.
@return EFI_SUCCESS Guid ptr should be updated to point to static memeory
which contains a valid guid.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetImageTypeIdGuidPtr (
OUT EFI_GUID **Guid
)
{
return EFI_UNSUPPORTED;
}
/**
Returns values used to fill in the AttributesSupported and AttributesSettings
fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the
GetImageInfo() service of the Firmware Management Protocol. The following
bit values from the Firmware Management Protocol may be combined:
IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
IMAGE_ATTRIBUTE_RESET_REQUIRED
IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
IMAGE_ATTRIBUTE_IN_USE
IMAGE_ATTRIBUTE_UEFI_IMAGE
@param[out] Supported Attributes supported by this firmware device.
@param[out] Setting Attributes settings for this firmware device.
@retval EFI_SUCCESS The attributes supported by the firmware
device were returned.
@retval EFI_INVALID_PARAMETER Supported is NULL.
@retval EFI_INVALID_PARAMETER Setting is NULL.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetAttributes (
IN OUT UINT64 *Supported,
IN OUT UINT64 *Setting
)
{
if (Supported == NULL || Setting == NULL) {
return EFI_INVALID_PARAMETER;
}
*Supported = (IMAGE_ATTRIBUTE_IMAGE_UPDATABLE |
IMAGE_ATTRIBUTE_RESET_REQUIRED |
IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED |
IMAGE_ATTRIBUTE_IN_USE
);
*Setting = (IMAGE_ATTRIBUTE_IMAGE_UPDATABLE |
IMAGE_ATTRIBUTE_RESET_REQUIRED |
IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED |
IMAGE_ATTRIBUTE_IN_USE
);
return EFI_SUCCESS;
}
/**
Gets the current Lowest Supported Version.
This is a protection mechanism so that a previous version with known issue is
not applied. ONLY implement this if your running firmware has a method to
return this at runtime. If EFI_UNSUPPORTED is returned, then the Lowest
Supported Version is stored in a UEFI Variable.
@param[out] Version On return this value represents the current Lowest
Supported Version (in same format as GetVersion).
@retval EFI_SUCCESS The Lowest Supported Version was correctly retrieved
@retval EFI_UNSUPPORTED Device firmware doesn't support reporting LSV
@retval EFI_DEVICE_ERROR Error occurred when trying to get the LSV
**/
EFI_STATUS
EFIAPI
FmpDeviceGetLowestSupportedVersion (
IN OUT UINT32 *LowestSupportedVersion
)
{
//
// Retrieve the lowest support version from a PCD
// NOTE: This method of using a PCD can only be used for the system firmware
// FMP instance that is updated every time the system firmware is
// updated. If system firmware updates support partial updates that
// would not include the system firmware FMP instance, then a PCD can
// not be used and the value must come from the currently running system
// firmware image.
//
*LowestSupportedVersion = PcdGet32 (PcdSystemFirmwareFmpLowestSupportedVersion);
return EFI_SUCCESS;
}
/**
Returns the Null-terminated Unicode string that is used to fill in the
VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is
returned by the GetImageInfo() service of the Firmware Management Protocol.
The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().
@note It is recommended that all firmware devices support a method to report
the VersionName string from the currently stored firmware image.
@param[out] VersionString The version string retrieved from the currently
stored firmware image.
@retval EFI_SUCCESS The version string of currently stored
firmware image was returned in Version.
@retval EFI_INVALID_PARAMETER VersionString is NULL.
@retval EFI_UNSUPPORTED The firmware device does not support a method
to report the version string of the currently
stored firmware image.
@retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the
version string of the currently stored
firmware image.
@retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the
buffer for the version string of the currently
stored firmware image.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetVersionString (
OUT CHAR16 **VersionString
)
{
if (VersionString == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Retrieve the version string from a PCD
// NOTE: This method of using a PCD can only be used for the system firmware
// FMP instance that is updated every time the system firmware is
// updated. If system firmware updates support partial updates that
// would not include the system firmware FMP instance, then a PCD can
// not be used and the value must come from the currently running system
// firmware image.
//
*VersionString = (CHAR16 *)AllocateCopyPool (
PcdGetSize (PcdSystemFirmwareFmpVersionString),
PcdGetPtr (PcdSystemFirmwareFmpVersionString)
);
if (*VersionString == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Gets the current running version.
ONLY implement this if your running firmware has a method to return this at
runtime.
@param[out] Version On return this value represents the current running
version.
@retval EFI_SUCCESS The version was correctly retrieved.
@retval EFI_UNSUPPORTED Device firmware doesn't support reporting current
version.
@retval EFI_DEVICE_ERROR Error occurred when trying to get the version.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetVersion (
IN OUT UINT32 *Version
)
{
//
// Retrieve the version string from a PCD
// NOTE: This method of using a PCD can only be used for the system firmware
// FMP instance that is updated every time the system firmware is
// updated. If system firmware updates support partial updates that
// would not include the system firmware FMP instance, then a PCD can
// not be used and the value must come from the currently running system
// firmware image.
//
*Version = PcdGet32 (PcdSystemFirmwareFmpVersion);
return EFI_SUCCESS;
}
/**
Returns the value used to fill in the HardwareInstance field of the
EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then
the firmware device supports a method to report the HardwareInstance value.
If the value can not be reported for the firmware device, then EFI_UNSUPPORTED
must be returned. EFI_DEVICE_ERROR is returned if an error occurs attempting
to retrieve the HardwareInstance value for the firmware device.
@param[out] HardwareInstance The hardware instance value for the firmware
device.
@retval EFI_SUCCESS The hardware instance for the current firmware
devide is returned in HardwareInstance.
@retval EFI_UNSUPPORTED The firmware device does not support a method to
report the hardware instance value.
@retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the hardware
instance value.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetHardwareInstance (
OUT UINT64 *HardwareInstance
)
{
return EFI_UNSUPPORTED;
}
/**
Retrieves a copy of the current firmware image of the device.
This function allows a copy of the current firmware image to be created and
saved. The saved copy could later been used, for example, in firmware image
recovery or rollback.
@param[out] Image Points to the buffer where the current image is copied
to.
@param[out] ImageSize On entry, points to the size of the buffer pointed to
by Image, in bytes. On return, points to the length of
the image, in bytes.
@retval EFI_SUCCESS The image was successfully read from the device.
@retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small
to hold the image. The current buffer size
needed to hold the image is returned in
ImageSize.
@retval EFI_INVALID_PARAMETER The Image was NULL.
@retval EFI_NOT_FOUND The current image is not copied to the buffer.
@retval EFI_UNSUPPORTED The operation is not supported.
**/
EFI_STATUS
EFIAPI
FmpDeviceGetImage (
IN OUT VOID *Image,
IN OUT UINTN *ImageSize
)
{
//
// Check for invalid p;arameters
//
if (Image == NULL || ImageSize == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Make sure the buffer is big enough to hold the device image
//
if (*ImageSize < PcdGet32 (PcdBiosRomSize)) {
*ImageSize = PcdGet32 (PcdBiosRomSize);
return EFI_BUFFER_TOO_SMALL;
}
//
// Copy the device image to the buffer
//
*ImageSize = PcdGet32 (PcdBiosRomSize);
CopyMem (
Image,
(VOID *)(UINTN)PcdGet32 (PcdBiosRomBase),
*ImageSize
);
return EFI_SUCCESS;
}
/**
Updates the firmware image of the device.
This function updates the hardware with the new firmware image. This function
returns EFI_UNSUPPORTED if the firmware image is not updatable. If the
firmware image is updatable, the function should perform the following minimal
validations before proceeding to do the firmware image update.
- Validate the image is a supported image for this device. The function
returns EFI_ABORTED if the image is unsupported. The function can
optionally provide more detailed information on why the image is not a
supported image.
- Validate the data from VendorCode if not null. Image validation must be
performed before VendorCode data validation. VendorCode data is ignored
or considered invalid if image validation failed. The function returns
EFI_ABORTED if the data is invalid.
VendorCode enables vendor to implement vendor-specific firmware image update
policy. Null if the caller did not specify the policy or use the default
policy. As an example, vendor can implement a policy to allow an option to
force a firmware image update when the abort reason is due to the new firmware
image version is older than the current firmware image version or bad image
checksum. Sensitive operations such as those wiping the entire firmware image
and render the device to be non-functional should be encoded in the image
itself rather than passed with the VendorCode. AbortReason enables vendor to
have the option to provide a more detailed description of the abort reason to
the caller.
@param[in] Image Points to the new image.
@param[in] ImageSize Size of the new image in bytes.
@param[in] VendorCode This enables vendor to implement vendor-specific
firmware image update policy. Null indicates the
caller did not specify the policy or use the
default policy.
@param[in] Progress A function used by the driver to report the
progress of the firmware update.
@param[in] CapsuleFwVersion FMP Payload Header version of the image.
@param[out] AbortReason A pointer to a pointer to a null-terminated
string providing more details for the aborted
operation. The buffer is allocated by this
function with AllocatePool(), and it is the
caller's responsibility to free it with a call
to FreePool().
@retval EFI_SUCCESS The device was successfully updated with the
new image.
@retval EFI_ABORTED The operation is aborted.
@retval EFI_INVALID_PARAMETER The Image was NULL.
@retval EFI_UNSUPPORTED The operation is not supported.
**/
EFI_STATUS
EFIAPI
FmpDeviceSetImage (
IN CONST VOID *Image,
IN UINTN ImageSize,
IN CONST VOID *VendorCode,
IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
IN UINT32 CapsuleFwVersion,
OUT CHAR16 **AbortReason
)
{
EFI_STATUS Status;
UINT32 Updateable;
UINTN Percentage;
UINTN Index;
UPDATE_CONFIG_DATA *ConfigData;
UINTN TotalSize;
UINTN BytesWritten;
Updateable = 0;
Status = FmpDeviceCheckImage (Image, ImageSize, &Updateable);
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Check Image failed with %r.\n", Status));
return Status;
}
if (Updateable != IMAGE_UPDATABLE_VALID) {
DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Check Image returned that the Image was not valid for update. Updatable value = 0x%X.\n", Updateable));
return EFI_ABORTED;
}
if (Progress == NULL) {
DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Invalid progress callback\n"));
return EFI_INVALID_PARAMETER;
}
Status = Progress (15);
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Progress Callback failed with Status %r.\n", Status));
}
//
// Write the image to the firmware device
//
Progress (20);
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Progress Callback failed with Status %r.\n", Status));
}
//
// Simulate update with delays between progress updates
//
for (Percentage = 20; Percentage <= 100; Percentage++) {
//
// Wait 0.05 seconds
//
// gBS->Stall (50000);
// Progress (Percentage);
// if (EFI_ERROR (Status)) {
// DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Progress Callback failed with Status %r.\n", Status));
// }
}
DEBUG ((DEBUG_INFO, "FmpDeviceSetImage - %d Images ...\n", ARRAY_SIZE (mUpdateConfigData)));
if (ARRAY_SIZE (mUpdateConfigData) == 0) {
DEBUG((DEBUG_INFO, "PlatformUpdate: BaseAddress - 0x%lx ImageOffset - 0x%x Length - 0x%x\n", 0, 0, ImageSize));
Status = PerformFlashWriteWithProgress (
PlatformFirmwareTypeSystemFirmware, // FirmwareType
0x00000000, // FlashAddress
FlashAddressTypeRelativeAddress, // FlashAddressType
(VOID *)(UINTN)Image, // Buffer
ImageSize, // BufferLength
Progress, // Progress
20, // StartPercentage
100 // EndPercentage
);
}
//
// Compute total size of update
//
for (Index = 0, TotalSize = 0; Index < ARRAY_SIZE (mUpdateConfigData); Index++) {
TotalSize += mUpdateConfigData[Index].Length;
}
BytesWritten = 0;
for (Index = 0, ConfigData = mUpdateConfigData; Index < ARRAY_SIZE (mUpdateConfigData); Index++, ConfigData++) {
DEBUG((DEBUG_INFO, "PlatformUpdate(%d): BaseAddress - 0x%lx ImageOffset - 0x%x Length - 0x%x\n",
Index,
ConfigData->BaseAddress,
ConfigData->ImageOffset,
ConfigData->Length
));
Status = PerformFlashWriteWithProgress (
ConfigData->FirmwareType, // FirmwareType
ConfigData->BaseAddress, // FlashAddress
ConfigData->AddressType, // FlashAddressType
(VOID *)((UINTN)Image + (UINTN)ConfigData->ImageOffset), // Buffer
ConfigData->Length, // BufferLength
Progress, // Progress
20 + (BytesWritten * 80) / TotalSize, // StartPercentage
20 + ((BytesWritten + ConfigData->Length) * 80) / TotalSize // EndPercentage
);
if (EFI_ERROR(Status)) {
break;
}
BytesWritten += ConfigData->Length;
}
DEBUG ((DEBUG_INFO, "FmpDeviceSetImage - %r\n", Status));
return Status;
}
/**
Checks if the firmware image is valid for the device.
This function allows firmware update application to validate the firmware image without
invoking the SetImage() first.
@param[in] Image Points to the new image.
@param[in] ImageSize Size of the new image in bytes.
@param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides,
if available, additional information if the image is invalid.
@retval EFI_SUCCESS The image was successfully checked.
@retval EFI_INVALID_PARAMETER The Image was NULL.
**/
EFI_STATUS
EFIAPI
FmpDeviceCheckImage (
IN CONST VOID *Image,
IN UINTN ImageSize,
OUT UINT32 *ImageUpdateable
)
{
if (ImageUpdateable == NULL) {
DEBUG((DEBUG_ERROR, "CheckImage - ImageUpdateable Pointer Parameter is NULL.\n"));
return EFI_INVALID_PARAMETER;
}
//
//Set to valid and then if any tests fail it will update this flag.
//
*ImageUpdateable = IMAGE_UPDATABLE_VALID;
if (Image == NULL) {
DEBUG((DEBUG_ERROR, "CheckImage - Image Pointer Parameter is NULL.\n"));
//
// Not sure if this is needed
//
*ImageUpdateable = IMAGE_UPDATABLE_INVALID;
return EFI_INVALID_PARAMETER;
}
//
// Make sure the image size is correct
//
if (ImageSize != PcdGet32 (PcdBiosRomSize)) {
*ImageUpdateable = IMAGE_UPDATABLE_INVALID;
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
Device firmware should trigger lock mechanism so that device fw can not be
updated or tampered with. This lock mechanism is generally only cleared by a
full system reset (not just sleep state/low power mode)
@retval EFI_SUCCESS The device was successfully locked.
@retval EFI_UNSUPPORTED The hardware device/firmware doesn't support locking
**/
EFI_STATUS
EFIAPI
FmpDeviceLock (
VOID
)
{
DEBUG ((DEBUG_INFO, "VLV2: FmpDeviceLock() for system FLASH\n"));
// TODO: Add lock logic
return EFI_UNSUPPORTED;
}
|