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 
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 **/
45 typedef
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 **/
71 typedef
75  IN UINT32 MediaId,
76  IN EFI_LBA Lba,
78  OUT VOID *Buffer
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 **/
101 typedef
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 **/
121 typedef
125  );
126 
127 /**
128  Block IO read only mode data and updated only via members of BlockIO
129 **/
130 typedef 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 
235 
236 #endif
EFI_BLOCK_RESET Reset
Definition: BlockIo.h:228
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
BOOLEAN LogicalPartition
TRUE if LBA 0 is the first block of a partition; otherwise FALSE.
Definition: BlockIo.h:152
unsigned char BOOLEAN
BOOLEAN ReadOnly
TRUE if the media is marked read-only otherwise, FALSE.
Definition: BlockIo.h:158
EFI_BLOCK_WRITE WriteBlocks
Definition: BlockIo.h:230
This protocol provides control over block devices.
Definition: BlockIo.h:216
EFI_BLOCK_FLUSH FlushBlocks
Definition: BlockIo.h:231
unsigned int UINT32
Definition: ProcessorBind.h:98
UINT16_t BufferSize
Buffer size.
Definition: pxe_api.h:64
EFI_BLOCK_READ ReadBlocks
Definition: BlockIo.h:229
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
#define OUT
Definition: mlx_utils.h:29
UINT64 EFI_LBA
Logical block address.
Definition: UefiBaseType.h:47
BOOLEAN RemovableMedia
TRUE if the media is removable; otherwise, FALSE.
Definition: BlockIo.h:139
#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:163
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:146
EFI_STATUS(EFIAPI * EFI_BLOCK_FLUSH)(IN EFI_BLOCK_IO_PROTOCOL *This)
Flush the Block Device.
Definition: BlockIo.h:123
#define VOID
Undeclared type.
Definition: Base.h:271
UINT32 IoAlign
Supplies the alignment requirement for any buffer to read or write block(s).
Definition: BlockIo.h:174
unsigned long long UINT64
Definition: ProcessorBind.h:96
EFI_STATUS(EFIAPI * EFI_BLOCK_RESET)(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Reset the Block Device.
Definition: BlockIo.h:47
#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:226
Block IO read only mode data and updated only via members of BlockIO.
Definition: BlockIo.h:130
EFI_LBA LastBlock
The last logical block address on the device.
Definition: BlockIo.h:180
FILE_LICENCE(BSD2_PATENT)
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
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
EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO
Protocol defined in EFI1.1.
Definition: BlockIo.h:32
UINT32 MediaId
The curent media Id.
Definition: BlockIo.h:134
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_GUID gEfiBlockIoProtocolGuid
UINT64 Revision
The revision to which the block IO interface adheres.
Definition: BlockIo.h:222
UINT32 BlockSize
The intrinsic block size of the device.
Definition: BlockIo.h:169
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
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