]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/Fat.c
Change Fat driver to support asynchronous File IO introduced in UEFI spec 2.3.1.D.
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Fat.c
index 38b70882c5c5ca796af0216c9437e1ca9512030e..a52e6ea828a07025606ab919d59ad293a7023a1a 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
@@ -269,6 +269,7 @@ Returns:
   EFI_STATUS            Status;\r
   EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
   EFI_DISK_IO_PROTOCOL  *DiskIo;\r
+  EFI_DISK_IO2_PROTOCOL *DiskIo2;\r
   BOOLEAN               LockedByMe;\r
 \r
   LockedByMe = FALSE;\r
@@ -311,11 +312,24 @@ Returns:
   if (EFI_ERROR (Status)) {\r
     goto Exit;\r
   }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDiskIo2ProtocolGuid,\r
+                  (VOID **) &DiskIo2,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    DiskIo2 = NULL;\r
+  }\r
+\r
   //\r
   // Allocate Volume structure. In FatAllocateVolume(), Resources\r
   // are allocated with protocol installed and cached initialized\r
   //\r
-  Status = FatAllocateVolume (ControllerHandle, DiskIo, BlockIo);\r
+  Status = FatAllocateVolume (ControllerHandle, DiskIo, DiskIo2, BlockIo);\r
 \r
   //\r
   // When the media changes on a device it will Reinstall the BlockIo interaface.\r
@@ -338,6 +352,12 @@ Returns:
              This->DriverBindingHandle,\r
              ControllerHandle\r
              );\r
+      gBS->CloseProtocol (\r
+             ControllerHandle,\r
+             &gEfiDiskIo2ProtocolGuid,\r
+             This->DriverBindingHandle,\r
+             ControllerHandle\r
+             );\r
     }\r
   }\r
 \r
@@ -406,6 +426,12 @@ Returns:
                   This->DriverBindingHandle,\r
                   ControllerHandle\r
                   );\r
+  Status = gBS->CloseProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDiskIo2ProtocolGuid,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle\r
+                  );\r
 \r
   return Status;\r
 }\r