@@ -34,6 +34,7 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
3434typedef struct tagDISKCONTEXT
3535{
3636 UCHAR DriveNumber ;
37+ BOOLEAN IsFloppy ;
3738 ULONG SectorSize ;
3839 ULONGLONG SectorOffset ;
3940 ULONGLONG SectorCount ;
@@ -77,13 +78,16 @@ DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information)
7778 Information -> EndingAddress .QuadPart = (Context -> SectorOffset + Context -> SectorCount ) * Context -> SectorSize ;
7879 Information -> CurrentAddress .QuadPart = Context -> SectorNumber * Context -> SectorSize ;
7980
81+ Information -> Type = (Context -> IsFloppy ? FloppyDiskPeripheral : DiskPeripheral );
82+
8083 return ESUCCESS ;
8184}
8285
8386static ARC_STATUS
8487DiskOpen (CHAR * Path , OPENMODE OpenMode , ULONG * FileId )
8588{
8689 DISKCONTEXT * Context ;
90+ CONFIGURATION_TYPE DriveType ;
8791 UCHAR DriveNumber ;
8892 ULONG DrivePartition , SectorSize ;
8993 ULONGLONG SectorOffset = 0 ;
@@ -100,19 +104,16 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
100104 if (!DissectArcPath (Path , NULL , & DriveNumber , & DrivePartition ))
101105 return EINVAL ;
102106
103- if (DrivePartition == 0xff )
107+ DriveType = DiskGetConfigType (DriveNumber );
108+ if (DriveType == CdromController )
104109 {
105110 /* This is a CD-ROM device */
106111 SectorSize = 2048 ;
107112 }
108113 else
109114 {
110- /*
111- * This is either a floppy disk device (DrivePartition == 0) or
112- * a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF)
113- * but it doesn't matter which one because they both have 512 bytes
114- * per sector.
115- */
115+ /* This is either a floppy disk or a hard disk device, but it doesn't
116+ * matter which one because they both have 512 bytes per sector */
116117 SectorSize = 512 ;
117118 }
118119
@@ -145,6 +146,7 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
145146 return ENOMEM ;
146147
147148 Context -> DriveNumber = DriveNumber ;
149+ Context -> IsFloppy = (DriveType == FloppyDiskPeripheral );
148150 Context -> SectorSize = SectorSize ;
149151 Context -> SectorOffset = SectorOffset ;
150152 Context -> SectorCount = SectorCount ;
@@ -399,23 +401,6 @@ EnumerateHarddisks(OUT PBOOLEAN BootDriveReported)
399401 return DiskCount ;
400402}
401403
402- // FIXME: Copied from pcdisk.c
403- // Actually this function is REALLY PC-specific!!
404- static BOOLEAN
405- DiskIsDriveRemovable (UCHAR DriveNumber )
406- {
407- /*
408- * Hard disks use drive numbers >= 0x80 . So if the drive number
409- * indicates a hard disk then return FALSE.
410- * 0x49 is our magic ramdisk drive, so return FALSE for that too.
411- */
412- if ((DriveNumber >= 0x80 ) || (DriveNumber == 0x49 ))
413- return FALSE;
414-
415- /* The drive is a floppy diskette so return TRUE */
416- return TRUE;
417- }
418-
419404static BOOLEAN
420405DiskGetBootPath (BOOLEAN IsPxe )
421406{
@@ -474,23 +459,25 @@ PcInitializeBootDevices(VOID)
474459{
475460 UCHAR DiskCount ;
476461 BOOLEAN BootDriveReported = FALSE;
477- ULONG i ;
462+ CONFIGURATION_TYPE DriveType ;
478463
479464 DiskCount = EnumerateHarddisks (& BootDriveReported );
480465
481466 /* Initialize FrLdrBootPath, the boot path we're booting from (the "SystemPartition") */
482467 DiskGetBootPath (PxeInit ());
483468
484- /* Add it, if it's a floppy or cdrom */
469+ /* Add it, if it's a floppy or CD-ROM */
470+ DriveType = DiskGetConfigType (FrldrBootDrive );
485471 if ((FrldrBootDrive >= FIRST_BIOS_DISK && !BootDriveReported ) ||
486- DiskIsDriveRemovable ( FrldrBootDrive ))
472+ ( DriveType == FloppyDiskPeripheral || DriveType == CdromController ))
487473 {
488- /* TODO: Check if it's really a CDROM drive */
474+ /* TODO: Check if it's really a CD-ROM drive */
489475
490476 PMASTER_BOOT_RECORD Mbr ;
491477 PULONG Buffer ;
492478 ULONG Checksum = 0 ;
493479 ULONG Signature ;
480+ ULONG i ;
494481
495482 /* Read the MBR */
496483 if (!MachDiskReadLogicalSectors (FrldrBootDrive , 16ULL , 1 , DiskReadBuffer ))
0 commit comments