/** @file\r
Master header file for DiskIo driver. It includes the module private defininitions.\r
\r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 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
#include <Uefi.h>\r
#include <Protocol/BlockIo.h>\r
+#include <Protocol/BlockIo2.h>\r
+#include <Protocol/DiskIo2.h>\r
#include <Protocol/ComponentName.h>\r
#include <Protocol/DriverBinding.h>\r
#include <Protocol/DiskIo.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
\r
-\r
+//\r
+// Pre-allocate an aligned buffer of 64 blocks so very large Disk I/O requests\r
+// will be broken up into 64 * BlockSize chunks to provide better performance\r
+// than allocating an aligned 1 block buffer.\r
+//\r
#define DATA_BUFFER_BLOCK_NUM 64\r
\r
#define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')\r
-\r
typedef struct {\r
- UINTN Signature;\r
- EFI_DISK_IO_PROTOCOL DiskIo;\r
- EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ UINT32 Signature;\r
+\r
+ EFI_DISK_IO_PROTOCOL DiskIo;\r
+ EFI_DISK_IO2_PROTOCOL DiskIo2;\r
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
+\r
+ UINT8 *SharedWorkingBuffer;\r
+\r
+ EFI_LOCK TaskQueueLock;\r
+ LIST_ENTRY TaskQueue;\r
} DISK_IO_PRIVATE_DATA;\r
+#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)\r
+#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO2(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo2, DISK_IO_PRIVATE_DATA_SIGNATURE)\r
\r
-#define DISK_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)\r
+#define DISK_IO2_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'a', 't')\r
+typedef struct {\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link; /// < link to other task\r
+ LIST_ENTRY Subtasks; /// < header of subtasks\r
+ EFI_DISK_IO2_TOKEN *Token;\r
+ DISK_IO_PRIVATE_DATA *Instance;\r
+} DISK_IO2_TASK;\r
+\r
+#define DISK_IO2_FLUSH_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'f', 't')\r
+typedef struct {\r
+ UINT32 Signature;\r
+ EFI_BLOCK_IO2_TOKEN BlockIo2Token;\r
+ EFI_DISK_IO2_TOKEN *Token;\r
+} DISK_IO2_FLUSH_TASK;\r
+\r
+#define DISK_IO_SUBTASK_SIGNATURE SIGNATURE_32 ('d', 'i', 's', 't')\r
+typedef struct {\r
+ //\r
+ // UnderRun: Offset != 0, Length < BlockSize\r
+ // OverRun: Offset == 0, Length < BlockSize\r
+ // Middle: Offset is block aligned, Length is multiple of block size\r
+ //\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+ BOOLEAN Write;\r
+ UINT64 Lba;\r
+ UINT32 Offset;\r
+ UINTN Length;\r
+ UINT8 *WorkingBuffer; /// < NULL indicates using "Buffer" directly\r
+ UINT8 *Buffer;\r
+ BOOLEAN Blocking;\r
+\r
+ //\r
+ // Following fields are for DiskIo2\r
+ //\r
+ DISK_IO2_TASK *Task;\r
+ EFI_BLOCK_IO2_TOKEN BlockIo2Token;\r
+} DISK_IO_SUBTASK;\r
\r
//\r
// Global Variables\r
IN VOID *Buffer\r
);\r
\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
+EFI_STATUS\r
+EFIAPI\r
+DiskIo2Cancel (\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
+EFI_STATUS\r
+EFIAPI\r
+DiskIo2ReadDiskEx (\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
+EFI_STATUS\r
+EFIAPI\r
+DiskIo2WriteDiskEx (\r
+ IN EFI_DISK_IO2_PROTOCOL *This,\r
+ IN UINT32 MediaId,\r
+ IN UINT64 Offset,\r
+ IN 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 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_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DiskIo2FlushDiskEx (\r
+ IN EFI_DISK_IO2_PROTOCOL *This,\r
+ IN OUT EFI_DISK_IO2_TOKEN *Token\r
+ );\r
+\r
//\r
// EFI Component Name Functions\r
//\r
driver specified by This was returned in\r
DriverName.\r
\r
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
\r
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
EFI_HANDLE.\r