]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiBlockIo.h
MdeModulePkg/SdMmcPciHcDxe Fix eMMC HS400 switch sequence
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressPei / NvmExpressPeiBlockIo.h
CommitLineData
b8b69433
HW
1/** @file\r
2 The NvmExpressPei driver is used to manage non-volatile memory subsystem\r
3 which follows NVM Express specification at PEI phase.\r
4\r
5 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r
6\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions\r
9 of the BSD License which accompanies this distribution. The\r
10 full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef _NVM_EXPRESS_PEI_BLOCKIO_H_\r
19#define _NVM_EXPRESS_PEI_BLOCKIO_H_\r
20\r
21//\r
22// Nvme device for EFI_PEI_BLOCK_DEVICE_TYPE\r
23//\r
24#define EDKII_PEI_BLOCK_DEVICE_TYPE_NVME 7\r
25\r
26#define NVME_READ_MAX_RETRY 3\r
27\r
28/**\r
29 Gets the count of block I/O devices that one specific block driver detects.\r
30\r
31 This function is used for getting the count of block I/O devices that one\r
32 specific block driver detects. If no device is detected, then the function\r
33 will return zero.\r
34\r
35 @param[in] PeiServices General-purpose services that are available\r
36 to every PEIM.\r
37 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI\r
38 instance.\r
39 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
40\r
41 @retval EFI_SUCCESS The operation performed successfully.\r
42\r
43**/\r
44EFI_STATUS\r
45EFIAPI\r
46NvmeBlockIoPeimGetDeviceNo (\r
47 IN EFI_PEI_SERVICES **PeiServices,\r
48 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
49 OUT UINTN *NumberBlockDevices\r
50 );\r
51\r
52/**\r
53 Gets a block device's media information.\r
54\r
55 This function will provide the caller with the specified block device's media\r
56 information. If the media changes, calling this function will update the media\r
57 information accordingly.\r
58\r
59 @param[in] PeiServices General-purpose services that are available to every\r
60 PEIM\r
61 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
62 @param[in] DeviceIndex Specifies the block device to which the function wants\r
63 to talk. Because the driver that implements Block I/O\r
64 PPIs will manage multiple block devices, the PPIs that\r
65 want to talk to a single device must specify the\r
66 device index that was assigned during the enumeration\r
67 process. This index is a number from one to\r
68 NumberBlockDevices.\r
69 @param[out] MediaInfo The media information of the specified block media.\r
70 The caller is responsible for the ownership of this\r
71 data structure.\r
72\r
73 @par Note:\r
74 The MediaInfo structure describes an enumeration of possible block device\r
75 types. This enumeration exists because no device paths are actually passed\r
76 across interfaces that describe the type or class of hardware that is publishing\r
77 the block I/O interface. This enumeration will allow for policy decisions\r
78 in the Recovery PEIM, such as "Try to recover from legacy floppy first,\r
79 LS-120 second, CD-ROM third." If there are multiple partitions abstracted\r
80 by a given device type, they should be reported in ascending order; this\r
81 order also applies to nested partitions, such as legacy MBR, where the\r
82 outermost partitions would have precedence in the reporting order. The\r
83 same logic applies to systems such as IDE that have precedence relationships\r
84 like "Master/Slave" or "Primary/Secondary". The master device should be\r
85 reported first, the slave second.\r
86\r
87 @retval EFI_SUCCESS Media information about the specified block device\r
88 was obtained successfully.\r
89 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
90 error.\r
91\r
92**/\r
93EFI_STATUS\r
94EFIAPI\r
95NvmeBlockIoPeimGetMediaInfo (\r
96 IN EFI_PEI_SERVICES **PeiServices,\r
97 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
98 IN UINTN DeviceIndex,\r
99 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
100 );\r
101\r
102/**\r
103 Reads the requested number of blocks from the specified block device.\r
104\r
105 The function reads the requested number of blocks from the device. All the\r
106 blocks are read, or an error is returned. If there is no media in the device,\r
107 the function returns EFI_NO_MEDIA.\r
108\r
109 @param[in] PeiServices General-purpose services that are available to\r
110 every PEIM.\r
111 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
112 @param[in] DeviceIndex Specifies the block device to which the function wants\r
113 to talk. Because the driver that implements Block I/O\r
114 PPIs will manage multiple block devices, PPIs that\r
115 want to talk to a single device must specify the device\r
116 index that was assigned during the enumeration process.\r
117 This index is a number from one to NumberBlockDevices.\r
118 @param[in] StartLBA The starting logical block address (LBA) to read from\r
119 on the device\r
120 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
121 a multiple of the intrinsic block size of the device.\r
122 @param[out] Buffer A pointer to the destination buffer for the data.\r
123 The caller is responsible for the ownership of the\r
124 buffer.\r
125\r
126 @retval EFI_SUCCESS The data was read correctly from the device.\r
127 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
128 to perform the read operation.\r
129 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
130 valid, or the buffer is not properly aligned.\r
131 @retval EFI_NO_MEDIA There is no media in the device.\r
132 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
133 the intrinsic block size of the device.\r
134\r
135**/\r
136EFI_STATUS\r
137EFIAPI\r
138NvmeBlockIoPeimReadBlocks (\r
139 IN EFI_PEI_SERVICES **PeiServices,\r
140 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
141 IN UINTN DeviceIndex,\r
142 IN EFI_PEI_LBA StartLBA,\r
143 IN UINTN BufferSize,\r
144 OUT VOID *Buffer\r
145 );\r
146\r
147/**\r
148 Gets the count of block I/O devices that one specific block driver detects.\r
149\r
150 This function is used for getting the count of block I/O devices that one\r
151 specific block driver detects. If no device is detected, then the function\r
152 will return zero.\r
153\r
154 @param[in] PeiServices General-purpose services that are available\r
155 to every PEIM.\r
156 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI\r
157 instance.\r
158 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
159\r
160 @retval EFI_SUCCESS The operation performed successfully.\r
161\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165NvmeBlockIoPeimGetDeviceNo2 (\r
166 IN EFI_PEI_SERVICES **PeiServices,\r
167 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
168 OUT UINTN *NumberBlockDevices\r
169 );\r
170\r
171/**\r
172 Gets a block device's media information.\r
173\r
174 This function will provide the caller with the specified block device's media\r
175 information. If the media changes, calling this function will update the media\r
176 information accordingly.\r
177\r
178 @param[in] PeiServices General-purpose services that are available to every\r
179 PEIM\r
180 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
181 @param[in] DeviceIndex Specifies the block device to which the function wants\r
182 to talk. Because the driver that implements Block I/O\r
183 PPIs will manage multiple block devices, the PPIs that\r
184 want to talk to a single device must specify the\r
185 device index that was assigned during the enumeration\r
186 process. This index is a number from one to\r
187 NumberBlockDevices.\r
188 @param[out] MediaInfo The media information of the specified block media.\r
189 The caller is responsible for the ownership of this\r
190 data structure.\r
191\r
192 @par Note:\r
193 The MediaInfo structure describes an enumeration of possible block device\r
194 types. This enumeration exists because no device paths are actually passed\r
195 across interfaces that describe the type or class of hardware that is publishing\r
196 the block I/O interface. This enumeration will allow for policy decisions\r
197 in the Recovery PEIM, such as "Try to recover from legacy floppy first,\r
198 LS-120 second, CD-ROM third." If there are multiple partitions abstracted\r
199 by a given device type, they should be reported in ascending order; this\r
200 order also applies to nested partitions, such as legacy MBR, where the\r
201 outermost partitions would have precedence in the reporting order. The\r
202 same logic applies to systems such as IDE that have precedence relationships\r
203 like "Master/Slave" or "Primary/Secondary". The master device should be\r
204 reported first, the slave second.\r
205\r
206 @retval EFI_SUCCESS Media information about the specified block device\r
207 was obtained successfully.\r
208 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
209 error.\r
210\r
211**/\r
212EFI_STATUS\r
213EFIAPI\r
214NvmeBlockIoPeimGetMediaInfo2 (\r
215 IN EFI_PEI_SERVICES **PeiServices,\r
216 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
217 IN UINTN DeviceIndex,\r
218 OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo\r
219 );\r
220\r
221/**\r
222 Reads the requested number of blocks from the specified block device.\r
223\r
224 The function reads the requested number of blocks from the device. All the\r
225 blocks are read, or an error is returned. If there is no media in the device,\r
226 the function returns EFI_NO_MEDIA.\r
227\r
228 @param[in] PeiServices General-purpose services that are available to\r
229 every PEIM.\r
230 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
231 @param[in] DeviceIndex Specifies the block device to which the function wants\r
232 to talk. Because the driver that implements Block I/O\r
233 PPIs will manage multiple block devices, PPIs that\r
234 want to talk to a single device must specify the device\r
235 index that was assigned during the enumeration process.\r
236 This index is a number from one to NumberBlockDevices.\r
237 @param[in] StartLBA The starting logical block address (LBA) to read from\r
238 on the device\r
239 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
240 a multiple of the intrinsic block size of the device.\r
241 @param[out] Buffer A pointer to the destination buffer for the data.\r
242 The caller is responsible for the ownership of the\r
243 buffer.\r
244\r
245 @retval EFI_SUCCESS The data was read correctly from the device.\r
246 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
247 to perform the read operation.\r
248 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
249 valid, or the buffer is not properly aligned.\r
250 @retval EFI_NO_MEDIA There is no media in the device.\r
251 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
252 the intrinsic block size of the device.\r
253\r
254**/\r
255EFI_STATUS\r
256EFIAPI\r
257NvmeBlockIoPeimReadBlocks2 (\r
258 IN EFI_PEI_SERVICES **PeiServices,\r
259 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
260 IN UINTN DeviceIndex,\r
261 IN EFI_PEI_LBA StartLBA,\r
262 IN UINTN BufferSize,\r
263 OUT VOID *Buffer\r
264 );\r
265\r
266#endif\r