2 Header file for EmmcDxe Driver.
4 This file defines common data structures, macro definitions and some module
5 internal function header files.
7 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef _EMMC_BLOCK_IO_H_
19 #define _EMMC_BLOCK_IO_H_
22 Reset the Block Device.
24 @param This Indicates a pointer to the calling context.
25 @param ExtendedVerification Driver may perform diagnostics on reset.
27 @retval EFI_SUCCESS The device was reset.
28 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
35 IN EFI_BLOCK_IO_PROTOCOL
*This
,
36 IN BOOLEAN ExtendedVerification
40 Read BufferSize bytes from Lba into Buffer.
42 @param This Indicates a pointer to the calling context.
43 @param MediaId Id of the media, changes every time the media is replaced.
44 @param Lba The starting Logical Block Address to read from
45 @param BufferSize Size of Buffer, must be a multiple of device block size.
46 @param Buffer A pointer to the destination buffer for the data. The caller is
47 responsible for either having implicit or explicit ownership of the buffer.
49 @retval EFI_SUCCESS The data was read correctly from the device.
50 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
51 @retval EFI_NO_MEDIA There is no media in the device.
52 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
53 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
54 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
55 or the buffer is not on proper alignment.
61 IN EFI_BLOCK_IO_PROTOCOL
*This
,
69 Write BufferSize bytes from Lba into Buffer.
71 @param This Indicates a pointer to the calling context.
72 @param MediaId The media ID that the write request is for.
73 @param Lba The starting logical block address to be written. The caller is
74 responsible for writing to only legitimate locations.
75 @param BufferSize Size of Buffer, must be a multiple of device block size.
76 @param Buffer A pointer to the source buffer for the data.
78 @retval EFI_SUCCESS The data was written correctly to the device.
79 @retval EFI_WRITE_PROTECTED The device can not be written to.
80 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
81 @retval EFI_NO_MEDIA There is no media in the device.
82 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
83 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
84 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
85 or the buffer is not on proper alignment.
91 IN EFI_BLOCK_IO_PROTOCOL
*This
,
99 Flush the Block Device.
101 @param This Indicates a pointer to the calling context.
103 @retval EFI_SUCCESS All outstanding data was written to the device
104 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data
105 @retval EFI_NO_MEDIA There is no media in the device.
111 IN EFI_BLOCK_IO_PROTOCOL
*This
115 Reset the Block Device.
117 @param[in] This Indicates a pointer to the calling context.
118 @param[in] ExtendedVerification Driver may perform diagnostics on reset.
120 @retval EFI_SUCCESS The device was reset.
121 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
128 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
129 IN BOOLEAN ExtendedVerification
133 Read BufferSize bytes from Lba into Buffer.
135 @param[in] This Indicates a pointer to the calling context.
136 @param[in] MediaId Id of the media, changes every time the media is replaced.
137 @param[in] Lba The starting Logical Block Address to read from.
138 @param[in, out] Token A pointer to the token associated with the transaction.
139 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
140 @param[out] Buffer A pointer to the destination buffer for the data. The caller is
141 responsible for either having implicit or explicit ownership of the buffer.
143 @retval EFI_SUCCESS The read request was queued if Event is not NULL.
144 The data was read correctly from the device if
146 @retval EFI_DEVICE_ERROR The device reported an error while performing
148 @retval EFI_NO_MEDIA There is no media in the device.
149 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
150 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
151 intrinsic block size of the device.
152 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
153 or the buffer is not on proper alignment.
154 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
161 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
164 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
170 Write BufferSize bytes from Lba into Buffer.
172 @param[in] This Indicates a pointer to the calling context.
173 @param[in] MediaId The media ID that the write request is for.
174 @param[in] Lba The starting logical block address to be written. The
175 caller is responsible for writing to only legitimate
177 @param[in, out] Token A pointer to the token associated with the transaction.
178 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
179 @param[in] Buffer A pointer to the source buffer for the data.
181 @retval EFI_SUCCESS The data was written correctly to the device.
182 @retval EFI_WRITE_PROTECTED The device can not be written to.
183 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
184 @retval EFI_NO_MEDIA There is no media in the device.
185 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
186 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
187 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
188 or the buffer is not on proper alignment.
194 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
197 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
203 Flush the Block Device.
205 @param[in] This Indicates a pointer to the calling context.
206 @param[in, out] Token A pointer to the token associated with the transaction.
208 @retval EFI_SUCCESS All outstanding data was written to the device
209 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data
210 @retval EFI_NO_MEDIA There is no media in the device.
216 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
217 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
221 Send a security protocol command to a device that receives data and/or the result
222 of one or more commands sent by SendData.
224 The ReceiveData function sends a security protocol command to the given MediaId.
225 The security protocol command sent is defined by SecurityProtocolId and contains
226 the security protocol specific data SecurityProtocolSpecificData. The function
227 returns the data from the security protocol command in PayloadBuffer.
229 For devices supporting the SCSI command set, the security protocol command is sent
230 using the SECURITY PROTOCOL IN command defined in SPC-4.
232 For devices supporting the ATA command set, the security protocol command is sent
233 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
236 If the PayloadBufferSize is zero, the security protocol command is sent using the
237 Trusted Non-Data command defined in ATA8-ACS.
239 If PayloadBufferSize is too small to store the available data from the security
240 protocol command, the function shall copy PayloadBufferSize bytes into the
241 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
243 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
244 the function shall return EFI_INVALID_PARAMETER.
246 If the given MediaId does not support security protocol commands, the function shall
247 return EFI_UNSUPPORTED. If there is no media in the device, the function returns
248 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
249 the function returns EFI_MEDIA_CHANGED.
251 If the security protocol fails to complete within the Timeout period, the function
252 shall return EFI_TIMEOUT.
254 If the security protocol command completes without an error, the function shall
255 return EFI_SUCCESS. If the security protocol command completes with an error, the
256 function shall return EFI_DEVICE_ERROR.
258 @param[in] This Indicates a pointer to the calling context.
259 @param[in] MediaId ID of the medium to receive data from.
260 @param[in] Timeout The timeout, in 100ns units, to use for the execution
261 of the security protocol command. A Timeout value of 0
262 means that this function will wait indefinitely for the
263 security protocol command to execute. If Timeout is greater
264 than zero, then this function will return EFI_TIMEOUT
265 if the time required to execute the receive data command
266 is greater than Timeout.
267 @param[in] SecurityProtocolId The value of the "Security Protocol" parameter of
268 the security protocol command to be sent.
269 @param[in] SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
270 of the security protocol command to be sent.
271 @param[in] PayloadBufferSize Size in bytes of the payload data buffer.
272 @param[out] PayloadBuffer A pointer to a destination buffer to store the security
273 protocol command specific payload data for the security
274 protocol command. The caller is responsible for having
275 either implicit or explicit ownership of the buffer.
276 @param[out] PayloadTransferSize A pointer to a buffer to store the size in bytes of the
277 data written to the payload data buffer.
278 @param[in] IsRead Indicates it is a read or write operation.
280 @retval EFI_SUCCESS The security protocol command completed successfully.
281 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
282 data from the device. The PayloadBuffer contains the truncated data.
283 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
284 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
285 @retval EFI_NO_MEDIA There is no media in the device.
286 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
287 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
288 PayloadBufferSize is non-zero.
289 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
290 protocol command to execute.
295 EmmcSecurityProtocolInOut (
296 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
*This
,
299 IN UINT8 SecurityProtocolId
,
300 IN UINT16 SecurityProtocolSpecificData
,
301 IN UINTN PayloadBufferSize
,
302 OUT VOID
*PayloadBuffer
,
303 OUT UINTN
*PayloadTransferSize
,
308 Send a security protocol command to a device that receives data and/or the result
309 of one or more commands sent by SendData.
311 The ReceiveData function sends a security protocol command to the given MediaId.
312 The security protocol command sent is defined by SecurityProtocolId and contains
313 the security protocol specific data SecurityProtocolSpecificData. The function
314 returns the data from the security protocol command in PayloadBuffer.
316 For devices supporting the SCSI command set, the security protocol command is sent
317 using the SECURITY PROTOCOL IN command defined in SPC-4.
319 For devices supporting the ATA command set, the security protocol command is sent
320 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
323 If the PayloadBufferSize is zero, the security protocol command is sent using the
324 Trusted Non-Data command defined in ATA8-ACS.
326 If PayloadBufferSize is too small to store the available data from the security
327 protocol command, the function shall copy PayloadBufferSize bytes into the
328 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
330 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
331 the function shall return EFI_INVALID_PARAMETER.
333 If the given MediaId does not support security protocol commands, the function shall
334 return EFI_UNSUPPORTED. If there is no media in the device, the function returns
335 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
336 the function returns EFI_MEDIA_CHANGED.
338 If the security protocol fails to complete within the Timeout period, the function
339 shall return EFI_TIMEOUT.
341 If the security protocol command completes without an error, the function shall
342 return EFI_SUCCESS. If the security protocol command completes with an error, the
343 function shall return EFI_DEVICE_ERROR.
345 @param This Indicates a pointer to the calling context.
346 @param MediaId ID of the medium to receive data from.
347 @param Timeout The timeout, in 100ns units, to use for the execution
348 of the security protocol command. A Timeout value of 0
349 means that this function will wait indefinitely for the
350 security protocol command to execute. If Timeout is greater
351 than zero, then this function will return EFI_TIMEOUT
352 if the time required to execute the receive data command
353 is greater than Timeout.
354 @param SecurityProtocolId The value of the "Security Protocol" parameter of
355 the security protocol command to be sent.
356 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
357 of the security protocol command to be sent.
358 @param PayloadBufferSize Size in bytes of the payload data buffer.
359 @param PayloadBuffer A pointer to a destination buffer to store the security
360 protocol command specific payload data for the security
361 protocol command. The caller is responsible for having
362 either implicit or explicit ownership of the buffer.
363 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the
364 data written to the payload data buffer.
366 @retval EFI_SUCCESS The security protocol command completed successfully.
367 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
368 data from the device. The PayloadBuffer contains the truncated data.
369 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
370 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
371 @retval EFI_NO_MEDIA There is no media in the device.
372 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
373 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
374 PayloadBufferSize is non-zero.
375 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
376 protocol command to execute.
381 EmmcSecurityProtocolIn (
382 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
*This
,
385 IN UINT8 SecurityProtocolId
,
386 IN UINT16 SecurityProtocolSpecificData
,
387 IN UINTN PayloadBufferSize
,
388 OUT VOID
*PayloadBuffer
,
389 OUT UINTN
*PayloadTransferSize
393 Send a security protocol command to a device.
395 The SendData function sends a security protocol command containing the payload
396 PayloadBuffer to the given MediaId. The security protocol command sent is
397 defined by SecurityProtocolId and contains the security protocol specific data
398 SecurityProtocolSpecificData. If the underlying protocol command requires a
399 specific padding for the command payload, the SendData function shall add padding
400 bytes to the command payload to satisfy the padding requirements.
402 For devices supporting the SCSI command set, the security protocol command is sent
403 using the SECURITY PROTOCOL OUT command defined in SPC-4.
405 For devices supporting the ATA command set, the security protocol command is sent
406 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
407 is non-zero. If the PayloadBufferSize is zero, the security protocol command is
408 sent using the Trusted Non-Data command defined in ATA8-ACS.
410 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
411 return EFI_INVALID_PARAMETER.
413 If the given MediaId does not support security protocol commands, the function
414 shall return EFI_UNSUPPORTED. If there is no media in the device, the function
415 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the
416 device, the function returns EFI_MEDIA_CHANGED.
418 If the security protocol fails to complete within the Timeout period, the function
419 shall return EFI_TIMEOUT.
421 If the security protocol command completes without an error, the function shall return
422 EFI_SUCCESS. If the security protocol command completes with an error, the function
423 shall return EFI_DEVICE_ERROR.
425 @param This Indicates a pointer to the calling context.
426 @param MediaId ID of the medium to receive data from.
427 @param Timeout The timeout, in 100ns units, to use for the execution
428 of the security protocol command. A Timeout value of 0
429 means that this function will wait indefinitely for the
430 security protocol command to execute. If Timeout is greater
431 than zero, then this function will return EFI_TIMEOUT
432 if the time required to execute the receive data command
433 is greater than Timeout.
434 @param SecurityProtocolId The value of the "Security Protocol" parameter of
435 the security protocol command to be sent.
436 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
437 of the security protocol command to be sent.
438 @param PayloadBufferSize Size in bytes of the payload data buffer.
439 @param PayloadBuffer A pointer to a destination buffer to store the security
440 protocol command specific payload data for the security
443 @retval EFI_SUCCESS The security protocol command completed successfully.
444 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
445 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.
446 @retval EFI_NO_MEDIA There is no media in the device.
447 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
448 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.
449 @retval EFI_TIMEOUT A timeout occurred while waiting for the security
450 protocol command to execute.
455 EmmcSecurityProtocolOut (
456 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
*This
,
459 IN UINT8 SecurityProtocolId
,
460 IN UINT16 SecurityProtocolSpecificData
,
461 IN UINTN PayloadBufferSize
,
462 IN VOID
*PayloadBuffer
466 Erase a specified number of device blocks.
468 @param[in] This Indicates a pointer to the calling context.
469 @param[in] MediaId The media ID that the erase request is for.
470 @param[in] Lba The starting logical block address to be
471 erased. The caller is responsible for erasing
472 only legitimate locations.
473 @param[in, out] Token A pointer to the token associated with the
475 @param[in] Size The size in bytes to be erased. This must be
476 a multiple of the physical block size of the
479 @retval EFI_SUCCESS The erase request was queued if Event is not
480 NULL. The data was erased correctly to the
481 device if the Event is NULL.to the device.
482 @retval EFI_WRITE_PROTECTED The device cannot be erased due to write
484 @retval EFI_DEVICE_ERROR The device reported an error while attempting
485 to perform the erase operation.
486 @retval EFI_INVALID_PARAMETER The erase request contains LBAs that are not
488 @retval EFI_NO_MEDIA There is no media in the device.
489 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
495 IN EFI_ERASE_BLOCK_PROTOCOL
*This
,
498 IN OUT EFI_ERASE_BLOCK_TOKEN
*Token
,