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