blob: 6f0c280089b0926f0ed6c4f316e4df44578cc276 [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2 Block IO2 protocol as defined in the UEFI 2.3.1 specification.
3
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
6 manner.
7
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
13
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.
16
17**/
18
19#ifndef __BLOCK_IO2_H__
20#define __BLOCK_IO2_H__
21
22#include <Protocol/BlockIo.h>
23
24#define EFI_BLOCK_IO2_PROTOCOL_GUID \
25 { \
26 0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} \
27 }
28
29typedef struct _EFI_BLOCK_IO2_PROTOCOL EFI_BLOCK_IO2_PROTOCOL;
30
31/**
32 The struct of Block IO2 Token.
33**/
34typedef struct {
35
36 ///
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.
40 ///
41 EFI_EVENT Event;
42
43 ///
44 /// Defines whether or not the signaled event encountered an error.
45 ///
46 EFI_STATUS TransactionStatus;
47} EFI_BLOCK_IO2_TOKEN;
48
49
50/**
51 Reset the block device hardware.
52
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
56 during reset.
57
58 @retval EFI_SUCCESS The device was reset.
59 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
60 not be reset.
61
62**/
63typedef
64EFI_STATUS
65(EFIAPI *EFI_BLOCK_RESET_EX) (
66 IN EFI_BLOCK_IO2_PROTOCOL *This,
67 IN BOOLEAN ExtendedVerification
68 );
69
70/**
71 Read BufferSize bytes from Lba into Buffer.
72
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
77 not be signaled.
78
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
81 replaced.
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.
88
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
93 the read.
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
101 of resources.
102**/
103typedef
104EFI_STATUS
105(EFIAPI *EFI_BLOCK_READ_EX) (
106 IN EFI_BLOCK_IO2_PROTOCOL *This,
107 IN UINT32 MediaId,
108 IN EFI_LBA LBA,
109 IN OUT EFI_BLOCK_IO2_TOKEN *Token,
110 IN UINTN BufferSize,
111 OUT VOID *Buffer
112 );
113
114/**
115 Write BufferSize bytes from Lba into Buffer.
116
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.
121
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
126 locations.
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.
130
131 @retval EFI_SUCCESS The write request was queued if Event is not NULL.
132 The data was written correctly to the device if
133 the Event is NULL.
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
142 of resources.
143
144**/
145typedef
146EFI_STATUS
147(EFIAPI *EFI_BLOCK_WRITE_EX) (
148 IN EFI_BLOCK_IO2_PROTOCOL *This,
149 IN UINT32 MediaId,
150 IN EFI_LBA LBA,
151 IN OUT EFI_BLOCK_IO2_TOKEN *Token,
152 IN UINTN BufferSize,
153 IN VOID *Buffer
154 );
155
156/**
157 Flush the Block Device.
158
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.
162
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
165
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
170 the data.
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
175 of resources.
176
177**/
178typedef
179EFI_STATUS
180(EFIAPI *EFI_BLOCK_FLUSH_EX) (
181 IN EFI_BLOCK_IO2_PROTOCOL *This,
182 IN OUT EFI_BLOCK_IO2_TOKEN *Token
183 );
184
185///
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
188// manner.
189///
190struct _EFI_BLOCK_IO2_PROTOCOL {
191 ///
192 /// A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
193 /// Type EFI_BLOCK_IO_MEDIA is defined in BlockIo.h.
194 ///
195 EFI_BLOCK_IO_MEDIA *Media;
196
197 EFI_BLOCK_RESET_EX Reset;
198 EFI_BLOCK_READ_EX ReadBlocksEx;
199 EFI_BLOCK_WRITE_EX WriteBlocksEx;
200 EFI_BLOCK_FLUSH_EX FlushBlocksEx;
201};
202
203extern EFI_GUID gEfiBlockIo2ProtocolGuid;
204
205#endif
206