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