]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /** @file\r |
2 | Block IO protocol as defined in the UEFI 2.0 specification.\r | |
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 | |
7 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r | |
8 | 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 | |
16 | **/\r | |
17 | \r | |
18 | #ifndef __PEI_BLOCK_IO_H__\r | |
19 | #define __PEI_BLOCK_IO_H__\r | |
20 | // {BC5FA650-EDBB-4d0d-B3A3-D98907F847DF}\r | |
21 | #ifndef ECP_FLAG\r | |
22 | #define PEI_BLOCK_IO_PPI_GUID \\r | |
23 | { \\r | |
24 | 0xbc5fa650, 0xedbb, 0x4d0d, { 0xb3, 0xa3, 0xd9, 0x89, 0x7, 0xf8, 0x47, 0xdf } \\r | |
25 | }\r | |
26 | #endif\r | |
27 | typedef struct _PEI_BLOCK_IO_PPI PEI_BLOCK_IO_PPI;\r | |
28 | \r | |
29 | \r | |
30 | /**\r | |
31 | Reset the Block Device.\r | |
32 | \r | |
33 | @param This Indicates a pointer to the calling context.\r | |
34 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
35 | \r | |
36 | @retval EFI_SUCCESS The device was reset.\r | |
37 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
38 | not be reset.\r | |
39 | \r | |
40 | **/\r | |
41 | typedef\r | |
42 | EFI_STATUS\r | |
43 | (EFIAPI *PEI_BLOCK_RESET)(\r | |
44 | IN PEI_BLOCK_IO_PPI *This,\r | |
45 | IN BOOLEAN ExtendedVerification\r | |
46 | );\r | |
47 | \r | |
48 | /**\r | |
49 | Read BufferSize bytes from Lba into Buffer.\r | |
50 | \r | |
51 | @param This Indicates a pointer to the calling context.\r | |
52 | @param MediaId Id of the media, changes every time the media is replaced.\r | |
53 | @param Lba The starting Logical Block Address to read from\r | |
54 | @param BufferSize Size of Buffer, must be a multiple of device block size.\r | |
55 | @param Buffer A pointer to the destination buffer for the data. The caller is\r | |
56 | responsible for either having implicit or explicit ownership of the buffer.\r | |
57 | \r | |
58 | @retval EFI_SUCCESS The data was read correctly from the device.\r | |
59 | @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r | |
60 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
61 | @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r | |
62 | @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r | |
63 | @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r | |
64 | or the buffer is not on proper alignment.\r | |
65 | \r | |
66 | **/\r | |
67 | typedef\r | |
68 | EFI_STATUS\r | |
69 | (EFIAPI *PEI_BLOCK_READ)(\r | |
70 | IN EFI_PEI_SERVICES **PeiServices,\r | |
71 | IN PEI_BLOCK_IO_PPI *This,\r | |
72 | IN UINT32 MediaId,\r | |
73 | IN EFI_LBA Lba,\r | |
74 | IN UINTN BufferSize,\r | |
75 | OUT VOID *Buffer\r | |
76 | );\r | |
77 | \r | |
78 | /**\r | |
79 | Write BufferSize bytes from Lba into Buffer.\r | |
80 | \r | |
81 | @param This Indicates a pointer to the calling context.\r | |
82 | @param MediaId The media ID that the write request is for.\r | |
83 | @param Lba The starting logical block address to be written. The caller is\r | |
84 | responsible for writing to only legitimate locations.\r | |
85 | @param BufferSize Size of Buffer, must be a multiple of device block size.\r | |
86 | @param Buffer A pointer to the source buffer for the data.\r | |
87 | \r | |
88 | @retval EFI_SUCCESS The data was written correctly to the device.\r | |
89 | @retval EFI_WRITE_PROTECTED The device can not be written to.\r | |
90 | @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r | |
91 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
92 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
93 | @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r | |
94 | @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r | |
95 | or the buffer is not on proper alignment.\r | |
96 | \r | |
97 | **/\r | |
98 | typedef\r | |
99 | EFI_STATUS\r | |
100 | (EFIAPI *PEI_BLOCK_WRITE)(\r | |
101 | IN EFI_PEI_SERVICES **PeiServices,\r | |
102 | IN PEI_BLOCK_IO_PPI *This,\r | |
103 | IN UINT32 MediaId,\r | |
104 | IN EFI_LBA Lba,\r | |
105 | IN UINTN BufferSize,\r | |
106 | IN VOID *Buffer\r | |
107 | );\r | |
108 | \r | |
109 | /**\r | |
110 | Flush the Block Device.\r | |
111 | \r | |
112 | @param This Indicates a pointer to the calling context.\r | |
113 | \r | |
114 | @retval EFI_SUCCESS All outstanding data was written to the device\r | |
115 | @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r | |
116 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
117 | \r | |
118 | **/\r | |
119 | typedef\r | |
120 | EFI_STATUS\r | |
121 | (EFIAPI *PEI_BLOCK_FLUSH)(\r | |
122 | IN PEI_BLOCK_IO_PPI *This\r | |
123 | );\r | |
124 | \r | |
125 | /**\r | |
126 | Block IO read only mode data and updated only via members of BlockIO\r | |
127 | **/\r | |
128 | typedef struct {\r | |
129 | ///\r | |
130 | /// The curent media Id. If the media changes, this value is changed.\r | |
131 | ///\r | |
132 | UINT32 MediaId;\r | |
133 | \r | |
134 | ///\r | |
135 | /// TRUE if the media is removable; otherwise, FALSE.\r | |
136 | ///\r | |
137 | BOOLEAN RemovableMedia;\r | |
138 | \r | |
139 | ///\r | |
140 | /// TRUE if there is a media currently present in the device;\r | |
141 | /// othersise, FALSE. THis field shows the media present status\r | |
142 | /// as of the most recent ReadBlocks() or WriteBlocks() call.\r | |
143 | ///\r | |
144 | BOOLEAN MediaPresent;\r | |
145 | \r | |
146 | ///\r | |
147 | /// TRUE if LBA 0 is the first block of a partition; otherwise\r | |
148 | /// FALSE. For media with only one partition this would be TRUE.\r | |
149 | ///\r | |
150 | BOOLEAN LogicalPartition;\r | |
151 | \r | |
152 | ///\r | |
153 | /// TRUE if the media is marked read-only otherwise, FALSE.\r | |
154 | /// This field shows the read-only status as of the most recent WriteBlocks () call.\r | |
155 | ///\r | |
156 | BOOLEAN ReadOnly;\r | |
157 | \r | |
158 | ///\r | |
159 | /// TRUE if the WriteBlock () function caches write data.\r | |
160 | ///\r | |
161 | BOOLEAN WriteCaching;\r | |
162 | \r | |
163 | ///\r | |
164 | /// The intrinsic block size of the device. If the media changes, then\r | |
165 | /// this field is updated.\r | |
166 | ///\r | |
167 | UINT32 BlockSize;\r | |
168 | \r | |
169 | ///\r | |
170 | /// Supplies the alignment requirement for any buffer to read or write block(s).\r | |
171 | ///\r | |
172 | UINT32 IoAlign;\r | |
173 | \r | |
174 | ///\r | |
175 | /// The last logical block address on the device.\r | |
176 | /// If the media changes, then this field is updated.\r | |
177 | ///\r | |
178 | EFI_LBA LastBlock;\r | |
179 | \r | |
180 | ///\r | |
181 | /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to\r | |
182 | /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to\r | |
183 | /// a physical block boundary.\r | |
184 | ///\r | |
185 | EFI_LBA LowestAlignedLba;\r | |
186 | \r | |
187 | ///\r | |
188 | /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to\r | |
189 | /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks\r | |
190 | /// per physical block.\r | |
191 | ///\r | |
192 | UINT32 LogicalBlocksPerPhysicalBlock;\r | |
193 | \r | |
194 | ///\r | |
195 | /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to\r | |
196 | /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length\r | |
197 | /// granularity as a number of logical blocks.\r | |
198 | ///\r | |
199 | UINT32 OptimalTransferLengthGranularity;\r | |
200 | #ifdef ECP_FLAG\r | |
201 | } PEI_BLOCK_IO_MEDIA2;\r | |
202 | #else\r | |
203 | } PEI_BLOCK_IO_MEDIA;\r | |
204 | #endif\r | |
205 | #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000\r | |
206 | #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001\r | |
207 | #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031\r | |
208 | \r | |
209 | ///\r | |
210 | /// Revision defined in EFI1.1.\r | |
211 | ///\r | |
212 | #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION\r | |
213 | \r | |
214 | ///\r | |
215 | /// This protocol provides control over block devices.\r | |
216 | ///\r | |
217 | struct _PEI_BLOCK_IO_PPI {\r | |
218 | ///\r | |
219 | /// The revision to which the block IO interface adheres. All future\r | |
220 | /// revisions must be backwards compatible. If a future version is not\r | |
221 | /// back wards compatible, it is not the same GUID.\r | |
222 | ///\r | |
223 | UINT64 Revision;\r | |
224 | ///\r | |
225 | /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.\r | |
226 | ///\r | |
227 | PEI_BLOCK_IO_MEDIA *Media;\r | |
228 | PEI_BLOCK_RESET Reset;\r | |
229 | PEI_BLOCK_READ ReadBlocks;\r | |
230 | PEI_BLOCK_WRITE WriteBlocks;\r | |
231 | PEI_BLOCK_FLUSH FlushBlocks;\r | |
232 | };\r | |
233 | \r | |
234 | //extern EFI_GUID gEfiBlockIoProtocolGuid;\r | |
235 | extern EFI_GUID gPeiBlockIoPpiGuid;\r | |
236 | #endif\r |