]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/BlockIo.h
Code Scrub for Protocol and Ppi Definition
[mirror_edk2.git] / MdePkg / Include / Protocol / BlockIo.h
CommitLineData
d1f95000 1/** @file\r
8a7d75b0 2 Block IO protocol as defined in the UEFI 2.0 specification.\r
d1f95000 3\r
4 The Block IO protocol is used to abstract block devices like hard drives,\r
5 DVD-ROMs and floppy drives.\r
6\r
4ca9b6c4 7 Copyright (c) 2006 - 2008, Intel Corporation \r
d1f95000 8 All rights reserved. This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
d1f95000 16**/\r
17\r
18#ifndef __BLOCK_IO_H__\r
19#define __BLOCK_IO_H__\r
20\r
21#define EFI_BLOCK_IO_PROTOCOL_GUID \\r
22 { \\r
23 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
24 }\r
25\r
a6508c05 26typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;\r
27\r
d1f95000 28//\r
a6508c05 29// Protocol GUID name defined in EFI1.1.\r
30// \r
31#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID\r
32\r
d1f95000 33//\r
a6508c05 34// Protocol defined in EFI1.1.\r
35// \r
36typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;\r
d1f95000 37\r
38/**\r
39 Reset the Block Device.\r
40\r
41 @param This Protocol instance pointer.\r
42 @param ExtendedVerification Driver may perform diagnostics on reset.\r
43\r
44 @retval EFI_SUCCESS The device was reset.\r
45 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
46 not be reset.\r
47\r
48**/\r
49typedef\r
50EFI_STATUS\r
8b13229b 51(EFIAPI *EFI_BLOCK_RESET)(\r
d1f95000 52 IN EFI_BLOCK_IO_PROTOCOL *This,\r
53 IN BOOLEAN ExtendedVerification\r
54 )\r
55;\r
56\r
57/**\r
58 Read BufferSize bytes from Lba into Buffer.\r
59\r
60 @param This Protocol instance pointer.\r
61 @param MediaId Id of the media, changes every time the media is replaced.\r
62 @param Lba The starting Logical Block Address to read from\r
63 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
64 @param Buffer Buffer containing read data\r
65\r
66 @retval EFI_SUCCESS The data was read correctly from the device.\r
67 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
68 @retval EFI_NO_MEDIA There is no media in the device.\r
69 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
70 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
71 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
72 valid for the device.\r
73\r
74**/\r
75typedef\r
76EFI_STATUS\r
8b13229b 77(EFIAPI *EFI_BLOCK_READ)(\r
d1f95000 78 IN EFI_BLOCK_IO_PROTOCOL *This,\r
79 IN UINT32 MediaId,\r
80 IN EFI_LBA Lba,\r
81 IN UINTN BufferSize,\r
82 OUT VOID *Buffer\r
83 )\r
84;\r
85\r
86/**\r
87 Write BufferSize bytes from Lba into Buffer.\r
88\r
89 @param This Protocol instance pointer.\r
90 @param MediaId Id of the media, changes every time the media is replaced.\r
91 @param Lba The starting Logical Block Address to read from\r
92 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
93 @param Buffer Buffer containing read data\r
94\r
95 @retval EFI_SUCCESS The data was written correctly to the device.\r
96 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
97 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
98 @retval EFI_NO_MEDIA There is no media in the device.\r
99 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
100 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
101 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not\r
102 valid for the device.\r
103\r
104**/\r
105typedef\r
106EFI_STATUS\r
8b13229b 107(EFIAPI *EFI_BLOCK_WRITE)(\r
d1f95000 108 IN EFI_BLOCK_IO_PROTOCOL *This,\r
109 IN UINT32 MediaId,\r
110 IN EFI_LBA Lba,\r
111 IN UINTN BufferSize,\r
112 IN VOID *Buffer\r
113 )\r
114;\r
115\r
116/**\r
117 Flush the Block Device.\r
118\r
119 @param This Protocol instance pointer.\r
120\r
121 @retval EFI_SUCCESS All outstanding data was written to the device\r
122 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
123 @retval EFI_NO_MEDIA There is no media in the device.\r
124\r
125**/\r
126typedef\r
127EFI_STATUS\r
8b13229b 128(EFIAPI *EFI_BLOCK_FLUSH)(\r
d1f95000 129 IN EFI_BLOCK_IO_PROTOCOL *This\r
130 )\r
131;\r
132\r
133/**\r
134 Block IO read only mode data and updated only via members of BlockIO\r
4ca9b6c4
LG
135 \r
136 @param MediaId\r
137 The curent media Id. If the media changes, this value is changed.\r
138 \r
139 @param RemovableMedia\r
140 TRUE if the media is removable; otherwise, FALSE.\r
141 \r
142 @param MediaPresent\r
143 TRUE if there is a media currently present in the device;\r
144 othersise, FALSE. THis field shows the media present status\r
145 as of the most recent ReadBlocks() or WriteBlocks() call.\r
146\r
147 @param LogicalPartition\r
148 TRUE if LBA 0 is the first block of a partition; otherwise\r
149 FALSE. For media with only one partition this would be TRUE.\r
150 \r
151 @param ReadOnly\r
152 TRUE if the media is marked read-only otherwise, FALSE.\r
153 This field shows the read-only status as of the most recent WriteBlocks () call.\r
154 \r
155 @param WriteCaching\r
156 TRUE if the WriteBlock () function caches write data.\r
157\r
158 @param BlockSize\r
159 The intrinsic block size of the device. If the media changes, then\r
160 this field is updated. \r
161\r
162 @param IoAlign\r
163 Supplies the alignment requirement for any buffer to read or write block(s).\r
164 \r
165 @param LastBlock\r
166 The last logical block address on the device.\r
167 If the media changes, then this field is updated. \r
d1f95000 168\r
169**/\r
170typedef struct {\r
4ca9b6c4
LG
171 UINT32 MediaId; \r
172 BOOLEAN RemovableMedia;\r
173 BOOLEAN MediaPresent;\r
174 BOOLEAN LogicalPartition;\r
175 BOOLEAN ReadOnly;\r
176 BOOLEAN WriteCaching; \r
177 UINT32 BlockSize; \r
178 UINT32 IoAlign; \r
179 EFI_LBA LastBlock; \r
d1f95000 180} EFI_BLOCK_IO_MEDIA;\r
181\r
182#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000\r
a6508c05 183//\r
184// Revision defined in EFI1.1.\r
185// \r
186#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION\r
d1f95000 187\r
4ca9b6c4
LG
188/**\r
189 @par Protocol Description:\r
190 This protocol provides control over block devices.\r
191\r
192 @param Revision \r
193 The revision to which the block IO interface adheres. All future\r
194 revisions must be backwards compatible. If a future version is not\r
195 back wards compatible, it is not the same GUID.\r
196 \r
197 @param Media \r
198 A pointer to the EFI_BLOCK_IO_MEDIA data for this device.\r
199\r
200 @param Reset \r
201 Resets the block device hardware.\r
202\r
203 @param ReadBlocks \r
204 Reads the requested number of blocks from the device. \r
205\r
206 @param WriteBlocks \r
207 Writes the requested number of blocks to the device. \r
208\r
209 @param FlushBlocks \r
210 Flushes and cache blocks. This function is optional and only\r
211 needs to be supported on block devices that cache writes. \r
212**/\r
d1f95000 213struct _EFI_BLOCK_IO_PROTOCOL {\r
214 UINT64 Revision;\r
215\r
216 EFI_BLOCK_IO_MEDIA *Media;\r
217\r
218 EFI_BLOCK_RESET Reset;\r
219 EFI_BLOCK_READ ReadBlocks;\r
220 EFI_BLOCK_WRITE WriteBlocks;\r
221 EFI_BLOCK_FLUSH FlushBlocks;\r
222\r
223};\r
224\r
225extern EFI_GUID gEfiBlockIoProtocolGuid;\r
226\r
227#endif\r