]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.h
MdeModulePkg NvmExpressDxe: Add BlockIo2 support
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressDxe / NvmExpressBlockIo.h
CommitLineData
eb290d02
FT
1/** @file\r
2 Header file for EFI_BLOCK_IO_PROTOCOL interface.\r
3\r
758ea946 4Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
eb290d02
FT
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _EFI_NVME_BLOCKIO_H_\r
16#define _EFI_NVME_BLOCKIO_H_\r
17\r
18/**\r
19 Reset the Block Device.\r
20\r
21 @param This Indicates a pointer to the calling context.\r
22 @param ExtendedVerification Driver may perform diagnostics on reset.\r
23\r
24 @retval EFI_SUCCESS The device was reset.\r
25 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
26 not be reset.\r
27\r
28**/\r
29EFI_STATUS\r
30EFIAPI\r
31NvmeBlockIoReset (\r
32 IN EFI_BLOCK_IO_PROTOCOL *This,\r
33 IN BOOLEAN ExtendedVerification\r
34 );\r
35\r
36/**\r
37 Read BufferSize bytes from Lba into Buffer.\r
38\r
39 @param This Indicates a pointer to the calling context.\r
40 @param MediaId Id of the media, changes every time the media is replaced.\r
41 @param Lba The starting Logical Block Address to read from\r
42 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
43 @param Buffer A pointer to the destination buffer for the data. The caller is\r
44 responsible for either having implicit or explicit ownership of the buffer.\r
45\r
46 @retval EFI_SUCCESS The data was read correctly from the device.\r
47 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
48 @retval EFI_NO_MEDIA There is no media in the device.\r
49 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
50 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
51 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
52 or the buffer is not on proper alignment.\r
53\r
54**/\r
55EFI_STATUS\r
56EFIAPI\r
57NvmeBlockIoReadBlocks (\r
58 IN EFI_BLOCK_IO_PROTOCOL *This,\r
59 IN UINT32 MediaId,\r
60 IN EFI_LBA Lba,\r
61 IN UINTN BufferSize,\r
62 OUT VOID *Buffer\r
63 );\r
64\r
65/**\r
66 Write BufferSize bytes from Lba into Buffer.\r
67\r
68 @param This Indicates a pointer to the calling context.\r
69 @param MediaId The media ID that the write request is for.\r
70 @param Lba The starting logical block address to be written. The caller is\r
71 responsible for writing to only legitimate locations.\r
72 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
73 @param Buffer A pointer to the source buffer for the data.\r
74\r
75 @retval EFI_SUCCESS The data was written correctly to the device.\r
76 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
77 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
78 @retval EFI_NO_MEDIA There is no media in the device.\r
79 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
80 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
81 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
82 or the buffer is not on proper alignment.\r
83\r
84**/\r
85EFI_STATUS\r
86EFIAPI\r
87NvmeBlockIoWriteBlocks (\r
88 IN EFI_BLOCK_IO_PROTOCOL *This,\r
89 IN UINT32 MediaId,\r
90 IN EFI_LBA Lba,\r
91 IN UINTN BufferSize,\r
92 IN VOID *Buffer\r
93 );\r
94\r
95/**\r
96 Flush the Block Device.\r
97\r
98 @param This Indicates a pointer to the calling context.\r
99\r
100 @retval EFI_SUCCESS All outstanding data was written to the device\r
101 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
102 @retval EFI_NO_MEDIA There is no media in the device.\r
103\r
104**/\r
105EFI_STATUS\r
106EFIAPI\r
107NvmeBlockIoFlushBlocks (\r
108 IN EFI_BLOCK_IO_PROTOCOL *This\r
109 );\r
110\r
758ea946
HW
111/**\r
112 Reset the block device hardware.\r
113\r
114 @param[in] This Indicates a pointer to the calling context.\r
115 @param[in] ExtendedVerification Indicates that the driver may perform a more\r
116 exhausive verfication operation of the\r
117 device during reset.\r
118\r
119 @retval EFI_SUCCESS The device was reset.\r
120 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
121 not be reset.\r
122\r
123**/\r
124EFI_STATUS\r
125EFIAPI\r
126NvmeBlockIoResetEx (\r
127 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
128 IN BOOLEAN ExtendedVerification\r
129 );\r
130\r
131/**\r
132 Read BufferSize bytes from Lba into Buffer.\r
133\r
134 This function reads the requested number of blocks from the device. All the\r
135 blocks are read, or an error is returned.\r
136 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
137 non-blocking I/O is being used, the Event associated with this request will\r
138 not be signaled.\r
139\r
140 @param[in] This Indicates a pointer to the calling context.\r
141 @param[in] MediaId Id of the media, changes every time the media is\r
142 replaced.\r
143 @param[in] Lba The starting Logical Block Address to read from.\r
144 @param[in, out] Token A pointer to the token associated with the\r
145 transaction.\r
146 @param[in] BufferSize Size of Buffer, must be a multiple of device\r
147 block size.\r
148 @param[out] Buffer A pointer to the destination buffer for the data.\r
149 The caller is responsible for either having\r
150 implicit or explicit ownership of the buffer.\r
151\r
152 @retval EFI_SUCCESS The read request was queued if Token->Event is\r
153 not NULL.The data was read correctly from the\r
154 device if the Token->Event is NULL.\r
155 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
156 the read.\r
157 @retval EFI_NO_MEDIA There is no media in the device.\r
158 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
159 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
160 the intrinsic block size of the device.\r
161 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
162 valid, or the buffer is not on proper\r
163 alignment.\r
164 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
165 lack of resources.\r
166\r
167**/\r
168EFI_STATUS\r
169EFIAPI\r
170NvmeBlockIoReadBlocksEx (\r
171 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
172 IN UINT32 MediaId,\r
173 IN EFI_LBA Lba,\r
174 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
175 IN UINTN BufferSize,\r
176 OUT VOID *Buffer\r
177 );\r
178\r
179/**\r
180 Write BufferSize bytes from Lba into Buffer.\r
181\r
182 This function writes the requested number of blocks to the device. All blocks\r
183 are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
184 EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
185 being used, the Event associated with this request will not be signaled.\r
186\r
187 @param[in] This Indicates a pointer to the calling context.\r
188 @param[in] MediaId The media ID that the write request is for.\r
189 @param[in] Lba The starting logical block address to be written.\r
190 The caller is responsible for writing to only\r
191 legitimate locations.\r
192 @param[in, out] Token A pointer to the token associated with the\r
193 transaction.\r
194 @param[in] BufferSize Size of Buffer, must be a multiple of device\r
195 block size.\r
196 @param[in] Buffer A pointer to the source buffer for the data.\r
197\r
198 @retval EFI_SUCCESS The write request was queued if Event is not\r
199 NULL.\r
200 The data was written correctly to the device if\r
201 the Event is NULL.\r
202 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
203 @retval EFI_NO_MEDIA There is no media in the device.\r
204 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current\r
205 device.\r
206 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
207 the write.\r
208 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size\r
209 of the device.\r
210 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not\r
211 valid, or the buffer is not on proper\r
212 alignment.\r
213 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
214 lack of resources.\r
215\r
216**/\r
217EFI_STATUS\r
218EFIAPI\r
219NvmeBlockIoWriteBlocksEx (\r
220 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
221 IN UINT32 MediaId,\r
222 IN EFI_LBA Lba,\r
223 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
224 IN UINTN BufferSize,\r
225 IN VOID *Buffer\r
226 );\r
227\r
228/**\r
229 Flush the Block Device.\r
230\r
231 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
232 is returned and non-blocking I/O is being used, the Event associated with\r
233 this request will not be signaled.\r
234\r
235 @param[in] This Indicates a pointer to the calling context.\r
236 @param[in,out] Token A pointer to the token associated with the\r
237 transaction.\r
238\r
239 @retval EFI_SUCCESS The flush request was queued if Event is not\r
240 NULL.\r
241 All outstanding data was written correctly to\r
242 the device if the Event is NULL.\r
243 @retval EFI_DEVICE_ERROR The device reported an error while writting back\r
244 the data.\r
245 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
246 @retval EFI_NO_MEDIA There is no media in the device.\r
247 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
248 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
249 of resources.\r
250\r
251**/\r
252EFI_STATUS\r
253EFIAPI\r
254NvmeBlockIoFlushBlocksEx (\r
255 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
256 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
257 );\r
258\r
754b489b
TF
259/**\r
260 Send a security protocol command to a device that receives data and/or the result\r
261 of one or more commands sent by SendData.\r
262\r
263 The ReceiveData function sends a security protocol command to the given MediaId.\r
264 The security protocol command sent is defined by SecurityProtocolId and contains\r
265 the security protocol specific data SecurityProtocolSpecificData. The function\r
266 returns the data from the security protocol command in PayloadBuffer.\r
267\r
268 For devices supporting the SCSI command set, the security protocol command is sent\r
269 using the SECURITY PROTOCOL IN command defined in SPC-4.\r
270\r
271 For devices supporting the ATA command set, the security protocol command is sent\r
272 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
273 is non-zero.\r
274\r
275 If the PayloadBufferSize is zero, the security protocol command is sent using the\r
276 Trusted Non-Data command defined in ATA8-ACS.\r
277\r
278 If PayloadBufferSize is too small to store the available data from the security\r
279 protocol command, the function shall copy PayloadBufferSize bytes into the\r
280 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
281\r
282 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
283 the function shall return EFI_INVALID_PARAMETER.\r
284\r
285 If the given MediaId does not support security protocol commands, the function shall\r
286 return EFI_UNSUPPORTED. If there is no media in the device, the function returns\r
287 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,\r
288 the function returns EFI_MEDIA_CHANGED.\r
289\r
290 If the security protocol fails to complete within the Timeout period, the function\r
291 shall return EFI_TIMEOUT.\r
292\r
293 If the security protocol command completes without an error, the function shall\r
294 return EFI_SUCCESS. If the security protocol command completes with an error, the\r
295 function shall return EFI_DEVICE_ERROR.\r
296\r
297 @param This Indicates a pointer to the calling context.\r
298 @param MediaId ID of the medium to receive data from.\r
299 @param Timeout The timeout, in 100ns units, to use for the execution\r
300 of the security protocol command. A Timeout value of 0\r
301 means that this function will wait indefinitely for the\r
302 security protocol command to execute. If Timeout is greater\r
303 than zero, then this function will return EFI_TIMEOUT\r
304 if the time required to execute the receive data command\r
305 is greater than Timeout.\r
306 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
307 the security protocol command to be sent.\r
308 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
309 of the security protocol command to be sent.\r
310 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
311 @param PayloadBuffer A pointer to a destination buffer to store the security\r
312 protocol command specific payload data for the security\r
313 protocol command. The caller is responsible for having\r
314 either implicit or explicit ownership of the buffer.\r
315 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the\r
316 data written to the payload data buffer.\r
317\r
318 @retval EFI_SUCCESS The security protocol command completed successfully.\r
319 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available\r
320 data from the device. The PayloadBuffer contains the truncated data.\r
321 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
322 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
323 @retval EFI_NO_MEDIA There is no media in the device.\r
324 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
325 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and\r
326 PayloadBufferSize is non-zero.\r
327 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
328 protocol command to execute.\r
329\r
330**/\r
331EFI_STATUS\r
332EFIAPI\r
333NvmeStorageSecurityReceiveData (\r
334 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
335 IN UINT32 MediaId,\r
336 IN UINT64 Timeout,\r
337 IN UINT8 SecurityProtocolId,\r
338 IN UINT16 SecurityProtocolSpecificData,\r
339 IN UINTN PayloadBufferSize,\r
340 OUT VOID *PayloadBuffer,\r
341 OUT UINTN *PayloadTransferSize\r
342 );\r
343\r
344/**\r
345 Send a security protocol command to a device.\r
346\r
347 The SendData function sends a security protocol command containing the payload\r
348 PayloadBuffer to the given MediaId. The security protocol command sent is\r
349 defined by SecurityProtocolId and contains the security protocol specific data\r
350 SecurityProtocolSpecificData. If the underlying protocol command requires a\r
351 specific padding for the command payload, the SendData function shall add padding\r
352 bytes to the command payload to satisfy the padding requirements.\r
353\r
354 For devices supporting the SCSI command set, the security protocol command is sent\r
355 using the SECURITY PROTOCOL OUT command defined in SPC-4.\r
356\r
357 For devices supporting the ATA command set, the security protocol command is sent\r
358 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize\r
359 is non-zero. If the PayloadBufferSize is zero, the security protocol command is\r
360 sent using the Trusted Non-Data command defined in ATA8-ACS.\r
361\r
362 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall\r
363 return EFI_INVALID_PARAMETER.\r
364\r
365 If the given MediaId does not support security protocol commands, the function\r
366 shall return EFI_UNSUPPORTED. If there is no media in the device, the function\r
367 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the\r
368 device, the function returns EFI_MEDIA_CHANGED.\r
369\r
370 If the security protocol fails to complete within the Timeout period, the function\r
371 shall return EFI_TIMEOUT.\r
372\r
373 If the security protocol command completes without an error, the function shall return\r
374 EFI_SUCCESS. If the security protocol command completes with an error, the function\r
375 shall return EFI_DEVICE_ERROR.\r
376\r
377 @param This Indicates a pointer to the calling context.\r
378 @param MediaId ID of the medium to receive data from.\r
379 @param Timeout The timeout, in 100ns units, to use for the execution\r
380 of the security protocol command. A Timeout value of 0\r
381 means that this function will wait indefinitely for the\r
382 security protocol command to execute. If Timeout is greater\r
383 than zero, then this function will return EFI_TIMEOUT\r
384 if the time required to execute the receive data command\r
385 is greater than Timeout.\r
386 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
387 the security protocol command to be sent.\r
388 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
389 of the security protocol command to be sent.\r
390 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
391 @param PayloadBuffer A pointer to a destination buffer to store the security\r
392 protocol command specific payload data for the security\r
393 protocol command.\r
394\r
395 @retval EFI_SUCCESS The security protocol command completed successfully.\r
396 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
397 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
398 @retval EFI_NO_MEDIA There is no media in the device.\r
399 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
400 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.\r
401 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
402 protocol command to execute.\r
403\r
404**/\r
405EFI_STATUS\r
406EFIAPI\r
407NvmeStorageSecuritySendData (\r
408 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
409 IN UINT32 MediaId,\r
410 IN UINT64 Timeout,\r
411 IN UINT8 SecurityProtocolId,\r
412 IN UINT16 SecurityProtocolSpecificData,\r
413 IN UINTN PayloadBufferSize,\r
414 IN VOID *PayloadBuffer\r
415 );\r
416\r
eb290d02 417#endif\r