]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / EmmcDxe / EmmcBlockIo.h
CommitLineData
48555339
FT
1/** @file\r
2 Header file for EmmcDxe Driver.\r
3\r
4 This file defines common data structures, macro definitions and some module\r
5 internal function header files.\r
6\r
275d5136 7 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
9d510e61 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
48555339
FT
9\r
10**/\r
11\r
12#ifndef _EMMC_BLOCK_IO_H_\r
13#define _EMMC_BLOCK_IO_H_\r
14\r
15/**\r
16 Reset the Block Device.\r
17\r
18 @param This Indicates a pointer to the calling context.\r
19 @param ExtendedVerification Driver may perform diagnostics on reset.\r
20\r
21 @retval EFI_SUCCESS The device was reset.\r
22 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
23 not be reset.\r
24\r
25**/\r
26EFI_STATUS\r
27EFIAPI\r
28EmmcReset (\r
29 IN EFI_BLOCK_IO_PROTOCOL *This,\r
30 IN BOOLEAN ExtendedVerification\r
31 );\r
32\r
33/**\r
34 Read BufferSize bytes from Lba into Buffer.\r
35\r
36 @param This Indicates a pointer to the calling context.\r
37 @param MediaId Id of the media, changes every time the media is replaced.\r
38 @param Lba The starting Logical Block Address to read from\r
39 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
40 @param Buffer A pointer to the destination buffer for the data. The caller is\r
41 responsible for either having implicit or explicit ownership of the buffer.\r
42\r
43 @retval EFI_SUCCESS The data was read correctly from the device.\r
44 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
45 @retval EFI_NO_MEDIA There is no media in the device.\r
46 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
47 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
48 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
49 or the buffer is not on proper alignment.\r
50\r
51**/\r
52EFI_STATUS\r
53EFIAPI\r
54EmmcReadBlocks (\r
55 IN EFI_BLOCK_IO_PROTOCOL *This,\r
56 IN UINT32 MediaId,\r
57 IN EFI_LBA Lba,\r
58 IN UINTN BufferSize,\r
59 OUT VOID *Buffer\r
60 );\r
61\r
62/**\r
63 Write BufferSize bytes from Lba into Buffer.\r
64\r
65 @param This Indicates a pointer to the calling context.\r
66 @param MediaId The media ID that the write request is for.\r
67 @param Lba The starting logical block address to be written. The caller is\r
68 responsible for writing to only legitimate locations.\r
69 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
70 @param Buffer A pointer to the source buffer for the data.\r
71\r
72 @retval EFI_SUCCESS The data was written correctly to the device.\r
73 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
74 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
75 @retval EFI_NO_MEDIA There is no media in the device.\r
76 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
77 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
78 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
79 or the buffer is not on proper alignment.\r
80\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84EmmcWriteBlocks (\r
85 IN EFI_BLOCK_IO_PROTOCOL *This,\r
86 IN UINT32 MediaId,\r
87 IN EFI_LBA Lba,\r
88 IN UINTN BufferSize,\r
89 IN VOID *Buffer\r
90 );\r
91\r
92/**\r
93 Flush the Block Device.\r
94\r
95 @param This Indicates a pointer to the calling context.\r
96\r
97 @retval EFI_SUCCESS All outstanding data was written to the device\r
98 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
99 @retval EFI_NO_MEDIA There is no media in the device.\r
100\r
101**/\r
102EFI_STATUS\r
103EFIAPI\r
104EmmcFlushBlocks (\r
105 IN EFI_BLOCK_IO_PROTOCOL *This\r
106 );\r
107\r
108/**\r
109 Reset the Block Device.\r
110\r
111 @param[in] This Indicates a pointer to the calling context.\r
112 @param[in] ExtendedVerification Driver may perform diagnostics on reset.\r
113\r
114 @retval EFI_SUCCESS The device was reset.\r
115 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
116 not be reset.\r
117\r
118**/\r
119EFI_STATUS\r
120EFIAPI\r
121EmmcResetEx (\r
122 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
123 IN BOOLEAN ExtendedVerification\r
124 );\r
125\r
126/**\r
127 Read BufferSize bytes from Lba into Buffer.\r
128\r
129 @param[in] This Indicates a pointer to the calling context.\r
130 @param[in] MediaId Id of the media, changes every time the media is replaced.\r
131 @param[in] Lba The starting Logical Block Address to read from.\r
132 @param[in, out] Token A pointer to the token associated with the transaction.\r
133 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
134 @param[out] Buffer A pointer to the destination buffer for the data. The caller is\r
135 responsible for either having implicit or explicit ownership of the buffer.\r
136\r
137 @retval EFI_SUCCESS The read request was queued if Event is not NULL.\r
138 The data was read correctly from the device if\r
139 the Event is NULL.\r
140 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
141 the read.\r
142 @retval EFI_NO_MEDIA There is no media in the device.\r
143 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
144 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
145 intrinsic block size of the device.\r
146 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
147 or the buffer is not on proper alignment.\r
148 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
149 of resources.\r
150\r
151**/\r
152EFI_STATUS\r
153EFIAPI\r
154EmmcReadBlocksEx (\r
155 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
156 IN UINT32 MediaId,\r
157 IN EFI_LBA Lba,\r
158 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
159 IN UINTN BufferSize,\r
160 OUT VOID *Buffer\r
161 );\r
162\r
163/**\r
164 Write BufferSize bytes from Lba into Buffer.\r
165\r
166 @param[in] This Indicates a pointer to the calling context.\r
167 @param[in] MediaId The media ID that the write request is for.\r
168 @param[in] Lba The starting logical block address to be written. The\r
169 caller is responsible for writing to only legitimate\r
170 locations.\r
171 @param[in, out] Token A pointer to the token associated with the transaction.\r
172 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
173 @param[in] Buffer A pointer to the source buffer for the data.\r
174\r
175 @retval EFI_SUCCESS The data was written correctly to the device.\r
176 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
177 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
178 @retval EFI_NO_MEDIA There is no media in the device.\r
179 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
180 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
181 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
182 or the buffer is not on proper alignment.\r
183\r
184**/\r
185EFI_STATUS\r
186EFIAPI\r
187EmmcWriteBlocksEx (\r
188 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
189 IN UINT32 MediaId,\r
190 IN EFI_LBA Lba,\r
191 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
192 IN UINTN BufferSize,\r
193 IN VOID *Buffer\r
194 );\r
195\r
196/**\r
197 Flush the Block Device.\r
198\r
199 @param[in] This Indicates a pointer to the calling context.\r
200 @param[in, out] Token A pointer to the token associated with the transaction.\r
201\r
202 @retval EFI_SUCCESS All outstanding data was written to the device\r
203 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
204 @retval EFI_NO_MEDIA There is no media in the device.\r
205\r
206**/\r
207EFI_STATUS\r
208EFIAPI\r
209EmmcFlushBlocksEx (\r
210 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
211 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
212 );\r
213\r
214/**\r
215 Send a security protocol command to a device that receives data and/or the result\r
216 of one or more commands sent by SendData.\r
217\r
218 The ReceiveData function sends a security protocol command to the given MediaId.\r
219 The security protocol command sent is defined by SecurityProtocolId and contains\r
220 the security protocol specific data SecurityProtocolSpecificData. The function\r
221 returns the data from the security protocol command in PayloadBuffer.\r
222\r
223 For devices supporting the SCSI command set, the security protocol command is sent\r
224 using the SECURITY PROTOCOL IN command defined in SPC-4.\r
225\r
226 For devices supporting the ATA command set, the security protocol command is sent\r
227 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
228 is non-zero.\r
229\r
230 If the PayloadBufferSize is zero, the security protocol command is sent using the\r
231 Trusted Non-Data command defined in ATA8-ACS.\r
232\r
233 If PayloadBufferSize is too small to store the available data from the security\r
234 protocol command, the function shall copy PayloadBufferSize bytes into the\r
235 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
236\r
237 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
238 the function shall return EFI_INVALID_PARAMETER.\r
239\r
240 If the given MediaId does not support security protocol commands, the function shall\r
241 return EFI_UNSUPPORTED. If there is no media in the device, the function returns\r
242 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,\r
243 the function returns EFI_MEDIA_CHANGED.\r
244\r
245 If the security protocol fails to complete within the Timeout period, the function\r
246 shall return EFI_TIMEOUT.\r
247\r
248 If the security protocol command completes without an error, the function shall\r
249 return EFI_SUCCESS. If the security protocol command completes with an error, the\r
250 function shall return EFI_DEVICE_ERROR.\r
251\r
252 @param[in] This Indicates a pointer to the calling context.\r
253 @param[in] MediaId ID of the medium to receive data from.\r
254 @param[in] Timeout The timeout, in 100ns units, to use for the execution\r
255 of the security protocol command. A Timeout value of 0\r
256 means that this function will wait indefinitely for the\r
257 security protocol command to execute. If Timeout is greater\r
258 than zero, then this function will return EFI_TIMEOUT\r
259 if the time required to execute the receive data command\r
260 is greater than Timeout.\r
261 @param[in] SecurityProtocolId The value of the "Security Protocol" parameter of\r
262 the security protocol command to be sent.\r
263 @param[in] SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
264 of the security protocol command to be sent.\r
265 @param[in] PayloadBufferSize Size in bytes of the payload data buffer.\r
266 @param[out] PayloadBuffer A pointer to a destination buffer to store the security\r
267 protocol command specific payload data for the security\r
268 protocol command. The caller is responsible for having\r
269 either implicit or explicit ownership of the buffer.\r
270 @param[out] PayloadTransferSize A pointer to a buffer to store the size in bytes of the\r
271 data written to the payload data buffer.\r
272 @param[in] IsRead Indicates it is a read or write operation.\r
273\r
274 @retval EFI_SUCCESS The security protocol command completed successfully.\r
275 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available\r
276 data from the device. The PayloadBuffer contains the truncated data.\r
277 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
278 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
279 @retval EFI_NO_MEDIA There is no media in the device.\r
280 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
281 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and\r
282 PayloadBufferSize is non-zero.\r
283 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
284 protocol command to execute.\r
285\r
286**/\r
287EFI_STATUS\r
288EFIAPI\r
289EmmcSecurityProtocolInOut (\r
290 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
291 IN UINT32 MediaId,\r
292 IN UINT64 Timeout,\r
293 IN UINT8 SecurityProtocolId,\r
294 IN UINT16 SecurityProtocolSpecificData,\r
295 IN UINTN PayloadBufferSize,\r
296 OUT VOID *PayloadBuffer,\r
297 OUT UINTN *PayloadTransferSize,\r
298 IN BOOLEAN IsRead\r
299 );\r
300\r
301/**\r
302 Send a security protocol command to a device that receives data and/or the result\r
303 of one or more commands sent by SendData.\r
304\r
305 The ReceiveData function sends a security protocol command to the given MediaId.\r
306 The security protocol command sent is defined by SecurityProtocolId and contains\r
307 the security protocol specific data SecurityProtocolSpecificData. The function\r
308 returns the data from the security protocol command in PayloadBuffer.\r
309\r
310 For devices supporting the SCSI command set, the security protocol command is sent\r
311 using the SECURITY PROTOCOL IN command defined in SPC-4.\r
312\r
313 For devices supporting the ATA command set, the security protocol command is sent\r
314 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
315 is non-zero.\r
316\r
317 If the PayloadBufferSize is zero, the security protocol command is sent using the\r
318 Trusted Non-Data command defined in ATA8-ACS.\r
319\r
320 If PayloadBufferSize is too small to store the available data from the security\r
321 protocol command, the function shall copy PayloadBufferSize bytes into the\r
322 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
323\r
324 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
325 the function shall return EFI_INVALID_PARAMETER.\r
326\r
327 If the given MediaId does not support security protocol commands, the function shall\r
328 return EFI_UNSUPPORTED. If there is no media in the device, the function returns\r
329 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,\r
330 the function returns EFI_MEDIA_CHANGED.\r
331\r
332 If the security protocol fails to complete within the Timeout period, the function\r
333 shall return EFI_TIMEOUT.\r
334\r
335 If the security protocol command completes without an error, the function shall\r
336 return EFI_SUCCESS. If the security protocol command completes with an error, the\r
337 function shall return EFI_DEVICE_ERROR.\r
338\r
339 @param This Indicates a pointer to the calling context.\r
340 @param MediaId ID of the medium to receive data from.\r
341 @param Timeout The timeout, in 100ns units, to use for the execution\r
342 of the security protocol command. A Timeout value of 0\r
343 means that this function will wait indefinitely for the\r
344 security protocol command to execute. If Timeout is greater\r
345 than zero, then this function will return EFI_TIMEOUT\r
346 if the time required to execute the receive data command\r
347 is greater than Timeout.\r
348 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
349 the security protocol command to be sent.\r
350 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
351 of the security protocol command to be sent.\r
352 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
353 @param PayloadBuffer A pointer to a destination buffer to store the security\r
354 protocol command specific payload data for the security\r
355 protocol command. The caller is responsible for having\r
356 either implicit or explicit ownership of the buffer.\r
357 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the\r
358 data written to the payload data buffer.\r
359\r
360 @retval EFI_SUCCESS The security protocol command completed successfully.\r
361 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available\r
362 data from the device. The PayloadBuffer contains the truncated data.\r
363 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
364 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
365 @retval EFI_NO_MEDIA There is no media in the device.\r
366 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
367 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and\r
368 PayloadBufferSize is non-zero.\r
369 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
370 protocol command to execute.\r
371\r
372**/\r
373EFI_STATUS\r
374EFIAPI\r
375EmmcSecurityProtocolIn (\r
376 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
377 IN UINT32 MediaId,\r
378 IN UINT64 Timeout,\r
379 IN UINT8 SecurityProtocolId,\r
380 IN UINT16 SecurityProtocolSpecificData,\r
381 IN UINTN PayloadBufferSize,\r
382 OUT VOID *PayloadBuffer,\r
383 OUT UINTN *PayloadTransferSize\r
384 );\r
385\r
386/**\r
387 Send a security protocol command to a device.\r
388\r
389 The SendData function sends a security protocol command containing the payload\r
390 PayloadBuffer to the given MediaId. The security protocol command sent is\r
391 defined by SecurityProtocolId and contains the security protocol specific data\r
392 SecurityProtocolSpecificData. If the underlying protocol command requires a\r
393 specific padding for the command payload, the SendData function shall add padding\r
394 bytes to the command payload to satisfy the padding requirements.\r
395\r
396 For devices supporting the SCSI command set, the security protocol command is sent\r
397 using the SECURITY PROTOCOL OUT command defined in SPC-4.\r
398\r
399 For devices supporting the ATA command set, the security protocol command is sent\r
400 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize\r
401 is non-zero. If the PayloadBufferSize is zero, the security protocol command is\r
402 sent using the Trusted Non-Data command defined in ATA8-ACS.\r
403\r
404 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall\r
405 return EFI_INVALID_PARAMETER.\r
406\r
407 If the given MediaId does not support security protocol commands, the function\r
408 shall return EFI_UNSUPPORTED. If there is no media in the device, the function\r
409 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the\r
410 device, the function returns EFI_MEDIA_CHANGED.\r
411\r
412 If the security protocol fails to complete within the Timeout period, the function\r
413 shall return EFI_TIMEOUT.\r
414\r
415 If the security protocol command completes without an error, the function shall return\r
416 EFI_SUCCESS. If the security protocol command completes with an error, the function\r
417 shall return EFI_DEVICE_ERROR.\r
418\r
419 @param This Indicates a pointer to the calling context.\r
420 @param MediaId ID of the medium to receive data from.\r
421 @param Timeout The timeout, in 100ns units, to use for the execution\r
422 of the security protocol command. A Timeout value of 0\r
423 means that this function will wait indefinitely for the\r
424 security protocol command to execute. If Timeout is greater\r
425 than zero, then this function will return EFI_TIMEOUT\r
426 if the time required to execute the receive data command\r
427 is greater than Timeout.\r
428 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
429 the security protocol command to be sent.\r
430 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
431 of the security protocol command to be sent.\r
432 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
433 @param PayloadBuffer A pointer to a destination buffer to store the security\r
434 protocol command specific payload data for the security\r
435 protocol command.\r
436\r
437 @retval EFI_SUCCESS The security protocol command completed successfully.\r
438 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
439 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
440 @retval EFI_NO_MEDIA There is no media in the device.\r
441 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
442 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.\r
443 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
444 protocol command to execute.\r
445\r
446**/\r
447EFI_STATUS\r
448EFIAPI\r
449EmmcSecurityProtocolOut (\r
450 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
451 IN UINT32 MediaId,\r
452 IN UINT64 Timeout,\r
453 IN UINT8 SecurityProtocolId,\r
454 IN UINT16 SecurityProtocolSpecificData,\r
455 IN UINTN PayloadBufferSize,\r
456 IN VOID *PayloadBuffer\r
457 );\r
458\r
275d5136
FT
459/**\r
460 Erase a specified number of device blocks.\r
461\r
462 @param[in] This Indicates a pointer to the calling context.\r
463 @param[in] MediaId The media ID that the erase request is for.\r
464 @param[in] Lba The starting logical block address to be\r
465 erased. The caller is responsible for erasing\r
466 only legitimate locations.\r
467 @param[in, out] Token A pointer to the token associated with the\r
468 transaction.\r
469 @param[in] Size The size in bytes to be erased. This must be\r
470 a multiple of the physical block size of the\r
471 device.\r
472\r
473 @retval EFI_SUCCESS The erase request was queued if Event is not\r
474 NULL. The data was erased correctly to the\r
475 device if the Event is NULL.to the device.\r
476 @retval EFI_WRITE_PROTECTED The device cannot be erased due to write\r
477 protection.\r
478 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
479 to perform the erase operation.\r
480 @retval EFI_INVALID_PARAMETER The erase request contains LBAs that are not\r
481 valid.\r
482 @retval EFI_NO_MEDIA There is no media in the device.\r
483 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
484\r
485**/\r
486EFI_STATUS\r
487EFIAPI\r
488EmmcEraseBlocks (\r
489 IN EFI_ERASE_BLOCK_PROTOCOL *This,\r
490 IN UINT32 MediaId,\r
491 IN EFI_LBA Lba,\r
492 IN OUT EFI_ERASE_BLOCK_TOKEN *Token,\r
493 IN UINTN Size\r
494 );\r
495\r
48555339
FT
496#endif\r
497\r