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 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #ifndef __PEI_BLOCK_IO_H__
13 #define __PEI_BLOCK_IO_H__
14 // {BC5FA650-EDBB-4d0d-B3A3-D98907F847DF}
16 #define PEI_BLOCK_IO_PPI_GUID \
18 0xbc5fa650, 0xedbb, 0x4d0d, { 0xb3, 0xa3, 0xd9, 0x89, 0x7, 0xf8, 0x47, 0xdf } \
21 typedef struct _PEI_BLOCK_IO_PPI PEI_BLOCK_IO_PPI
;
25 Reset the Block Device.
27 @param This Indicates a pointer to the calling context.
28 @param ExtendedVerification Driver may perform diagnostics on reset.
30 @retval EFI_SUCCESS The device was reset.
31 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
37 (EFIAPI
*PEI_BLOCK_RESET
)(
38 IN PEI_BLOCK_IO_PPI
*This
,
39 IN BOOLEAN ExtendedVerification
43 Read BufferSize bytes from Lba into Buffer.
45 @param This Indicates a pointer to the calling context.
46 @param MediaId Id of the media, changes every time the media is replaced.
47 @param Lba The starting Logical Block Address to read from
48 @param BufferSize Size of Buffer, must be a multiple of device block size.
49 @param Buffer A pointer to the destination buffer for the data. The caller is
50 responsible for either having implicit or explicit ownership of the buffer.
52 @retval EFI_SUCCESS The data was read correctly from the device.
53 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
54 @retval EFI_NO_MEDIA There is no media in the device.
55 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
56 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
57 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
58 or the buffer is not on proper alignment.
63 (EFIAPI
*PEI_BLOCK_READ
)(
64 IN EFI_PEI_SERVICES
**PeiServices
,
65 IN PEI_BLOCK_IO_PPI
*This
,
73 Write BufferSize bytes from Lba into Buffer.
75 @param This Indicates a pointer to the calling context.
76 @param MediaId The media ID that the write request is for.
77 @param Lba The starting logical block address to be written. The caller is
78 responsible for writing to only legitimate locations.
79 @param BufferSize Size of Buffer, must be a multiple of device block size.
80 @param Buffer A pointer to the source buffer for the data.
82 @retval EFI_SUCCESS The data was written correctly to the device.
83 @retval EFI_WRITE_PROTECTED The device can not be written to.
84 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
85 @retval EFI_NO_MEDIA There is no media in the device.
86 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
87 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
88 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
89 or the buffer is not on proper alignment.
94 (EFIAPI
*PEI_BLOCK_WRITE
)(
95 IN EFI_PEI_SERVICES
**PeiServices
,
96 IN PEI_BLOCK_IO_PPI
*This
,
104 Flush the Block Device.
106 @param This Indicates a pointer to the calling context.
108 @retval EFI_SUCCESS All outstanding data was written to the device
109 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
110 @retval EFI_NO_MEDIA There is no media in the device.
115 (EFIAPI
*PEI_BLOCK_FLUSH
)(
116 IN PEI_BLOCK_IO_PPI
*This
120 Block IO read only mode data and updated only via members of BlockIO
124 /// The curent media Id. If the media changes, this value is changed.
129 /// TRUE if the media is removable; otherwise, FALSE.
131 BOOLEAN RemovableMedia
;
134 /// TRUE if there is a media currently present in the device;
135 /// othersise, FALSE. THis field shows the media present status
136 /// as of the most recent ReadBlocks() or WriteBlocks() call.
138 BOOLEAN MediaPresent
;
141 /// TRUE if LBA 0 is the first block of a partition; otherwise
142 /// FALSE. For media with only one partition this would be TRUE.
144 BOOLEAN LogicalPartition
;
147 /// TRUE if the media is marked read-only otherwise, FALSE.
148 /// This field shows the read-only status as of the most recent WriteBlocks () call.
153 /// TRUE if the WriteBlock () function caches write data.
155 BOOLEAN WriteCaching
;
158 /// The intrinsic block size of the device. If the media changes, then
159 /// this field is updated.
164 /// Supplies the alignment requirement for any buffer to read or write block(s).
169 /// The last logical block address on the device.
170 /// If the media changes, then this field is updated.
175 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
176 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
177 /// a physical block boundary.
179 EFI_LBA LowestAlignedLba
;
182 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
183 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
184 /// per physical block.
186 UINT32 LogicalBlocksPerPhysicalBlock
;
189 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
190 /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
191 /// granularity as a number of logical blocks.
193 UINT32 OptimalTransferLengthGranularity
;
195 } PEI_BLOCK_IO_MEDIA2
;
197 } PEI_BLOCK_IO_MEDIA
;
199 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
200 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
201 #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031
204 /// Revision defined in EFI1.1.
206 #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
209 /// This protocol provides control over block devices.
211 struct _PEI_BLOCK_IO_PPI
{
213 /// The revision to which the block IO interface adheres. All future
214 /// revisions must be backwards compatible. If a future version is not
215 /// back wards compatible, it is not the same GUID.
219 /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
221 PEI_BLOCK_IO_MEDIA
*Media
;
222 PEI_BLOCK_RESET Reset
;
223 PEI_BLOCK_READ ReadBlocks
;
224 PEI_BLOCK_WRITE WriteBlocks
;
225 PEI_BLOCK_FLUSH FlushBlocks
;
228 //extern EFI_GUID gEfiBlockIoProtocolGuid;
229 extern EFI_GUID gPeiBlockIoPpiGuid
;