]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/BlockIo.h
clean up the un-suitable ';' location when declaring the functions.
[mirror_edk2.git] / MdePkg / Include / Protocol / BlockIo.h
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 - 2008, Intel Corporation
8 All rights reserved. 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 #define EFI_BLOCK_IO_PROTOCOL_GUID \
22 { \
23 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
24 }
25
26 typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;
27
28 ///
29 /// Protocol GUID name defined in EFI1.1.
30 ///
31 #define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID
32
33 ///
34 /// Protocol defined in EFI1.1.
35 ///
36 typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;
37
38 /**
39 Reset the Block Device.
40
41 @param This Protocol instance pointer.
42 @param ExtendedVerification Driver may perform diagnostics on reset.
43
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.
47
48 **/
49 typedef
50 EFI_STATUS
51 (EFIAPI *EFI_BLOCK_RESET)(
52 IN EFI_BLOCK_IO_PROTOCOL *This,
53 IN BOOLEAN ExtendedVerification
54 );
55
56 /**
57 Read BufferSize bytes from Lba into Buffer.
58
59 @param This Protocol instance pointer.
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 Buffer containing read data
64
65 @retval EFI_SUCCESS The data was read correctly from the device.
66 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
67 @retval EFI_NO_MEDIA There is no media in the device.
68 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
69 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
70 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
71 valid for the device.
72
73 **/
74 typedef
75 EFI_STATUS
76 (EFIAPI *EFI_BLOCK_READ)(
77 IN EFI_BLOCK_IO_PROTOCOL *This,
78 IN UINT32 MediaId,
79 IN EFI_LBA Lba,
80 IN UINTN BufferSize,
81 OUT VOID *Buffer
82 );
83
84 /**
85 Write BufferSize bytes from Lba into Buffer.
86
87 @param This Protocol instance pointer.
88 @param MediaId Id of the media, changes every time the media is replaced.
89 @param Lba The starting Logical Block Address to read from
90 @param BufferSize Size of Buffer, must be a multiple of device block size.
91 @param Buffer Buffer containing read data
92
93 @retval EFI_SUCCESS The data was written correctly to the device.
94 @retval EFI_WRITE_PROTECTED The device can not be written to.
95 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
96 @retval EFI_NO_MEDIA There is no media in the device.
97 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
98 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
99 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not
100 valid for the device.
101
102 **/
103 typedef
104 EFI_STATUS
105 (EFIAPI *EFI_BLOCK_WRITE)(
106 IN EFI_BLOCK_IO_PROTOCOL *This,
107 IN UINT32 MediaId,
108 IN EFI_LBA Lba,
109 IN UINTN BufferSize,
110 IN VOID *Buffer
111 );
112
113 /**
114 Flush the Block Device.
115
116 @param This Protocol instance pointer.
117
118 @retval EFI_SUCCESS All outstanding data was written to the device
119 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
120 @retval EFI_NO_MEDIA There is no media in the device.
121
122 **/
123 typedef
124 EFI_STATUS
125 (EFIAPI *EFI_BLOCK_FLUSH)(
126 IN EFI_BLOCK_IO_PROTOCOL *This
127 );
128
129 /**
130 Block IO read only mode data and updated only via members of BlockIO
131
132 @param MediaId
133 The curent media Id. If the media changes, this value is changed.
134
135 @param RemovableMedia
136 TRUE if the media is removable; otherwise, FALSE.
137
138 @param MediaPresent
139 TRUE if there is a media currently present in the device;
140 othersise, FALSE. THis field shows the media present status
141 as of the most recent ReadBlocks() or WriteBlocks() call.
142
143 @param LogicalPartition
144 TRUE if LBA 0 is the first block of a partition; otherwise
145 FALSE. For media with only one partition this would be TRUE.
146
147 @param ReadOnly
148 TRUE if the media is marked read-only otherwise, FALSE.
149 This field shows the read-only status as of the most recent WriteBlocks () call.
150
151 @param WriteCaching
152 TRUE if the WriteBlock () function caches write data.
153
154 @param BlockSize
155 The intrinsic block size of the device. If the media changes, then
156 this field is updated.
157
158 @param IoAlign
159 Supplies the alignment requirement for any buffer to read or write block(s).
160
161 @param LastBlock
162 The last logical block address on the device.
163 If the media changes, then this field is updated.
164
165 **/
166 typedef struct {
167 UINT32 MediaId;
168 BOOLEAN RemovableMedia;
169 BOOLEAN MediaPresent;
170 BOOLEAN LogicalPartition;
171 BOOLEAN ReadOnly;
172 BOOLEAN WriteCaching;
173 UINT32 BlockSize;
174 UINT32 IoAlign;
175 EFI_LBA LastBlock;
176 } EFI_BLOCK_IO_MEDIA;
177
178 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
179 //
180 // Revision defined in EFI1.1.
181 //
182 #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
183
184 /**
185 @par Protocol Description:
186 This protocol provides control over block devices.
187
188 @param Revision
189 The revision to which the block IO interface adheres. All future
190 revisions must be backwards compatible. If a future version is not
191 back wards compatible, it is not the same GUID.
192
193 @param Media
194 A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
195
196 @param Reset
197 Resets the block device hardware.
198
199 @param ReadBlocks
200 Reads the requested number of blocks from the device.
201
202 @param WriteBlocks
203 Writes the requested number of blocks to the device.
204
205 @param FlushBlocks
206 Flushes and cache blocks. This function is optional and only
207 needs to be supported on block devices that cache writes.
208 **/
209 struct _EFI_BLOCK_IO_PROTOCOL {
210 UINT64 Revision;
211
212 EFI_BLOCK_IO_MEDIA *Media;
213
214 EFI_BLOCK_RESET Reset;
215 EFI_BLOCK_READ ReadBlocks;
216 EFI_BLOCK_WRITE WriteBlocks;
217 EFI_BLOCK_FLUSH FlushBlocks;
218
219 };
220
221 extern EFI_GUID gEfiBlockIoProtocolGuid;
222
223 #endif