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