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