]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Include/Library/FlashDeviceLib.h
Vlv2TbltDevicePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2TbltDevicePkg / Include / Library / FlashDeviceLib.h
1 /*++
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9
10 Flash device library class header file.
11
12 Flash Device Library common type, MACRO and API definition. The basic idea for
13 this library is to provide API to abstract the different between flash
14 technology (SPI, FWH etc..), flash controller (SPI host controller on
15 ICH, MMIO type access for FWH), flash chip (programming command, method
16 of status checking). This library class can be consumed by drivers or applications
17 such as Firmware Volume Block driver, Flash Update application. These driver
18 can be written in a generic manner so that they are more easy to be
19 ported to other platforms.
20
21 This library can be build on a set of APIs which can touch flash controller, flash
22 chip directly for a platform with simple flash device configuration.
23
24 For a platform with complex flash device configuration, this library can be built
25 on the Flash Device Operate Library. Please see the header file for that library
26 class for detailed usage.
27
28 **/
29
30 #ifndef __FLASHDEVICE_LIB_H__
31 #define __FLASHDEVICE_LIB_H__
32
33 /**
34 Read NumBytes bytes of data from the address specified by
35 PAddress into Buffer.
36
37 @param[in] PAddress The starting physical address of the read.
38 @param[in,out] NumBytes On input, the number of bytes to read. On output, the number
39 of bytes actually read.
40 @param[out] Buffer The destination data buffer for the read.
41
42 @retval EFI_SUCCESS. Opertion is successful.
43 @retval EFI_DEVICE_ERROR If there is any device errors.
44
45 **/
46 EFI_STATUS
47 EFIAPI
48 LibFvbFlashDeviceRead (
49 IN UINTN PAddress,
50 IN OUT UINTN *NumBytes,
51 OUT UINT8 *Buffer
52 );
53
54 /**
55 Write NumBytes bytes of data from Buffer to the address specified by
56 PAddresss.
57
58 @param[in] PAddress The starting physical address of the write.
59 @param[in,out] NumBytes On input, the number of bytes to write. On output,
60 the actual number of bytes written.
61 @param[in] Buffer The source data buffer for the write.
62
63 @retval EFI_SUCCESS. Opertion is successful.
64 @retval EFI_DEVICE_ERROR If there is any device errors.
65
66 **/
67 EFI_STATUS
68 EFIAPI
69 LibFvbFlashDeviceWrite (
70 IN UINTN PAddress,
71 IN OUT UINTN *NumBytes,
72 IN UINT8 *Buffer
73 );
74
75 /**
76 Erase the block staring at PAddress.
77
78 @param[in] PAddress The starting physical address of the region to be erased.
79 @param[in] LbaLength The length of the region to be erased. This parameter is necessary
80 as the physical block size on a flash device could be different than
81 the logical block size of Firmware Volume Block protocol. Erase on
82 flash chip is always performed block by block. Therefore, the ERASE
83 operation to a logical block is converted a number of ERASE operation
84 (or a partial erase) on the hardware.
85
86 @retval EFI_SUCCESS. Opertion is successful.
87 @retval EFI_DEVICE_ERROR If there is any device errors.
88
89 **/
90 EFI_STATUS
91 EFIAPI
92 LibFvbFlashDeviceBlockErase (
93 IN UINTN PAddress,
94 IN UINTN LbaLength
95 );
96
97 /**
98 Lock or unlock the block staring at PAddress.
99
100 @param[in] PAddress The starting physical address of region to be (un)locked.
101 @param[in] LbaLength The length of the region to be (un)locked. This parameter is necessary
102 as the physical block size on a flash device could be different than
103 the logical block size of Firmware Volume Block protocol. (Un)Lock on
104 flash chip is always performed block by block. Therefore, the (Un)Lock
105 operation to a logical block is converted a number of (Un)Lock operation
106 (or a partial erase) on the hardware.
107 @param[in] Lock TRUE to lock. FALSE to unlock.
108
109 @retval EFI_SUCCESS. Opertion is successful.
110
111 **/
112 EFI_STATUS
113 EFIAPI
114 LibFvbFlashDeviceBlockLock (
115 IN UINTN PAddress,
116 IN UINTN LbaLength,
117 IN BOOLEAN Lock
118 );
119
120 #endif
121
122