]> git.proxmox.com Git - mirror_edk2.git/blob - SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
SignedCapsulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SignedCapsulePkg / Library / PlatformFlashAccessLibNull / PlatformFlashAccessLibNull.c
1 /** @file
2 Platform flash device access library NULL instance.
3
4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <PiDxe.h>
10
11 #include <Library/BaseMemoryLib.h>
12 #include <Library/PlatformFlashAccessLib.h>
13
14 UINT64 mInternalFdAddress;
15
16 /**
17 Perform flash write operation with progress indicator. The start and end
18 completion percentage values are passed into this function. If the requested
19 flash write operation is broken up, then completion percentage between the
20 start and end values may be passed to the provided Progress function. The
21 caller of this function is required to call the Progress function for the
22 start and end completion percentage values. This allows the Progress,
23 StartPercentage, and EndPercentage parameters to be ignored if the requested
24 flash write operation can not be broken up
25
26 @param[in] FirmwareType The type of firmware.
27 @param[in] FlashAddress The address of flash device to be accessed.
28 @param[in] FlashAddressType The type of flash device address.
29 @param[in] Buffer The pointer to the data buffer.
30 @param[in] Length The length of data buffer in bytes.
31 @param[in] Progress A function used report the progress of the
32 firmware update. This is an optional parameter
33 that may be NULL.
34 @param[in] StartPercentage The start completion percentage value that may
35 be used to report progress during the flash
36 write operation.
37 @param[in] EndPercentage The end completion percentage value that may
38 be used to report progress during the flash
39 write operation.
40
41 @retval EFI_SUCCESS The operation returns successfully.
42 @retval EFI_WRITE_PROTECTED The flash device is read only.
43 @retval EFI_UNSUPPORTED The flash device access is unsupported.
44 @retval EFI_INVALID_PARAMETER The input parameter is not valid.
45 **/
46 EFI_STATUS
47 EFIAPI
48 PerformFlashWriteWithProgress (
49 IN PLATFORM_FIRMWARE_TYPE FirmwareType,
50 IN EFI_PHYSICAL_ADDRESS FlashAddress,
51 IN FLASH_ADDRESS_TYPE FlashAddressType,
52 IN VOID *Buffer,
53 IN UINTN Length,
54 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL
55 IN UINTN StartPercentage,
56 IN UINTN EndPercentage
57 )
58 {
59 if (FlashAddressType == FlashAddressTypeRelativeAddress) {
60 FlashAddress = FlashAddress + mInternalFdAddress;
61 }
62 CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);
63 return EFI_SUCCESS;
64 }
65
66 /**
67 Perform flash write operation.
68
69 @param[in] FirmwareType The type of firmware.
70 @param[in] FlashAddress The address of flash device to be accessed.
71 @param[in] FlashAddressType The type of flash device address.
72 @param[in] Buffer The pointer to the data buffer.
73 @param[in] Length The length of data buffer in bytes.
74
75 @retval EFI_SUCCESS The operation returns successfully.
76 @retval EFI_WRITE_PROTECTED The flash device is read only.
77 @retval EFI_UNSUPPORTED The flash device access is unsupported.
78 @retval EFI_INVALID_PARAMETER The input parameter is not valid.
79 **/
80 EFI_STATUS
81 EFIAPI
82 PerformFlashWrite (
83 IN PLATFORM_FIRMWARE_TYPE FirmwareType,
84 IN EFI_PHYSICAL_ADDRESS FlashAddress,
85 IN FLASH_ADDRESS_TYPE FlashAddressType,
86 IN VOID *Buffer,
87 IN UINTN Length
88 )
89 {
90 return PerformFlashWriteWithProgress (
91 FirmwareType,
92 FlashAddress,
93 FlashAddressType,
94 Buffer,
95 Length,
96 NULL,
97 0,
98 0
99 );
100 }
101