boot/efi: Bring in a bunch of additional TianoCore EDK II headers.
[dragonfly.git] / sys / contrib / edk2 / Include / Protocol / BlockIo.h
blob4bc2109db12275b3acad4c9237906b30ff787222
1 /** @file
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 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
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.
16 **/
18 #ifndef __BLOCK_IO_H__
19 #define __BLOCK_IO_H__
21 #define EFI_BLOCK_IO_PROTOCOL_GUID \
22 { \
23 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
26 typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;
28 ///
29 /// Protocol GUID name defined in EFI1.1.
30 ///
31 #define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID
33 ///
34 /// Protocol defined in EFI1.1.
35 ///
36 typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;
38 /**
39 Reset the Block Device.
41 @param This Indicates a pointer to the calling context.
42 @param ExtendedVerification Driver may perform diagnostics on reset.
44 @retval EFI_SUCCESS The device was reset.
45 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
46 not be reset.
48 **/
49 typedef
50 EFI_STATUS
51 (EFIAPI *EFI_BLOCK_RESET)(
52 IN EFI_BLOCK_IO_PROTOCOL *This,
53 IN BOOLEAN ExtendedVerification
56 /**
57 Read BufferSize bytes from Lba into Buffer.
59 @param This Indicates a pointer to the calling context.
60 @param MediaId Id of the media, changes every time the media is replaced.
61 @param Lba The starting Logical Block Address to read from
62 @param BufferSize Size of Buffer, must be a multiple of device block size.
63 @param Buffer A pointer to the destination buffer for the data. The caller is
64 responsible for either having implicit or explicit ownership of the buffer.
66 @retval EFI_SUCCESS The data was read correctly from the device.
67 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
68 @retval EFI_NO_MEDIA There is no media in the device.
69 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
70 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
71 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
72 or the buffer is not on proper alignment.
74 **/
75 typedef
76 EFI_STATUS
77 (EFIAPI *EFI_BLOCK_READ)(
78 IN EFI_BLOCK_IO_PROTOCOL *This,
79 IN UINT32 MediaId,
80 IN EFI_LBA Lba,
81 IN UINTN BufferSize,
82 OUT VOID *Buffer
85 /**
86 Write BufferSize bytes from Lba into Buffer.
88 @param This Indicates a pointer to the calling context.
89 @param MediaId The media ID that the write request is for.
90 @param Lba The starting logical block address to be written. The caller is
91 responsible for writing to only legitimate locations.
92 @param BufferSize Size of Buffer, must be a multiple of device block size.
93 @param Buffer A pointer to the source buffer for the data.
95 @retval EFI_SUCCESS The data was written correctly to the device.
96 @retval EFI_WRITE_PROTECTED The device can not be written to.
97 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
98 @retval EFI_NO_MEDIA There is no media in the device.
99 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
100 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
101 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
102 or the buffer is not on proper alignment.
105 typedef
106 EFI_STATUS
107 (EFIAPI *EFI_BLOCK_WRITE)(
108 IN EFI_BLOCK_IO_PROTOCOL *This,
109 IN UINT32 MediaId,
110 IN EFI_LBA Lba,
111 IN UINTN BufferSize,
112 IN VOID *Buffer
116 Flush the Block Device.
118 @param This Indicates a pointer to the calling context.
120 @retval EFI_SUCCESS All outstanding data was written to the device
121 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
122 @retval EFI_NO_MEDIA There is no media in the device.
125 typedef
126 EFI_STATUS
127 (EFIAPI *EFI_BLOCK_FLUSH)(
128 IN EFI_BLOCK_IO_PROTOCOL *This
132 Block IO read only mode data and updated only via members of BlockIO
134 typedef struct {
136 /// The curent media Id. If the media changes, this value is changed.
138 UINT32 MediaId;
141 /// TRUE if the media is removable; otherwise, FALSE.
142 ///
143 BOOLEAN RemovableMedia;
146 /// TRUE if there is a media currently present in the device;
147 /// othersise, FALSE. THis field shows the media present status
148 /// as of the most recent ReadBlocks() or WriteBlocks() call.
150 BOOLEAN MediaPresent;
153 /// TRUE if LBA 0 is the first block of a partition; otherwise
154 /// FALSE. For media with only one partition this would be TRUE.
156 BOOLEAN LogicalPartition;
159 /// TRUE if the media is marked read-only otherwise, FALSE.
160 /// This field shows the read-only status as of the most recent WriteBlocks () call.
162 BOOLEAN ReadOnly;
165 /// TRUE if the WriteBlock () function caches write data.
167 BOOLEAN WriteCaching;
170 /// The intrinsic block size of the device. If the media changes, then
171 /// this field is updated.
173 UINT32 BlockSize;
176 /// Supplies the alignment requirement for any buffer to read or write block(s).
178 UINT32 IoAlign;
181 /// The last logical block address on the device.
182 /// If the media changes, then this field is updated.
184 EFI_LBA LastBlock;
187 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
188 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
189 /// a physical block boundary.
191 EFI_LBA LowestAlignedLba;
194 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
195 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
196 /// per physical block.
198 UINT32 LogicalBlocksPerPhysicalBlock;
201 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
202 /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
203 /// granularity as a number of logical blocks.
205 UINT32 OptimalTransferLengthGranularity;
206 } EFI_BLOCK_IO_MEDIA;
208 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
209 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
210 #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031
213 /// Revision defined in EFI1.1.
214 ///
215 #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
218 /// This protocol provides control over block devices.
220 struct _EFI_BLOCK_IO_PROTOCOL {
222 /// The revision to which the block IO interface adheres. All future
223 /// revisions must be backwards compatible. If a future version is not
224 /// back wards compatible, it is not the same GUID.
226 UINT64 Revision;
228 /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
230 EFI_BLOCK_IO_MEDIA *Media;
232 EFI_BLOCK_RESET Reset;
233 EFI_BLOCK_READ ReadBlocks;
234 EFI_BLOCK_WRITE WriteBlocks;
235 EFI_BLOCK_FLUSH FlushBlocks;
239 extern EFI_GUID gEfiBlockIoProtocolGuid;
241 #endif