2 Emu Block IO2 protocol as defined in the UEFI 2.3.1 specification.
4 The Block IO2 protocol defines an extension to the Block IO protocol which
5 enables the ability to read and write data at a block level in a non-blocking
8 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #ifndef __EMU_BLOCK_IO_H__
14 #define __EMU_BLOCK_IO_H__
16 #include <Protocol/BlockIo.h>
17 #include <Protocol/BlockIo2.h>
19 #define EMU_BLOCK_IO_PROTOCOL_GUID \
20 { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }
22 typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL
;
25 Reset the block device hardware.
27 @param[in] This Indicates a pointer to the calling context.
28 @param[in] ExtendedVerification Indicates that the driver may perform a more
29 exhausive verfication operation of the device
32 @retval EFI_SUCCESS The device was reset.
33 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
39 (EFIAPI
*EMU_BLOCK_RESET
)(
40 IN EMU_BLOCK_IO_PROTOCOL
*This
,
41 IN BOOLEAN ExtendedVerification
45 Read BufferSize bytes from Lba into Buffer.
47 This function reads the requested number of blocks from the device. All the
48 blocks are read, or an error is returned.
49 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and
50 non-blocking I/O is being used, the Event associated with this request will
53 @param[in] This Indicates a pointer to the calling context.
54 @param[in] MediaId Id of the media, changes every time the media is
56 @param[in] Lba The starting Logical Block Address to read from.
57 @param[in, out] Token A pointer to the token associated with the transaction.
58 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
59 @param[out] Buffer A pointer to the destination buffer for the data. The
60 caller is responsible for either having implicit or
61 explicit ownership of the buffer.
63 @retval EFI_SUCCESS The read request was queued if Token->Event is
64 not NULL.The data was read correctly from the
65 device if the Token->Event is NULL.
66 @retval EFI_DEVICE_ERROR The device reported an error while performing
68 @retval EFI_NO_MEDIA There is no media in the device.
69 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
70 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
71 intrinsic block size of the device.
72 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
73 or the buffer is not on proper alignment.
74 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
79 (EFIAPI
*EMU_BLOCK_READ
)(
80 IN EMU_BLOCK_IO_PROTOCOL
*This
,
83 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
89 Write BufferSize bytes from Lba into Buffer.
91 This function writes the requested number of blocks to the device. All blocks
92 are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,
93 EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is
94 being used, the Event associated with this request will not be signaled.
96 @param[in] This Indicates a pointer to the calling context.
97 @param[in] MediaId The media ID that the write request is for.
98 @param[in] Lba The starting logical block address to be written. The
99 caller is responsible for writing to only legitimate
101 @param[in, out] Token A pointer to the token associated with the transaction.
102 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
103 @param[in] Buffer A pointer to the source buffer for the data.
105 @retval EFI_SUCCESS The write request was queued if Event is not NULL.
106 The data was written correctly to the device if
108 @retval EFI_WRITE_PROTECTED The device can not be written to.
109 @retval EFI_NO_MEDIA There is no media in the device.
110 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
111 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
112 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
113 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
114 or the buffer is not on proper alignment.
115 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
121 (EFIAPI
*EMU_BLOCK_WRITE
)(
122 IN EMU_BLOCK_IO_PROTOCOL
*This
,
125 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
131 Flush the Block Device.
133 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED
134 is returned and non-blocking I/O is being used, the Event associated with
135 this request will not be signaled.
137 @param[in] This Indicates a pointer to the calling context.
138 @param[in,out] Token A pointer to the token associated with the transaction
140 @retval EFI_SUCCESS The flush request was queued if Event is not NULL.
141 All outstanding data was written correctly to the
142 device if the Event is NULL.
143 @retval EFI_DEVICE_ERROR The device reported an error while writting back
145 @retval EFI_WRITE_PROTECTED The device cannot be written to.
146 @retval EFI_NO_MEDIA There is no media in the device.
147 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
148 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
154 (EFIAPI
*EMU_BLOCK_FLUSH
)(
155 IN EMU_BLOCK_IO_PROTOCOL
*This
,
156 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
161 (EFIAPI
*EMU_BLOCK_CREATE_MAPPING
)(
162 IN EMU_BLOCK_IO_PROTOCOL
*This
,
163 IN EFI_BLOCK_IO_MEDIA
*Media
167 /// The Block I/O2 protocol defines an extension to the Block I/O protocol which
168 /// enables the ability to read and write data at a block level in a non-blocking
171 struct _EMU_BLOCK_IO_PROTOCOL
{
172 EMU_BLOCK_RESET Reset
;
173 EMU_BLOCK_READ ReadBlocks
;
174 EMU_BLOCK_WRITE WriteBlocks
;
175 EMU_BLOCK_FLUSH FlushBlocks
;
176 EMU_BLOCK_CREATE_MAPPING CreateMapping
;
179 extern EFI_GUID gEmuBlockIoProtocolGuid
;