2 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 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #ifndef __BLOCK_IO2_H__
20 #define __BLOCK_IO2_H__
22 #include <Protocol/BlockIo.h>
24 #define EFI_BLOCK_IO2_PROTOCOL_GUID \
26 0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} \
29 typedef struct _EFI_BLOCK_IO2_PROTOCOL EFI_BLOCK_IO2_PROTOCOL
;
32 The struct of Block IO2 Token.
37 /// If Event is NULL, then blocking I/O is performed.If Event is not NULL and
38 /// non-blocking I/O is supported, then non-blocking I/O is performed, and
39 /// Event will be signaled when the read request is completed.
44 /// Defines whether or not the signaled event encountered an error.
46 EFI_STATUS TransactionStatus
;
47 } EFI_BLOCK_IO2_TOKEN
;
51 Reset the block device hardware.
53 @param[in] This Indicates a pointer to the calling context.
54 @param[in] ExtendedVerification Indicates that the driver may perform a more
55 exhausive verfication operation of the device
58 @retval EFI_SUCCESS The device was reset.
59 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
65 (EFIAPI
*EFI_BLOCK_RESET_EX
) (
66 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
67 IN BOOLEAN ExtendedVerification
71 Read BufferSize bytes from Lba into Buffer.
73 This function reads the requested number of blocks from the device. All the
74 blocks are read, or an error is returned.
75 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and
76 non-blocking I/O is being used, the Event associated with this request will
79 @param[in] This Indicates a pointer to the calling context.
80 @param[in] MediaId Id of the media, changes every time the media is
82 @param[in] Lba The starting Logical Block Address to read from.
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[out] Buffer A pointer to the destination buffer for the data. The
86 caller is responsible for either having implicit or
87 explicit ownership of the buffer.
89 @retval EFI_SUCCESS The read request was queued if Token->Event is
90 not NULL.The data was read correctly from the
91 device if the Token->Event is NULL.
92 @retval EFI_DEVICE_ERROR The device reported an error while performing
94 @retval EFI_NO_MEDIA There is no media in the device.
95 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
96 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
97 intrinsic block size of the device.
98 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
99 or the buffer is not on proper alignment.
100 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
105 (EFIAPI
*EFI_BLOCK_READ_EX
) (
106 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
109 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
115 Write BufferSize bytes from Lba into Buffer.
117 This function writes the requested number of blocks to the device. All blocks
118 are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,
119 EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is
120 being used, the Event associated with this request will not be signaled.
122 @param[in] This Indicates a pointer to the calling context.
123 @param[in] MediaId The media ID that the write request is for.
124 @param[in] Lba The starting logical block address to be written. The
125 caller is responsible for writing to only legitimate
127 @param[in, out] Token A pointer to the token associated with the transaction.
128 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
129 @param[in] Buffer A pointer to the source buffer for the data.
131 @retval EFI_SUCCESS The write request was queued if Event is not NULL.
132 The data was written correctly to the device if
134 @retval EFI_WRITE_PROTECTED The device can not be written to.
135 @retval EFI_NO_MEDIA There is no media in the device.
136 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
137 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
138 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
139 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
140 or the buffer is not on proper alignment.
141 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
147 (EFIAPI
*EFI_BLOCK_WRITE_EX
) (
148 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
151 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
,
157 Flush the Block Device.
159 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED
160 is returned and non-blocking I/O is being used, the Event associated with
161 this request will not be signaled.
163 @param[in] This Indicates a pointer to the calling context.
164 @param[in,out] Token A pointer to the token associated with the transaction
166 @retval EFI_SUCCESS The flush request was queued if Event is not NULL.
167 All outstanding data was written correctly to the
168 device if the Event is NULL.
169 @retval EFI_DEVICE_ERROR The device reported an error while writting back
171 @retval EFI_WRITE_PROTECTED The device cannot be written to.
172 @retval EFI_NO_MEDIA There is no media in the device.
173 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
174 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
180 (EFIAPI
*EFI_BLOCK_FLUSH_EX
) (
181 IN EFI_BLOCK_IO2_PROTOCOL
*This
,
182 IN OUT EFI_BLOCK_IO2_TOKEN
*Token
186 /// The Block I/O2 protocol defines an extension to the Block I/O protocol which
187 /// enables the ability to read and write data at a block level in a non-blocking
190 struct _EFI_BLOCK_IO2_PROTOCOL
{
192 /// A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
193 /// Type EFI_BLOCK_IO_MEDIA is defined in BlockIo.h.
195 EFI_BLOCK_IO_MEDIA
*Media
;
197 EFI_BLOCK_RESET_EX Reset
;
198 EFI_BLOCK_READ_EX ReadBlocksEx
;
199 EFI_BLOCK_WRITE_EX WriteBlocksEx
;
200 EFI_BLOCK_FLUSH_EX FlushBlocksEx
;
203 extern EFI_GUID gEfiBlockIo2ProtocolGuid
;