]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance Partition driver for EFI_NO_MEDIA case
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Aug 2009 05:41:10 +0000 (05:41 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Aug 2009 05:41:10 +0000 (05:41 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9070 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c

index 41001fa2b2ee433b2bba63570b5b0b98bdb93066..375f07aa18b2402844927d43b95f57d2c0e6d521 100644 (file)
@@ -4,7 +4,7 @@
   of the raw block devices media. Currently "El Torito CD-ROM", Legacy\r
   MBR, and GPT partition schemes are supported.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
 All rights reserved. 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
@@ -179,6 +179,7 @@ PartitionDriverBindingStart (
   EFI_DISK_IO_PROTOCOL      *DiskIo;\r
   EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
   PARTITION_DETECT_ROUTINE  *Routine;\r
+  BOOLEAN                   MediaPresent;\r
 \r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -227,10 +228,12 @@ PartitionDriverBindingStart (
   OpenStatus = Status;\r
 \r
   //\r
-  // If no media is present, do nothing here.\r
+  // Try to read blocks when there's media or it is removable physical partition.\r
   //\r
-  Status = EFI_UNSUPPORTED;\r
-  if (BlockIo->Media->MediaPresent) {\r
+  Status       = EFI_UNSUPPORTED;\r
+  MediaPresent = BlockIo->Media->MediaPresent;\r
+  if (BlockIo->Media->MediaPresent ||\r
+      (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {\r
     //\r
     // Try for GPT, then El Torito, and then legacy MBR partition types. If the\r
     // media supports a given partition type install child handles to represent\r
@@ -245,7 +248,7 @@ PartitionDriverBindingStart (
                    BlockIo,\r
                    ParentDevicePath\r
                    );\r
-      if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED) {\r
+      if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA) {\r
         break;\r
       }\r
       Routine++;\r
@@ -257,7 +260,16 @@ PartitionDriverBindingStart (
   // driver. So don't try to close them. Otherwise, we will break the dependency\r
   // between the controller and the driver set up before.\r
   //\r
-  if (EFI_ERROR (Status) && !EFI_ERROR (OpenStatus) && Status != EFI_MEDIA_CHANGED) {\r
+  // In the case that when the media changes on a device it will Reinstall the \r
+  // BlockIo interaface. This will cause a call to our Stop(), and a subsequent\r
+  // reentrant call to our Start() successfully. We should leave the device open\r
+  // when this happen. The "media change" case includes either the status is\r
+  // EFI_MEDIA_CHANGED or it is a "media" to "no media" change. \r
+  //  \r
+  if (EFI_ERROR (Status)          &&\r
+      !EFI_ERROR (OpenStatus)     &&\r
+      Status != EFI_MEDIA_CHANGED &&\r
+      !(MediaPresent && Status == EFI_NO_MEDIA)) {\r
     gBS->CloseProtocol (\r
           ControllerHandle,\r
           &gEfiDiskIoProtocolGuid,\r