]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassBoot.c
index a8b6a1c5f13c9cca81490650ddb6c0a5ca013fa5..613008bde76837f174b37335c5a7e47d4bdae30f 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of the command set of USB Mass Storage Specification\r
   for Bootability, Revision 1.0.\r
 \r
-Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2018, 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
@@ -630,8 +630,10 @@ UsbBootGetParams (
 {\r
   EFI_BLOCK_IO_MEDIA          *Media;\r
   EFI_STATUS                  Status;\r
+  UINT8                       CmdSet;\r
 \r
   Media  = &(UsbMass->BlockIoMedia);\r
+  CmdSet = ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->InterfaceSubClass;\r
 \r
   Status = UsbBootInquiry (UsbMass);\r
   if (EFI_ERROR (Status)) {\r
@@ -666,9 +668,18 @@ UsbBootGetParams (
     Media->BlockSize        = 0x0800;\r
   }\r
 \r
-  Status = UsbBootDetectMedia (UsbMass);\r
+  if ((UsbMass->Pdt != USB_PDT_CDROM) && (CmdSet == USB_MASS_STORE_SCSI)) {\r
+    //\r
+    // ModeSense is required for the device with PDT of 0x00/0x07/0x0E,\r
+    // which is from [MassStorageBootabilitySpec-Page7].\r
+    // ModeSense(10) is useless here, while ModeSense(6) defined in SCSI\r
+    // could get the information of WriteProtected.\r
+    // Since not all device support this command, so skip if fail.\r
+    //\r
+    UsbScsiModeSense (UsbMass);\r
+  }\r
 \r
-  return Status;\r
+  return UsbBootReadCapacity (UsbMass);\r
 }\r
 \r
 \r
@@ -699,7 +710,7 @@ UsbBootDetectMedia (
   CmdSet = ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->InterfaceSubClass;\r
 \r
   Status = UsbBootIsUnitReady (UsbMass);\r
-  if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {\r
+  if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
 \r