2 The NvmExpressPei driver is used to manage non-volatile memory subsystem
3 which follows NVM Express specification at PEI phase.
5 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #ifndef _NVM_EXPRESS_PEI_BLOCKIO_H_
12 #define _NVM_EXPRESS_PEI_BLOCKIO_H_
15 // Nvme device for EFI_PEI_BLOCK_DEVICE_TYPE
17 #define EDKII_PEI_BLOCK_DEVICE_TYPE_NVME 7
19 #define NVME_READ_MAX_RETRY 3
22 Gets the count of block I/O devices that one specific block driver detects.
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
28 @param[in] PeiServices General-purpose services that are available
30 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI
32 @param[out] NumberBlockDevices The number of block I/O devices discovered.
34 @retval EFI_SUCCESS The operation performed successfully.
39 NvmeBlockIoPeimGetDeviceNo (
40 IN EFI_PEI_SERVICES
**PeiServices
,
41 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
42 OUT UINTN
*NumberBlockDevices
46 Gets a block device's media information.
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.
52 @param[in] PeiServices General-purpose services that are available to every
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
62 @param[out] MediaInfo The media information of the specified block media.
63 The caller is responsible for the ownership of this
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.
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
88 NvmeBlockIoPeimGetMediaInfo (
89 IN EFI_PEI_SERVICES
**PeiServices
,
90 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
92 OUT EFI_PEI_BLOCK_IO_MEDIA
*MediaInfo
96 Reads the requested number of blocks from the specified block device.
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.
102 @param[in] PeiServices General-purpose services that are available to
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
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
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.
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
,
141 Gets the count of block I/O devices that one specific block driver detects.
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
147 @param[in] PeiServices General-purpose services that are available
149 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI
151 @param[out] NumberBlockDevices The number of block I/O devices discovered.
153 @retval EFI_SUCCESS The operation performed successfully.
158 NvmeBlockIoPeimGetDeviceNo2 (
159 IN EFI_PEI_SERVICES
**PeiServices
,
160 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
161 OUT UINTN
*NumberBlockDevices
165 Gets a block device's media information.
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.
171 @param[in] PeiServices General-purpose services that are available to every
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
181 @param[out] MediaInfo The media information of the specified block media.
182 The caller is responsible for the ownership of this
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.
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
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
215 Reads the requested number of blocks from the specified block device.
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.
221 @param[in] PeiServices General-purpose services that are available to
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
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
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.
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
,