]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/BlockIo.h
Import Pal.h and Sal.h.
[mirror_edk2.git] / MdePkg / Include / Protocol / BlockIo.h
CommitLineData
d1f95000 1/** @file\r
2 Block IO protocol as defined in the EFI 1.0 specification.\r
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
7 Copyright (c) 2006, Intel Corporation \r
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
16 Module Name: BlockIo.h\r
17\r
18**/\r
19\r
20#ifndef __BLOCK_IO_H__\r
21#define __BLOCK_IO_H__\r
22\r
23#define EFI_BLOCK_IO_PROTOCOL_GUID \\r
24 { \\r
25 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
26 }\r
27\r
a6508c05 28typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;\r
29\r
d1f95000 30//\r
a6508c05 31// Protocol GUID name defined in EFI1.1.\r
32// \r
33#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID\r
34\r
d1f95000 35//\r
a6508c05 36// Protocol defined in EFI1.1.\r
37// \r
38typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;\r
d1f95000 39\r
40/**\r
41 Reset the Block Device.\r
42\r
43 @param This Protocol instance pointer.\r
44 @param ExtendedVerification Driver may perform diagnostics on reset.\r
45\r
46 @retval EFI_SUCCESS The device was reset.\r
47 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
48 not be reset.\r
49\r
50**/\r
51typedef\r
52EFI_STATUS\r
53(EFIAPI *EFI_BLOCK_RESET) (\r
54 IN EFI_BLOCK_IO_PROTOCOL *This,\r
55 IN BOOLEAN ExtendedVerification\r
56 )\r
57;\r
58\r
59/**\r
60 Read BufferSize bytes from Lba into Buffer.\r
61\r
62 @param This Protocol instance pointer.\r
63 @param MediaId Id of the media, changes every time the media is replaced.\r
64 @param Lba The starting Logical Block Address to read from\r
65 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
66 @param Buffer Buffer containing read data\r
67\r
68 @retval EFI_SUCCESS The data was read correctly from the device.\r
69 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
70 @retval EFI_NO_MEDIA There is no media in the device.\r
71 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
72 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
73 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
74 valid for the device.\r
75\r
76**/\r
77typedef\r
78EFI_STATUS\r
79(EFIAPI *EFI_BLOCK_READ) (\r
80 IN EFI_BLOCK_IO_PROTOCOL *This,\r
81 IN UINT32 MediaId,\r
82 IN EFI_LBA Lba,\r
83 IN UINTN BufferSize,\r
84 OUT VOID *Buffer\r
85 )\r
86;\r
87\r
88/**\r
89 Write BufferSize bytes from Lba into Buffer.\r
90\r
91 @param This Protocol instance pointer.\r
92 @param MediaId Id of the media, changes every time the media is replaced.\r
93 @param Lba The starting Logical Block Address to read from\r
94 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
95 @param Buffer Buffer containing read data\r
96\r
97 @retval EFI_SUCCESS The data was written correctly to the device.\r
98 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
99 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
100 @retval EFI_NO_MEDIA There is no media in the device.\r
101 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
102 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
103 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not\r
104 valid for the device.\r
105\r
106**/\r
107typedef\r
108EFI_STATUS\r
109(EFIAPI *EFI_BLOCK_WRITE) (\r
110 IN EFI_BLOCK_IO_PROTOCOL *This,\r
111 IN UINT32 MediaId,\r
112 IN EFI_LBA Lba,\r
113 IN UINTN BufferSize,\r
114 IN VOID *Buffer\r
115 )\r
116;\r
117\r
118/**\r
119 Flush the Block Device.\r
120\r
121 @param This Protocol instance pointer.\r
122\r
123 @retval EFI_SUCCESS All outstanding data was written to the device\r
124 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
125 @retval EFI_NO_MEDIA There is no media in the device.\r
126\r
127**/\r
128typedef\r
129EFI_STATUS\r
130(EFIAPI *EFI_BLOCK_FLUSH) (\r
131 IN EFI_BLOCK_IO_PROTOCOL *This\r
132 )\r
133;\r
134\r
135/**\r
136 Block IO read only mode data and updated only via members of BlockIO\r
137\r
138**/\r
139typedef struct {\r
140 UINT32 MediaId; ///< The curent media Id. If the media changes, this value is changed.\r
141 BOOLEAN RemovableMedia; ///< TRUE if the media is removable; otherwise, FALSE.\r
142 BOOLEAN MediaPresent; /**< TRUE if there is a media currently present in the device;\r
143 othersise, FALSE. THis field shows the media present status\r
144 as of the most recent ReadBlocks() or WriteBlocks() call.\r
145 **/\r
146 BOOLEAN LogicalPartition; /**< TRUE if LBA 0 is the first block of a partition; otherwise\r
147 FALSE. For media with only one partition this would be TRUE.\r
148 **/\r
149 BOOLEAN ReadOnly; /**< TRUE if the media is marked read-only otherwise, FALSE.\r
150 This field shows the read-only status as of the most recent WriteBlocks () call.\r
151 **/\r
152 BOOLEAN WriteCaching; ///< TRUE if the WriteBlock () function caches write data.\r
153\r
154 UINT32 BlockSize; /**< The intrinsic block size of the device. If the media changes, then\r
155 this field is updated.\r
156 **/\r
157 UINT32 IoAlign; ///< Supplies the alignment requirement for any buffer to read or write block(s).\r
158\r
159 EFI_LBA LastBlock; /**< The last logical block address on the device.\r
160 If the media changes, then this field is updated.\r
161 **/\r
162} EFI_BLOCK_IO_MEDIA;\r
163\r
164#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000\r
a6508c05 165//\r
166// Revision defined in EFI1.1.\r
167// \r
168#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION\r
d1f95000 169\r
170struct _EFI_BLOCK_IO_PROTOCOL {\r
171 UINT64 Revision;\r
172\r
173 EFI_BLOCK_IO_MEDIA *Media;\r
174\r
175 EFI_BLOCK_RESET Reset;\r
176 EFI_BLOCK_READ ReadBlocks;\r
177 EFI_BLOCK_WRITE WriteBlocks;\r
178 EFI_BLOCK_FLUSH FlushBlocks;\r
179\r
180};\r
181\r
182extern EFI_GUID gEfiBlockIoProtocolGuid;\r
183\r
184#endif\r