Author: cgutman Date: Wed Apr 28 05:07:21 2010 New Revision: 47052
URL: http://svn.reactos.org/svn/reactos?rev=47052&view=rev Log: [FREELDR] - Remove the useless function MachDiskNormalizeSystemPath - Rewrite DiskGetBootPath to be much less hacky (but still not hack free) - Freeloader doesn't have to be installed on multi(0)disk(0)rdisk(0)partition(1) (IDE primary master) anymore :) - Freeloader successfully booted ROS after loading itself from multi(0)disk(0)rdisk(1)partition(1)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c trunk/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c trunk/reactos/boot/freeldr/freeldr/disk/disk.c trunk/reactos/boot/freeldr/freeldr/disk/partition.c trunk/reactos/boot/freeldr/freeldr/include/disk.h trunk/reactos/boot/freeldr/freeldr/include/machine.h trunk/reactos/boot/freeldr/freeldr/linuxboot.c trunk/reactos/boot/freeldr/freeldr/machine.c trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -45,7 +45,6 @@ MachVtbl.PrepareForReactOS = PcPrepareForReactOS; MachVtbl.GetMemoryMap = PcMemGetMemoryMap; MachVtbl.DiskGetBootPath = DiskGetBootPath; - MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath; MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors; MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry; MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -48,7 +48,6 @@ MachVtbl.PrepareForReactOS = XboxPrepareForReactOS; MachVtbl.GetMemoryMap = XboxMemGetMemoryMap; MachVtbl.DiskGetBootPath = DiskGetBootPath; - MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath; MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors; MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry; MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -44,12 +44,6 @@ return; }
- if (!MachDiskNormalizeSystemPath(FileName, sizeof(FileName))) - { - UiMessageBox("Invalid path to boot sector file"); - return; - } - FilePointer = FsOpenFile(FileName); if (!FilePointer) {
Modified: trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/p... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -440,7 +440,6 @@
MachVtbl.GetMemoryMap = PpcGetMemoryMap;
- MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath; MachVtbl.DiskGetBootPath = PpcDiskGetBootPath; MachVtbl.DiskReadLogicalSectors = PpcDiskReadLogicalSectors; MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry;
Modified: trunk/reactos/boot/freeldr/freeldr/disk/disk.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/d... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -107,61 +107,79 @@ { static char Path[] = "multi(0)disk(0)"; char Device[4]; - - _itoa(BootDrive, Device, 10); - if (Size <= sizeof(Path) + 6 + strlen(Device)) + char Partition[4]; + PARTITION_TABLE_ENTRY PartitionEntry; + MASTER_BOOT_RECORD MasterBootRecord; + + if (BootDrive < 0x80) { - return FALSE; + /* This is a floppy */ + + if (Size <= sizeof(Path) + 7 + strlen(Device)) + { + return FALSE; + } + + strcpy(BootPath, Path); + + strcat(BootPath, "fdisk"); + + _itoa(BootDrive, Device, 10); + strcat(BootPath, "("); + strcat(BootPath, Device); + strcat(BootPath, ")"); } - strcpy(BootPath, Path); - strcat(BootPath, BootDrive < 0x80 ? "fdisk" : "cdrom"); - strcat(strcat(strcat(BootPath, "("), Device), ")"); - - if (strcmp(BootPath, "multi(0)disk(0)cdrom(128)") == 0) - strcpy(BootPath, "multi(0)disk(0)rdisk(0)partition(1)"); + /* FIXME */ + else if (DiskReadBootRecord(BootDrive, 0, &MasterBootRecord)) + { + /* This is a hard disk */ + + if (!DiskGetActivePartitionEntry(BootDrive, &PartitionEntry, &BootPartition)) + { + DbgPrint("Invalid active partition information\n"); + return FALSE; + } + + if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition)) + { + return FALSE; + } + + strcpy(BootPath, Path); + + strcat(BootPath, "rdisk"); + + _itoa(BootDrive - 0x80, Device, 10); + strcat(BootPath, "("); + strcat(BootPath, Device); + strcat(BootPath, ")"); + + _itoa(BootPartition, Partition, 10); + strcat(BootPath, "partition("); + strcat(BootPath, Partition); + strcat(BootPath, ")"); + } + else + { + /* This is a CD-ROM drive */ + + if (Size <= sizeof(Path) + 7 + strlen(Device)) + { + return FALSE; + } + + strcpy(BootPath, Path); + + strcat(BootPath, "cdrom"); + + _itoa(BootDrive - 0x80, Device, 10); + strcat(BootPath, "("); + strcat(BootPath, Device); + strcat(BootPath, ")"); + } + 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 || DriveNumber < 0x80) - { - 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)
Modified: trunk/reactos/boot/freeldr/freeldr/disk/partition.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/p... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/disk/partition.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/disk/partition.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -197,7 +197,6 @@
BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord) { - char ErrMsg[64]; ULONG Index;
// Read master boot record @@ -231,9 +230,6 @@ // Check the partition table magic value if (BootRecord->MasterBootRecordMagic != 0xaa55) { - sprintf(ErrMsg, "Invalid partition table magic 0x%x found on drive 0x%lx", - BootRecord->MasterBootRecordMagic, DriveNumber); - DiskError(ErrMsg, 0); return FALSE; }
Modified: trunk/reactos/boot/freeldr/freeldr/include/disk.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/disk.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/disk.h [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -127,7 +127,6 @@ extern ULONG BootPartition;
BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size); -BOOLEAN DiskNormalizeSystemPath(char *SystemPath, unsigned Size);
///////////////////////////////////////////////////////////////////////////////////////
Modified: trunk/reactos/boot/freeldr/freeldr/include/machine.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/machine.h [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/include/machine.h [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -62,7 +62,6 @@ ULONG (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
BOOLEAN (*DiskGetBootPath)(char *BootPath, unsigned Size); - BOOLEAN (*DiskNormalizeSystemPath)(char *SystemPath, unsigned Size); BOOLEAN (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry); ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber);
Modified: trunk/reactos/boot/freeldr/freeldr/linuxboot.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/linuxb... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/linuxboot.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/linuxboot.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -97,13 +97,6 @@ goto LinuxBootFailed; }
- // Open the boot volume - if (!MachDiskNormalizeSystemPath(LinuxBootPath, sizeof(LinuxBootPath))) - { - UiMessageBox("Invalid boot path"); - goto LinuxBootFailed; - } - // Open the kernel LinuxKernel = FsOpenFile(LinuxKernelName); if (!LinuxKernel)
Modified: trunk/reactos/boot/freeldr/freeldr/machine.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/machin... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/machine.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/machine.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -37,7 +37,6 @@ #undef MachBeep #undef MachPrepareForReactOS #undef MachDiskGetBootPath -#undef MachDiskNormalizeSystemPath #undef MachDiskReadLogicalSectors #undef MachDiskGetDriveGeometry #undef MachDiskGetCacheableBlockCount @@ -153,12 +152,6 @@ }
BOOLEAN -MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size) -{ - return MachVtbl.DiskNormalizeSystemPath(SystemPath, Size); -} - -BOOLEAN MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer) { return MachVtbl.DiskReadLogicalSectors(DriveNumber, SectorNumber, SectorCount, Buffer);
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/reacto... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/arcname.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -69,7 +69,7 @@ * multi(0)disk(0)cdrom(x)\path */ p = p + 6; - *BootDrive = atoi(p); + *BootDrive = atoi(p) + 0x80; p = strchr(p, ')'); if (p == NULL) return FALSE;
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/reacto... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/reactos.c [iso-8859-1] Wed Apr 28 05:07:21 2010 @@ -718,12 +718,6 @@ } else { - if (! MachDiskNormalizeSystemPath(SystemPath, - sizeof(SystemPath))) - { - UiMessageBox("Invalid system path"); - return; - } /* copy system path into kernel command line */ strcpy(reactos_kernel_cmdline, SystemPath); }