[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.GetMemoryMap = PcMemGetMemoryMap;
MachVtbl.DiskGetBootPath = DiskGetBootPath;
MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath;
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;

View file

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

View file

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

View file

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

View file

@ -107,62 +107,80 @@ 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))
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)

View file

@ -197,7 +197,6 @@ BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord,
BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
{
char ErrMsg[64];
ULONG Index;
// Read master boot record
@ -231,9 +230,6 @@ BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMA
// 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;
}

View file

@ -127,7 +127,6 @@ extern ULONG BootDrive;
extern ULONG BootPartition;
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);
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);

View file

@ -97,13 +97,6 @@ VOID LoadAndBootLinux(PCSTR OperatingSystemName, PCSTR Description)
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)

View file

@ -37,7 +37,6 @@
#undef MachBeep
#undef MachPrepareForReactOS
#undef MachDiskGetBootPath
#undef MachDiskNormalizeSystemPath
#undef MachDiskReadLogicalSectors
#undef MachDiskGetDriveGeometry
#undef MachDiskGetCacheableBlockCount
@ -152,12 +151,6 @@ MachDiskGetBootPath(char *BootPath, unsigned Size)
return MachVtbl.DiskGetBootPath(BootPath, Size);
}
BOOLEAN
MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size)
{
return MachVtbl.DiskNormalizeSystemPath(SystemPath, Size);
}
BOOLEAN
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
*/
p = p + 6;
*BootDrive = atoi(p);
*BootDrive = atoi(p) + 0x80;
p = strchr(p, ')');
if (p == NULL)
return FALSE;

View file

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