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