]>
Commit | Line | Data |
---|---|---|
adbcbf8f | 1 | /** @file\r |
ff61847d | 2 | Master header file for DiskIo driver. It includes the module private defininitions.\r |
adbcbf8f | 3 | \r |
f42be642 | 4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
adbcbf8f | 12 | \r |
13 | **/\r | |
14 | \r | |
ea7cb08c | 15 | #ifndef _DISK_IO_H_\r |
16 | #define _DISK_IO_H_\r | |
adbcbf8f | 17 | \r |
18 | #include <Uefi.h>\r | |
19 | #include <Protocol/BlockIo.h>\r | |
20 | #include <Protocol/ComponentName.h>\r | |
21 | #include <Protocol/DriverBinding.h>\r | |
22 | #include <Protocol/DiskIo.h>\r | |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/UefiDriverEntryPoint.h>\r | |
25 | #include <Library/UefiLib.h>\r | |
26 | #include <Library/BaseLib.h>\r | |
27 | #include <Library/BaseMemoryLib.h>\r | |
28 | #include <Library/MemoryAllocationLib.h>\r | |
29 | #include <Library/UefiBootServicesTableLib.h>\r | |
30 | \r | |
31 | \r | |
48557c65 | 32 | #define DATA_BUFFER_BLOCK_NUM 64\r |
adbcbf8f | 33 | \r |
48557c65 | 34 | #define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')\r |
adbcbf8f | 35 | \r |
36 | typedef struct {\r | |
37 | UINTN Signature;\r | |
38 | EFI_DISK_IO_PROTOCOL DiskIo;\r | |
39 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r | |
40 | } DISK_IO_PRIVATE_DATA;\r | |
41 | \r | |
42 | #define DISK_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)\r | |
43 | \r | |
44 | //\r | |
45 | // Global Variables\r | |
46 | //\r | |
d38a0f44 | 47 | extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;\r |
48 | extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;\r | |
49 | extern EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2;\r | |
adbcbf8f | 50 | \r |
51 | //\r | |
52 | // Prototypes\r | |
53 | // Driver model protocol interface\r | |
54 | //\r | |
a8d0c20e | 55 | /**\r |
56 | Test to see if this driver supports ControllerHandle. \r | |
57 | \r | |
58 | @param This Protocol instance pointer.\r | |
59 | @param ControllerHandle Handle of device to test\r | |
60 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
61 | device to start.\r | |
62 | \r | |
63 | @retval EFI_SUCCESS This driver supports this device\r | |
64 | @retval EFI_ALREADY_STARTED This driver is already running on this device\r | |
65 | @retval other This driver does not support this device\r | |
66 | \r | |
67 | **/\r | |
adbcbf8f | 68 | EFI_STATUS\r |
69 | EFIAPI\r | |
70 | DiskIoDriverBindingSupported (\r | |
ea7cb08c | 71 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
72 | IN EFI_HANDLE ControllerHandle,\r | |
73 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
adbcbf8f | 74 | );\r |
75 | \r | |
a8d0c20e | 76 | /**\r |
77 | Start this driver on ControllerHandle by opening a Block IO protocol and\r | |
78 | installing a Disk IO protocol on ControllerHandle.\r | |
79 | \r | |
80 | @param This Protocol instance pointer.\r | |
81 | @param ControllerHandle Handle of device to bind driver to\r | |
82 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
83 | device to start.\r | |
84 | \r | |
85 | @retval EFI_SUCCESS This driver is added to ControllerHandle\r | |
86 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r | |
87 | @retval other This driver does not support this device\r | |
88 | \r | |
89 | **/\r | |
adbcbf8f | 90 | EFI_STATUS\r |
91 | EFIAPI\r | |
92 | DiskIoDriverBindingStart (\r | |
ea7cb08c | 93 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
94 | IN EFI_HANDLE ControllerHandle,\r | |
95 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
adbcbf8f | 96 | );\r |
97 | \r | |
a8d0c20e | 98 | /**\r |
99 | Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r | |
100 | the Block IO protocol on ControllerHandle.\r | |
101 | \r | |
102 | @param This Protocol instance pointer.\r | |
103 | @param ControllerHandle Handle of device to stop driver on\r | |
104 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
105 | children is zero stop the entire bus driver.\r | |
106 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
107 | \r | |
108 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
109 | @retval other This driver was not removed from this device\r | |
110 | \r | |
111 | **/\r | |
adbcbf8f | 112 | EFI_STATUS\r |
113 | EFIAPI\r | |
114 | DiskIoDriverBindingStop (\r | |
115 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
116 | IN EFI_HANDLE ControllerHandle,\r | |
117 | IN UINTN NumberOfChildren,\r | |
118 | IN EFI_HANDLE *ChildHandleBuffer\r | |
119 | );\r | |
120 | \r | |
121 | //\r | |
122 | // Disk I/O Protocol Interface\r | |
123 | //\r | |
a8d0c20e | 124 | /**\r |
125 | Read BufferSize bytes from Offset into Buffer.\r | |
126 | Reads may support reads that are not aligned on\r | |
127 | sector boundaries. There are three cases:\r | |
128 | UnderRun - The first byte is not on a sector boundary or the read request is\r | |
129 | less than a sector in length.\r | |
130 | Aligned - A read of N contiguous sectors.\r | |
131 | OverRun - The last byte is not on a sector boundary.\r | |
132 | \r | |
133 | @param This Protocol instance pointer.\r | |
134 | @param MediaId Id of the media, changes every time the media is replaced.\r | |
135 | @param Offset The starting byte offset to read from\r | |
136 | @param BufferSize Size of Buffer\r | |
137 | @param Buffer Buffer containing read data\r | |
138 | \r | |
139 | @retval EFI_SUCCESS The data was read correctly from the device.\r | |
140 | @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r | |
141 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
142 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
143 | @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r | |
144 | valid for the device.\r | |
145 | \r | |
146 | **/\r | |
adbcbf8f | 147 | EFI_STATUS\r |
148 | EFIAPI\r | |
149 | DiskIoReadDisk (\r | |
150 | IN EFI_DISK_IO_PROTOCOL *This,\r | |
151 | IN UINT32 MediaId,\r | |
152 | IN UINT64 Offset,\r | |
153 | IN UINTN BufferSize,\r | |
154 | OUT VOID *Buffer\r | |
155 | );\r | |
156 | \r | |
a8d0c20e | 157 | /**\r |
ff61847d | 158 | Writes BufferSize bytes from Buffer into Offset.\r |
a8d0c20e | 159 | Writes may require a read modify write to support writes that are not\r |
160 | aligned on sector boundaries. There are three cases:\r | |
161 | UnderRun - The first byte is not on a sector boundary or the write request\r | |
162 | is less than a sector in length. Read modify write is required.\r | |
163 | Aligned - A write of N contiguous sectors.\r | |
164 | OverRun - The last byte is not on a sector boundary. Read modified write\r | |
165 | required.\r | |
166 | \r | |
167 | @param This Protocol instance pointer.\r | |
168 | @param MediaId Id of the media, changes every time the media is replaced.\r | |
169 | @param Offset The starting byte offset to read from\r | |
170 | @param BufferSize Size of Buffer\r | |
171 | @param Buffer Buffer containing read data\r | |
172 | \r | |
173 | @retval EFI_SUCCESS The data was written correctly to the device.\r | |
174 | @retval EFI_WRITE_PROTECTED The device can not be written to.\r | |
175 | @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r | |
176 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
177 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
178 | @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not\r | |
179 | valid for the device.\r | |
180 | \r | |
181 | **/\r | |
adbcbf8f | 182 | EFI_STATUS\r |
183 | EFIAPI\r | |
184 | DiskIoWriteDisk (\r | |
185 | IN EFI_DISK_IO_PROTOCOL *This,\r | |
186 | IN UINT32 MediaId,\r | |
187 | IN UINT64 Offset,\r | |
188 | IN UINTN BufferSize,\r | |
189 | IN VOID *Buffer\r | |
190 | );\r | |
191 | \r | |
192 | //\r | |
193 | // EFI Component Name Functions\r | |
194 | //\r | |
d38a0f44 | 195 | /**\r |
196 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
197 | \r | |
198 | This function retrieves the user readable name of a driver in the form of a\r | |
199 | Unicode string. If the driver specified by This has a user readable name in\r | |
200 | the language specified by Language, then a pointer to the driver name is\r | |
201 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
202 | by This does not support the language specified by Language,\r | |
203 | then EFI_UNSUPPORTED is returned.\r | |
204 | \r | |
205 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
206 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
207 | \r | |
208 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
209 | array indicating the language. This is the\r | |
210 | language of the driver name that the caller is\r | |
211 | requesting, and it must match one of the\r | |
212 | languages specified in SupportedLanguages. The\r | |
213 | number of languages supported by a driver is up\r | |
214 | to the driver writer. Language is specified\r | |
215 | in RFC 3066 or ISO 639-2 language code format.\r | |
216 | \r | |
217 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
218 | This Unicode string is the name of the\r | |
219 | driver specified by This in the language\r | |
220 | specified by Language.\r | |
221 | \r | |
222 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
223 | This and the language specified by Language was\r | |
224 | returned in DriverName.\r | |
225 | \r | |
226 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
227 | \r | |
228 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
229 | \r | |
230 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
231 | the language specified by Language.\r | |
232 | \r | |
233 | **/\r | |
adbcbf8f | 234 | EFI_STATUS\r |
235 | EFIAPI\r | |
236 | DiskIoComponentNameGetDriverName (\r | |
237 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
238 | IN CHAR8 *Language,\r | |
239 | OUT CHAR16 **DriverName\r | |
240 | );\r | |
241 | \r | |
d38a0f44 | 242 | \r |
243 | /**\r | |
244 | Retrieves a Unicode string that is the user readable name of the controller\r | |
245 | that is being managed by a driver.\r | |
246 | \r | |
247 | This function retrieves the user readable name of the controller specified by\r | |
248 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
249 | driver specified by This has a user readable name in the language specified by\r | |
250 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
251 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
252 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
253 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
254 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
255 | \r | |
256 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
257 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
258 | \r | |
259 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
260 | specified by This is managing. This handle\r | |
261 | specifies the controller whose name is to be\r | |
262 | returned.\r | |
263 | \r | |
264 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
265 | the name of. This is an optional parameter that\r | |
266 | may be NULL. It will be NULL for device\r | |
267 | drivers. It will also be NULL for a bus drivers\r | |
268 | that wish to retrieve the name of the bus\r | |
269 | controller. It will not be NULL for a bus\r | |
270 | driver that wishes to retrieve the name of a\r | |
271 | child controller.\r | |
272 | \r | |
273 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
274 | array indicating the language. This is the\r | |
275 | language of the driver name that the caller is\r | |
276 | requesting, and it must match one of the\r | |
277 | languages specified in SupportedLanguages. The\r | |
278 | number of languages supported by a driver is up\r | |
279 | to the driver writer. Language is specified in\r | |
280 | RFC 3066 or ISO 639-2 language code format.\r | |
281 | \r | |
282 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
283 | This Unicode string is the name of the\r | |
284 | controller specified by ControllerHandle and\r | |
285 | ChildHandle in the language specified by\r | |
286 | Language from the point of view of the driver\r | |
287 | specified by This.\r | |
288 | \r | |
289 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
290 | the language specified by Language for the\r | |
291 | driver specified by This was returned in\r | |
292 | DriverName.\r | |
293 | \r | |
294 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
295 | \r | |
296 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
297 | EFI_HANDLE.\r | |
298 | \r | |
299 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
300 | \r | |
301 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
302 | \r | |
303 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
304 | managing the controller specified by\r | |
305 | ControllerHandle and ChildHandle.\r | |
306 | \r | |
307 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
308 | the language specified by Language.\r | |
309 | \r | |
310 | **/\r | |
adbcbf8f | 311 | EFI_STATUS\r |
312 | EFIAPI\r | |
313 | DiskIoComponentNameGetControllerName (\r | |
314 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
315 | IN EFI_HANDLE ControllerHandle,\r | |
316 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
317 | IN CHAR8 *Language,\r | |
318 | OUT CHAR16 **ControllerName\r | |
319 | );\r | |
320 | \r | |
d38a0f44 | 321 | \r |
adbcbf8f | 322 | #endif\r |