iPXE
BlockIo.h
Go to the documentation of this file.
1/** @file
2 Block IO protocol as defined in the UEFI 2.0 specification.
3
4 The Block IO protocol is used to abstract block devices like hard drives,
5 DVD-ROMs and floppy drives.
6
7 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10**/
11
12#pragma once
13
14FILE_LICENCE ( BSD2_PATENT );
15FILE_SECBOOT ( PERMITTED );
16
17#define EFI_BLOCK_IO_PROTOCOL_GUID \
18 { \
19 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
20 }
21
23
24///
25/// Protocol GUID name defined in EFI1.1.
26///
27#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID
28
29///
30/// Protocol defined in EFI1.1.
31///
33
34/**
35 Reset the Block Device.
36
37 @param This Indicates a pointer to the calling context.
38 @param ExtendedVerification Driver may perform diagnostics on reset.
39
40 @retval EFI_SUCCESS The device was reset.
41 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
42 not be reset.
43
44**/
45typedef
49 IN BOOLEAN ExtendedVerification
50 );
51
52/**
53 Read BufferSize bytes from Lba into Buffer.
54
55 @param This Indicates a pointer to the calling context.
56 @param MediaId Id of the media, changes every time the media is replaced.
57 @param Lba The starting Logical Block Address to read from
58 @param BufferSize Size of Buffer, must be a multiple of device block size.
59 @param Buffer A pointer to the destination buffer for the data. The caller is
60 responsible for either having implicit or explicit ownership of the buffer.
61
62 @retval EFI_SUCCESS The data was read correctly from the device.
63 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
64 @retval EFI_NO_MEDIA There is no media in the device.
65 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
66 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
67 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
68 or the buffer is not on proper alignment.
69
70**/
71typedef
75 IN UINT32 MediaId,
76 IN EFI_LBA Lba,
79 );
80
81/**
82 Write BufferSize bytes from Lba into Buffer.
83
84 @param This Indicates a pointer to the calling context.
85 @param MediaId The media ID that the write request is for.
86 @param Lba The starting logical block address to be written. The caller is
87 responsible for writing to only legitimate locations.
88 @param BufferSize Size of Buffer, must be a multiple of device block size.
89 @param Buffer A pointer to the source buffer for the data.
90
91 @retval EFI_SUCCESS The data was written correctly to the device.
92 @retval EFI_WRITE_PROTECTED The device can not be written to.
93 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
94 @retval EFI_NO_MEDIA There is no media in the device.
95 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
96 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
97 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
98 or the buffer is not on proper alignment.
99
100**/
101typedef
105 IN UINT32 MediaId,
106 IN EFI_LBA Lba,
108 IN VOID *Buffer
109 );
110
111/**
112 Flush the Block Device.
113
114 @param This Indicates a pointer to the calling context.
115
116 @retval EFI_SUCCESS All outstanding data was written to the device
117 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
118 @retval EFI_NO_MEDIA There is no media in the device.
119
120**/
121typedef
125 );
126
127/**
128 Block IO read only mode data and updated only via members of BlockIO
129**/
130typedef struct {
131 ///
132 /// The curent media Id. If the media changes, this value is changed.
133 ///
135
136 ///
137 /// TRUE if the media is removable; otherwise, FALSE.
138 ///
140
141 ///
142 /// TRUE if there is a media currently present in the device;
143 /// othersise, FALSE. THis field shows the media present status
144 /// as of the most recent ReadBlocks() or WriteBlocks() call.
145 ///
147
148 ///
149 /// TRUE if LBA 0 is the first block of a partition; otherwise
150 /// FALSE. For media with only one partition this would be TRUE.
151 ///
153
154 ///
155 /// TRUE if the media is marked read-only otherwise, FALSE.
156 /// This field shows the read-only status as of the most recent WriteBlocks () call.
157 ///
159
160 ///
161 /// TRUE if the WriteBlock () function caches write data.
162 ///
164
165 ///
166 /// The intrinsic block size of the device. If the media changes, then
167 /// this field is updated.
168 ///
170
171 ///
172 /// Supplies the alignment requirement for any buffer to read or write block(s).
173 ///
175
176 ///
177 /// The last logical block address on the device.
178 /// If the media changes, then this field is updated.
179 ///
181
182 ///
183 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
184 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
185 /// a physical block boundary.
186 ///
188
189 ///
190 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
191 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
192 /// per physical block.
193 ///
195
196 ///
197 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
198 /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
199 /// granularity as a number of logical blocks.
200 ///
203
204#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
205#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
206#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x0002001F
207
208///
209/// Revision defined in EFI1.1.
210///
211#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
212
213///
214/// This protocol provides control over block devices.
215///
217 ///
218 /// The revision to which the block IO interface adheres. All future
219 /// revisions must be backwards compatible. If a future version is not
220 /// back wards compatible, it is not the same GUID.
221 ///
223 ///
224 /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
225 ///
227
232};
233
unsigned char BOOLEAN
Logical Boolean.
UINT64 UINTN
Unsigned value of native width.
unsigned long long UINT64
8-byte unsigned value.
#define EFIAPI
unsigned int UINT32
4-byte unsigned value.
#define VOID
Undeclared type.
Definition Base.h:271
EFI_STATUS(EFIAPI * EFI_BLOCK_RESET)(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Reset the Block Device.
Definition BlockIo.h:47
EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO
Protocol defined in EFI1.1.
Definition BlockIo.h:32
EFI_STATUS(EFIAPI * EFI_BLOCK_READ)(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
Read BufferSize bytes from Lba into Buffer.
Definition BlockIo.h:73
EFI_GUID gEfiBlockIoProtocolGuid
EFI_STATUS(EFIAPI * EFI_BLOCK_WRITE)(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
Write BufferSize bytes from Lba into Buffer.
Definition BlockIo.h:103
EFI_STATUS(EFIAPI * EFI_BLOCK_FLUSH)(IN EFI_BLOCK_IO_PROTOCOL *This)
Flush the Block Device.
Definition BlockIo.h:123
struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL
Definition BlockIo.h:22
UINT64 EFI_LBA
Logical block address.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
#define IN
Definition mlx_utils.h:28
#define OUT
Definition mlx_utils.h:29
UINT16_t BufferSize
Buffer size.
Definition pxe_api.h:7
SEGOFF16_t Buffer
Buffer address.
Definition pxe_api.h:8
Block IO read only mode data and updated only via members of BlockIO.
Definition BlockIo.h:130
UINT32 IoAlign
Supplies the alignment requirement for any buffer to read or write block(s).
Definition BlockIo.h:174
BOOLEAN RemovableMedia
TRUE if the media is removable; otherwise, FALSE.
Definition BlockIo.h:139
UINT32 LogicalBlocksPerPhysicalBlock
Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to EFI_BLOCK_IO_PROTOCOL_REVI...
Definition BlockIo.h:194
BOOLEAN LogicalPartition
TRUE if LBA 0 is the first block of a partition; otherwise FALSE.
Definition BlockIo.h:152
UINT32 BlockSize
The intrinsic block size of the device.
Definition BlockIo.h:169
EFI_LBA LastBlock
The last logical block address on the device.
Definition BlockIo.h:180
BOOLEAN WriteCaching
TRUE if the WriteBlock () function caches write data.
Definition BlockIo.h:163
UINT32 OptimalTransferLengthGranularity
Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to EFI_BLOCK_IO_PROTOCOL_REVI...
Definition BlockIo.h:201
UINT32 MediaId
The curent media Id.
Definition BlockIo.h:134
BOOLEAN MediaPresent
TRUE if there is a media currently present in the device; othersise, FALSE.
Definition BlockIo.h:146
BOOLEAN ReadOnly
TRUE if the media is marked read-only otherwise, FALSE.
Definition BlockIo.h:158
EFI_LBA LowestAlignedLba
Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to EFI_BLOCK_IO_PROTOCOL_REVI...
Definition BlockIo.h:187
This protocol provides control over block devices.
Definition BlockIo.h:216
EFI_BLOCK_IO_MEDIA * Media
Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
Definition BlockIo.h:226
UINT64 Revision
The revision to which the block IO interface adheres.
Definition BlockIo.h:222
EFI_BLOCK_READ ReadBlocks
Definition BlockIo.h:229
EFI_BLOCK_WRITE WriteBlocks
Definition BlockIo.h:230
EFI_BLOCK_RESET Reset
Definition BlockIo.h:228
EFI_BLOCK_FLUSH FlushBlocks
Definition BlockIo.h:231