3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Block IO protocol as defined in the EFI 1.0 specification.
20 The Block IO protocol is used to abstract block devices like hard drives,
21 DVD-ROMs and floppy drives.
26 #ifndef __BLOCK_IO_H__
27 #define __BLOCK_IO_H__
29 #define EFI_BLOCK_IO_PROTOCOL_GUID \
31 0x964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
35 // Forward reference for pure ANSI compatability
37 EFI_FORWARD_DECLARATION (EFI_BLOCK_IO_PROTOCOL
);
41 (EFIAPI
*EFI_BLOCK_RESET
) (
42 IN EFI_BLOCK_IO_PROTOCOL
* This
,
43 IN BOOLEAN ExtendedVerification
48 Reset the Block Device.
51 This - Protocol instance pointer.
52 ExtendedVerification - Driver may perform diagnostics on reset.
55 EFI_SUCCESS - The device was reset.
56 EFI_DEVICE_ERROR - The device is not functioning properly and could
64 (EFIAPI
*EFI_BLOCK_READ
) (
65 IN EFI_BLOCK_IO_PROTOCOL
* This
,
74 Read BufferSize bytes from Lba into Buffer.
77 This - Protocol instance pointer.
78 MediaId - Id of the media, changes every time the media is replaced.
79 Lba - The starting Logical Block Address to read from
80 BufferSize - Size of Buffer, must be a multiple of device block size.
81 Buffer - Buffer containing read data
84 EFI_SUCCESS - The data was read correctly from the device.
85 EFI_DEVICE_ERROR - The device reported an error while performing the read.
86 EFI_NO_MEDIA - There is no media in the device.
87 EFI_MEDIA_CHANGED - The MediaId does not matched the current device.
88 EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the
90 EFI_INVALID_PARAMETER - The read request contains device addresses that are not
98 (EFIAPI
*EFI_BLOCK_WRITE
) (
99 IN EFI_BLOCK_IO_PROTOCOL
* This
,
108 Write BufferSize bytes from Lba into Buffer.
111 This - Protocol instance pointer.
112 MediaId - Id of the media, changes every time the media is replaced.
113 Lba - The starting Logical Block Address to read from
114 BufferSize - Size of Buffer, must be a multiple of device block size.
115 Buffer - Buffer containing read data
118 EFI_SUCCESS - The data was written correctly to the device.
119 EFI_WRITE_PROTECTED - The device can not be written to.
120 EFI_DEVICE_ERROR - The device reported an error while performing the write.
121 EFI_NO_MEDIA - There is no media in the device.
122 EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
123 EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the
125 EFI_INVALID_PARAMETER - The write request contains a LBA that is not
126 valid for the device.
133 (EFIAPI
*EFI_BLOCK_FLUSH
) (
134 IN EFI_BLOCK_IO_PROTOCOL
* This
139 Flush the Block Device.
142 This - Protocol instance pointer.
145 EFI_SUCCESS - All outstanding data was written to the device
146 EFI_DEVICE_ERROR - The device reported an error while writting back the data
147 EFI_NO_MEDIA - There is no media in the device.
154 Block IO read only mode data and updated only via members of BlockIO
156 MediaId - The curent media Id. If the media changes, this value is changed.
157 RemovableMedia - TRUE if the media is removable; otherwise, FALSE.
158 MediaPresent - TRUE if there is a media currently present in the device;
159 othersise, FALSE. THis field shows the media present status
160 as of the most recent ReadBlocks() or WriteBlocks() call.
161 LogicalPartition - TRUE if LBA 0 is the first block of a partition; otherwise
162 FALSE. For media with only one partition this would be TRUE.
163 ReadOnly - TRUE if the media is marked read-only otherwise, FALSE. This
164 field shows the read-only status as of the most recent
166 WriteCaching - TRUE if the WriteBlock () function caches write data.
167 BlockSize - The intrinsic block size of the device. If the media changes, then
168 this field is updated.
169 IoAlign - Supplies the alignment requirement for any buffer to read or write
171 LastBlock - The last logical block address on the device. If the media changes,
172 then this field is updated.
177 BOOLEAN RemovableMedia
;
178 BOOLEAN MediaPresent
;
180 BOOLEAN LogicalPartition
;
182 BOOLEAN WriteCaching
;
188 } EFI_BLOCK_IO_MEDIA
;
190 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
192 typedef struct _EFI_BLOCK_IO_PROTOCOL
{
195 EFI_BLOCK_IO_MEDIA
*Media
;
197 EFI_BLOCK_RESET Reset
;
198 EFI_BLOCK_READ ReadBlocks
;
199 EFI_BLOCK_WRITE WriteBlocks
;
200 EFI_BLOCK_FLUSH FlushBlocks
;
202 } EFI_BLOCK_IO_PROTOCOL
;
204 extern EFI_GUID gEfiBlockIoProtocolGuid
;