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