[FREELDR]: Report the correct number of BIOS (hard) disk drives detected, that is...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 9 May 2017 19:33:46 +0000 (19:33 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 9 May 2017 19:33:46 +0000 (19:33 +0000)
This fixes the list of disks enumerated in HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\MultifunctionAdapter\0\DiskController\0\DiskPeripheral\
and we now behave in this regards similarly to Windows 2003 & co.
I thank Lesan Ilie for reporting & testing, and Serge Gautherie and Peter Hater for reviewing.
This fixes a bug introduced in commit r59079.
CORE-13131

svn path=/trunk/; revision=74515

reactos/boot/freeldr/freeldr/arch/i386/hardware.c
reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c

index 80bf398..62ee77f 100644 (file)
@@ -35,6 +35,8 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
 #define LATCH (CLOCK_TICK_RATE / HZ)
 
 static unsigned int delay_count = 1;
+
+/* Used for BIOS disks pre-enumeration performed when detecting the boot devices in InitializeBootDevices() */
 extern UCHAR PcBiosDiskCount;
 
 /* This function is slightly different in its PC and XBOX versions */
index 1541cb3..59b028b 100644 (file)
@@ -44,6 +44,7 @@ extern ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[];
 
 static CHAR Hex[] = "0123456789abcdef";
 
+/* Data cache for BIOS disks pre-enumeration */
 UCHAR PcBiosDiskCount = 0;
 static CHAR PcDiskIdentifier[32][20];
 
@@ -323,8 +324,8 @@ PcInitializeBootDevices(VOID)
         }
         if (!Changed)
         {
-            TRACE("BIOS reports success for disk %d but data didn't change\n",
-                  (int)DiskCount);
+            TRACE("BIOS reports success for disk %d (0x%02X) but data didn't change\n",
+                  (int)DiskCount, DriveNumber);
             break;
         }
 
@@ -340,6 +341,8 @@ PcInitializeBootDevices(VOID)
         memset(DiskReadBuffer, 0xcd, DiskReadBufferSize);
     }
     DiskReportError(TRUE);
+
+    PcBiosDiskCount = DiskCount;
     TRACE("BIOS reports %d harddisk%s\n",
           (int)DiskCount, (DiskCount == 1) ? "" : "s");
 
@@ -384,12 +387,9 @@ PcInitializeBootDevices(VOID)
         reactos_disk_count++;
 
         FsRegisterDevice(BootPath, &DiskVtbl);
-        DiskCount++;
+        DiskCount++; // This is not accounted for in the number of pre-enumerated BIOS drives!
+        TRACE("Additional boot drive detected: 0x%02X\n", (int)FrldrBootDrive);
     }
 
-    PcBiosDiskCount = DiskCount;
-    TRACE("BIOS reports %d harddisk%s\n",
-          (int)DiskCount, (DiskCount == 1) ? "": "s");
-
     return (DiskCount != 0);
 }