TianoCore EDK2 master
|
#include "SdDxe.h"
Go to the source code of this file.
The helper functions for BlockIo and BlockIo2 protocol.
Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SdBlockIo.c.
Nonblocking I/O callback function when the event is signaled.
[in] | Event | The Event this notify function registered to. |
[in] | Context | Pointer to the context data registered to the Event. |
Definition at line 21 of file SdBlockIo.c.
EFI_STATUS SdEraseBlock | ( | IN SD_DEVICE * | Device, |
IN EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN BOOLEAN | IsEnd | ||
) |
Erase specified blocks through sync or async I/O request.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Token | A pointer to the token associated with the transaction. |
[in] | IsEnd | A boolean to show whether it's the last cmd in a series of cmds. This parameter is only meaningful in async I/O request. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 1219 of file SdBlockIo.c.
EFI_STATUS SdEraseBlockEnd | ( | IN SD_DEVICE * | Device, |
IN EFI_LBA | EndLba, | ||
IN EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN BOOLEAN | IsEnd | ||
) |
Set the erase end address through sync or async I/O request.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | EndLba | The ending logical block address to be erased. |
[in] | Token | A pointer to the token associated with the transaction. |
[in] | IsEnd | A boolean to show whether it's the last cmd in a series of cmds. This parameter is only meaningful in async I/O request. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 1115 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdEraseBlocks | ( | IN EFI_ERASE_BLOCK_PROTOCOL * | This, |
IN UINT32 | MediaId, | ||
IN EFI_LBA | Lba, | ||
IN OUT EFI_ERASE_BLOCK_TOKEN * | Token, | ||
IN UINTN | Size | ||
) |
Erase a specified number of device blocks.
[in] | This | Indicates a pointer to the calling context. |
[in] | MediaId | The media ID that the erase request is for. |
[in] | Lba | The starting logical block address to be erased. The caller is responsible for erasing only legitimate locations. |
[in,out] | Token | A pointer to the token associated with the transaction. |
[in] | Size | The size in bytes to be erased. This must be a multiple of the physical block size of the device. |
EFI_SUCCESS | The erase request was queued if Event is not NULL. The data was erased correctly to the device if the Event is NULL.to the device. |
EFI_WRITE_PROTECTED | The device cannot be erased due to write protection. |
EFI_DEVICE_ERROR | The device reported an error while attempting to perform the erase operation. |
EFI_INVALID_PARAMETER | The erase request contains LBAs that are not valid. |
EFI_NO_MEDIA | There is no media in the device. |
EFI_MEDIA_CHANGED | The MediaId is not for the current media. |
Definition at line 1331 of file SdBlockIo.c.
EFI_STATUS SdEraseBlockStart | ( | IN SD_DEVICE * | Device, |
IN EFI_LBA | StartLba, | ||
IN EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN BOOLEAN | IsEnd | ||
) |
Set the erase start address through sync or async I/O request.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | StartLba | The starting logical block address to be erased. |
[in] | Token | A pointer to the token associated with the transaction. |
[in] | IsEnd | A boolean to show whether it's the last cmd in a series of cmds. This parameter is only meaningful in async I/O request. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 1010 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdFlushBlocks | ( | IN EFI_BLOCK_IO_PROTOCOL * | This | ) |
Flush the Block Device.
This | Indicates a pointer to the calling context. |
EFI_SUCCESS | All outstanding data was written to the device |
EFI_DEVICE_ERROR | The device reported an error while writing back the data |
EFI_NO_MEDIA | There is no media in the device. |
Definition at line 817 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdFlushBlocksEx | ( | IN EFI_BLOCK_IO2_PROTOCOL * | This, |
IN OUT EFI_BLOCK_IO2_TOKEN * | Token | ||
) |
Flush the Block Device.
[in] | This | Indicates a pointer to the calling context. |
[in,out] | Token | A pointer to the token associated with the transaction. |
EFI_SUCCESS | All outstanding data was written to the device |
EFI_DEVICE_ERROR | The device reported an error while writing back the data |
EFI_NO_MEDIA | There is no media in the device. |
Definition at line 979 of file SdBlockIo.c.
Send command SEND_CID to the device to get the CID register data.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Rca | The relative device address to use. |
[out] | Cid | The buffer to store the SD_CID register data. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 258 of file SdBlockIo.c.
Send command SEND_CSD to the device to get the CSD register data.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Rca | The relative device address to use. |
[out] | Csd | The buffer to store the SD_CSD register data. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 205 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdReadBlocks | ( | IN EFI_BLOCK_IO_PROTOCOL * | This, |
IN UINT32 | MediaId, | ||
IN EFI_LBA | Lba, | ||
IN UINTN | BufferSize, | ||
OUT VOID * | Buffer | ||
) |
Read BufferSize bytes from Lba into Buffer.
This | Indicates a pointer to the calling context. |
MediaId | Id of the media, changes every time the media is replaced. |
Lba | The starting Logical Block Address to read from |
BufferSize | Size of Buffer, must be a multiple of device block size. |
Buffer | A pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer. |
EFI_SUCCESS | The data was read correctly from the device. |
EFI_DEVICE_ERROR | The device reported an error while performing the read. |
EFI_NO_MEDIA | There is no media in the device. |
EFI_MEDIA_CHANGED | The MediaId does not match the current device. |
EFI_BAD_BUFFER_SIZE | The Buffer was not a multiple of the block size of the device. |
EFI_INVALID_PARAMETER | The read request contains LBAs that are not valid, or the buffer is not on proper alignment. |
Definition at line 749 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdReadBlocksEx | ( | IN EFI_BLOCK_IO2_PROTOCOL * | This, |
IN UINT32 | MediaId, | ||
IN EFI_LBA | Lba, | ||
IN OUT EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN UINTN | BufferSize, | ||
OUT VOID * | Buffer | ||
) |
Read BufferSize bytes from Lba into Buffer.
[in] | This | Indicates a pointer to the calling context. |
[in] | MediaId | Id of the media, changes every time the media is replaced. |
[in] | Lba | The starting Logical Block Address to read from. |
[in,out] | Token | A pointer to the token associated with the transaction. |
[in] | BufferSize | Size of Buffer, must be a multiple of device block size. |
[out] | Buffer | A pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer. |
EFI_SUCCESS | The read request was queued if Event is not NULL. The data was read correctly from the device if the Event is NULL. |
EFI_DEVICE_ERROR | The device reported an error while performing the read. |
EFI_NO_MEDIA | There is no media in the device. |
EFI_MEDIA_CHANGED | The MediaId is not for the current media. |
EFI_BAD_BUFFER_SIZE | The BufferSize parameter is not a multiple of the intrinsic block size of the device. |
EFI_INVALID_PARAMETER | The read request contains LBAs that are not valid, or the buffer is not on proper alignment. |
EFI_OUT_OF_RESOURCES | The request could not be completed due to a lack of resources. |
Definition at line 906 of file SdBlockIo.c.
EFI_STATUS SdReadWrite | ( | IN SD_DEVICE * | Device, |
IN UINT32 | MediaId, | ||
IN EFI_LBA | Lba, | ||
IN OUT VOID * | Buffer, | ||
IN UINTN | BufferSize, | ||
IN BOOLEAN | IsRead, | ||
IN OUT EFI_BLOCK_IO2_TOKEN * | Token | ||
) |
This function transfers data from/to the sd memory card device.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | MediaId | The media ID that the read/write request is for. |
[in] | Lba | The starting logical block address to be read/written. The caller is responsible for reading/writing to only legitimate locations. |
[in,out] | Buffer | A pointer to the destination/source buffer for the data. |
[in] | BufferSize | Size of Buffer, must be a multiple of device block size. |
[in] | IsRead | Indicates it is a read or write operation. |
[in,out] | Token | A pointer to the token associated with the transaction. |
EFI_SUCCESS | The data was read/written correctly to the device. |
EFI_WRITE_PROTECTED | The device can not be read/written to. |
EFI_DEVICE_ERROR | The device reported an error while performing the read/write. |
EFI_NO_MEDIA | There is no media in the device. |
EFI_MEDIA_CHANGED | The MediaId does not match the current device. |
EFI_BAD_BUFFER_SIZE | The Buffer was not a multiple of the block size of the device. |
EFI_INVALID_PARAMETER | The read/write request contains LBAs that are not valid, or the buffer is not on proper alignment. |
Definition at line 587 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdReset | ( | IN EFI_BLOCK_IO_PROTOCOL * | This, |
IN BOOLEAN | ExtendedVerification | ||
) |
Reset the Block Device.
This | Indicates a pointer to the calling context. |
ExtendedVerification | Driver may perform diagnostics on reset. |
EFI_SUCCESS | The device was reset. |
EFI_DEVICE_ERROR | The device is not functioning properly and could not be reset. |
Definition at line 708 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdResetEx | ( | IN EFI_BLOCK_IO2_PROTOCOL * | This, |
IN BOOLEAN | ExtendedVerification | ||
) |
Reset the Block Device.
[in] | This | Indicates a pointer to the calling context. |
[in] | ExtendedVerification | Driver may perform diagnostics on reset. |
EFI_SUCCESS | The device was reset. |
EFI_DEVICE_ERROR | The device is not functioning properly and could not be reset. |
Definition at line 840 of file SdBlockIo.c.
EFI_STATUS SdRwMultiBlocks | ( | IN SD_DEVICE * | Device, |
IN EFI_LBA | Lba, | ||
IN VOID * | Buffer, | ||
IN UINTN | BufferSize, | ||
IN BOOLEAN | IsRead, | ||
IN EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN BOOLEAN | IsEnd | ||
) |
Read/write multiple blocks through sync or async I/O request.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Lba | The starting logical block address to be read/written. The caller is responsible for reading/writing to only legitimate locations. |
[in] | Buffer | A pointer to the destination/source buffer for the data. |
[in] | BufferSize | Size of Buffer, must be a multiple of device block size. |
[in] | IsRead | Indicates it is a read or write operation. |
[in] | Token | A pointer to the token associated with the transaction. |
[in] | IsEnd | A boolean to show whether it's the last cmd in a series of cmds. This parameter is only meaningful in async I/O request. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 450 of file SdBlockIo.c.
EFI_STATUS SdRwSingleBlock | ( | IN SD_DEVICE * | Device, |
IN EFI_LBA | Lba, | ||
IN VOID * | Buffer, | ||
IN UINTN | BufferSize, | ||
IN BOOLEAN | IsRead, | ||
IN EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN BOOLEAN | IsEnd | ||
) |
Read/write single block through sync or async I/O request.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Lba | The starting logical block address to be read/written. The caller is responsible for reading/writing to only legitimate locations. |
[in] | Buffer | A pointer to the destination/source buffer for the data. |
[in] | BufferSize | Size of Buffer, must be a multiple of device block size. |
[in] | IsRead | Indicates it is a read or write operation. |
[in] | Token | A pointer to the token associated with the transaction. |
[in] | IsEnd | A boolean to show whether it's the last cmd in a series of cmds. This parameter is only meaningful in async I/O request. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 318 of file SdBlockIo.c.
EFI_STATUS SdSelect | ( | IN SD_DEVICE * | Device, |
IN UINT16 | Rca | ||
) |
Send command SELECT to the device to select/deselect the device.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Rca | The relative device address to use. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 112 of file SdBlockIo.c.
EFI_STATUS SdSendStatus | ( | IN SD_DEVICE * | Device, |
IN UINT16 | Rca, | ||
OUT UINT32 * | DevStatus | ||
) |
Send command SEND_STATUS to the device to get device status.
[in] | Device | A pointer to the SD_DEVICE instance. |
[in] | Rca | The relative device address to use. |
[out] | DevStatus | The buffer to store the device status. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 158 of file SdBlockIo.c.
EFI_STATUS SdSetRca | ( | IN SD_DEVICE * | Device, |
OUT UINT16 * | Rca | ||
) |
Send command SET_RELATIVE_ADDRESS to the device to set the device address.
[in] | Device | A pointer to the SD_DEVICE instance. |
[out] | Rca | The relative device address to assign. |
EFI_SUCCESS | The request is executed successfully. |
EFI_OUT_OF_RESOURCES | The request could not be executed due to a lack of resources. |
Others | The request could not be executed successfully. |
Definition at line 67 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdWriteBlocks | ( | IN EFI_BLOCK_IO_PROTOCOL * | This, |
IN UINT32 | MediaId, | ||
IN EFI_LBA | Lba, | ||
IN UINTN | BufferSize, | ||
IN VOID * | Buffer | ||
) |
Write BufferSize bytes from Lba into Buffer.
This | Indicates a pointer to the calling context. |
MediaId | The media ID that the write request is for. |
Lba | The starting logical block address to be written. The caller is responsible for writing to only legitimate locations. |
BufferSize | Size of Buffer, must be a multiple of device block size. |
Buffer | A pointer to the source buffer for the data. |
EFI_SUCCESS | The data was written correctly to the device. |
EFI_WRITE_PROTECTED | The device can not be written to. |
EFI_DEVICE_ERROR | The device reported an error while performing the write. |
EFI_NO_MEDIA | There is no media in the device. |
EFI_MEDIA_CHANGED | The MediaId does not match the current device. |
EFI_BAD_BUFFER_SIZE | The Buffer was not a multiple of the block size of the device. |
EFI_INVALID_PARAMETER | The write request contains LBAs that are not valid, or the buffer is not on proper alignment. |
Definition at line 788 of file SdBlockIo.c.
EFI_STATUS EFIAPI SdWriteBlocksEx | ( | IN EFI_BLOCK_IO2_PROTOCOL * | This, |
IN UINT32 | MediaId, | ||
IN EFI_LBA | Lba, | ||
IN OUT EFI_BLOCK_IO2_TOKEN * | Token, | ||
IN UINTN | BufferSize, | ||
IN VOID * | Buffer | ||
) |
Write BufferSize bytes from Lba into Buffer.
[in] | This | Indicates a pointer to the calling context. |
[in] | MediaId | The media ID that the write request is for. |
[in] | Lba | The starting logical block address to be written. The caller is responsible for writing to only legitimate locations. |
[in,out] | Token | A pointer to the token associated with the transaction. |
[in] | BufferSize | Size of Buffer, must be a multiple of device block size. |
[in] | Buffer | A pointer to the source buffer for the data. |
EFI_SUCCESS | The data was written correctly to the device. |
EFI_WRITE_PROTECTED | The device can not be written to. |
EFI_DEVICE_ERROR | The device reported an error while performing the write. |
EFI_NO_MEDIA | There is no media in the device. |
EFI_MEDIA_CHANGED | The MediaId does not match the current device. |
EFI_BAD_BUFFER_SIZE | The Buffer was not a multiple of the block size of the device. |
EFI_INVALID_PARAMETER | The write request contains LBAs that are not valid, or the buffer is not on proper alignment. |
Definition at line 948 of file SdBlockIo.c.