+/** @file\r
+ Disk IO protocol as defined in the UEFI 2.0 specification.\r
+\r
+ The Disk IO2 protocol is used to convert block oriented devices into byte\r
+ oriented devices. The Disk IO protocol is intended to layer on top of the\r
+ Block IO protocol.\r
+\r
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef __DISK_IO2_H__\r
+#define __DISK_IO2_H__\r
+\r
+#define EFI_DISK_IO2_PROTOCOL_GUID \\r
+ { \\r
+ 0x151c8eae, 0x7f2c, 0x472c, 0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88 \\r
+ }\r
+\r
+typedef struct _EFI_DISK_IO2_PROTOCOL EFI_DISK_IO2_PROTOCOL;\r
+\r
+/**\r
+ The struct of Disk IO2 Token.\r
+**/\r
+typedef struct {\r
+ //\r
+ // If Event is NULL, then blocking I/O is performed.\r
+ // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed,\r
+ // and Event will be signaled when the I/O request is completed.\r
+ // The caller must be prepared to handle the case where the callback associated with Event occurs\r
+ // before the original asynchronous I/O request call returns.\r
+ //\r
+ EFI_EVENT Event;\r
+\r
+ //\r
+ // Defines whether or not the signaled event encountered an error.\r
+ //\r
+ EFI_STATUS TransactionStatus;\r
+} EFI_DISK_IO2_TOKEN;\r
+\r
+/**\r
+ Terminate outstanding asynchronous requests to a device.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+\r
+ @retval EFI_SUCCESS All outstanding requests were successfully terminated.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel\r
+ operation.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_CANCEL_EX) (\r
+ IN EFI_DISK_IO2_PROTOCOL *This\r
+ );\r
+\r
+/**\r
+ Reads a specified number of bytes from a device.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+ @param MediaId ID of the medium to be read.\r
+ @param Offset The starting byte offset on the logical block I/O device to read from.\r
+ @param Token A pointer to the token associated with the transaction.\r
+ If this field is NULL, synchronous/blocking IO is performed.\r
+ @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.\r
+ @param Buffer A pointer to the destination buffer for the data.\r
+ The caller is responsible either having implicit or explicit ownership of the buffer.\r
+\r
+ @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device.\r
+ If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.\r
+ Event will be signaled upon completion.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
+ @retval EFI_NO_MEDIA There is no medium in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.\r
+ @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_READ_EX) (\r
+ IN EFI_DISK_IO2_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN UINT64 Offset,\r
+ IN OUT EFI_DISK_IO2_TOKEN *Token,\r
+ IN UINTN BufferSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Writes a specified number of bytes to a device.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+ @param MediaId ID of the medium to be written.\r
+ @param Offset The starting byte offset on the logical block I/O device to write to.\r
+ @param Token A pointer to the token associated with the transaction.\r
+ If this field is NULL, synchronous/blocking IO is performed.\r
+ @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device.\r
+ @param Buffer A pointer to the buffer containing the data to be written.\r
+\r
+ @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device.\r
+ If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.\r
+ Event will be signaled upon completion.\r
+ @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.\r
+ @retval EFI_NO_MEDIA There is no medium in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.\r
+ @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_WRITE_EX) (\r
+ IN EFI_DISK_IO2_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN UINT64 Offset,\r
+ IN OUT EFI_DISK_IO2_TOKEN *Token,\r
+ IN UINTN BufferSize,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Flushes all modified data to the physical device.\r
+\r
+ @param This Indicates a pointer to the calling context.\r
+ @param MediaId ID of the medium to be written.\r
+ @param Token A pointer to the token associated with the transaction.\r
+ If this field is NULL, synchronous/blocking IO is performed.\r
+\r
+ @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device.\r
+ If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.\r
+ Event will be signaled upon completion.\r
+ @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.\r
+ @retval EFI_NO_MEDIA There is no medium in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DISK_FLUSH_EX) (\r
+ IN EFI_DISK_IO2_PROTOCOL *This,\r
+ IN OUT EFI_DISK_IO2_TOKEN *Token\r
+ );\r
+\r
+#define EFI_DISK_IO2_PROTOCOL_REVISION 0x00020000\r
+\r
+///\r
+/// This protocol is used to abstract Block I/O interfaces.\r
+///\r
+struct _EFI_DISK_IO2_PROTOCOL {\r
+ ///\r
+ /// The revision to which the disk I/O interface adheres. All future\r
+ /// revisions must be backwards compatible. If a future version is not\r
+ /// backwards compatible, it is not the same GUID.\r
+ ///\r
+ UINT64 Revision;\r
+ EFI_DISK_CANCEL_EX Cancel;\r
+ EFI_DISK_READ_EX ReadDiskEx;\r
+ EFI_DISK_WRITE_EX WriteDiskEx;\r
+ EFI_DISK_FLUSH_EX FlushDiskEx;\r
+};\r
+\r
+extern EFI_GUID gEfiDiskIo2ProtocolGuid;\r
+\r
+#endif\r