]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
EDK II: Add Maintainers.txt file
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / DiskIoDxe / DiskIo.h
CommitLineData
adbcbf8f 1/** @file\r
ff61847d 2 Master header file for DiskIo driver. It includes the module private defininitions.\r
adbcbf8f 3\r
493d8e3a 4Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
f42be642 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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
493d8e3a
RN
20#include <Protocol/BlockIo2.h>\r
21#include <Protocol/DiskIo2.h>\r
adbcbf8f 22#include <Protocol/ComponentName.h>\r
23#include <Protocol/DriverBinding.h>\r
24#include <Protocol/DiskIo.h>\r
25#include <Library/DebugLib.h>\r
26#include <Library/UefiDriverEntryPoint.h>\r
27#include <Library/UefiLib.h>\r
28#include <Library/BaseLib.h>\r
29#include <Library/BaseMemoryLib.h>\r
30#include <Library/MemoryAllocationLib.h>\r
31#include <Library/UefiBootServicesTableLib.h>\r
32\r
48557c65 33#define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')\r
adbcbf8f 34typedef struct {\r
493d8e3a
RN
35 UINT32 Signature;\r
36\r
37 EFI_DISK_IO_PROTOCOL DiskIo;\r
38 EFI_DISK_IO2_PROTOCOL DiskIo2;\r
39 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
40 EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
41\r
42 UINT8 *SharedWorkingBuffer;\r
43\r
44 EFI_LOCK TaskQueueLock;\r
45 LIST_ENTRY TaskQueue;\r
adbcbf8f 46} DISK_IO_PRIVATE_DATA;\r
493d8e3a
RN
47#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)\r
48#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO2(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo2, DISK_IO_PRIVATE_DATA_SIGNATURE)\r
adbcbf8f 49\r
493d8e3a
RN
50#define DISK_IO2_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'a', 't')\r
51typedef struct {\r
52 UINT32 Signature;\r
53 LIST_ENTRY Link; /// < link to other task\r
54 LIST_ENTRY Subtasks; /// < header of subtasks\r
55 EFI_DISK_IO2_TOKEN *Token;\r
56 DISK_IO_PRIVATE_DATA *Instance;\r
57} DISK_IO2_TASK;\r
58\r
59#define DISK_IO2_FLUSH_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'f', 't')\r
60typedef struct {\r
61 UINT32 Signature;\r
62 EFI_BLOCK_IO2_TOKEN BlockIo2Token;\r
63 EFI_DISK_IO2_TOKEN *Token;\r
64} DISK_IO2_FLUSH_TASK;\r
65\r
66#define DISK_IO_SUBTASK_SIGNATURE SIGNATURE_32 ('d', 'i', 's', 't')\r
67typedef struct {\r
68 //\r
69 // UnderRun: Offset != 0, Length < BlockSize\r
70 // OverRun: Offset == 0, Length < BlockSize\r
71 // Middle: Offset is block aligned, Length is multiple of block size\r
72 //\r
73 UINT32 Signature;\r
74 LIST_ENTRY Link;\r
75 BOOLEAN Write;\r
76 UINT64 Lba;\r
77 UINT32 Offset;\r
78 UINTN Length;\r
79 UINT8 *WorkingBuffer; /// < NULL indicates using "Buffer" directly\r
80 UINT8 *Buffer;\r
81 BOOLEAN Blocking;\r
82\r
83 //\r
84 // Following fields are for DiskIo2\r
85 //\r
86 DISK_IO2_TASK *Task;\r
87 EFI_BLOCK_IO2_TOKEN BlockIo2Token;\r
88} DISK_IO_SUBTASK;\r
adbcbf8f 89\r
90//\r
91// Global Variables\r
92//\r
d38a0f44 93extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;\r
94extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;\r
95extern EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2;\r
adbcbf8f 96\r
97//\r
98// Prototypes\r
99// Driver model protocol interface\r
100//\r
a8d0c20e 101/**\r
102 Test to see if this driver supports ControllerHandle. \r
103\r
104 @param This Protocol instance pointer.\r
105 @param ControllerHandle Handle of device to test\r
106 @param RemainingDevicePath Optional parameter use to pick a specific child\r
107 device to start.\r
108\r
109 @retval EFI_SUCCESS This driver supports this device\r
110 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
111 @retval other This driver does not support this device\r
112\r
113**/\r
adbcbf8f 114EFI_STATUS\r
115EFIAPI\r
116DiskIoDriverBindingSupported (\r
ea7cb08c 117 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
118 IN EFI_HANDLE ControllerHandle,\r
119 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
adbcbf8f 120 );\r
121\r
a8d0c20e 122/**\r
123 Start this driver on ControllerHandle by opening a Block IO protocol and\r
124 installing a Disk IO protocol on ControllerHandle.\r
125\r
126 @param This Protocol instance pointer.\r
127 @param ControllerHandle Handle of device to bind driver to\r
128 @param RemainingDevicePath Optional parameter use to pick a specific child\r
129 device to start.\r
130\r
131 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
132 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
133 @retval other This driver does not support this device\r
134\r
135**/\r
adbcbf8f 136EFI_STATUS\r
137EFIAPI\r
138DiskIoDriverBindingStart (\r
ea7cb08c 139 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
140 IN EFI_HANDLE ControllerHandle,\r
141 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
adbcbf8f 142 );\r
143\r
a8d0c20e 144/**\r
145 Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r
146 the Block IO protocol on ControllerHandle.\r
147\r
148 @param This Protocol instance pointer.\r
149 @param ControllerHandle Handle of device to stop driver on\r
150 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
151 children is zero stop the entire bus driver.\r
152 @param ChildHandleBuffer List of Child Handles to Stop.\r
153\r
154 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
155 @retval other This driver was not removed from this device\r
156\r
157**/\r
adbcbf8f 158EFI_STATUS\r
159EFIAPI\r
160DiskIoDriverBindingStop (\r
161 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
162 IN EFI_HANDLE ControllerHandle,\r
163 IN UINTN NumberOfChildren,\r
164 IN EFI_HANDLE *ChildHandleBuffer\r
165 );\r
166\r
167//\r
168// Disk I/O Protocol Interface\r
169//\r
a8d0c20e 170/**\r
171 Read BufferSize bytes from Offset into Buffer.\r
172 Reads may support reads that are not aligned on\r
173 sector boundaries. There are three cases:\r
174 UnderRun - The first byte is not on a sector boundary or the read request is\r
175 less than a sector in length.\r
176 Aligned - A read of N contiguous sectors.\r
177 OverRun - The last byte is not on a sector boundary.\r
178\r
179 @param This Protocol instance pointer.\r
180 @param MediaId Id of the media, changes every time the media is replaced.\r
181 @param Offset The starting byte offset to read from\r
182 @param BufferSize Size of Buffer\r
183 @param Buffer Buffer containing read data\r
184\r
185 @retval EFI_SUCCESS The data was read correctly from the device.\r
186 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
187 @retval EFI_NO_MEDIA There is no media in the device.\r
188 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
189 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
190 valid for the device.\r
191\r
192**/\r
adbcbf8f 193EFI_STATUS\r
194EFIAPI\r
195DiskIoReadDisk (\r
196 IN EFI_DISK_IO_PROTOCOL *This,\r
197 IN UINT32 MediaId,\r
198 IN UINT64 Offset,\r
199 IN UINTN BufferSize,\r
200 OUT VOID *Buffer\r
201 );\r
202\r
a8d0c20e 203/**\r
ff61847d 204 Writes BufferSize bytes from Buffer into Offset.\r
a8d0c20e 205 Writes may require a read modify write to support writes that are not\r
206 aligned on sector boundaries. There are three cases:\r
207 UnderRun - The first byte is not on a sector boundary or the write request\r
208 is less than a sector in length. Read modify write is required.\r
209 Aligned - A write of N contiguous sectors.\r
210 OverRun - The last byte is not on a sector boundary. Read modified write\r
211 required.\r
212\r
213 @param This Protocol instance pointer.\r
214 @param MediaId Id of the media, changes every time the media is replaced.\r
215 @param Offset The starting byte offset to read from\r
216 @param BufferSize Size of Buffer\r
217 @param Buffer Buffer containing read data\r
218\r
219 @retval EFI_SUCCESS The data was written correctly to the device.\r
220 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
221 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
222 @retval EFI_NO_MEDIA There is no media in the device.\r
223 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
224 @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not\r
225 valid for the device.\r
226\r
227**/\r
adbcbf8f 228EFI_STATUS\r
229EFIAPI\r
230DiskIoWriteDisk (\r
231 IN EFI_DISK_IO_PROTOCOL *This,\r
232 IN UINT32 MediaId,\r
233 IN UINT64 Offset,\r
234 IN UINTN BufferSize,\r
235 IN VOID *Buffer\r
236 );\r
237\r
493d8e3a
RN
238\r
239/**\r
240 Terminate outstanding asynchronous requests to a device.\r
241\r
242 @param This Indicates a pointer to the calling context.\r
243\r
244 @retval EFI_SUCCESS All outstanding requests were successfully terminated.\r
245 @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel\r
246 operation.\r
247**/\r
248EFI_STATUS\r
249EFIAPI\r
250DiskIo2Cancel (\r
251 IN EFI_DISK_IO2_PROTOCOL *This\r
252 );\r
253\r
254/**\r
255 Reads a specified number of bytes from a device.\r
256\r
257 @param This Indicates a pointer to the calling context.\r
258 @param MediaId ID of the medium to be read.\r
259 @param Offset The starting byte offset on the logical block I/O device to read from.\r
260 @param Token A pointer to the token associated with the transaction.\r
261 If this field is NULL, synchronous/blocking IO is performed.\r
262 @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.\r
263 @param Buffer A pointer to the destination buffer for the data.\r
264 The caller is responsible either having implicit or explicit ownership of the buffer.\r
265\r
266 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device.\r
267 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.\r
268 Event will be signaled upon completion.\r
269 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
270 @retval EFI_NO_MEDIA There is no medium in the device.\r
271 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.\r
272 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.\r
273 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
274\r
275**/\r
276EFI_STATUS\r
277EFIAPI\r
278DiskIo2ReadDiskEx (\r
279 IN EFI_DISK_IO2_PROTOCOL *This,\r
280 IN UINT32 MediaId,\r
281 IN UINT64 Offset,\r
282 IN OUT EFI_DISK_IO2_TOKEN *Token,\r
283 IN UINTN BufferSize,\r
284 OUT VOID *Buffer\r
285 );\r
286\r
287/**\r
288 Writes a specified number of bytes to a device.\r
289\r
290 @param This Indicates a pointer to the calling context.\r
291 @param MediaId ID of the medium to be written.\r
292 @param Offset The starting byte offset on the logical block I/O device to write to.\r
293 @param Token A pointer to the token associated with the transaction.\r
294 If this field is NULL, synchronous/blocking IO is performed.\r
295 @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device.\r
296 @param Buffer A pointer to the buffer containing the data to be written.\r
297\r
298 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device.\r
299 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.\r
300 Event will be signaled upon completion.\r
301 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
302 @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.\r
303 @retval EFI_NO_MEDIA There is no medium in the device.\r
304 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.\r
305 @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.\r
306 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
307\r
308**/\r
309EFI_STATUS\r
310EFIAPI\r
311DiskIo2WriteDiskEx (\r
312 IN EFI_DISK_IO2_PROTOCOL *This,\r
313 IN UINT32 MediaId,\r
314 IN UINT64 Offset,\r
315 IN EFI_DISK_IO2_TOKEN *Token,\r
316 IN UINTN BufferSize,\r
317 IN VOID *Buffer\r
318 );\r
319\r
320/**\r
321 Flushes all modified data to the physical device.\r
322\r
323 @param This Indicates a pointer to the calling context.\r
324 @param Token A pointer to the token associated with the transaction.\r
325 If this field is NULL, synchronous/blocking IO is performed.\r
326\r
327 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device.\r
328 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.\r
329 Event will be signaled upon completion.\r
330 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
331 @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.\r
332 @retval EFI_NO_MEDIA There is no medium in the device.\r
333 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
334**/\r
335EFI_STATUS\r
336EFIAPI\r
337DiskIo2FlushDiskEx (\r
338 IN EFI_DISK_IO2_PROTOCOL *This,\r
339 IN OUT EFI_DISK_IO2_TOKEN *Token\r
340 );\r
341\r
adbcbf8f 342//\r
343// EFI Component Name Functions\r
344//\r
d38a0f44 345/**\r
346 Retrieves a Unicode string that is the user readable name of the driver.\r
347\r
348 This function retrieves the user readable name of a driver in the form of a\r
349 Unicode string. If the driver specified by This has a user readable name in\r
350 the language specified by Language, then a pointer to the driver name is\r
351 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
352 by This does not support the language specified by Language,\r
353 then EFI_UNSUPPORTED is returned.\r
354\r
355 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
356 EFI_COMPONENT_NAME_PROTOCOL instance.\r
357\r
358 @param Language[in] A pointer to a Null-terminated ASCII string\r
359 array indicating the language. This is the\r
360 language of the driver name that the caller is\r
361 requesting, and it must match one of the\r
362 languages specified in SupportedLanguages. The\r
363 number of languages supported by a driver is up\r
364 to the driver writer. Language is specified\r
0254efc0 365 in RFC 4646 or ISO 639-2 language code format.\r
d38a0f44 366\r
367 @param DriverName[out] A pointer to the Unicode string to return.\r
368 This Unicode string is the name of the\r
369 driver specified by This in the language\r
370 specified by Language.\r
371\r
372 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
373 This and the language specified by Language was\r
374 returned in DriverName.\r
375\r
376 @retval EFI_INVALID_PARAMETER Language is NULL.\r
377\r
378 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
379\r
380 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
381 the language specified by Language.\r
382\r
383**/\r
adbcbf8f 384EFI_STATUS\r
385EFIAPI\r
386DiskIoComponentNameGetDriverName (\r
387 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
388 IN CHAR8 *Language,\r
389 OUT CHAR16 **DriverName\r
390 );\r
391\r
d38a0f44 392\r
393/**\r
394 Retrieves a Unicode string that is the user readable name of the controller\r
395 that is being managed by a driver.\r
396\r
397 This function retrieves the user readable name of the controller specified by\r
398 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
399 driver specified by This has a user readable name in the language specified by\r
400 Language, then a pointer to the controller name is returned in ControllerName,\r
401 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
402 managing the controller specified by ControllerHandle and ChildHandle,\r
403 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
404 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
405\r
406 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
407 EFI_COMPONENT_NAME_PROTOCOL instance.\r
408\r
409 @param ControllerHandle[in] The handle of a controller that the driver\r
410 specified by This is managing. This handle\r
411 specifies the controller whose name is to be\r
412 returned.\r
413\r
414 @param ChildHandle[in] The handle of the child controller to retrieve\r
415 the name of. This is an optional parameter that\r
416 may be NULL. It will be NULL for device\r
417 drivers. It will also be NULL for a bus drivers\r
418 that wish to retrieve the name of the bus\r
419 controller. It will not be NULL for a bus\r
420 driver that wishes to retrieve the name of a\r
421 child controller.\r
422\r
423 @param Language[in] A pointer to a Null-terminated ASCII string\r
424 array indicating the language. This is the\r
425 language of the driver name that the caller is\r
426 requesting, and it must match one of the\r
427 languages specified in SupportedLanguages. The\r
428 number of languages supported by a driver is up\r
429 to the driver writer. Language is specified in\r
0254efc0 430 RFC 4646 or ISO 639-2 language code format.\r
d38a0f44 431\r
432 @param ControllerName[out] A pointer to the Unicode string to return.\r
433 This Unicode string is the name of the\r
434 controller specified by ControllerHandle and\r
435 ChildHandle in the language specified by\r
436 Language from the point of view of the driver\r
437 specified by This.\r
438\r
439 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
440 the language specified by Language for the\r
441 driver specified by This was returned in\r
442 DriverName.\r
443\r
284ee2e8 444 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
d38a0f44 445\r
446 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
447 EFI_HANDLE.\r
448\r
449 @retval EFI_INVALID_PARAMETER Language is NULL.\r
450\r
451 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
452\r
453 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
454 managing the controller specified by\r
455 ControllerHandle and ChildHandle.\r
456\r
457 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
458 the language specified by Language.\r
459\r
460**/\r
adbcbf8f 461EFI_STATUS\r
462EFIAPI\r
463DiskIoComponentNameGetControllerName (\r
464 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
465 IN EFI_HANDLE ControllerHandle,\r
466 IN EFI_HANDLE ChildHandle OPTIONAL,\r
467 IN CHAR8 *Language,\r
468 OUT CHAR16 **ControllerName\r
469 );\r
470\r
d38a0f44 471\r
adbcbf8f 472#endif\r