/** @file\r
- DiskIo driver that layers it's self on every Block IO protocol in the system.\r
- DiskIo converts a block oriented device to a byte oriented device.\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
**/\r
\r
-#ifndef _DISK_IO_H\r
-#define _DISK_IO_H\r
+#ifndef _DISK_IO_H_\r
+#define _DISK_IO_H_\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
+// 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 EFI_SIGNATURE_32 ('d', 's', 'k', 'I')\r
+#define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')\r
+typedef struct {\r
+ UINT32 Signature;\r
\r
-#define DATA_BUFFER_BLOCK_NUM (64)\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
-typedef struct {\r
- UINTN Signature;\r
- EFI_DISK_IO_PROTOCOL DiskIo;\r
- EFI_BLOCK_IO_PROTOCOL *BlockIo;\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
// Prototypes\r
// Driver model protocol interface\r
//\r
+/**\r
+ Test to see if this driver supports ControllerHandle. \r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to test\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device\r
+ @retval EFI_ALREADY_STARTED This driver is already running on this device\r
+ @retval other This driver does not support this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
);\r
\r
+/**\r
+ Start this driver on ControllerHandle by opening a Block IO protocol and\r
+ installing a Disk IO protocol on ControllerHandle.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to bind driver to\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver is added to ControllerHandle\r
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
+ @retval other This driver does not support this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
);\r
\r
+/**\r
+ Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r
+ the Block IO protocol on ControllerHandle.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to stop driver on\r
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
+ children is zero stop the entire bus driver.\r
+ @param ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCESS This driver is removed ControllerHandle\r
+ @retval other This driver was not removed from this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoDriverBindingStop (\r
//\r
// Disk I/O Protocol Interface\r
//\r
+/**\r
+ Read BufferSize bytes from Offset into Buffer.\r
+ Reads may support reads that are not aligned on\r
+ sector boundaries. There are three cases:\r
+ UnderRun - The first byte is not on a sector boundary or the read request is\r
+ less than a sector in length.\r
+ Aligned - A read of N contiguous sectors.\r
+ OverRun - The last byte is not on a sector boundary.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId Id of the media, changes every time the media is replaced.\r
+ @param Offset The starting byte offset to read from\r
+ @param BufferSize Size of Buffer\r
+ @param Buffer Buffer containing read data\r
+\r
+ @retval EFI_SUCCESS The data was read correctly from the device.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
+ valid for the device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoReadDisk (\r
OUT VOID *Buffer\r
);\r
\r
+/**\r
+ Writes BufferSize bytes from Buffer into Offset.\r
+ Writes may require a read modify write to support writes that are not\r
+ aligned on sector boundaries. There are three cases:\r
+ UnderRun - The first byte is not on a sector boundary or the write request\r
+ is less than a sector in length. Read modify write is required.\r
+ Aligned - A write of N contiguous sectors.\r
+ OverRun - The last byte is not on a sector boundary. Read modified write\r
+ required.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId Id of the media, changes every time the media is replaced.\r
+ @param Offset The starting byte offset to read from\r
+ @param BufferSize Size of Buffer\r
+ @param Buffer Buffer containing read data\r
+\r
+ @retval EFI_SUCCESS The data was written correctly to the device.\r
+ @retval EFI_WRITE_PROTECTED The device can not be written to.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not\r
+ valid for the device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoWriteDisk (\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
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified\r
- in RFC 3066 or ISO 639-2 language code format.\r
+ in RFC 4646 or ISO 639-2 language code format.\r
\r
@param DriverName[out] A pointer to the Unicode string to return.\r
This Unicode string is the name of the\r
languages specified in SupportedLanguages. The\r
number of languages supported by a driver is up\r
to the driver writer. Language is specified in\r
- RFC 3066 or ISO 639-2 language code format.\r
+ RFC 4646 or ISO 639-2 language code format.\r
\r
@param ControllerName[out] A pointer to the Unicode string to return.\r
This Unicode string is the name of the\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