]>
Commit | Line | Data |
---|---|---|
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 | 26 | typedef 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 | 36 | typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;\r |
d1f95000 | 37 | \r |
38 | /**\r | |
39 | Reset the Block Device.\r | |
40 | \r | |
f1004231 | 41 | @param This Indicates a pointer to the calling context.\r |
d1f95000 | 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 | |
49 | typedef\r | |
50 | EFI_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 | |
f1004231 | 59 | @param This Indicates a pointer to the calling context.\r |
d1f95000 | 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 | |
f1004231 LG |
63 | @param Buffer A pointer to the destination buffer for the data. The caller is\r |
64 | responsible for either having implicit or explicit ownership of the buffer.\r | |
d1f95000 | 65 | \r |
66 | @retval EFI_SUCCESS The data was read correctly from the device.\r | |
67 | @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r | |
68 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
69 | @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r | |
70 | @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r | |
f1004231 LG |
71 | @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r |
72 | or the buffer is not on proper alignment.\r | |
d1f95000 | 73 | \r |
74 | **/\r | |
75 | typedef\r | |
76 | EFI_STATUS\r | |
8b13229b | 77 | (EFIAPI *EFI_BLOCK_READ)(\r |
d1f95000 | 78 | IN EFI_BLOCK_IO_PROTOCOL *This,\r |
79 | IN UINT32 MediaId,\r | |
80 | IN EFI_LBA Lba,\r | |
81 | IN UINTN BufferSize,\r | |
82 | OUT VOID *Buffer\r | |
ed66e1bc | 83 | );\r |
d1f95000 | 84 | \r |
85 | /**\r | |
86 | Write BufferSize bytes from Lba into Buffer.\r | |
87 | \r | |
f1004231 LG |
88 | @param This Indicates a pointer to the calling context.\r |
89 | @param MediaId The media ID that the write request is for.\r | |
90 | @param Lba The starting logical block address to be written. The caller is\r | |
91 | responsible for writing to only legitimate locations.\r | |
d1f95000 | 92 | @param BufferSize Size of Buffer, must be a multiple of device block size.\r |
f1004231 | 93 | @param Buffer A pointer to the source buffer for the data.\r |
d1f95000 | 94 | \r |
95 | @retval EFI_SUCCESS The data was written correctly to the device.\r | |
96 | @retval EFI_WRITE_PROTECTED The device can not be written to.\r | |
97 | @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r | |
98 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
99 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
100 | @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r | |
f1004231 LG |
101 | @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r |
102 | or the buffer is not on proper alignment.\r | |
d1f95000 | 103 | \r |
104 | **/\r | |
105 | typedef\r | |
106 | EFI_STATUS\r | |
8b13229b | 107 | (EFIAPI *EFI_BLOCK_WRITE)(\r |
d1f95000 | 108 | IN EFI_BLOCK_IO_PROTOCOL *This,\r |
109 | IN UINT32 MediaId,\r | |
110 | IN EFI_LBA Lba,\r | |
111 | IN UINTN BufferSize,\r | |
112 | IN VOID *Buffer\r | |
ed66e1bc | 113 | );\r |
d1f95000 | 114 | \r |
115 | /**\r | |
116 | Flush the Block Device.\r | |
117 | \r | |
f1004231 | 118 | @param This Indicates a pointer to the calling context.\r |
d1f95000 | 119 | \r |
120 | @retval EFI_SUCCESS All outstanding data was written to the device\r | |
121 | @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r | |
122 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
123 | \r | |
124 | **/\r | |
125 | typedef\r | |
126 | EFI_STATUS\r | |
8b13229b | 127 | (EFIAPI *EFI_BLOCK_FLUSH)(\r |
d1f95000 | 128 | IN EFI_BLOCK_IO_PROTOCOL *This\r |
ed66e1bc | 129 | );\r |
d1f95000 | 130 | \r |
131 | /**\r | |
132 | Block IO read only mode data and updated only via members of BlockIO\r | |
d1f95000 | 133 | **/\r |
134 | typedef struct {\r | |
8b6c989b | 135 | ///\r |
136 | /// The curent media Id. If the media changes, this value is changed.\r | |
137 | ///\r | |
138 | UINT32 MediaId; \r | |
139 | \r | |
140 | ///\r | |
141 | /// TRUE if the media is removable; otherwise, FALSE.\r | |
142 | /// \r | |
4ca9b6c4 | 143 | BOOLEAN RemovableMedia;\r |
8b6c989b | 144 | \r |
145 | ///\r | |
146 | /// TRUE if there is a media currently present in the device;\r | |
147 | /// othersise, FALSE. THis field shows the media present status\r | |
148 | /// as of the most recent ReadBlocks() or WriteBlocks() call. \r | |
149 | ///\r | |
4ca9b6c4 | 150 | BOOLEAN MediaPresent;\r |
8b6c989b | 151 | \r |
152 | ///\r | |
153 | /// TRUE if LBA 0 is the first block of a partition; otherwise\r | |
154 | /// FALSE. For media with only one partition this would be TRUE.\r | |
155 | ///\r | |
4ca9b6c4 | 156 | BOOLEAN LogicalPartition;\r |
8b6c989b | 157 | \r |
158 | ///\r | |
159 | /// TRUE if the media is marked read-only otherwise, FALSE.\r | |
160 | /// This field shows the read-only status as of the most recent WriteBlocks () call.\r | |
161 | ///\r | |
4ca9b6c4 | 162 | BOOLEAN ReadOnly;\r |
8b6c989b | 163 | \r |
164 | ///\r | |
165 | /// TRUE if the WriteBlock () function caches write data.\r | |
166 | ///\r | |
4ca9b6c4 | 167 | BOOLEAN WriteCaching; \r |
8b6c989b | 168 | \r |
169 | ///\r | |
170 | /// The intrinsic block size of the device. If the media changes, then\r | |
171 | /// this field is updated. \r | |
172 | ///\r | |
4ca9b6c4 | 173 | UINT32 BlockSize; \r |
8b6c989b | 174 | \r |
175 | ///\r | |
176 | /// Supplies the alignment requirement for any buffer to read or write block(s).\r | |
177 | ///\r | |
4ca9b6c4 | 178 | UINT32 IoAlign; \r |
8b6c989b | 179 | \r |
180 | ///\r | |
181 | /// The last logical block address on the device.\r | |
182 | /// If the media changes, then this field is updated. \r | |
183 | ///\r | |
4ca9b6c4 | 184 | EFI_LBA LastBlock; \r |
312bc8f8 | 185 | \r |
186 | ///\r | |
187 | /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to\r | |
188 | /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to \r | |
189 | /// a physical block boundary. \r | |
190 | ///\r | |
191 | EFI_LBA LowestAlignedLba;\r | |
192 | \r | |
193 | ///\r | |
194 | /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to\r | |
195 | /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks \r | |
196 | /// per physical block.\r | |
197 | ///\r | |
198 | UINT32 LogicalBlocksPerPhysicalBlock;\r | |
d1f95000 | 199 | } EFI_BLOCK_IO_MEDIA;\r |
200 | \r | |
201 | #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000\r | |
312bc8f8 | 202 | #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001\r |
8b6c989b | 203 | \r |
204 | ///\r | |
205 | /// Revision defined in EFI1.1.\r | |
206 | /// \r | |
a6508c05 | 207 | #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION\r |
d1f95000 | 208 | \r |
44717a39 | 209 | ///\r |
210 | /// This protocol provides control over block devices.\r | |
211 | ///\r | |
d1f95000 | 212 | struct _EFI_BLOCK_IO_PROTOCOL {\r |
8b6c989b | 213 | ///\r |
214 | /// The revision to which the block IO interface adheres. All future\r | |
215 | /// revisions must be backwards compatible. If a future version is not\r | |
216 | /// back wards compatible, it is not the same GUID.\r | |
217 | ///\r | |
d1f95000 | 218 | UINT64 Revision;\r |
44717a39 | 219 | ///\r |
220 | /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.\r | |
221 | ///\r | |
d1f95000 | 222 | EFI_BLOCK_IO_MEDIA *Media;\r |
223 | \r | |
224 | EFI_BLOCK_RESET Reset;\r | |
225 | EFI_BLOCK_READ ReadBlocks;\r | |
226 | EFI_BLOCK_WRITE WriteBlocks;\r | |
227 | EFI_BLOCK_FLUSH FlushBlocks;\r | |
228 | \r | |
229 | };\r | |
230 | \r | |
231 | extern EFI_GUID gEfiBlockIoProtocolGuid;\r | |
232 | \r | |
233 | #endif\r |