]> git.proxmox.com Git - mirror_edk2.git/blob - SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h
e3308251c2785e4b12d8c2b6b3c6747dd944b985
[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 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
16 #ifndef __PLATFORM_FLASH_ACCESS_LIB_H__
17 #define __PLATFORM_FLASH_ACCESS_LIB_H__
18
19 #include <Protocol/FirmwareManagement.h>
20
21 typedef enum {
22 FlashAddressTypeRelativeAddress,
23 FlashAddressTypeAbsoluteAddress,
24 } FLASH_ADDRESS_TYPE;
25
26 //
27 // Type 0 ~ 0x7FFFFFFF is defined in this library.
28 // Type 0x80000000 ~ 0xFFFFFFFF is reserved for OEM.
29 //
30 typedef enum {
31 PlatformFirmwareTypeSystemFirmware,
32 PlatformFirmwareTypeNvRam,
33 } PLATFORM_FIRMWARE_TYPE;
34
35 /**
36 Perform flash write operation.
37
38 @param[in] FirmwareType The type of firmware.
39 @param[in] FlashAddress The address of flash device to be accessed.
40 @param[in] FlashAddressType The type of flash device address.
41 @param[in] Buffer The pointer to the data buffer.
42 @param[in] Length The length of data buffer in bytes.
43
44 @retval EFI_SUCCESS The operation returns successfully.
45 @retval EFI_WRITE_PROTECTED The flash device is read only.
46 @retval EFI_UNSUPPORTED The flash device access is unsupported.
47 @retval EFI_INVALID_PARAMETER The input parameter is not valid.
48 **/
49 EFI_STATUS
50 EFIAPI
51 PerformFlashWrite (
52 IN PLATFORM_FIRMWARE_TYPE FirmwareType,
53 IN EFI_PHYSICAL_ADDRESS FlashAddress,
54 IN FLASH_ADDRESS_TYPE FlashAddressType,
55 IN VOID *Buffer,
56 IN UINTN Length
57 );
58
59 /**
60 Perform flash write operation with progress indicator. The start and end
61 completion percentage values are passed into this function. If the requested
62 flash write operation is broken up, then completion percentage between the
63 start and end values may be passed to the provided Progress function. The
64 caller of this function is required to call the Progress function for the
65 start and end completion percentage values. This allows the Progress,
66 StartPercentage, and EndPercentage parameters to be ignored if the requested
67 flash write operation can not be broken up
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 @param[in] Progress A function used report the progress of the
75 firmware update. This is an optional parameter
76 that may be NULL.
77 @param[in] StartPercentage The start completion percentage value that may
78 be used to report progress during the flash
79 write operation.
80 @param[in] EndPercentage The end completion percentage value that may
81 be used to report progress during the flash
82 write operation.
83
84 @retval EFI_SUCCESS The operation returns successfully.
85 @retval EFI_WRITE_PROTECTED The flash device is read only.
86 @retval EFI_UNSUPPORTED The flash device access is unsupported.
87 @retval EFI_INVALID_PARAMETER The input parameter is not valid.
88 **/
89 EFI_STATUS
90 EFIAPI
91 PerformFlashWriteWithProgress (
92 IN PLATFORM_FIRMWARE_TYPE FirmwareType,
93 IN EFI_PHYSICAL_ADDRESS FlashAddress,
94 IN FLASH_ADDRESS_TYPE FlashAddressType,
95 IN VOID *Buffer,
96 IN UINTN Length,
97 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL
98 IN UINTN StartPercentage,
99 IN UINTN EndPercentage
100 );
101
102 #endif