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