]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/BlockIo.h
Formalize comments for Protocols and PPIs.
[mirror_edk2.git] / MdePkg / Include / Protocol / BlockIo.h
CommitLineData
d1f95000 1/** @file\r
8a7d75b0 2 Block IO protocol as defined in the UEFI 2.0 specification.\r
d1f95000 3\r
4 The Block IO protocol is used to abstract block devices like hard drives,\r
5 DVD-ROMs and floppy drives.\r
6\r
4ca9b6c4 7 Copyright (c) 2006 - 2008, Intel Corporation \r
d1f95000 8 All rights reserved. This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
d1f95000 16**/\r
17\r
18#ifndef __BLOCK_IO_H__\r
19#define __BLOCK_IO_H__\r
20\r
21#define EFI_BLOCK_IO_PROTOCOL_GUID \\r
22 { \\r
23 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
24 }\r
25\r
a6508c05 26typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;\r
27\r
99e8ed21 28///\r
29/// Protocol GUID name defined in EFI1.1.\r
30/// \r
a6508c05 31#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID\r
32\r
99e8ed21 33///\r
34/// Protocol defined in EFI1.1.\r
35/// \r
a6508c05 36typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;\r
d1f95000 37\r
38/**\r
39 Reset the Block Device.\r
40\r
41 @param This Protocol instance pointer.\r
42 @param ExtendedVerification Driver may perform diagnostics on reset.\r
43\r
44 @retval EFI_SUCCESS The device was reset.\r
45 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
46 not be reset.\r
47\r
48**/\r
49typedef\r
50EFI_STATUS\r
8b13229b 51(EFIAPI *EFI_BLOCK_RESET)(\r
d1f95000 52 IN EFI_BLOCK_IO_PROTOCOL *This,\r
53 IN BOOLEAN ExtendedVerification\r
ed66e1bc 54 );\r
d1f95000 55\r
56/**\r
57 Read BufferSize bytes from Lba into Buffer.\r
58\r
59 @param This Protocol instance pointer.\r
60 @param MediaId Id of the media, changes every time the media is replaced.\r
61 @param Lba The starting Logical Block Address to read from\r
62 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
63 @param Buffer Buffer containing read data\r
64\r
65 @retval EFI_SUCCESS The data was read correctly from the device.\r
66 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
67 @retval EFI_NO_MEDIA There is no media in the device.\r
68 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
69 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
70 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
71 valid for the device.\r
72\r
73**/\r
74typedef\r
75EFI_STATUS\r
8b13229b 76(EFIAPI *EFI_BLOCK_READ)(\r
d1f95000 77 IN EFI_BLOCK_IO_PROTOCOL *This,\r
78 IN UINT32 MediaId,\r
79 IN EFI_LBA Lba,\r
80 IN UINTN BufferSize,\r
81 OUT VOID *Buffer\r
ed66e1bc 82 );\r
d1f95000 83\r
84/**\r
85 Write BufferSize bytes from Lba into Buffer.\r
86\r
87 @param This Protocol instance pointer.\r
88 @param MediaId Id of the media, changes every time the media is replaced.\r
89 @param Lba The starting Logical Block Address to read from\r
90 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
91 @param Buffer Buffer containing read data\r
92\r
93 @retval EFI_SUCCESS The data was written correctly to the device.\r
94 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
95 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
96 @retval EFI_NO_MEDIA There is no media in the device.\r
97 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
98 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
99 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not\r
100 valid for the device.\r
101\r
102**/\r
103typedef\r
104EFI_STATUS\r
8b13229b 105(EFIAPI *EFI_BLOCK_WRITE)(\r
d1f95000 106 IN EFI_BLOCK_IO_PROTOCOL *This,\r
107 IN UINT32 MediaId,\r
108 IN EFI_LBA Lba,\r
109 IN UINTN BufferSize,\r
110 IN VOID *Buffer\r
ed66e1bc 111 );\r
d1f95000 112\r
113/**\r
114 Flush the Block Device.\r
115\r
116 @param This Protocol instance pointer.\r
117\r
118 @retval EFI_SUCCESS All outstanding data was written to the device\r
119 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
120 @retval EFI_NO_MEDIA There is no media in the device.\r
121\r
122**/\r
123typedef\r
124EFI_STATUS\r
8b13229b 125(EFIAPI *EFI_BLOCK_FLUSH)(\r
d1f95000 126 IN EFI_BLOCK_IO_PROTOCOL *This\r
ed66e1bc 127 );\r
d1f95000 128\r
129/**\r
130 Block IO read only mode data and updated only via members of BlockIO\r
d1f95000 131**/\r
132typedef struct {\r
8b6c989b 133 ///\r
134 /// The curent media Id. If the media changes, this value is changed.\r
135 ///\r
136 UINT32 MediaId; \r
137 \r
138 ///\r
139 /// TRUE if the media is removable; otherwise, FALSE.\r
140 /// \r
4ca9b6c4 141 BOOLEAN RemovableMedia;\r
8b6c989b 142 \r
143 ///\r
144 /// TRUE if there is a media currently present in the device;\r
145 /// othersise, FALSE. THis field shows the media present status\r
146 /// as of the most recent ReadBlocks() or WriteBlocks() call. \r
147 ///\r
4ca9b6c4 148 BOOLEAN MediaPresent;\r
8b6c989b 149\r
150 ///\r
151 /// TRUE if LBA 0 is the first block of a partition; otherwise\r
152 /// FALSE. For media with only one partition this would be TRUE.\r
153 ///\r
4ca9b6c4 154 BOOLEAN LogicalPartition;\r
8b6c989b 155 \r
156 ///\r
157 /// TRUE if the media is marked read-only otherwise, FALSE.\r
158 /// This field shows the read-only status as of the most recent WriteBlocks () call.\r
159 ///\r
4ca9b6c4 160 BOOLEAN ReadOnly;\r
8b6c989b 161 \r
162 ///\r
163 /// TRUE if the WriteBlock () function caches write data.\r
164 ///\r
4ca9b6c4 165 BOOLEAN WriteCaching; \r
8b6c989b 166 \r
167 ///\r
168 /// The intrinsic block size of the device. If the media changes, then\r
169 /// this field is updated. \r
170 ///\r
4ca9b6c4 171 UINT32 BlockSize; \r
8b6c989b 172 \r
173 ///\r
174 /// Supplies the alignment requirement for any buffer to read or write block(s).\r
175 ///\r
4ca9b6c4 176 UINT32 IoAlign; \r
8b6c989b 177 \r
178 ///\r
179 /// The last logical block address on the device.\r
180 /// If the media changes, then this field is updated. \r
181 ///\r
4ca9b6c4 182 EFI_LBA LastBlock; \r
d1f95000 183} EFI_BLOCK_IO_MEDIA;\r
184\r
185#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000\r
8b6c989b 186\r
187///\r
188/// Revision defined in EFI1.1.\r
189/// \r
a6508c05 190#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION\r
d1f95000 191\r
44717a39 192///\r
193/// This protocol provides control over block devices.\r
194///\r
d1f95000 195struct _EFI_BLOCK_IO_PROTOCOL {\r
8b6c989b 196 ///\r
197 /// The revision to which the block IO interface adheres. All future\r
198 /// revisions must be backwards compatible. If a future version is not\r
199 /// back wards compatible, it is not the same GUID.\r
200 ///\r
d1f95000 201 UINT64 Revision;\r
44717a39 202 ///\r
203 /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.\r
204 ///\r
d1f95000 205 EFI_BLOCK_IO_MEDIA *Media;\r
206\r
207 EFI_BLOCK_RESET Reset;\r
208 EFI_BLOCK_READ ReadBlocks;\r
209 EFI_BLOCK_WRITE WriteBlocks;\r
210 EFI_BLOCK_FLUSH FlushBlocks;\r
211\r
212};\r
213\r
214extern EFI_GUID gEfiBlockIoProtocolGuid;\r
215\r
216#endif\r