Made the ARM code use the shared disk routines, which allowed us to remove some hacks -> we now detect the boot/system volume just like on x86.
FreeLDR now loads NTOSKRNL.EXE on ARM.
Also made the DiskIsBootDeviceFloppy return FALSE for ramdisks.
Finally, note that the disk routines were still kept as Machine-specific routines in the Mach Table, so other architectures can still override them if they really need to (for example, the XBOX port overrides one of them for a specific XBOX hack).
svn path=/trunk/; revision=32173
//
}
-
BOOLEAN
ArmDiskGetDriveGeometry(IN ULONG DriveNumber,
OUT PGEOMETRY Geometry)
return FALSE;
}
-BOOLEAN
-ArmDiskGetBootVolume(IN PULONG DriveNumber,
- IN PULONGLONG StartSector,
- IN PULONGLONG SectorCount,
- OUT PINT FsType)
+VOID
+ArmPrepareForReactOS(IN BOOLEAN Setup)
{
+ while (TRUE);
+}
+
+PCONFIGURATION_COMPONENT_DATA
+ArmHwDetect(VOID)
+{
+ PCONFIGURATION_COMPONENT_DATA RootNode;
+
//
- // We only support RAM disk for now -- add support for NAND later
+ // Create the root node
//
- ASSERT(gRamDiskBase);
- ASSERT(gRamDiskSize);
-
+ FldrCreateSystemKey(&RootNode);
+
//
- // Use magic ramdisk drive number and count the number of 512-byte sectors
+ // Write null component information
//
- *DriveNumber = 0x49;
- *StartSector = 63;
- *SectorCount = gRamDiskSize * 512;
-
+ FldrSetComponentInformation(RootNode,
+ 0x0,
+ 0x0,
+ 0xFFFFFFFF);
+
//
- // Ramdisk support is FAT-only for now
+ // TODO:
+ // There's no such thing as "PnP" on embedded hardware.
+ // The boot loader will send us a device tree, similar to ACPI
+ // or OpenFirmware device trees, and we will convert it to ARC.
//
- *FsType = FS_FAT;
//
- // Now that ramdisk is enabled, use ramdisk routines
+ // Return the root node
//
- RamDiskSwitchFromBios();
- return TRUE;
-}
-
-BOOLEAN
-ArmDiskGetSystemVolume(IN PCHAR SystemPath,
- OUT PCHAR RemainingPath,
- OUT PULONG Device,
- OUT PULONG DriveNumber,
- OUT PULONGLONG StartSector,
- OUT PULONGLONG SectorCount,
- OUT PINT FsType)
-{
- while (TRUE);
- return FALSE;
-}
-
-BOOLEAN
-ArmDiskNormalizeSystemPath(IN PCHAR SystemPath,
- IN unsigned Size)
-{
- while (TRUE);
- return FALSE;
-}
-
-VOID
-ArmPrepareForReactOS(IN BOOLEAN Setup)
-{
- while (TRUE);
-}
-
-PCONFIGURATION_COMPONENT_DATA
-ArmHwDetect(VOID)
-{
- while (TRUE);
- return NULL;
+ return RootNode;
}
ULONG
}
//
- // Setup generic ARM routines
+ // Setup generic ARM routines for all boards
//
MachVtbl.PrepareForReactOS = ArmPrepareForReactOS;
MachVtbl.GetMemoryMap = ArmMemGetMemoryMap;
- MachVtbl.DiskGetBootVolume = ArmDiskGetBootVolume;
- MachVtbl.DiskGetSystemVolume = ArmDiskGetSystemVolume;
- MachVtbl.DiskNormalizeSystemPath = ArmDiskNormalizeSystemPath;
+ MachVtbl.HwDetect = ArmHwDetect;
+
+ //
+ // Setup disk I/O routines, switch to ramdisk ones for non-NAND boot
+ //
MachVtbl.DiskReadLogicalSectors = ArmDiskReadLogicalSectors;
MachVtbl.DiskGetDriveGeometry = ArmDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = ArmDiskGetCacheableBlockCount;
- MachVtbl.HwDetect = ArmHwDetect;
-
+ RamDiskSwitchFromBios();
+
+ //
+ // Now set default disk handling routines -- we don't need to override
+ //
+ MachVtbl.DiskGetBootVolume = DiskGetBootVolume;
+ MachVtbl.DiskGetSystemVolume = DiskGetSystemVolume;
+ MachVtbl.DiskGetBootPath = DiskGetBootPath;
+ MachVtbl.DiskGetBootDevice = DiskGetBootDevice;
+ MachVtbl.DiskBootingFromFloppy = DiskBootingFromFloppy;
+ MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
+ MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
+
//
// We can now print to the console
//
.code32
- /* Zero i386BootDrive and i386BootPartition */
+ /* Zero BootDrive and BootPartition */
xorl %eax,%eax
- movl %eax,(_i386BootDrive)
- movl %eax,(_i386BootPartition)
+ movl %eax,(_BootDrive)
+ movl %eax,(_BootPartition)
/* Store the boot drive */
- movb %dl,(_i386BootDrive)
+ movb %dl,(_BootDrive)
/* Store the boot partition */
- movb %dh,(_i386BootPartition)
+ movb %dh,(_BootPartition)
/* GO! */
pushl %eax
movl MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax
shrl $16,%eax
incb %al
- movb %al,_i386BootPartition
- movb %ah,_i386BootDrive
+ movb %al,_BootPartition
+ movb %ah,_BootDrive
jmp mb6
mb5: /* No boot device known, assume first partition of first harddisk */
- movb $0x80,_i386BootDrive
- movb $1,_i386BootPartition
+ movb $0x80,_BootDrive
+ movb $1,_BootPartition
mb6:
/* Check for command line */
mov $cmdline,%eax
.word 0x3ff /* Limit */
.long 0 /* Base Address */
-EXTERN(_i386BootDrive)
- .long 0
-
-EXTERN(_i386BootPartition)
- .long 0
-
mb_info:
.fill MB_INFO_SIZE, 1, 0
cmdline:
.fill CMDLINE_SIZE, 1, 0
+
+EXTERN(_BootDrive)
+ .long 0
+
+EXTERN(_BootPartition)
+ .long 0
.code16
/* Set the boot drive */
- movb (_i386BootDrive),%dl
+ movb (_BootDrive),%dl
/* Load segment registers */
cli
return TRUE;
}
-BOOLEAN i386DiskGetBootVolume(PULONG DriveNumber, PULONGLONG StartSector, PULONGLONG SectorCount, int *FsType)
-{
- PARTITION_TABLE_ENTRY PartitionTableEntry;
- UCHAR VolumeType;
- ULONG ActivePartition;
-
- DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", i386BootDrive, i386BootPartition));
-
- // Check and see if it is a floppy drive
- // If so then just assume FAT12 file system type
- if (DiskIsDriveRemovable(i386BootDrive))
- {
- DbgPrint((DPRINT_FILESYSTEM, "Drive is a floppy diskette drive. Assuming FAT12 file system.\n"));
-
- *DriveNumber = i386BootDrive;
- *StartSector = 0;
- *SectorCount = 2 * 80 * 18; /* FIXME hardcoded for 1.44 Mb */
- *FsType = FS_FAT;
- return TRUE;
- }
-
- // Check for ISO9660 file system type
- if (i386BootDrive >= 0x80 && FsRecIsIso9660(i386BootDrive))
- {
- DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
-
- *DriveNumber = i386BootDrive;
- *StartSector = 0;
- *SectorCount = 0;
- *FsType = FS_ISO9660;
- return TRUE;
- }
-
- // Get the requested partition entry
- if (i386BootPartition == 0)
- {
- // Partition requested was zero which means the boot partition
- if (! DiskGetActivePartitionEntry(i386BootDrive, &PartitionTableEntry, &ActivePartition))
- {
- /* Try partition-less disk */
- *StartSector = 0;
- *SectorCount = 0;
- }
- /* Check for valid partition */
- else if (PartitionTableEntry.SystemIndicator == PARTITION_ENTRY_UNUSED)
- {
- return FALSE;
- }
- else
- {
- *StartSector = PartitionTableEntry.SectorCountBeforePartition;
- *SectorCount = PartitionTableEntry.PartitionSectorCount;
- }
- }
- else if (0xff == i386BootPartition)
- {
- /* Partition-less disk */
- *StartSector = 0;
- *SectorCount = 0;
- }
- else
- {
- // Get requested partition
- if (! MachDiskGetPartitionEntry(i386BootDrive, i386BootPartition, &PartitionTableEntry))
- {
- return FALSE;
- }
- /* Check for valid partition */
- else if (PartitionTableEntry.SystemIndicator == PARTITION_ENTRY_UNUSED)
- {
- return FALSE;
- }
- else
- {
- *StartSector = PartitionTableEntry.SectorCountBeforePartition;
- *SectorCount = PartitionTableEntry.PartitionSectorCount;
- }
- }
-
- // Try to recognize the file system
- if (!FsRecognizeVolume(i386BootDrive, *StartSector, &VolumeType))
- {
- return FALSE;
- }
-
- *DriveNumber = i386BootDrive;
-
- switch (VolumeType)
- {
- case PARTITION_FAT_12:
- case PARTITION_FAT_16:
- case PARTITION_HUGE:
- case PARTITION_XINT13:
- case PARTITION_FAT32:
- case PARTITION_FAT32_XINT13:
- *FsType = FS_FAT;
- return TRUE;
- case PARTITION_EXT2:
- *FsType = FS_EXT2;
- return TRUE;
- case PARTITION_NTFS:
- *FsType = FS_NTFS;
- return TRUE;
- default:
- *FsType = 0;
- return FALSE;
- }
-
- return TRUE;
-}
-
-VOID
-i386DiskGetBootDevice(PULONG BootDevice)
-{
- ((char *)BootDevice)[0] = (char)i386BootDrive;
- ((char *)BootDevice)[1] = (char)i386BootPartition;
-}
-
-BOOLEAN
-i386DiskBootingFromFloppy(VOID)
-{
- return i386BootDrive < 0x80;
-}
-
-#define IsRecognizedPartition(P) \
- ((P) == PARTITION_FAT_12 || \
- (P) == PARTITION_FAT_16 || \
- (P) == PARTITION_HUGE || \
- (P) == PARTITION_IFS || \
- (P) == PARTITION_EXT2 || \
- (P) == PARTITION_FAT32 || \
- (P) == PARTITION_FAT32_XINT13 || \
- (P) == PARTITION_XINT13)
-
-#define IsContainerPartition(P) \
- ((P) == PARTITION_EXTENDED || \
- (P) == PARTITION_XINT13_EXTENDED)
-
-BOOLEAN i386DiskGetSystemVolume(char *SystemPath,
- char *RemainingPath,
- PULONG Device,
- PULONG DriveNumber,
- PULONGLONG StartSector,
- PULONGLONG SectorCount,
- int *FsType)
-{
- ULONG PartitionNumber;
- PARTITION_TABLE_ENTRY PartitionTableEntry;
- UCHAR VolumeType;
- CHAR BootPath[256];
- unsigned i, RosPartition;
-
- /*
- * Verify system path
- */
- if (!DissectArcPath(SystemPath, BootPath, DriveNumber, &PartitionNumber))
- {
- return FALSE;
- }
- if (NULL != RemainingPath)
- {
- strcpy(RemainingPath, BootPath);
- }
-
- /* 0xff -> no partition table present, use whole device */
- if (0xff == PartitionNumber)
- {
- PartitionTableEntry.SectorCountBeforePartition = 0;
- i = 0xff;
- }
- else
- {
- /* recalculate the boot partition for freeldr */
- i = 0;
- RosPartition = 0;
- while (1)
- {
- if (!MachDiskGetPartitionEntry(*DriveNumber, ++i, &PartitionTableEntry))
- {
- return FALSE;
- }
- if (!IsContainerPartition(PartitionTableEntry.SystemIndicator) &&
- PartitionTableEntry.SystemIndicator != PARTITION_ENTRY_UNUSED)
- {
- if (++RosPartition == PartitionNumber)
- {
- break;
- }
- }
- }
- }
-
- /* Check for ISO9660 file system type */
- if (*DriveNumber >= 0x80 && FsRecIsIso9660(*DriveNumber))
- {
- DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
-
- if (NULL != Device)
- {
- ((char *)Device)[0] = (char)(*DriveNumber);
- ((char *)Device)[1] = (char)i;
- }
- *StartSector = 0;
- *SectorCount = 0;
- *FsType = FS_ISO9660;
- return TRUE;
- }
-
- if (!FsRecognizeVolume(*DriveNumber, PartitionTableEntry.SectorCountBeforePartition, &VolumeType))
- {
- return FALSE;
- }
-
- if (NULL != Device)
- {
- ((char *)Device)[0] = (char)(*DriveNumber);
- ((char *)Device)[1] = (char)i;
- }
- *StartSector = PartitionTableEntry.SectorCountBeforePartition;
- *SectorCount = PartitionTableEntry.PartitionSectorCount;
-
- switch (VolumeType)
- {
- case PARTITION_FAT_12:
- case PARTITION_FAT_16:
- case PARTITION_HUGE:
- case PARTITION_XINT13:
- case PARTITION_FAT32:
- case PARTITION_FAT32_XINT13:
- *FsType = FS_FAT;
- return TRUE;
- case PARTITION_EXT2:
- *FsType = FS_EXT2;
- return TRUE;
- case PARTITION_NTFS:
- *FsType = FS_NTFS;
- return TRUE;
- default:
- *FsType = 0;
- return FALSE;
- }
-
- return FALSE;
-}
-
-BOOLEAN
-i386DiskGetBootPath(char *BootPath, unsigned Size)
-{
- static char Path[] = "multi(0)disk(0)";
- char Device[4];
-
- _itoa(i386BootDrive, Device, 10);
- if (Size <= sizeof(Path) + 6 + strlen(Device))
- {
- return FALSE;
- }
- strcpy(BootPath, Path);
- strcat(BootPath, MachDiskBootingFromFloppy() ? "fdisk" : "cdrom");
- strcat(strcat(strcat(BootPath, "("), Device), ")");
-
- return TRUE;
-}
-
-BOOLEAN
-i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
-{
- CHAR BootPath[256];
- ULONG PartitionNumber;
- ULONG DriveNumber;
- PARTITION_TABLE_ENTRY PartEntry;
- char *p;
-
- if (!DissectArcPath(SystemPath, BootPath, &DriveNumber, &PartitionNumber))
- {
- return FALSE;
- }
-
- if (0 != PartitionNumber)
- {
- return TRUE;
- }
-
- if (! DiskGetActivePartitionEntry(DriveNumber,
- &PartEntry,
- &PartitionNumber) ||
- PartitionNumber < 1 || 9 < PartitionNumber)
- {
- return FALSE;
- }
-
- p = SystemPath;
- while ('\0' != *p && 0 != _strnicmp(p, "partition(", 10)) {
- p++;
- }
- p = strchr(p, ')');
- if (NULL == p || '0' != *(p - 1)) {
- return FALSE;
- }
- *(p - 1) = '0' + PartitionNumber;
-
- return TRUE;
-}
-
#endif /* defined __i386__ */
/* EOF */
.code16
/* Set the boot drive */
- movb (_i386BootDrive),%dl
+ movb (_BootDrive),%dl
/* Load segment registers */
cli
.code16
/* Set the boot drive */
- movb (_i386BootDrive),%dl
+ movb (_BootDrive),%dl
/* Load segment registers */
cli
MachVtbl.Beep = PcBeep;
MachVtbl.PrepareForReactOS = PcPrepareForReactOS;
MachVtbl.GetMemoryMap = PcMemGetMemoryMap;
- MachVtbl.DiskGetBootVolume = i386DiskGetBootVolume;
- MachVtbl.DiskGetSystemVolume = i386DiskGetSystemVolume;
- MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
- MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
- MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
- MachVtbl.DiskNormalizeSystemPath = i386DiskNormalizeSystemPath;
+ MachVtbl.DiskGetBootVolume = DiskGetBootVolume;
+ MachVtbl.DiskGetSystemVolume = DiskGetSystemVolume;
+ MachVtbl.DiskGetBootPath = DiskGetBootPath;
+ MachVtbl.DiskGetBootDevice = DiskGetBootDevice;
+ MachVtbl.DiskBootingFromFloppy = DiskBootingFromFloppy;
+ MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
- MachVtbl.DiskGetPartitionEntry = PcDiskGetPartitionEntry;
+ MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
MachVtbl.RTCGetCurrentDateTime = PcRTCGetCurrentDateTime;
MachVtbl.Beep = PcBeep;
MachVtbl.PrepareForReactOS = XboxPrepareForReactOS;
MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
- MachVtbl.DiskGetBootVolume = i386DiskGetBootVolume;
- MachVtbl.DiskGetSystemVolume = i386DiskGetSystemVolume;
- MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
- MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
- MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
- MachVtbl.DiskNormalizeSystemPath = i386DiskNormalizeSystemPath;
+ MachVtbl.DiskGetBootVolume = DiskGetBootVolume;
+ MachVtbl.DiskGetSystemVolume = DiskGetSystemVolume;
+ MachVtbl.DiskGetBootPath = DiskGetBootPath;
+ MachVtbl.DiskGetBootDevice = DiskGetBootDevice;
+ MachVtbl.DiskBootingFromFloppy = DiskBootingFromFloppy;
+ MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
return TRUE;
}
-BOOLEAN
-PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
-{
- /* Just use the standard routine */
- return DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
-}
-
BOOLEAN
PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
{
// Hard disks use drive numbers >= 0x80
// So if the drive number indicates a hard disk
// then return FALSE
- if (DriveNumber >= 0x80)
+ // 0x49 is our magic ramdisk drive, so return FALSE for that too
+ if ((DriveNumber >= 0x80) || (DriveNumber == 0x49))
{
return FALSE;
}
return TRUE;
}
+BOOLEAN DiskGetBootVolume(PULONG DriveNumber, PULONGLONG StartSector, PULONGLONG SectorCount, int *FsType)
+{
+ PARTITION_TABLE_ENTRY PartitionTableEntry;
+ UCHAR VolumeType;
+ ULONG ActivePartition;
+
+ DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", BootDrive, BootPartition));
+
+ // Check and see if it is a floppy drive
+ // If so then just assume FAT12 file system type
+ if (DiskIsDriveRemovable(BootDrive))
+ {
+ DbgPrint((DPRINT_FILESYSTEM, "Drive is a floppy diskette drive. Assuming FAT12 file system.\n"));
+
+ *DriveNumber = BootDrive;
+ *StartSector = 0;
+ *SectorCount = 2 * 80 * 18; /* FIXME hardcoded for 1.44 Mb */
+ *FsType = FS_FAT;
+ return TRUE;
+ }
+
+ // Check for ISO9660 file system type
+ if (BootDrive >= 0x80 && FsRecIsIso9660(BootDrive))
+ {
+ DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
+
+ *DriveNumber = BootDrive;
+ *StartSector = 0;
+ *SectorCount = 0;
+ *FsType = FS_ISO9660;
+ return TRUE;
+ }
+
+ // Get the requested partition entry
+ if (BootPartition == 0)
+ {
+ // Partition requested was zero which means the boot partition
+ if (! DiskGetActivePartitionEntry(BootDrive, &PartitionTableEntry, &ActivePartition))
+ {
+ /* Try partition-less disk */
+ *StartSector = 0;
+ *SectorCount = 0;
+ }
+ /* Check for valid partition */
+ else if (PartitionTableEntry.SystemIndicator == PARTITION_ENTRY_UNUSED)
+ {
+ return FALSE;
+ }
+ else
+ {
+ *StartSector = PartitionTableEntry.SectorCountBeforePartition;
+ *SectorCount = PartitionTableEntry.PartitionSectorCount;
+ }
+ }
+ else if (0xff == BootPartition)
+ {
+ /* Partition-less disk */
+ *StartSector = 0;
+ *SectorCount = 0;
+ }
+ else
+ {
+ // Get requested partition
+ if (! MachDiskGetPartitionEntry(BootDrive, BootPartition, &PartitionTableEntry))
+ {
+ return FALSE;
+ }
+ /* Check for valid partition */
+ else if (PartitionTableEntry.SystemIndicator == PARTITION_ENTRY_UNUSED)
+ {
+ return FALSE;
+ }
+ else
+ {
+ *StartSector = PartitionTableEntry.SectorCountBeforePartition;
+ *SectorCount = PartitionTableEntry.PartitionSectorCount;
+ }
+ }
+
+ // Try to recognize the file system
+ if (!FsRecognizeVolume(BootDrive, *StartSector, &VolumeType))
+ {
+ return FALSE;
+ }
+
+ *DriveNumber = BootDrive;
+
+ switch (VolumeType)
+ {
+ case PARTITION_FAT_12:
+ case PARTITION_FAT_16:
+ case PARTITION_HUGE:
+ case PARTITION_XINT13:
+ case PARTITION_FAT32:
+ case PARTITION_FAT32_XINT13:
+ *FsType = FS_FAT;
+ return TRUE;
+ case PARTITION_EXT2:
+ *FsType = FS_EXT2;
+ return TRUE;
+ case PARTITION_NTFS:
+ *FsType = FS_NTFS;
+ return TRUE;
+ default:
+ *FsType = 0;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+VOID
+DiskGetBootDevice(PULONG BootDevice)
+{
+ ((char *)BootDevice)[0] = (char)BootDrive;
+ ((char *)BootDevice)[1] = (char)BootPartition;
+}
+
+BOOLEAN
+DiskBootingFromFloppy(VOID)
+{
+ return BootDrive < 0x80;
+}
+
+#define IsRecognizedPartition(P) \
+ ((P) == PARTITION_FAT_12 || \
+ (P) == PARTITION_FAT_16 || \
+ (P) == PARTITION_HUGE || \
+ (P) == PARTITION_IFS || \
+ (P) == PARTITION_EXT2 || \
+ (P) == PARTITION_FAT32 || \
+ (P) == PARTITION_FAT32_XINT13 || \
+ (P) == PARTITION_XINT13)
+
+#define IsContainerPartition(P) \
+ ((P) == PARTITION_EXTENDED || \
+ (P) == PARTITION_XINT13_EXTENDED)
+
+BOOLEAN DiskGetSystemVolume(char *SystemPath,
+ char *RemainingPath,
+ PULONG Device,
+ PULONG DriveNumber,
+ PULONGLONG StartSector,
+ PULONGLONG SectorCount,
+ int *FsType)
+{
+ ULONG PartitionNumber;
+ PARTITION_TABLE_ENTRY PartitionTableEntry;
+ UCHAR VolumeType;
+ CHAR BootPath[256];
+ unsigned i, RosPartition;
+
+ /*
+ * Verify system path
+ */
+ if (!DissectArcPath(SystemPath, BootPath, DriveNumber, &PartitionNumber))
+ {
+ return FALSE;
+ }
+ if (NULL != RemainingPath)
+ {
+ strcpy(RemainingPath, BootPath);
+ }
+
+ /* 0xff -> no partition table present, use whole device */
+ if (0xff == PartitionNumber)
+ {
+ PartitionTableEntry.SectorCountBeforePartition = 0;
+ i = 0xff;
+ }
+ else
+ {
+ /* recalculate the boot partition for freeldr */
+ i = 0;
+ RosPartition = 0;
+ while (1)
+ {
+ if (!MachDiskGetPartitionEntry(*DriveNumber, ++i, &PartitionTableEntry))
+ {
+ return FALSE;
+ }
+ if (!IsContainerPartition(PartitionTableEntry.SystemIndicator) &&
+ PartitionTableEntry.SystemIndicator != PARTITION_ENTRY_UNUSED)
+ {
+ if (++RosPartition == PartitionNumber)
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ /* Check for ISO9660 file system type */
+ if (*DriveNumber >= 0x80 && FsRecIsIso9660(*DriveNumber))
+ {
+ DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
+
+ if (NULL != Device)
+ {
+ ((char *)Device)[0] = (char)(*DriveNumber);
+ ((char *)Device)[1] = (char)i;
+ }
+ *StartSector = 0;
+ *SectorCount = 0;
+ *FsType = FS_ISO9660;
+ return TRUE;
+ }
+
+ if (!FsRecognizeVolume(*DriveNumber, PartitionTableEntry.SectorCountBeforePartition, &VolumeType))
+ {
+ return FALSE;
+ }
+
+ if (NULL != Device)
+ {
+ ((char *)Device)[0] = (char)(*DriveNumber);
+ ((char *)Device)[1] = (char)i;
+ }
+ *StartSector = PartitionTableEntry.SectorCountBeforePartition;
+ *SectorCount = PartitionTableEntry.PartitionSectorCount;
+
+ switch (VolumeType)
+ {
+ case PARTITION_FAT_12:
+ case PARTITION_FAT_16:
+ case PARTITION_HUGE:
+ case PARTITION_XINT13:
+ case PARTITION_FAT32:
+ case PARTITION_FAT32_XINT13:
+ *FsType = FS_FAT;
+ return TRUE;
+ case PARTITION_EXT2:
+ *FsType = FS_EXT2;
+ return TRUE;
+ case PARTITION_NTFS:
+ *FsType = FS_NTFS;
+ return TRUE;
+ default:
+ *FsType = 0;
+ return FALSE;
+ }
+
+ return FALSE;
+}
+
+BOOLEAN
+DiskGetBootPath(char *BootPath, unsigned Size)
+{
+ static char Path[] = "multi(0)disk(0)";
+ char Device[4];
+
+ _itoa(BootDrive, Device, 10);
+ if (Size <= sizeof(Path) + 6 + strlen(Device))
+ {
+ return FALSE;
+ }
+ strcpy(BootPath, Path);
+ strcat(BootPath, MachDiskBootingFromFloppy() ? "fdisk" : "cdrom");
+ strcat(strcat(strcat(BootPath, "("), Device), ")");
+
+ return TRUE;
+}
+
+BOOLEAN
+DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
+{
+ CHAR BootPath[256];
+ ULONG PartitionNumber;
+ ULONG DriveNumber;
+ PARTITION_TABLE_ENTRY PartEntry;
+ char *p;
+
+ if (!DissectArcPath(SystemPath, BootPath, &DriveNumber, &PartitionNumber))
+ {
+ return FALSE;
+ }
+
+ if (0 != PartitionNumber)
+ {
+ return TRUE;
+ }
+
+ if (! DiskGetActivePartitionEntry(DriveNumber,
+ &PartEntry,
+ &PartitionNumber) ||
+ PartitionNumber < 1 || 9 < PartitionNumber)
+ {
+ return FALSE;
+ }
+
+ p = SystemPath;
+ while ('\0' != *p && 0 != _strnicmp(p, "partition(", 10)) {
+ p++;
+ }
+ p = strchr(p, ')');
+ if (NULL == p || '0' != *(p - 1)) {
+ return FALSE;
+ }
+ *(p - 1) = '0' + PartitionNumber;
+
+ return TRUE;
+}
+
+
// This function is in arch/i386/i386disk.c
//VOID DiskStopFloppyMotor(VOID)
//
// Allow 32KB transfers (64 sectors), emulating BIOS LBA
//
+ ASSERT(Reserved == 0x49);
return 64;
}
//
// Should never be called when the caller expects valid Geometry!
//
+ ASSERT(Reserved == 0x49);
return TRUE;
}
{
PVOID StartAddress;
ULONG Length;
-
+ ASSERT(Reserved == 0x49);
+
//
// Get actual pointers and lengths
//
NTAPI
RamDiskSwitchFromBios(VOID)
{
+ extern ULONG BootDrive, BootPartition;
+
//
// Check if we have a ramdisk, in which case we need to switch routines
//
// Also disable cached FAT reads
//
gCacheEnabled = FALSE;
+
+ //
+ // Switch to ramdisk boot partition
+ //
+ BootDrive = 0x49;
+ BootPartition = 0;
}
}
#define __I386_I386_H_
-extern ULONG i386BootDrive;
-extern ULONG i386BootPartition;
-
-extern BOOLEAN i386DiskGetBootVolume(PULONG DriveNumber, PULONGLONG StartSector,
- PULONGLONG SectorCount, int *FsType);
-extern BOOLEAN i386DiskGetSystemVolume(char *SystemPath, char *RemainingPath,
- PULONG Device, PULONG DriveNumber,
- PULONGLONG StartSector,
- PULONGLONG SectorCount, int *FsType);
-extern BOOLEAN i386DiskGetBootPath(char *BootPath, unsigned Size);
-extern VOID i386DiskGetBootDevice(PULONG BootDevice);
-extern BOOLEAN i386DiskBootingFromFloppy(VOID);
-extern BOOLEAN i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size);
#endif /* __I386_I386_H_ */
BOOLEAN DiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); // Implemented in i386disk.c
BOOLEAN DiskIsDriveRemovable(ULONG DriveNumber);
VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
+extern ULONG BootDrive;
+extern ULONG BootPartition;
+
+BOOLEAN DiskGetBootVolume(PULONG DriveNumber, PULONGLONG StartSector,
+ PULONGLONG SectorCount, int *FsType);
+BOOLEAN DiskGetSystemVolume(char *SystemPath, char *RemainingPath,
+ PULONG Device, PULONG DriveNumber,
+ PULONGLONG StartSector,
+ PULONGLONG SectorCount, int *FsType);
+BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size);
+VOID DiskGetBootDevice(PULONG BootDevice);
+BOOLEAN DiskBootingFromFloppy(VOID);
+BOOLEAN DiskNormalizeSystemPath(char *SystemPath, unsigned Size);
+
///////////////////////////////////////////////////////////////////////////////////////
//