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