2 Block IO protocol as defined in the UEFI 2.0 specification.
4 The Block IO protocol is used to abstract block devices like hard drives,
5 DVD-ROMs and floppy drives.
7 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef __PEI_BLOCK_IO_H__
19 #define __PEI_BLOCK_IO_H__
20 // {BC5FA650-EDBB-4d0d-B3A3-D98907F847DF}
22 #define PEI_BLOCK_IO_PPI_GUID \
24 0xbc5fa650, 0xedbb, 0x4d0d, { 0xb3, 0xa3, 0xd9, 0x89, 0x7, 0xf8, 0x47, 0xdf } \
27 typedef struct _PEI_BLOCK_IO_PPI PEI_BLOCK_IO_PPI
;
31 Reset the Block Device.
33 @param This Indicates a pointer to the calling context.
34 @param ExtendedVerification Driver may perform diagnostics on reset.
36 @retval EFI_SUCCESS The device was reset.
37 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
43 (EFIAPI
*PEI_BLOCK_RESET
)(
44 IN PEI_BLOCK_IO_PPI
*This
,
45 IN BOOLEAN ExtendedVerification
49 Read BufferSize bytes from Lba into Buffer.
51 @param This Indicates a pointer to the calling context.
52 @param MediaId Id of the media, changes every time the media is replaced.
53 @param Lba The starting Logical Block Address to read from
54 @param BufferSize Size of Buffer, must be a multiple of device block size.
55 @param Buffer A pointer to the destination buffer for the data. The caller is
56 responsible for either having implicit or explicit ownership of the buffer.
58 @retval EFI_SUCCESS The data was read correctly from the device.
59 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
60 @retval EFI_NO_MEDIA There is no media in the device.
61 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
62 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
63 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
64 or the buffer is not on proper alignment.
69 (EFIAPI
*PEI_BLOCK_READ
)(
70 IN EFI_PEI_SERVICES
**PeiServices
,
71 IN PEI_BLOCK_IO_PPI
*This
,
79 Write BufferSize bytes from Lba into Buffer.
81 @param This Indicates a pointer to the calling context.
82 @param MediaId The media ID that the write request is for.
83 @param Lba The starting logical block address to be written. The caller is
84 responsible for writing to only legitimate locations.
85 @param BufferSize Size of Buffer, must be a multiple of device block size.
86 @param Buffer A pointer to the source buffer for the data.
88 @retval EFI_SUCCESS The data was written correctly to the device.
89 @retval EFI_WRITE_PROTECTED The device can not be written to.
90 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
91 @retval EFI_NO_MEDIA There is no media in the device.
92 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
93 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
94 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
95 or the buffer is not on proper alignment.
100 (EFIAPI
*PEI_BLOCK_WRITE
)(
101 IN EFI_PEI_SERVICES
**PeiServices
,
102 IN PEI_BLOCK_IO_PPI
*This
,
110 Flush the Block Device.
112 @param This Indicates a pointer to the calling context.
114 @retval EFI_SUCCESS All outstanding data was written to the device
115 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
116 @retval EFI_NO_MEDIA There is no media in the device.
121 (EFIAPI
*PEI_BLOCK_FLUSH
)(
122 IN PEI_BLOCK_IO_PPI
*This
126 Block IO read only mode data and updated only via members of BlockIO
130 /// The curent media Id. If the media changes, this value is changed.
135 /// TRUE if the media is removable; otherwise, FALSE.
137 BOOLEAN RemovableMedia
;
140 /// TRUE if there is a media currently present in the device;
141 /// othersise, FALSE. THis field shows the media present status
142 /// as of the most recent ReadBlocks() or WriteBlocks() call.
144 BOOLEAN MediaPresent
;
147 /// TRUE if LBA 0 is the first block of a partition; otherwise
148 /// FALSE. For media with only one partition this would be TRUE.
150 BOOLEAN LogicalPartition
;
153 /// TRUE if the media is marked read-only otherwise, FALSE.
154 /// This field shows the read-only status as of the most recent WriteBlocks () call.
159 /// TRUE if the WriteBlock () function caches write data.
161 BOOLEAN WriteCaching
;
164 /// The intrinsic block size of the device. If the media changes, then
165 /// this field is updated.
170 /// Supplies the alignment requirement for any buffer to read or write block(s).
175 /// The last logical block address on the device.
176 /// If the media changes, then this field is updated.
181 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
182 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
183 /// a physical block boundary.
185 EFI_LBA LowestAlignedLba
;
188 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
189 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
190 /// per physical block.
192 UINT32 LogicalBlocksPerPhysicalBlock
;
195 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
196 /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
197 /// granularity as a number of logical blocks.
199 UINT32 OptimalTransferLengthGranularity
;
201 } PEI_BLOCK_IO_MEDIA2
;
203 } PEI_BLOCK_IO_MEDIA
;
205 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
206 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
207 #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031
210 /// Revision defined in EFI1.1.
212 #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
215 /// This protocol provides control over block devices.
217 struct _PEI_BLOCK_IO_PPI
{
219 /// The revision to which the block IO interface adheres. All future
220 /// revisions must be backwards compatible. If a future version is not
221 /// back wards compatible, it is not the same GUID.
225 /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
227 PEI_BLOCK_IO_MEDIA
*Media
;
228 PEI_BLOCK_RESET Reset
;
229 PEI_BLOCK_READ ReadBlocks
;
230 PEI_BLOCK_WRITE WriteBlocks
;
231 PEI_BLOCK_FLUSH FlushBlocks
;
234 //extern EFI_GUID gEfiBlockIoProtocolGuid;
235 extern EFI_GUID gPeiBlockIoPpiGuid
;