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