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