]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / DiskIoDxe / DiskIo.h
index 77f6dbf89d398600b4a0fbdb5e96d704a6b4efc5..13edb5ff7bcd6aa7b35a320ffc1613bb11fb4971 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Master header file for DiskIo driver. It includes the module private defininitions.\r
 \r
-Copyright (c) 2006 - 2011, 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
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -17,6 +11,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \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
@@ -28,18 +24,63 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 \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
-#define DISK_IO_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('d', 's', 'k', 'I')\r
+  UINT8                     *SharedWorkingBuffer;\r
 \r
-typedef struct {\r
-  UINTN                 Signature;\r
-  EFI_DISK_IO_PROTOCOL  DiskIo;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\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_IO2_TASK_SIGNATURE  SIGNATURE_32 ('d', 'i', 'a', 't')\r
+typedef struct {\r
+  UINT32                  Signature;\r
+  LIST_ENTRY              Link;             /// < link to other task\r
+  EFI_LOCK                SubtasksLock;\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_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)\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
@@ -52,8 +93,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gDiskIoComponentName2;
 // Prototypes\r
 // Driver model protocol interface\r
 //\r
+\r
 /**\r
-  Test to see if this driver supports ControllerHandle. \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
@@ -112,15 +154,16 @@ DiskIoDriverBindingStart (
 EFI_STATUS\r
 EFIAPI\r
 DiskIoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     ControllerHandle,\r
-  IN  UINTN                          NumberOfChildren,\r
-  IN  EFI_HANDLE                     *ChildHandleBuffer\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
   );\r
 \r
 //\r
 // Disk I/O Protocol Interface\r
 //\r
+\r
 /**\r
   Read BufferSize bytes from Offset into Buffer.\r
   Reads may support reads that are not aligned on\r
@@ -189,9 +232,113 @@ DiskIoWriteDisk (
   IN VOID                  *Buffer\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
+\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the driver.\r
 \r
@@ -239,7 +386,6 @@ DiskIoComponentNameGetDriverName (
   OUT CHAR16                       **DriverName\r
   );\r
 \r
-\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the controller\r
   that is being managed by a driver.\r
@@ -311,12 +457,11 @@ DiskIoComponentNameGetDriverName (
 EFI_STATUS\r
 EFIAPI\r
 DiskIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_HANDLE                   ChildHandle        OPTIONAL,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **ControllerName\r
   );\r
 \r
-\r
 #endif\r