]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/BlockIo2.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / BlockIo2.h
CommitLineData
b5867578 1/** @file\r
2 Block IO2 protocol as defined in the UEFI 2.3.1 specification.\r
3\r
4 The Block IO2 protocol defines an extension to the Block IO protocol which\r
5 enables the ability to read and write data at a block level in a non-blocking\r
6 manner.\r
7\r
9095d37b 8 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 9 SPDX-License-Identifier: BSD-2-Clause-Patent\r
b5867578 10\r
11**/\r
12\r
13#ifndef __BLOCK_IO2_H__\r
14#define __BLOCK_IO2_H__\r
15\r
16#include <Protocol/BlockIo.h>\r
17\r
18#define EFI_BLOCK_IO2_PROTOCOL_GUID \\r
19 { \\r
20 0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} \\r
21 }\r
22\r
23typedef struct _EFI_BLOCK_IO2_PROTOCOL EFI_BLOCK_IO2_PROTOCOL;\r
24\r
25/**\r
26 The struct of Block IO2 Token.\r
27**/\r
28typedef struct {\r
29\r
30 ///\r
31 /// If Event is NULL, then blocking I/O is performed.If Event is not NULL and\r
32 /// non-blocking I/O is supported, then non-blocking I/O is performed, and\r
33 /// Event will be signaled when the read request is completed.\r
34 ///\r
35 EFI_EVENT Event;\r
36\r
37 ///\r
38 /// Defines whether or not the signaled event encountered an error.\r
39 ///\r
40 EFI_STATUS TransactionStatus;\r
41} EFI_BLOCK_IO2_TOKEN;\r
42\r
43\r
44/**\r
45 Reset the block device hardware.\r
46\r
47 @param[in] This Indicates a pointer to the calling context.\r
48 @param[in] ExtendedVerification Indicates that the driver may perform a more\r
00b7cc0f 49 exhausive verification operation of the device\r
b5867578 50 during reset.\r
51\r
52 @retval EFI_SUCCESS The device was reset.\r
53 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
54 not be reset.\r
55\r
56**/\r
57typedef\r
58EFI_STATUS\r
59(EFIAPI *EFI_BLOCK_RESET_EX) (\r
60 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
61 IN BOOLEAN ExtendedVerification\r
62 );\r
63\r
64/**\r
65 Read BufferSize bytes from Lba into Buffer.\r
9095d37b 66\r
b5867578 67 This function reads the requested number of blocks from the device. All the\r
68 blocks are read, or an error is returned.\r
69 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
70 non-blocking I/O is being used, the Event associated with this request will\r
71 not be signaled.\r
72\r
73 @param[in] This Indicates a pointer to the calling context.\r
9095d37b 74 @param[in] MediaId Id of the media, changes every time the media is\r
b5867578 75 replaced.\r
76 @param[in] Lba The starting Logical Block Address to read from.\r
9095d37b
LG
77 @param[in, out] Token A pointer to the token associated with the transaction.\r
78 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
79 @param[out] Buffer A pointer to the destination buffer for the data. The\r
80 caller is responsible for either having implicit or\r
b5867578 81 explicit ownership of the buffer.\r
82\r
83 @retval EFI_SUCCESS The read request was queued if Token->Event is\r
84 not NULL.The data was read correctly from the\r
85 device if the Token->Event is NULL.\r
86 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
87 the read.\r
88 @retval EFI_NO_MEDIA There is no media in the device.\r
89 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
90 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
91 intrinsic block size of the device.\r
9095d37b 92 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
b5867578 93 or the buffer is not on proper alignment.\r
94 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
95 of resources.\r
96**/\r
97typedef\r
98EFI_STATUS\r
99(EFIAPI *EFI_BLOCK_READ_EX) (\r
100 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
101 IN UINT32 MediaId,\r
102 IN EFI_LBA LBA,\r
103 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
104 IN UINTN BufferSize,\r
105 OUT VOID *Buffer\r
106 );\r
107\r
108/**\r
109 Write BufferSize bytes from Lba into Buffer.\r
110\r
111 This function writes the requested number of blocks to the device. All blocks\r
112 are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
113 EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
114 being used, the Event associated with this request will not be signaled.\r
115\r
116 @param[in] This Indicates a pointer to the calling context.\r
117 @param[in] MediaId The media ID that the write request is for.\r
118 @param[in] Lba The starting logical block address to be written. The\r
119 caller is responsible for writing to only legitimate\r
120 locations.\r
121 @param[in, out] Token A pointer to the token associated with the transaction.\r
122 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
123 @param[in] Buffer A pointer to the source buffer for the data.\r
124\r
125 @retval EFI_SUCCESS The write request was queued if Event is not NULL.\r
126 The data was written correctly to the device if\r
127 the Event is NULL.\r
128 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
129 @retval EFI_NO_MEDIA There is no media in the device.\r
130 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
131 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
132 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
9095d37b 133 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
b5867578 134 or the buffer is not on proper alignment.\r
135 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
136 of resources.\r
137\r
138**/\r
139typedef\r
140EFI_STATUS\r
141(EFIAPI *EFI_BLOCK_WRITE_EX) (\r
142 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
143 IN UINT32 MediaId,\r
144 IN EFI_LBA LBA,\r
145 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
146 IN UINTN BufferSize,\r
147 IN VOID *Buffer\r
148 );\r
149\r
150/**\r
151 Flush the Block Device.\r
9095d37b 152\r
b5867578 153 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
154 is returned and non-blocking I/O is being used, the Event associated with\r
9095d37b 155 this request will not be signaled.\r
b5867578 156\r
157 @param[in] This Indicates a pointer to the calling context.\r
158 @param[in,out] Token A pointer to the token associated with the transaction\r
159\r
160 @retval EFI_SUCCESS The flush request was queued if Event is not NULL.\r
161 All outstanding data was written correctly to the\r
162 device if the Event is NULL.\r
163 @retval EFI_DEVICE_ERROR The device reported an error while writting back\r
164 the data.\r
165 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
166 @retval EFI_NO_MEDIA There is no media in the device.\r
167 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
168 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
169 of resources.\r
170\r
171**/\r
172typedef\r
173EFI_STATUS\r
174(EFIAPI *EFI_BLOCK_FLUSH_EX) (\r
175 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
176 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
177 );\r
178\r
179///\r
180/// The Block I/O2 protocol defines an extension to the Block I/O protocol which\r
181/// enables the ability to read and write data at a block level in a non-blocking\r
182// manner.\r
183///\r
184struct _EFI_BLOCK_IO2_PROTOCOL {\r
185 ///\r
9095d37b 186 /// A pointer to the EFI_BLOCK_IO_MEDIA data for this device.\r
b5867578 187 /// Type EFI_BLOCK_IO_MEDIA is defined in BlockIo.h.\r
9095d37b 188 ///\r
b5867578 189 EFI_BLOCK_IO_MEDIA *Media;\r
190\r
191 EFI_BLOCK_RESET_EX Reset;\r
192 EFI_BLOCK_READ_EX ReadBlocksEx;\r
193 EFI_BLOCK_WRITE_EX WriteBlocksEx;\r
194 EFI_BLOCK_FLUSH_EX FlushBlocksEx;\r
195};\r
196\r
197extern EFI_GUID gEfiBlockIo2ProtocolGuid;\r
198\r
199#endif\r
200\r