]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Ebl/EfiDevice.c
Remove probe for removable media from FileLib, it was getting called way too much...
[mirror_edk2.git] / EmbeddedPkg / Ebl / EfiDevice.c
index 9b08fda12a3cd6f531ee315f45f461aa64d8a461..70ba70383c9af2fd4cb42076a73be21f27e4a128 100644 (file)
@@ -210,12 +210,34 @@ EblDeviceCmd (
   UINTN         Index;\r
   UINTN         CurrentRow;\r
   UINTN         Max;\r
+  EFI_OPEN_FILE *File;\r
 \r
   CurrentRow = 0;\r
   \r
   // Need to call here to make sure Device Counts are valid\r
   EblUpdateDeviceLists ();\r
 \r
+  //\r
+  // Probe for media insertion/removal in removable media devices\r
+  //\r
+  Max = EfiGetDeviceCounts (EfiOpenBlockIo);\r
+  if (Max != 0) {\r
+    for (Index = 0; Index < Max; Index++) {\r
+      File = EfiDeviceOpenByType (EfiOpenBlockIo, Index);\r
+      if (File != NULL) {\r
+        if (File->FsBlockIoMedia->RemovableMedia) {\r
+          if (File->FsBlockIoMedia->MediaPresent) {\r
+            gBS->DisconnectController (File->EfiHandle, NULL, NULL);\r
+          }\r
+          gBS->ConnectController (File->EfiHandle, NULL, NULL, TRUE);\r
+        }\r
+        EfiClose (File);\r
+      }\r
+    }\r
+  }\r
+\r
+  // Now we can print out the info...\r
+\r
   Max = EfiGetDeviceCounts (EfiOpenFirmwareVolume);\r
   if (Max != 0) {\r
     AsciiPrint ("Firmware Volume Devices:\n");\r
@@ -730,7 +752,7 @@ EblFileCopyCmd (
   UINTN         Size;\r
   UINTN         Offset;\r
   UINTN         Chunk = FILE_COPY_CHUNK;\r
-  \r
+\r
   if (Argc < 3) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -759,13 +781,13 @@ EblFileCopyCmd (
     \r
     Status = EfiRead(Source, Buffer, &Chunk);\r
     if (EFI_ERROR(Status)) {\r
-      AsciiPrint("Read file error\n");\r
+      AsciiPrint("Read file error %r\n", Status);\r
       goto Exit;\r
     }\r
 \r
     Status = EfiWrite(Destination, Buffer, &Chunk);\r
     if (EFI_ERROR(Status)) {\r
-      AsciiPrint("Write file error\n");\r
+      AsciiPrint("Write file error %r\n", Status);\r
       goto Exit;\r
     }    \r
   }\r
@@ -776,17 +798,18 @@ EblFileCopyCmd (
     \r
     Status = EfiRead(Source, Buffer, &Chunk);\r
     if (EFI_ERROR(Status)) {\r
-      AsciiPrint("Read file error\n");\r
+      AsciiPrint("Read file error %r\n", Status);\r
       goto Exit;\r
     }\r
 \r
     Status = EfiWrite(Destination, Buffer, &Chunk);\r
     if (EFI_ERROR(Status)) {\r
-      AsciiPrint("Write file error\n");\r
+      AsciiPrint("Write file error %r\n", Status);\r
       goto Exit;\r
     }    \r
   }\r
 \r
+\r
 Exit:\r
   if (Source != NULL) {\r
     Status = EfiClose(Source);\r
@@ -794,7 +817,6 @@ Exit:
       AsciiPrint("Source close error %r\n", Status);\r
     }\r
   }\r
-  \r
   if (Destination != NULL) {\r
     Status = EfiClose(Destination);\r
     if (EFI_ERROR(Status)) {\r