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