EmuBlockIo.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /** @file
  2. Emu Block IO2 protocol as defined in the UEFI 2.3.1 specification.
  3. The Block IO2 protocol defines an extension to the Block IO protocol which
  4. enables the ability to read and write data at a block level in a non-blocking
  5. manner.
  6. Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
  7. SPDX-License-Identifier: BSD-2-Clause-Patent
  8. **/
  9. #ifndef __EMU_BLOCK_IO_H__
  10. #define __EMU_BLOCK_IO_H__
  11. #include <Protocol/BlockIo.h>
  12. #include <Protocol/BlockIo2.h>
  13. #define EMU_BLOCK_IO_PROTOCOL_GUID \
  14. { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }
  15. typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;
  16. /**
  17. Reset the block device hardware.
  18. @param[in] This Indicates a pointer to the calling context.
  19. @param[in] ExtendedVerification Indicates that the driver may perform a more
  20. exhausive verfication operation of the device
  21. during reset.
  22. @retval EFI_SUCCESS The device was reset.
  23. @retval EFI_DEVICE_ERROR The device is not functioning properly and could
  24. not be reset.
  25. **/
  26. typedef
  27. EFI_STATUS
  28. (EFIAPI *EMU_BLOCK_RESET)(
  29. IN EMU_BLOCK_IO_PROTOCOL *This,
  30. IN BOOLEAN ExtendedVerification
  31. );
  32. /**
  33. Read BufferSize bytes from Lba into Buffer.
  34. This function reads the requested number of blocks from the device. All the
  35. blocks are read, or an error is returned.
  36. If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and
  37. non-blocking I/O is being used, the Event associated with this request will
  38. not be signaled.
  39. @param[in] This Indicates a pointer to the calling context.
  40. @param[in] MediaId Id of the media, changes every time the media is
  41. replaced.
  42. @param[in] Lba The starting Logical Block Address to read from.
  43. @param[in, out] Token A pointer to the token associated with the transaction.
  44. @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
  45. @param[out] Buffer A pointer to the destination buffer for the data. The
  46. caller is responsible for either having implicit or
  47. explicit ownership of the buffer.
  48. @retval EFI_SUCCESS The read request was queued if Token->Event is
  49. not NULL.The data was read correctly from the
  50. device if the Token->Event is NULL.
  51. @retval EFI_DEVICE_ERROR The device reported an error while performing
  52. the read.
  53. @retval EFI_NO_MEDIA There is no media in the device.
  54. @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
  55. @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
  56. intrinsic block size of the device.
  57. @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
  58. or the buffer is not on proper alignment.
  59. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
  60. of resources.
  61. **/
  62. typedef
  63. EFI_STATUS
  64. (EFIAPI *EMU_BLOCK_READ)(
  65. IN EMU_BLOCK_IO_PROTOCOL *This,
  66. IN UINT32 MediaId,
  67. IN EFI_LBA LBA,
  68. IN OUT EFI_BLOCK_IO2_TOKEN *Token,
  69. IN UINTN BufferSize,
  70. OUT VOID *Buffer
  71. );
  72. /**
  73. Write BufferSize bytes from Lba into Buffer.
  74. This function writes the requested number of blocks to the device. All blocks
  75. are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,
  76. EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is
  77. being used, the Event associated with this request will not be signaled.
  78. @param[in] This Indicates a pointer to the calling context.
  79. @param[in] MediaId The media ID that the write request is for.
  80. @param[in] Lba The starting logical block address to be written. The
  81. caller is responsible for writing to only legitimate
  82. locations.
  83. @param[in, out] Token A pointer to the token associated with the transaction.
  84. @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
  85. @param[in] Buffer A pointer to the source buffer for the data.
  86. @retval EFI_SUCCESS The write request was queued if Event is not NULL.
  87. The data was written correctly to the device if
  88. the Event is NULL.
  89. @retval EFI_WRITE_PROTECTED The device can not be written to.
  90. @retval EFI_NO_MEDIA There is no media in the device.
  91. @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
  92. @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
  93. @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
  94. @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
  95. or the buffer is not on proper alignment.
  96. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
  97. of resources.
  98. **/
  99. typedef
  100. EFI_STATUS
  101. (EFIAPI *EMU_BLOCK_WRITE)(
  102. IN EMU_BLOCK_IO_PROTOCOL *This,
  103. IN UINT32 MediaId,
  104. IN EFI_LBA LBA,
  105. IN OUT EFI_BLOCK_IO2_TOKEN *Token,
  106. IN UINTN BufferSize,
  107. IN VOID *Buffer
  108. );
  109. /**
  110. Flush the Block Device.
  111. If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED
  112. is returned and non-blocking I/O is being used, the Event associated with
  113. this request will not be signaled.
  114. @param[in] This Indicates a pointer to the calling context.
  115. @param[in,out] Token A pointer to the token associated with the transaction
  116. @retval EFI_SUCCESS The flush request was queued if Event is not NULL.
  117. All outstanding data was written correctly to the
  118. device if the Event is NULL.
  119. @retval EFI_DEVICE_ERROR The device reported an error while writting back
  120. the data.
  121. @retval EFI_WRITE_PROTECTED The device cannot be written to.
  122. @retval EFI_NO_MEDIA There is no media in the device.
  123. @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
  124. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
  125. of resources.
  126. **/
  127. typedef
  128. EFI_STATUS
  129. (EFIAPI *EMU_BLOCK_FLUSH)(
  130. IN EMU_BLOCK_IO_PROTOCOL *This,
  131. IN OUT EFI_BLOCK_IO2_TOKEN *Token
  132. );
  133. typedef
  134. EFI_STATUS
  135. (EFIAPI *EMU_BLOCK_CREATE_MAPPING)(
  136. IN EMU_BLOCK_IO_PROTOCOL *This,
  137. IN EFI_BLOCK_IO_MEDIA *Media
  138. );
  139. ///
  140. /// The Block I/O2 protocol defines an extension to the Block I/O protocol which
  141. /// enables the ability to read and write data at a block level in a non-blocking
  142. // manner.
  143. ///
  144. struct _EMU_BLOCK_IO_PROTOCOL {
  145. EMU_BLOCK_RESET Reset;
  146. EMU_BLOCK_READ ReadBlocks;
  147. EMU_BLOCK_WRITE WriteBlocks;
  148. EMU_BLOCK_FLUSH FlushBlocks;
  149. EMU_BLOCK_CREATE_MAPPING CreateMapping;
  150. };
  151. extern EFI_GUID gEmuBlockIoProtocolGuid;
  152. #endif