[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)

svn path=/trunk/; revision=47052
This commit is contained in:
Cameron Gutman 2010-04-28 03:07:21 +00:00
parent 5f783c4e2d
commit 9adb79a0d9
12 changed files with 70 additions and 87 deletions

View file

@ -45,7 +45,6 @@ PcMachInit(const char *CmdLine)
MachVtbl.PrepareForReactOS = PcPrepareForReactOS; MachVtbl.PrepareForReactOS = PcPrepareForReactOS;
MachVtbl.GetMemoryMap = PcMemGetMemoryMap; MachVtbl.GetMemoryMap = PcMemGetMemoryMap;
MachVtbl.DiskGetBootPath = DiskGetBootPath; MachVtbl.DiskGetBootPath = DiskGetBootPath;
MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors; MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount; MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;

View file

@ -48,7 +48,6 @@ XboxMachInit(const char *CmdLine)
MachVtbl.PrepareForReactOS = XboxPrepareForReactOS; MachVtbl.PrepareForReactOS = XboxPrepareForReactOS;
MachVtbl.GetMemoryMap = XboxMemGetMemoryMap; MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
MachVtbl.DiskGetBootPath = DiskGetBootPath; MachVtbl.DiskGetBootPath = DiskGetBootPath;
MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors; MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount; MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;

View file

@ -44,12 +44,6 @@ VOID LoadAndBootBootSector(PCSTR OperatingSystemName)
return; return;
} }
if (!MachDiskNormalizeSystemPath(FileName, sizeof(FileName)))
{
UiMessageBox("Invalid path to boot sector file");
return;
}
FilePointer = FsOpenFile(FileName); FilePointer = FsOpenFile(FileName);
if (!FilePointer) if (!FilePointer)
{ {

View file

@ -440,7 +440,6 @@ void PpcDefaultMachVtbl()
MachVtbl.GetMemoryMap = PpcGetMemoryMap; MachVtbl.GetMemoryMap = PpcGetMemoryMap;
MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
MachVtbl.DiskGetBootPath = PpcDiskGetBootPath; MachVtbl.DiskGetBootPath = PpcDiskGetBootPath;
MachVtbl.DiskReadLogicalSectors = PpcDiskReadLogicalSectors; MachVtbl.DiskReadLogicalSectors = PpcDiskReadLogicalSectors;
MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry;

View file

@ -107,62 +107,80 @@ DiskGetBootPath(char *BootPath, unsigned Size)
{ {
static char Path[] = "multi(0)disk(0)"; static char Path[] = "multi(0)disk(0)";
char Device[4]; char Device[4];
char Partition[4];
PARTITION_TABLE_ENTRY PartitionEntry;
MASTER_BOOT_RECORD MasterBootRecord;
if (BootDrive < 0x80)
{
/* This is a floppy */
if (Size <= sizeof(Path) + 7 + strlen(Device))
{
return FALSE;
}
strcpy(BootPath, Path);
strcat(BootPath, "fdisk");
_itoa(BootDrive, Device, 10); _itoa(BootDrive, Device, 10);
if (Size <= sizeof(Path) + 6 + strlen(Device)) strcat(BootPath, "(");
strcat(BootPath, Device);
strcat(BootPath, ")");
}
/* 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; return FALSE;
} }
strcpy(BootPath, Path); strcpy(BootPath, Path);
strcat(BootPath, BootDrive < 0x80 ? "fdisk" : "cdrom");
strcat(strcat(strcat(BootPath, "("), Device), ")");
if (strcmp(BootPath, "multi(0)disk(0)cdrom(128)") == 0) strcat(BootPath, "rdisk");
strcpy(BootPath, "multi(0)disk(0)rdisk(0)partition(1)");
return TRUE; _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
BOOLEAN
DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
{ {
CHAR BootPath[256]; /* This is a CD-ROM drive */
ULONG PartitionNumber;
ULONG DriveNumber;
PARTITION_TABLE_ENTRY PartEntry;
char *p;
if (!DissectArcPath(SystemPath, BootPath, &DriveNumber, &PartitionNumber)) if (Size <= sizeof(Path) + 7 + strlen(Device))
{ {
return FALSE; return FALSE;
} }
if (0 != PartitionNumber || DriveNumber < 0x80) strcpy(BootPath, Path);
{
return TRUE;
}
if (! DiskGetActivePartitionEntry(DriveNumber, strcat(BootPath, "cdrom");
&PartEntry,
&PartitionNumber) ||
PartitionNumber < 1 || 9 < PartitionNumber)
{
return FALSE;
}
p = SystemPath; _itoa(BootDrive - 0x80, Device, 10);
while ('\0' != *p && 0 != _strnicmp(p, "partition(", 10)) { strcat(BootPath, "(");
p++; strcat(BootPath, Device);
strcat(BootPath, ")");
} }
p = strchr(p, ')');
if (NULL == p || '0' != *(p - 1)) {
return FALSE;
}
*(p - 1) = '0' + PartitionNumber;
return TRUE; return TRUE;
} }
// This function is in arch/i386/i386disk.c // This function is in arch/i386/i386disk.c
//VOID DiskStopFloppyMotor(VOID) //VOID DiskStopFloppyMotor(VOID)

View file

@ -197,7 +197,6 @@ BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord,
BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord) BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
{ {
char ErrMsg[64];
ULONG Index; ULONG Index;
// Read master boot record // Read master boot record
@ -231,9 +230,6 @@ BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMA
// Check the partition table magic value // Check the partition table magic value
if (BootRecord->MasterBootRecordMagic != 0xaa55) 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; return FALSE;
} }

View file

@ -127,7 +127,6 @@ extern ULONG BootDrive;
extern ULONG BootPartition; extern ULONG BootPartition;
BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size); BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size);
BOOLEAN DiskNormalizeSystemPath(char *SystemPath, unsigned Size);
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////

View file

@ -62,7 +62,6 @@ typedef struct tagMACHVTBL
ULONG (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize); ULONG (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
BOOLEAN (*DiskGetBootPath)(char *BootPath, unsigned Size); BOOLEAN (*DiskGetBootPath)(char *BootPath, unsigned Size);
BOOLEAN (*DiskNormalizeSystemPath)(char *SystemPath, unsigned Size);
BOOLEAN (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); BOOLEAN (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber); ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber);

View file

@ -97,13 +97,6 @@ VOID LoadAndBootLinux(PCSTR OperatingSystemName, PCSTR Description)
goto LinuxBootFailed; goto LinuxBootFailed;
} }
// Open the boot volume
if (!MachDiskNormalizeSystemPath(LinuxBootPath, sizeof(LinuxBootPath)))
{
UiMessageBox("Invalid boot path");
goto LinuxBootFailed;
}
// Open the kernel // Open the kernel
LinuxKernel = FsOpenFile(LinuxKernelName); LinuxKernel = FsOpenFile(LinuxKernelName);
if (!LinuxKernel) if (!LinuxKernel)

View file

@ -37,7 +37,6 @@
#undef MachBeep #undef MachBeep
#undef MachPrepareForReactOS #undef MachPrepareForReactOS
#undef MachDiskGetBootPath #undef MachDiskGetBootPath
#undef MachDiskNormalizeSystemPath
#undef MachDiskReadLogicalSectors #undef MachDiskReadLogicalSectors
#undef MachDiskGetDriveGeometry #undef MachDiskGetDriveGeometry
#undef MachDiskGetCacheableBlockCount #undef MachDiskGetCacheableBlockCount
@ -152,12 +151,6 @@ MachDiskGetBootPath(char *BootPath, unsigned Size)
return MachVtbl.DiskGetBootPath(BootPath, Size); return MachVtbl.DiskGetBootPath(BootPath, Size);
} }
BOOLEAN
MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size)
{
return MachVtbl.DiskNormalizeSystemPath(SystemPath, Size);
}
BOOLEAN BOOLEAN
MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer) MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{ {

View file

@ -69,7 +69,7 @@ BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* B
* multi(0)disk(0)cdrom(x)\path * multi(0)disk(0)cdrom(x)\path
*/ */
p = p + 6; p = p + 6;
*BootDrive = atoi(p); *BootDrive = atoi(p) + 0x80;
p = strchr(p, ')'); p = strchr(p, ')');
if (p == NULL) if (p == NULL)
return FALSE; return FALSE;

View file

@ -718,12 +718,6 @@ LoadAndBootReactOS(PCSTR OperatingSystemName)
} }
else else
{ {
if (! MachDiskNormalizeSystemPath(SystemPath,
sizeof(SystemPath)))
{
UiMessageBox("Invalid system path");
return;
}
/* copy system path into kernel command line */ /* copy system path into kernel command line */
strcpy(reactos_kernel_cmdline, SystemPath); strcpy(reactos_kernel_cmdline, SystemPath);
} }