1 /** @file 2 Header file for SdDxe Driver. 3 4 This file defines common data structures, macro definitions and some module 5 internal function header files. 6 7 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> 8 SPDX-License-Identifier: BSD-2-Clause-Patent 9 10 **/ 11 12 #ifndef _SD_BLOCK_IO_H_ 13 #define _SD_BLOCK_IO_H_ 14 15 /** 16 Reset the Block Device. 17 18 @param This Indicates a pointer to the calling context. 19 @param ExtendedVerification Driver may perform diagnostics on reset. 20 21 @retval EFI_SUCCESS The device was reset. 22 @retval EFI_DEVICE_ERROR The device is not functioning properly and could 23 not be reset. 24 25 **/ 26 EFI_STATUS 27 EFIAPI 28 SdReset ( 29 IN EFI_BLOCK_IO_PROTOCOL *This, 30 IN BOOLEAN ExtendedVerification 31 ); 32 33 /** 34 Read BufferSize bytes from Lba into Buffer. 35 36 @param This Indicates a pointer to the calling context. 37 @param MediaId Id of the media, changes every time the media is replaced. 38 @param Lba The starting Logical Block Address to read from 39 @param BufferSize Size of Buffer, must be a multiple of device block size. 40 @param Buffer A pointer to the destination buffer for the data. The caller is 41 responsible for either having implicit or explicit ownership of the buffer. 42 43 @retval EFI_SUCCESS The data was read correctly from the device. 44 @retval EFI_DEVICE_ERROR The device reported an error while performing the read. 45 @retval EFI_NO_MEDIA There is no media in the device. 46 @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. 47 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device. 48 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, 49 or the buffer is not on proper alignment. 50 51 **/ 52 EFI_STATUS 53 EFIAPI 54 SdReadBlocks ( 55 IN EFI_BLOCK_IO_PROTOCOL *This, 56 IN UINT32 MediaId, 57 IN EFI_LBA Lba, 58 IN UINTN BufferSize, 59 OUT VOID *Buffer 60 ); 61 62 /** 63 Write BufferSize bytes from Lba into Buffer. 64 65 @param This Indicates a pointer to the calling context. 66 @param MediaId The media ID that the write request is for. 67 @param Lba The starting logical block address to be written. The caller is 68 responsible for writing to only legitimate locations. 69 @param BufferSize Size of Buffer, must be a multiple of device block size. 70 @param Buffer A pointer to the source buffer for the data. 71 72 @retval EFI_SUCCESS The data was written correctly to the device. 73 @retval EFI_WRITE_PROTECTED The device can not be written to. 74 @retval EFI_DEVICE_ERROR The device reported an error while performing the write. 75 @retval EFI_NO_MEDIA There is no media in the device. 76 @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. 77 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device. 78 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, 79 or the buffer is not on proper alignment. 80 81 **/ 82 EFI_STATUS 83 EFIAPI 84 SdWriteBlocks ( 85 IN EFI_BLOCK_IO_PROTOCOL *This, 86 IN UINT32 MediaId, 87 IN EFI_LBA Lba, 88 IN UINTN BufferSize, 89 IN VOID *Buffer 90 ); 91 92 /** 93 Flush the Block Device. 94 95 @param This Indicates a pointer to the calling context. 96 97 @retval EFI_SUCCESS All outstanding data was written to the device 98 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data 99 @retval EFI_NO_MEDIA There is no media in the device. 100 101 **/ 102 EFI_STATUS 103 EFIAPI 104 SdFlushBlocks ( 105 IN EFI_BLOCK_IO_PROTOCOL *This 106 ); 107 108 /** 109 Reset the Block Device. 110 111 @param[in] This Indicates a pointer to the calling context. 112 @param[in] ExtendedVerification Driver may perform diagnostics on reset. 113 114 @retval EFI_SUCCESS The device was reset. 115 @retval EFI_DEVICE_ERROR The device is not functioning properly and could 116 not be reset. 117 118 **/ 119 EFI_STATUS 120 EFIAPI 121 SdResetEx ( 122 IN EFI_BLOCK_IO2_PROTOCOL *This, 123 IN BOOLEAN ExtendedVerification 124 ); 125 126 /** 127 Read BufferSize bytes from Lba into Buffer. 128 129 @param[in] This Indicates a pointer to the calling context. 130 @param[in] MediaId Id of the media, changes every time the media is replaced. 131 @param[in] Lba The starting Logical Block Address to read from. 132 @param[in, out] Token A pointer to the token associated with the transaction. 133 @param[in] BufferSize Size of Buffer, must be a multiple of device block size. 134 @param[out] Buffer A pointer to the destination buffer for the data. The caller is 135 responsible for either having implicit or explicit ownership of the buffer. 136 137 @retval EFI_SUCCESS The read request was queued if Event is not NULL. 138 The data was read correctly from the device if 139 the Event is NULL. 140 @retval EFI_DEVICE_ERROR The device reported an error while performing 141 the read. 142 @retval EFI_NO_MEDIA There is no media in the device. 143 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. 144 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the 145 intrinsic block size of the device. 146 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, 147 or the buffer is not on proper alignment. 148 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack 149 of resources. 150 151 **/ 152 EFI_STATUS 153 EFIAPI 154 SdReadBlocksEx ( 155 IN EFI_BLOCK_IO2_PROTOCOL *This, 156 IN UINT32 MediaId, 157 IN EFI_LBA Lba, 158 IN OUT EFI_BLOCK_IO2_TOKEN *Token, 159 IN UINTN BufferSize, 160 OUT VOID *Buffer 161 ); 162 163 /** 164 Write BufferSize bytes from Lba into Buffer. 165 166 @param[in] This Indicates a pointer to the calling context. 167 @param[in] MediaId The media ID that the write request is for. 168 @param[in] Lba The starting logical block address to be written. The 169 caller is responsible for writing to only legitimate 170 locations. 171 @param[in, out] Token A pointer to the token associated with the transaction. 172 @param[in] BufferSize Size of Buffer, must be a multiple of device block size. 173 @param[in] Buffer A pointer to the source buffer for the data. 174 175 @retval EFI_SUCCESS The data was written correctly to the device. 176 @retval EFI_WRITE_PROTECTED The device can not be written to. 177 @retval EFI_DEVICE_ERROR The device reported an error while performing the write. 178 @retval EFI_NO_MEDIA There is no media in the device. 179 @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. 180 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device. 181 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, 182 or the buffer is not on proper alignment. 183 184 **/ 185 EFI_STATUS 186 EFIAPI 187 SdWriteBlocksEx ( 188 IN EFI_BLOCK_IO2_PROTOCOL *This, 189 IN UINT32 MediaId, 190 IN EFI_LBA Lba, 191 IN OUT EFI_BLOCK_IO2_TOKEN *Token, 192 IN UINTN BufferSize, 193 IN VOID *Buffer 194 ); 195 196 /** 197 Flush the Block Device. 198 199 @param[in] This Indicates a pointer to the calling context. 200 @param[in, out] Token A pointer to the token associated with the transaction. 201 202 @retval EFI_SUCCESS All outstanding data was written to the device 203 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data 204 @retval EFI_NO_MEDIA There is no media in the device. 205 206 **/ 207 EFI_STATUS 208 EFIAPI 209 SdFlushBlocksEx ( 210 IN EFI_BLOCK_IO2_PROTOCOL *This, 211 IN OUT EFI_BLOCK_IO2_TOKEN *Token 212 ); 213 214 /** 215 Erase a specified number of device blocks. 216 217 @param[in] This Indicates a pointer to the calling context. 218 @param[in] MediaId The media ID that the erase request is for. 219 @param[in] Lba The starting logical block address to be 220 erased. The caller is responsible for erasing 221 only legitimate locations. 222 @param[in, out] Token A pointer to the token associated with the 223 transaction. 224 @param[in] Size The size in bytes to be erased. This must be 225 a multiple of the physical block size of the 226 device. 227 228 @retval EFI_SUCCESS The erase request was queued if Event is not 229 NULL. The data was erased correctly to the 230 device if the Event is NULL.to the device. 231 @retval EFI_WRITE_PROTECTED The device cannot be erased due to write 232 protection. 233 @retval EFI_DEVICE_ERROR The device reported an error while attempting 234 to perform the erase operation. 235 @retval EFI_INVALID_PARAMETER The erase request contains LBAs that are not 236 valid. 237 @retval EFI_NO_MEDIA There is no media in the device. 238 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. 239 240 **/ 241 EFI_STATUS 242 EFIAPI 243 SdEraseBlocks ( 244 IN EFI_ERASE_BLOCK_PROTOCOL *This, 245 IN UINT32 MediaId, 246 IN EFI_LBA Lba, 247 IN OUT EFI_ERASE_BLOCK_TOKEN *Token, 248 IN UINTN Size 249 ); 250 251 #endif 252 253