[FREELDR]

- Fix date format in CHANGELOG (that uses that #$@! of US format)
- Diverse code style changes (whitespace, extra braces, C++ to C-style comments, ...)

svn path=/trunk/; revision=66144
This commit is contained in:
Hermès Bélusca-Maïto 2015-02-01 20:22:13 +00:00
parent 2682e03820
commit fd896be2a7
13 changed files with 419 additions and 562 deletions

View file

@ -1,4 +1,4 @@
Changes in v3.0+ (05/01/2015) (hbelusca) Changes in v3.0+ (01/05/2015) (hbelusca)
- Remove support for special value "LiveCD" of SystemPath option - Remove support for special value "LiveCD" of SystemPath option
for loading ReactOS since now we treat non-ARC SystemPath as for loading ReactOS since now we treat non-ARC SystemPath as

View file

@ -163,7 +163,7 @@ i386PrintExceptionText(ULONG TrapIndex, PKTRAP_FRAME TrapFrame, PKSPECIAL_REGIST
TrapFrame->SegSs, Special->Ldtr, Special->Idtr.Limit); TrapFrame->SegSs, Special->Ldtr, Special->Idtr.Limit);
InstructionPointer = (PUCHAR)TrapFrame->Rip; InstructionPointer = (PUCHAR)TrapFrame->Rip;
#endif #endif
PrintText("\nInstructionstream: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x \n", PrintText("\nInstruction stream: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x \n",
InstructionPointer[0], InstructionPointer[1], InstructionPointer[0], InstructionPointer[1],
InstructionPointer[2], InstructionPointer[3], InstructionPointer[2], InstructionPointer[3],
InstructionPointer[4], InstructionPointer[5], InstructionPointer[4], InstructionPointer[5],
@ -240,4 +240,3 @@ FrLdrBugCheck(ULONG BugCode)
{ {
FrLdrBugCheckEx(BugCode, 0, 0); FrLdrBugCheckEx(BugCode, 0, 0);
} }

View file

@ -17,9 +17,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* INCLUDES *******************************************************************/
#include <freeldr.h> #include <freeldr.h>
ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information /* GLOBALS ********************************************************************/
// ARC Disk Information
ARC_DISK_SIGNATURE reactos_arc_disk_info[32];
ULONG reactos_disk_count = 0; ULONG reactos_disk_count = 0;
CHAR reactos_arc_strings[32][256]; CHAR reactos_arc_strings[32][256];
@ -48,10 +53,10 @@ struct
{"WindowsNT40" , _WIN32_WINNT_NT4 , LoadAndBootWindows }, {"WindowsNT40" , _WIN32_WINNT_NT4 , LoadAndBootWindows },
#endif #endif
{"Windows2003" , _WIN32_WINNT_WS03, LoadAndBootWindows }, {"Windows2003" , _WIN32_WINNT_WS03, LoadAndBootWindows },
// {"Not found" , 0 , NULL }
}; };
/* FUNCTIONS ******************************************************************/
VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem) VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
@ -59,10 +64,10 @@ VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem)
CHAR BootType[80]; CHAR BootType[80];
ULONG i; ULONG i;
// Try to open the operating system section in the .ini file /* Try to open the operating system section in the .ini file */
if (IniOpenSection(SectionName, &SectionId)) if (IniOpenSection(SectionName, &SectionId))
{ {
// Try to read the boot type /* Try to read the boot type */
IniReadSettingByName(SectionId, "BootType", BootType, sizeof(BootType)); IniReadSettingByName(SectionId, "BootType", BootType, sizeof(BootType));
} }
else else
@ -72,7 +77,7 @@ VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem)
if (BootType[0] == ANSI_NULL && SectionName[0] != ANSI_NULL) if (BootType[0] == ANSI_NULL && SectionName[0] != ANSI_NULL)
{ {
// Try to infere the boot type value /* Try to infere the boot type value */
#ifdef _M_IX86 #ifdef _M_IX86
ULONG FileId; ULONG FileId;
if (ArcOpen((PSTR)SectionName, OpenReadOnly, &FileId) == ESUCCESS) if (ArcOpen((PSTR)SectionName, OpenReadOnly, &FileId) == ESUCCESS)
@ -87,12 +92,12 @@ VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem)
} }
} }
// Install the drive mapper according to this section drive mappings /* Install the drive mapper according to this section drive mappings */
#if defined(_M_IX86) && !defined(_MSC_VER) #if defined(_M_IX86) && !defined(_MSC_VER)
DriveMapMapDrivesInSection(SectionName); DriveMapMapDrivesInSection(SectionName);
#endif #endif
// Loop through the OS loading method table and find a suitable OS to boot /* Loop through the OS loading method table and find a suitable OS to boot */
for (i = 0; i < sizeof(OSLoadingMethods) / sizeof(OSLoadingMethods[0]); ++i) for (i = 0; i < sizeof(OSLoadingMethods) / sizeof(OSLoadingMethods[0]); ++i)
{ {
if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0) if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0)
@ -106,19 +111,17 @@ VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem)
ULONG GetDefaultOperatingSystem(OperatingSystemItem* OperatingSystemList, ULONG OperatingSystemCount) ULONG GetDefaultOperatingSystem(OperatingSystemItem* OperatingSystemList, ULONG OperatingSystemCount)
{ {
CHAR DefaultOSText[80]; CHAR DefaultOSText[80];
PCSTR DefaultOSName; PCSTR DefaultOSName;
ULONG_PTR SectionId; ULONG_PTR SectionId;
ULONG DefaultOS = 0; ULONG DefaultOS = 0;
ULONG Idx; ULONG Idx;
if (!IniOpenSection("FreeLoader", &SectionId)) if (!IniOpenSection("FreeLoader", &SectionId))
{
return 0; return 0;
}
DefaultOSName = CmdLineGetDefaultOS(); DefaultOSName = CmdLineGetDefaultOS();
if (NULL == DefaultOSName) if (DefaultOSName == NULL)
{ {
if (IniReadSettingByName(SectionId, "DefaultOS", DefaultOSText, sizeof(DefaultOSText))) if (IniReadSettingByName(SectionId, "DefaultOS", DefaultOSText, sizeof(DefaultOSText)))
{ {
@ -126,9 +129,9 @@ ULONG GetDefaultOperatingSystem(OperatingSystemItem* OperatingSystemList, ULONG
} }
} }
if (NULL != DefaultOSName) if (DefaultOSName != NULL)
{ {
for (Idx=0; Idx<OperatingSystemCount; Idx++) for (Idx = 0; Idx<OperatingSystemCount; Idx++)
{ {
if (_stricmp(DefaultOSName, OperatingSystemList[Idx].SystemPartition) == 0) if (_stricmp(DefaultOSName, OperatingSystemList[Idx].SystemPartition) == 0)
{ {
@ -148,24 +151,16 @@ LONG GetTimeOut(VOID)
ULONG_PTR SectionId; ULONG_PTR SectionId;
TimeOut = CmdLineGetTimeOut(); TimeOut = CmdLineGetTimeOut();
if (0 <= TimeOut) if (TimeOut >= 0)
{
return TimeOut; return TimeOut;
}
if (!IniOpenSection("FreeLoader", &SectionId)) if (!IniOpenSection("FreeLoader", &SectionId))
{
return -1; return -1;
}
if (IniReadSettingByName(SectionId, "TimeOut", TimeOutText, sizeof(TimeOutText))) if (IniReadSettingByName(SectionId, "TimeOut", TimeOutText, sizeof(TimeOutText)))
{
TimeOut = atoi(TimeOutText); TimeOut = atoi(TimeOutText);
}
else else
{
TimeOut = -1; TimeOut = -1;
}
return TimeOut; return TimeOut;
} }
@ -175,42 +170,41 @@ BOOLEAN MainBootMenuKeyPressFilter(ULONG KeyPress)
if (KeyPress == KEY_F8) if (KeyPress == KEY_F8)
{ {
DoOptionsMenu(); DoOptionsMenu();
return TRUE; return TRUE;
} }
// We didn't handle the key /* We didn't handle the key */
return FALSE; return FALSE;
} }
VOID RunLoader(VOID) VOID RunLoader(VOID)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
ULONG OperatingSystemCount; ULONG OperatingSystemCount;
OperatingSystemItem* OperatingSystemList; OperatingSystemItem* OperatingSystemList;
PCSTR* OperatingSystemDisplayNames; PCSTR* OperatingSystemDisplayNames;
ULONG DefaultOperatingSystem; ULONG DefaultOperatingSystem;
LONG TimeOut; LONG TimeOut;
ULONG SelectedOperatingSystem; ULONG SelectedOperatingSystem;
ULONG i; ULONG i;
if (!MachInitializeBootDevices()) if (!MachInitializeBootDevices())
{ {
UiMessageBoxCritical("Error when detecting hardware"); UiMessageBoxCritical("Error when detecting hardware.");
return; return;
} }
#ifdef _M_IX86 #ifdef _M_IX86
// Load additional SCSI driver (if any) /* Load additional SCSI driver (if any) */
if (LoadBootDeviceDriver() != ESUCCESS) if (LoadBootDeviceDriver() != ESUCCESS)
{ {
UiMessageBoxCritical("Unable to load additional boot device driver"); UiMessageBoxCritical("Unable to load additional boot device drivers.");
} }
#endif #endif
if (!IniFileInitialize()) if (!IniFileInitialize())
{ {
UiMessageBoxCritical("Error initializing .ini file"); UiMessageBoxCritical("Error initializing .ini file.");
return; return;
} }
@ -219,6 +213,7 @@ VOID RunLoader(VOID)
UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini."); UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
return; return;
} }
TimeOut = GetTimeOut(); TimeOut = GetTimeOut();
if (!UiInitialize(TRUE)) if (!UiInitialize(TRUE))
@ -231,41 +226,36 @@ VOID RunLoader(VOID)
if (!OperatingSystemList) if (!OperatingSystemList)
{ {
UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot."); UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
goto reboot; goto Reboot;
} }
if (OperatingSystemCount == 0) if (OperatingSystemCount == 0)
{ {
UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot."); UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
goto reboot; goto Reboot;
} }
DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemList, OperatingSystemCount); DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemList, OperatingSystemCount);
// /* Create list of display names */
// Create list of display names
//
OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO'); OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
if (!OperatingSystemDisplayNames) if (!OperatingSystemDisplayNames)
{ goto Reboot;
goto reboot;
}
for (i = 0; i < OperatingSystemCount; i++) for (i = 0; i < OperatingSystemCount; i++)
{ {
OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier; OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier;
} }
// /* Find all the message box settings and run them */
// Find all the message box settings and run them
//
UiShowMessageBoxesInSection("FreeLoader"); UiShowMessageBoxesInSection("FreeLoader");
for (;;) for (;;)
{ {
// Redraw the backdrop /* Redraw the backdrop */
UiDrawBackdrop(); UiDrawBackdrop();
// Show the operating system list menu /* Show the operating system list menu */
if (!UiDisplayMenu("Please select the operating system to start:", if (!UiDisplayMenu("Please select the operating system to start:",
"For troubleshooting and advanced startup options for " "For troubleshooting and advanced startup options for "
"ReactOS, press F8.", "ReactOS, press F8.",
@ -279,16 +269,16 @@ VOID RunLoader(VOID)
MainBootMenuKeyPressFilter)) MainBootMenuKeyPressFilter))
{ {
UiMessageBox("Press ENTER to reboot."); UiMessageBox("Press ENTER to reboot.");
goto reboot; goto Reboot;
} }
TimeOut = -1; TimeOut = -1;
// Load the chosen operating system /* Load the chosen operating system */
LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]); LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
} }
reboot: Reboot:
UiUnInitialize("Rebooting..."); UiUnInitialize("Rebooting...");
return; return;
} }

View file

@ -12,6 +12,12 @@
/* GLOBALS ********************************************************************/ /* GLOBALS ********************************************************************/
typedef struct tagCMDLINEINFO
{
const char *DefaultOperatingSystem;
LONG TimeOut;
} CMDLINEINFO, *PCMDLINEINFO;
CCHAR DefaultOs[256]; CCHAR DefaultOs[256];
CMDLINEINFO CmdLineInfo; CMDLINEINFO CmdLineInfo;
@ -23,43 +29,34 @@ CmdLineParse(IN PCHAR CmdLine)
PCHAR End, Setting; PCHAR End, Setting;
ULONG_PTR Length, Offset = 0; ULONG_PTR Length, Offset = 0;
// /* Set defaults */
// Set defaults
//
CmdLineInfo.DefaultOperatingSystem = NULL; CmdLineInfo.DefaultOperatingSystem = NULL;
CmdLineInfo.TimeOut = -1; CmdLineInfo.TimeOut = -1;
// /* Get timeout */
// Get timeout
//
Setting = strstr(CmdLine, "timeout="); Setting = strstr(CmdLine, "timeout=");
if (Setting) CmdLineInfo.TimeOut = atoi(Setting + if (Setting) CmdLineInfo.TimeOut = atoi(Setting +
sizeof("timeout=") + sizeof("timeout=") +
sizeof(ANSI_NULL)); sizeof(ANSI_NULL));
// /* Get default OS */
// Get default OS
//
Setting = strstr(CmdLine, "defaultos="); Setting = strstr(CmdLine, "defaultos=");
if (Setting) if (Setting)
{ {
// /* Check if there's more command-line parameters following */
// Check if there's more command-line parameters following
//
Setting += sizeof("defaultos=") + sizeof(ANSI_NULL); Setting += sizeof("defaultos=") + sizeof(ANSI_NULL);
End = strstr(Setting, " "); End = strstr(Setting, " ");
if (End) Length = End - Setting; else Length = sizeof(DefaultOs); if (End)
Length = End - Setting;
else
Length = sizeof(DefaultOs);
// /* Copy the default OS */
// Copy the default OS
//
strncpy(DefaultOs, Setting, Length); strncpy(DefaultOs, Setting, Length);
CmdLineInfo.DefaultOperatingSystem = DefaultOs; CmdLineInfo.DefaultOperatingSystem = DefaultOs;
} }
// /* Get ramdisk base address */
// Get ramdisk base address
//
Setting = strstr(CmdLine, "rdbase="); Setting = strstr(CmdLine, "rdbase=");
if (Setting) gRamDiskBase = (PVOID)(ULONG_PTR)strtoull(Setting + if (Setting) gRamDiskBase = (PVOID)(ULONG_PTR)strtoull(Setting +
sizeof("rdbase=") - sizeof("rdbase=") -
@ -67,9 +64,7 @@ CmdLineParse(IN PCHAR CmdLine)
NULL, NULL,
0); 0);
// /* Get ramdisk size */
// Get ramdisk size
//
Setting = strstr(CmdLine, "rdsize="); Setting = strstr(CmdLine, "rdsize=");
if (Setting) gRamDiskSize = strtoul(Setting + if (Setting) gRamDiskSize = strtoul(Setting +
sizeof("rdsize=") - sizeof("rdsize=") -
@ -77,9 +72,7 @@ CmdLineParse(IN PCHAR CmdLine)
NULL, NULL,
0); 0);
// /* Get ramdisk offset */
// Get ramdisk offset
//
Setting = strstr(CmdLine, "rdoffset="); Setting = strstr(CmdLine, "rdoffset=");
if (Setting) Offset = strtoul(Setting + if (Setting) Offset = strtoul(Setting +
sizeof("rdoffset=") - sizeof("rdoffset=") -
@ -87,9 +80,7 @@ CmdLineParse(IN PCHAR CmdLine)
NULL, NULL,
0); 0);
// /* Fix it up */
// Fix it up
//
gRamDiskBase = (PVOID)((ULONG_PTR)gRamDiskBase + Offset); gRamDiskBase = (PVOID)((ULONG_PTR)gRamDiskBase + Offset);
} }

View file

@ -17,32 +17,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <freeldr.h>
#ifdef _M_IX86 #ifdef _M_IX86
const CHAR BootDrivePrompt[] = "Enter the boot drive.\n\nExamples:\nfd0 - first floppy drive\nhd0 - first hard drive\nhd1 - second hard drive\ncd0 - first CD-ROM drive.\n\nBIOS drive numbers may also be used:\n0 - first floppy drive\n0x80 - first hard drive\n0x81 - second hard drive"; /* INCLUDES *******************************************************************/
const CHAR BootPartitionPrompt[] = "Enter the boot partition.\n\nEnter 0 for the active (bootable) partition.";
const CHAR BootSectorFilePrompt[] = "Enter the boot sector file path.\n\nExamples:\n\\BOOTSECT.DOS\n/boot/bootsect.dos";
const CHAR LinuxKernelPrompt[] = "Enter the Linux kernel image path.\n\nExamples:\n/vmlinuz\n/boot/vmlinuz-2.4.18";
const CHAR LinuxInitrdPrompt[] = "Enter the initrd image path.\n\nExamples:\n/initrd.gz\n/boot/root.img.gz\n\nLeave blank for no initial ram disk.";
const CHAR LinuxCommandLinePrompt[] = "Enter the Linux kernel command line.\n\nExamples:\nroot=/dev/hda1\nroot=/dev/fd0 read-only\nroot=/dev/sdb1 init=/sbin/init";
const CHAR ReactOSSystemPathPrompt[] = "Enter the path to your ReactOS system directory.\n\nExamples:\n\\REACTOS\n\\ROS";
const CHAR ReactOSOptionsPrompt[] = "Enter the options you want passed to the kernel.\n\nExamples:\n/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200\n/FASTDETECT /SOS /NOGUIBOOT\n/BASEVIDEO /MAXMEM=64\n/KERNEL=NTKRNLMP.EXE /HAL=HALMPS.DLL";
const CHAR CustomBootPrompt[] = "Press ENTER to boot your custom boot setup."; #include <freeldr.h>
/* GLOBALS ********************************************************************/
const CHAR BootDrivePrompt[] = "Enter the boot drive.\n\nExamples:\nfd0 - first floppy drive\nhd0 - first hard drive\nhd1 - second hard drive\ncd0 - first CD-ROM drive.\n\nBIOS drive numbers may also be used:\n0 - first floppy drive\n0x80 - first hard drive\n0x81 - second hard drive";
const CHAR BootPartitionPrompt[] = "Enter the boot partition.\n\nEnter 0 for the active (bootable) partition.";
const CHAR BootSectorFilePrompt[] = "Enter the boot sector file path.\n\nExamples:\n\\BOOTSECT.DOS\n/boot/bootsect.dos";
const CHAR LinuxKernelPrompt[] = "Enter the Linux kernel image path.\n\nExamples:\n/vmlinuz\n/boot/vmlinuz-2.4.18";
const CHAR LinuxInitrdPrompt[] = "Enter the initrd image path.\n\nExamples:\n/initrd.gz\n/boot/root.img.gz\n\nLeave blank for no initial ram disk.";
const CHAR LinuxCommandLinePrompt[] = "Enter the Linux kernel command line.\n\nExamples:\nroot=/dev/hda1\nroot=/dev/fd0 read-only\nroot=/dev/sdb1 init=/sbin/init";
const CHAR ReactOSSystemPathPrompt[] = "Enter the path to your ReactOS system directory.\n\nExamples:\n\\REACTOS\n\\ROS";
const CHAR ReactOSOptionsPrompt[] = "Enter the options you want passed to the kernel.\n\nExamples:\n/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200\n/FASTDETECT /SOS /NOGUIBOOT\n/BASEVIDEO /MAXMEM=64\n/KERNEL=NTKRNLMP.EXE /HAL=HALMPS.DLL";
const CHAR CustomBootPrompt[] = "Press ENTER to boot your custom boot setup.";
/* FUNCTIONS ******************************************************************/
VOID OptionMenuCustomBoot(VOID) VOID OptionMenuCustomBoot(VOID)
{ {
PCSTR CustomBootMenuList[] = { PCSTR CustomBootMenuList[] = {
"Disk", "Disk",
"Partition", "Partition",
"Boot Sector File", "Boot Sector File",
"ReactOS", "ReactOS",
"Linux" "Linux"
}; };
ULONG CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]); ULONG CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
ULONG SelectedMenuItem; ULONG SelectedMenuItem;
if (!UiDisplayMenu("Please choose a boot method:", "", if (!UiDisplayMenu("Please choose a boot method:", "",
FALSE, FALSE,
@ -59,61 +64,53 @@ VOID OptionMenuCustomBoot(VOID)
switch (SelectedMenuItem) switch (SelectedMenuItem)
{ {
case 0: // Disk case 0: // Disk
OptionMenuCustomBootDisk(); OptionMenuCustomBootDisk();
break; break;
case 1: // Partition case 1: // Partition
OptionMenuCustomBootPartition(); OptionMenuCustomBootPartition();
break; break;
case 2: // Boot Sector File case 2: // Boot Sector File
OptionMenuCustomBootBootSectorFile(); OptionMenuCustomBootBootSectorFile();
break; break;
case 3: // ReactOS case 3: // ReactOS
OptionMenuCustomBootReactOS(); OptionMenuCustomBootReactOS();
break; break;
case 4: // Linux case 4: // Linux
OptionMenuCustomBootLinux(); OptionMenuCustomBootLinux();
break; break;
} }
} }
VOID OptionMenuCustomBootDisk(VOID) VOID OptionMenuCustomBootDisk(VOID)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
CHAR SectionName[100]; CHAR SectionName[100];
CHAR BootDriveString[20]; CHAR BootDriveString[20];
TIMEINFO* TimeInfo; TIMEINFO* TimeInfo;
OperatingSystemItem OperatingSystem; OperatingSystemItem OperatingSystem;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
{
return; return;
}
// Generate a unique section name /* Generate a unique section name */
TimeInfo = ArcGetTime(); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomBootDisk%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); sprintf(SectionName, "CustomBootDisk%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section /* Add the section */
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
{
return; return;
}
// Add the BootType /* Add the BootType */
if (!IniAddSettingValueToSection(SectionId, "BootType", "Drive")) if (!IniAddSettingValueToSection(SectionId, "BootType", "Drive"))
{
return; return;
}
// Add the BootDrive /* Add the BootDrive */
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString)) if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
{
return; return;
}
UiMessageBox(CustomBootPrompt); UiMessageBox(CustomBootPrompt);
@ -127,54 +124,42 @@ VOID OptionMenuCustomBootDisk(VOID)
VOID OptionMenuCustomBootPartition(VOID) VOID OptionMenuCustomBootPartition(VOID)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
CHAR SectionName[100]; CHAR SectionName[100];
CHAR BootDriveString[20]; CHAR BootDriveString[20];
CHAR BootPartitionString[20]; CHAR BootPartitionString[20];
TIMEINFO* TimeInfo; TIMEINFO* TimeInfo;
OperatingSystemItem OperatingSystem; OperatingSystemItem OperatingSystem;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString)); RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
{
return; return;
}
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
{
return; return;
}
// Generate a unique section name /* Generate a unique section name */
TimeInfo = ArcGetTime(); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomBootPartition%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); sprintf(SectionName, "CustomBootPartition%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section /* Add the section */
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
{
return; return;
}
// Add the BootType /* Add the BootType */
if (!IniAddSettingValueToSection(SectionId, "BootType", "Partition")) if (!IniAddSettingValueToSection(SectionId, "BootType", "Partition"))
{
return; return;
}
// Add the BootDrive /* Add the BootDrive */
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString)) if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
{
return; return;
}
// Add the BootPartition /* Add the BootPartition */
if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString)) if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
{
return; return;
}
UiMessageBox(CustomBootPrompt); UiMessageBox(CustomBootPrompt);
@ -188,13 +173,13 @@ VOID OptionMenuCustomBootPartition(VOID)
VOID OptionMenuCustomBootBootSectorFile(VOID) VOID OptionMenuCustomBootBootSectorFile(VOID)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
CHAR SectionName[100]; CHAR SectionName[100];
CHAR BootDriveString[20]; CHAR BootDriveString[20];
CHAR BootPartitionString[20]; CHAR BootPartitionString[20];
CHAR BootSectorFileString[200]; CHAR BootSectorFileString[200];
TIMEINFO* TimeInfo; TIMEINFO* TimeInfo;
OperatingSystemItem OperatingSystem; OperatingSystemItem OperatingSystem;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -202,53 +187,37 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
RtlZeroMemory(BootSectorFileString, sizeof(BootSectorFileString)); RtlZeroMemory(BootSectorFileString, sizeof(BootSectorFileString));
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
{
return; return;
}
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
{
return; return;
}
if (!UiEditBox(BootSectorFilePrompt, BootSectorFileString, 200)) if (!UiEditBox(BootSectorFilePrompt, BootSectorFileString, 200))
{
return; return;
}
// Generate a unique section name /* Generate a unique section name */
TimeInfo = ArcGetTime(); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomBootSectorFile%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); sprintf(SectionName, "CustomBootSectorFile%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section /* Add the section */
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
{
return; return;
}
// Add the BootType /* Add the BootType */
if (!IniAddSettingValueToSection(SectionId, "BootType", "BootSector")) if (!IniAddSettingValueToSection(SectionId, "BootType", "BootSector"))
{
return; return;
}
// Add the BootDrive /* Add the BootDrive */
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString)) if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
{
return; return;
}
// Add the BootPartition /* Add the BootPartition */
if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString)) if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
{
return; return;
}
// Add the BootSectorFile /* Add the BootSectorFile */
if (!IniAddSettingValueToSection(SectionId, "BootSectorFile", BootSectorFileString)) if (!IniAddSettingValueToSection(SectionId, "BootSectorFile", BootSectorFileString))
{
return; return;
}
UiMessageBox(CustomBootPrompt); UiMessageBox(CustomBootPrompt);
@ -262,15 +231,15 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
VOID OptionMenuCustomBootReactOS(VOID) VOID OptionMenuCustomBootReactOS(VOID)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
CHAR SectionName[100]; CHAR SectionName[100];
CHAR BootDriveString[20]; CHAR BootDriveString[20];
CHAR BootPartitionString[20]; CHAR BootPartitionString[20];
CHAR ReactOSSystemPath[200]; CHAR ReactOSSystemPath[200];
CHAR ReactOSARCPath[200]; CHAR ReactOSARCPath[200];
CHAR ReactOSOptions[200]; CHAR ReactOSOptions[200];
TIMEINFO* TimeInfo; TIMEINFO* TimeInfo;
OperatingSystemItem OperatingSystem; OperatingSystemItem OperatingSystem;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -279,55 +248,39 @@ VOID OptionMenuCustomBootReactOS(VOID)
RtlZeroMemory(ReactOSOptions, sizeof(ReactOSOptions)); RtlZeroMemory(ReactOSOptions, sizeof(ReactOSOptions));
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
{
return; return;
}
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
{
return; return;
}
if (!UiEditBox(ReactOSSystemPathPrompt, ReactOSSystemPath, 200)) if (!UiEditBox(ReactOSSystemPathPrompt, ReactOSSystemPath, 200))
{
return; return;
}
if (!UiEditBox(ReactOSOptionsPrompt, ReactOSOptions, 200)) if (!UiEditBox(ReactOSOptionsPrompt, ReactOSOptions, 200))
{
return; return;
}
// Generate a unique section name /* Generate a unique section name */
TimeInfo = ArcGetTime(); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomReactOS%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); sprintf(SectionName, "CustomReactOS%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section /* Add the section */
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
{
return; return;
}
// Add the BootType /* Add the BootType */
if (!IniAddSettingValueToSection(SectionId, "BootType", "Windows2003")) if (!IniAddSettingValueToSection(SectionId, "BootType", "Windows2003"))
{
return; return;
}
// Construct the ReactOS ARC system path /* Construct the ReactOS ARC system path */
ConstructArcPath(ReactOSARCPath, ReactOSSystemPath, DriveMapGetBiosDriveNumber(BootDriveString), atoi(BootPartitionString)); ConstructArcPath(ReactOSARCPath, ReactOSSystemPath, DriveMapGetBiosDriveNumber(BootDriveString), atoi(BootPartitionString));
// Add the system path /* Add the system path */
if (!IniAddSettingValueToSection(SectionId, "SystemPath", ReactOSARCPath)) if (!IniAddSettingValueToSection(SectionId, "SystemPath", ReactOSARCPath))
{
return; return;
}
// Add the CommandLine /* Add the CommandLine */
if (!IniAddSettingValueToSection(SectionId, "Options", ReactOSOptions)) if (!IniAddSettingValueToSection(SectionId, "Options", ReactOSOptions))
{
return; return;
}
UiMessageBox(CustomBootPrompt); UiMessageBox(CustomBootPrompt);
@ -341,15 +294,15 @@ VOID OptionMenuCustomBootReactOS(VOID)
VOID OptionMenuCustomBootLinux(VOID) VOID OptionMenuCustomBootLinux(VOID)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
CHAR SectionName[100]; CHAR SectionName[100];
CHAR BootDriveString[20]; CHAR BootDriveString[20];
CHAR BootPartitionString[20]; CHAR BootPartitionString[20];
CHAR LinuxKernelString[200]; CHAR LinuxKernelString[200];
CHAR LinuxInitrdString[200]; CHAR LinuxInitrdString[200];
CHAR LinuxCommandLineString[200]; CHAR LinuxCommandLineString[200];
TIMEINFO* TimeInfo; TIMEINFO* TimeInfo;
OperatingSystemItem OperatingSystem; OperatingSystemItem OperatingSystem;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -359,78 +312,54 @@ VOID OptionMenuCustomBootLinux(VOID)
RtlZeroMemory(LinuxCommandLineString, sizeof(LinuxCommandLineString)); RtlZeroMemory(LinuxCommandLineString, sizeof(LinuxCommandLineString));
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
{
return; return;
}
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
{
return; return;
}
if (!UiEditBox(LinuxKernelPrompt, LinuxKernelString, 200)) if (!UiEditBox(LinuxKernelPrompt, LinuxKernelString, 200))
{
return; return;
}
if (!UiEditBox(LinuxInitrdPrompt, LinuxInitrdString, 200)) if (!UiEditBox(LinuxInitrdPrompt, LinuxInitrdString, 200))
{
return; return;
}
if (!UiEditBox(LinuxCommandLinePrompt, LinuxCommandLineString, 200)) if (!UiEditBox(LinuxCommandLinePrompt, LinuxCommandLineString, 200))
{
return; return;
}
// Generate a unique section name /* Generate a unique section name */
TimeInfo = ArcGetTime(); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomLinux%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); sprintf(SectionName, "CustomLinux%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section /* Add the section */
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
{
return; return;
}
// Add the BootType /* Add the BootType */
if (!IniAddSettingValueToSection(SectionId, "BootType", "Linux")) if (!IniAddSettingValueToSection(SectionId, "BootType", "Linux"))
{
return; return;
}
// Add the BootDrive /* Add the BootDrive */
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString)) if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
{
return; return;
}
// Add the BootPartition /* Add the BootPartition */
if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString)) if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
{
return; return;
}
// Add the Kernel /* Add the Kernel */
if (!IniAddSettingValueToSection(SectionId, "Kernel", LinuxKernelString)) if (!IniAddSettingValueToSection(SectionId, "Kernel", LinuxKernelString))
{
return; return;
}
// Add the Initrd /* Add the Initrd */
if (strlen(LinuxInitrdString) > 0) if (strlen(LinuxInitrdString) > 0)
{ {
if (!IniAddSettingValueToSection(SectionId, "Initrd", LinuxInitrdString)) if (!IniAddSettingValueToSection(SectionId, "Initrd", LinuxInitrdString))
{
return; return;
}
} }
// Add the CommandLine /* Add the CommandLine */
if (!IniAddSettingValueToSection(SectionId, "CommandLine", LinuxCommandLineString)) if (!IniAddSettingValueToSection(SectionId, "CommandLine", LinuxCommandLineString))
{
return; return;
}
UiMessageBox(CustomBootPrompt); UiMessageBox(CustomBootPrompt);

View file

@ -23,12 +23,12 @@
#if DBG && !defined(_M_ARM) #if DBG && !defined(_M_ARM)
//#define DEBUG_ALL // #define DEBUG_ALL
//#define DEBUG_WARN // #define DEBUG_WARN
//#define DEBUG_ERR // #define DEBUG_ERR
//#define DEBUG_INIFILE // #define DEBUG_INIFILE
//#define DEBUG_REACTOS // #define DEBUG_REACTOS
//#define DEBUG_CUSTOM // #define DEBUG_CUSTOM
#define DEBUG_NONE #define DEBUG_NONE
#define DBG_DEFAULT_LEVELS (ERR_LEVEL|FIXME_LEVEL) #define DBG_DEFAULT_LEVELS (ERR_LEVEL|FIXME_LEVEL)
@ -44,23 +44,22 @@
#define BOCHS_OUTPUT_PORT 0xe9 #define BOCHS_OUTPUT_PORT 0xe9
static UCHAR DbgChannels[DBG_CHANNELS_COUNT]; static UCHAR DbgChannels[DBG_CHANNELS_COUNT];
ULONG DebugPort = RS232; ULONG DebugPort = RS232;
//ULONG DebugPort = SCREEN; // ULONG DebugPort = SCREEN;
//ULONG DebugPort = BOCHS; // ULONG DebugPort = BOCHS;
//ULONG DebugPort = SCREEN|BOCHS; // ULONG DebugPort = SCREEN|BOCHS;
#ifdef _WINKD_ #ifdef _WINKD_
/* COM1 is the WinDbg port */ /* COM1 is the WinDbg port */
ULONG ComPort = COM2; ULONG ComPort = COM2;
#else #else
ULONG ComPort = COM1; ULONG ComPort = COM1;
#endif #endif
//ULONG BaudRate = 19200; // ULONG BaudRate = 19200;
ULONG BaudRate = 115200; ULONG BaudRate = 115200;
BOOLEAN DebugStartOfLine = TRUE; BOOLEAN DebugStartOfLine = TRUE;
VOID DebugInit(VOID) VOID DebugInit(VOID)
{ {
@ -93,16 +92,13 @@ VOID DebugInit(VOID)
VOID DebugPrintChar(UCHAR Character) VOID DebugPrintChar(UCHAR Character)
{ {
if (Character == '\n') if (Character == '\n')
{
DebugStartOfLine = TRUE; DebugStartOfLine = TRUE;
}
if (DebugPort & RS232) if (DebugPort & RS232)
{ {
if (Character == '\n') if (Character == '\n')
{
Rs232PortPutByte('\r'); Rs232PortPutByte('\r');
}
Rs232PortPutByte(Character); Rs232PortPutByte(Character);
} }
if (DebugPort & BOCHS) if (DebugPort & BOCHS)
@ -152,13 +148,13 @@ DbgPrint2(ULONG Mask, ULONG Level, const char *File, ULONG Line, char *Format, .
char Buffer[2096]; char Buffer[2096];
char *ptr = Buffer; char *ptr = Buffer;
// Mask out unwanted debug messages /* Mask out unwanted debug messages */
if (!(DbgChannels[Mask] & Level) && !(Level & DBG_DEFAULT_LEVELS )) if (!(DbgChannels[Mask] & Level) && !(Level & DBG_DEFAULT_LEVELS ))
{ {
return; return;
} }
// Print the header if we have started a new line /* Print the header if we have started a new line */
if (DebugStartOfLine) if (DebugStartOfLine)
{ {
DbgPrint("(%s:%lu) ", File, Line); DbgPrint("(%s:%lu) ", File, Line);
@ -199,11 +195,9 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
ULONG Idx; ULONG Idx;
ULONG Idx2; ULONG Idx2;
// Mask out unwanted debug messages /* Mask out unwanted debug messages */
if (!(DbgChannels[Mask] & TRACE_LEVEL)) if (!(DbgChannels[Mask] & TRACE_LEVEL))
{
return; return;
}
DebugStartOfLine = FALSE; // We don't want line headers DebugStartOfLine = FALSE; // We don't want line headers
DbgPrint("Dumping buffer at %p with length of %lu bytes:\n", Buffer, Length); DbgPrint("Dumping buffer at %p with length of %lu bytes:\n", Buffer, Length);
@ -213,21 +207,13 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
DebugStartOfLine = FALSE; // We don't want line headers DebugStartOfLine = FALSE; // We don't want line headers
if (Idx < 0x0010) if (Idx < 0x0010)
{
DbgPrint("000%x:\t", Idx); DbgPrint("000%x:\t", Idx);
}
else if (Idx < 0x0100) else if (Idx < 0x0100)
{
DbgPrint("00%x:\t", Idx); DbgPrint("00%x:\t", Idx);
}
else if (Idx < 0x1000) else if (Idx < 0x1000)
{
DbgPrint("0%x:\t", Idx); DbgPrint("0%x:\t", Idx);
}
else else
{
DbgPrint("%x:\t", Idx); DbgPrint("%x:\t", Idx);
}
for (Idx2=0; Idx2<16; Idx2++,Idx++) for (Idx2=0; Idx2<16; Idx2++,Idx++)
{ {
@ -267,40 +253,40 @@ DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
} }
static BOOLEAN static BOOLEAN
DbgAddDebugChannel( CHAR* channel, CHAR* level, CHAR op) DbgAddDebugChannel(CHAR* channel, CHAR* level, CHAR op)
{ {
int iLevel, iChannel; int iLevel, iChannel;
if(channel == NULL || *channel == L'\0' ||strlen(channel) == 0 ) if (channel == NULL || *channel == L'\0' || strlen(channel) == 0 )
return FALSE; return FALSE;
if(level == NULL || *level == L'\0' ||strlen(level) == 0 ) if (level == NULL || *level == L'\0' || strlen(level) == 0 )
iLevel = MAX_LEVEL; iLevel = MAX_LEVEL;
else if(strcmp(level, "err") == 0) else if (strcmp(level, "err") == 0)
iLevel = ERR_LEVEL; iLevel = ERR_LEVEL;
else if(strcmp(level, "fixme") == 0) else if (strcmp(level, "fixme") == 0)
iLevel = FIXME_LEVEL; iLevel = FIXME_LEVEL;
else if(strcmp(level, "warn") == 0) else if (strcmp(level, "warn") == 0)
iLevel = WARN_LEVEL; iLevel = WARN_LEVEL;
else if (strcmp(level, "trace") == 0) else if (strcmp(level, "trace") == 0)
iLevel = TRACE_LEVEL; iLevel = TRACE_LEVEL;
else else
return FALSE; return FALSE;
if(strcmp(channel, "memory") == 0) iChannel = DPRINT_MEMORY; if (strcmp(channel, "memory" ) == 0) iChannel = DPRINT_MEMORY;
else if(strcmp(channel, "filesystem") == 0) iChannel = DPRINT_FILESYSTEM; else if (strcmp(channel, "filesystem") == 0) iChannel = DPRINT_FILESYSTEM;
else if(strcmp(channel, "inifile") == 0) iChannel = DPRINT_INIFILE; else if (strcmp(channel, "inifile" ) == 0) iChannel = DPRINT_INIFILE;
else if(strcmp(channel, "ui") == 0) iChannel = DPRINT_UI; else if (strcmp(channel, "ui" ) == 0) iChannel = DPRINT_UI;
else if(strcmp(channel, "disk") == 0) iChannel = DPRINT_DISK; else if (strcmp(channel, "disk" ) == 0) iChannel = DPRINT_DISK;
else if(strcmp(channel, "cache") == 0) iChannel = DPRINT_CACHE; else if (strcmp(channel, "cache" ) == 0) iChannel = DPRINT_CACHE;
else if(strcmp(channel, "registry") == 0) iChannel = DPRINT_REGISTRY; else if (strcmp(channel, "registry" ) == 0) iChannel = DPRINT_REGISTRY;
else if(strcmp(channel, "linux") == 0) iChannel = DPRINT_LINUX; else if (strcmp(channel, "linux" ) == 0) iChannel = DPRINT_LINUX;
else if(strcmp(channel, "hwdetect") == 0) iChannel = DPRINT_HWDETECT; else if (strcmp(channel, "hwdetect" ) == 0) iChannel = DPRINT_HWDETECT;
else if(strcmp(channel, "windows") == 0) iChannel = DPRINT_WINDOWS; else if (strcmp(channel, "windows" ) == 0) iChannel = DPRINT_WINDOWS;
else if(strcmp(channel, "peloader") == 0) iChannel = DPRINT_PELOADER; else if (strcmp(channel, "peloader" ) == 0) iChannel = DPRINT_PELOADER;
else if(strcmp(channel, "scsiport") == 0) iChannel = DPRINT_SCSIPORT; else if (strcmp(channel, "scsiport" ) == 0) iChannel = DPRINT_SCSIPORT;
else if(strcmp(channel, "heap") == 0) iChannel = DPRINT_HEAP; else if (strcmp(channel, "heap" ) == 0) iChannel = DPRINT_HEAP;
else if(strcmp(channel, "all") == 0) else if (strcmp(channel, "all" ) == 0)
{ {
int i; int i;
@ -316,7 +302,7 @@ DbgAddDebugChannel( CHAR* channel, CHAR* level, CHAR op)
} }
else return FALSE; else return FALSE;
if(op==L'+') if (op == L'+')
DbgChannels[iChannel] |= iLevel; DbgChannels[iChannel] |= iLevel;
else else
DbgChannels[iChannel] &= ~iLevel; DbgChannels[iChannel] &= ~iLevel;
@ -333,25 +319,25 @@ DbgParseDebugChannels(PCHAR Value)
do do
{ {
separator = strchr(str, L','); separator = strchr(str, ',');
if(separator != NULL) if (separator != NULL)
*separator = L'\0'; *separator = '\0';
c = strchr(str, L'+'); c = strchr(str, '+');
if(c == NULL) if (c == NULL)
c = strchr(str, L'-'); c = strchr(str, '-');
if(c != NULL) if (c != NULL)
{ {
op = *c; op = *c;
*c = L'\0'; *c = '\0';
c++; c++;
DbgAddDebugChannel(c, str, op); DbgAddDebugChannel(c, str, op);
} }
str = separator + 1; str = separator + 1;
} while(separator != NULL); } while (separator != NULL);
} }
#else #else
@ -394,7 +380,7 @@ MsgBoxPrint(const char *Format, ...)
return 0; return 0;
} }
//DECLSPEC_NORETURN // DECLSPEC_NORETURN
VOID VOID
NTAPI NTAPI
KeBugCheckEx( KeBugCheckEx(
@ -406,8 +392,8 @@ KeBugCheckEx(
{ {
char Buffer[70]; char Buffer[70];
sprintf(Buffer, "*** STOP: 0x%08lX (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)", sprintf(Buffer, "*** STOP: 0x%08lX (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)",
BugCheckCode, BugCheckParameter1, BugCheckParameter2, BugCheckCode, BugCheckParameter1, BugCheckParameter2,
BugCheckParameter3, BugCheckParameter4); BugCheckParameter3, BugCheckParameter4);
UiMessageBoxCritical(Buffer); UiMessageBoxCritical(Buffer);
assert(FALSE); assert(FALSE);
for (;;); for (;;);
@ -420,23 +406,23 @@ RtlAssert(IN PVOID FailedAssertion,
IN ULONG LineNumber, IN ULONG LineNumber,
IN PCHAR Message OPTIONAL) IN PCHAR Message OPTIONAL)
{ {
if (Message) if (Message)
{ {
DbgPrint("Assertion \'%s\' failed at %s line %u: %s\n", DbgPrint("Assertion \'%s\' failed at %s line %u: %s\n",
(PCHAR)FailedAssertion, (PCHAR)FailedAssertion,
(PCHAR)FileName, (PCHAR)FileName,
LineNumber, LineNumber,
Message); Message);
} }
else else
{ {
DbgPrint("Assertion \'%s\' failed at %s line %u\n", DbgPrint("Assertion \'%s\' failed at %s line %u\n",
(PCHAR)FailedAssertion, (PCHAR)FailedAssertion,
(PCHAR)FileName, (PCHAR)FileName,
LineNumber); LineNumber);
} }
DbgBreakPoint(); DbgBreakPoint();
} }
char *BugCodeStrings[] = char *BugCodeStrings[] =
@ -448,4 +434,3 @@ char *BugCodeStrings[] =
}; };
ULONG_PTR BugCheckInfo[5]; ULONG_PTR BugCheckInfo[5];

View file

@ -17,20 +17,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* INCLUDES *******************************************************************/
#include <freeldr.h> #include <freeldr.h>
#include <debug.h> #include <debug.h>
DBG_DEFAULT_CHANNEL(WARNING); DBG_DEFAULT_CHANNEL(WARNING);
VOID NTAPI HalpInitializePciStubs(VOID); /* FUNCTIONS ******************************************************************/
VOID NTAPI HalpInitBusHandler(VOID);
VOID BootMain(LPSTR CmdLine) VOID BootMain(LPSTR CmdLine)
{ {
CmdLineParse(CmdLine); CmdLineParse(CmdLine);
MachInit(CmdLine); MachInit(CmdLine);
FsInit(); FsInit();
DebugInit(); DebugInit();
@ -43,22 +42,23 @@ VOID BootMain(LPSTR CmdLine)
if (!UiInitialize(FALSE)) if (!UiInitialize(FALSE))
{ {
UiMessageBoxCritical("Unable to initialize UI.\n"); UiMessageBoxCritical("Unable to initialize UI.\n");
goto quit; goto Quit;
} }
if (!MmInitializeMemoryManager()) if (!MmInitializeMemoryManager())
{ {
UiMessageBoxCritical("Unable to initialize memory manager"); UiMessageBoxCritical("Unable to initialize memory manager");
goto quit; goto Quit;
} }
#ifdef _M_IX86 #ifdef _M_IX86
HalpInitializePciStubs(); HalpInitializePciStubs();
HalpInitBusHandler(); HalpInitBusHandler();
#endif #endif
RunLoader(); RunLoader();
quit: Quit:
/* If we reach this point, something went wrong before, therefore reboot */ /* If we reach this point, something went wrong before, therefore reboot */
DiskStopFloppyMotor(); DiskStopFloppyMotor();
Reboot(); Reboot();
@ -73,7 +73,7 @@ int __cdecl wctomb(char *mbchar, wchar_t wchar)
return 1; return 1;
} }
int __cdecl mbtowc (wchar_t *wchar, const char *mbchar, size_t count) int __cdecl mbtowc(wchar_t *wchar, const char *mbchar, size_t count)
{ {
*wchar = (wchar_t)*mbchar; *wchar = (wchar_t)*mbchar;
return 1; return 1;

View file

@ -19,12 +19,6 @@
#pragma once #pragma once
typedef struct tagCMDLINEINFO
{
const char *DefaultOperatingSystem;
LONG TimeOut;
} CMDLINEINFO, *PCMDLINEINFO;
VOID CmdLineParse(IN PCHAR CmdLine); VOID CmdLineParse(IN PCHAR CmdLine);
PCCH CmdLineGetDefaultOS(VOID); PCCH CmdLineGetDefaultOS(VOID);

View file

@ -20,16 +20,16 @@
#ifndef __DEBUG_H #ifndef __DEBUG_H
#define __DEBUG_H #define __DEBUG_H
#define DPRINT_NONE 0 // No debug print #define DPRINT_NONE 0 // No debug print
#define DPRINT_WARNING 1 // debugger messages and other misc stuff #define DPRINT_WARNING 1 // debugger messages and other misc stuff
#define DPRINT_MEMORY 2 // memory management messages #define DPRINT_MEMORY 2 // memory management messages
#define DPRINT_FILESYSTEM 3 // file system messages #define DPRINT_FILESYSTEM 3 // file system messages
#define DPRINT_INIFILE 4 // .ini file messages #define DPRINT_INIFILE 4 // .ini file messages
#define DPRINT_UI 5 // user interface messages #define DPRINT_UI 5 // user interface messages
#define DPRINT_DISK 6 // disk messages #define DPRINT_DISK 6 // disk messages
#define DPRINT_CACHE 7 // cache messages #define DPRINT_CACHE 7 // cache messages
#define DPRINT_REGISTRY 8 // registry messages #define DPRINT_REGISTRY 8 // registry messages
#define DPRINT_REACTOS 9 // ReactOS messages #define DPRINT_REACTOS 9 // ReactOS messages
#define DPRINT_LINUX 10 // Linux messages #define DPRINT_LINUX 10 // Linux messages
#define DPRINT_HWDETECT 11 // hardware detection messages #define DPRINT_HWDETECT 11 // hardware detection messages
#define DPRINT_WINDOWS 12 // messages from Windows loader #define DPRINT_WINDOWS 12 // messages from Windows loader

View file

@ -29,7 +29,7 @@
#define ROUND_UP(n, align) \ #define ROUND_UP(n, align) \
ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
/* public headers */ /* Public headers */
#ifdef __REACTOS__ #ifdef __REACTOS__
#define NTOSAPI #define NTOSAPI
#define printf TuiPrintf #define printf TuiPrintf
@ -54,7 +54,7 @@
#include <ntsup.h> #include <ntsup.h>
#endif #endif
/* internal headers */ /* Internal headers */
// #include <arcemul.h> // #include <arcemul.h>
#include <bytesex.h> #include <bytesex.h>
#include <cache.h> #include <cache.h>
@ -62,6 +62,7 @@
#include <comm.h> #include <comm.h>
#include <disk.h> #include <disk.h>
#include <fs.h> #include <fs.h>
#include <hal.h>
#include <inffile.h> #include <inffile.h>
#include <inifile.h> #include <inifile.h>
#include <keycodes.h> #include <keycodes.h>
@ -81,20 +82,20 @@
#include <video.h> #include <video.h>
#include <winldr.h> #include <winldr.h>
/* file system headers */ /* File system headers */
#include <fs/ext2.h> #include <fs/ext2.h>
#include <fs/fat.h> #include <fs/fat.h>
#include <fs/ntfs.h> #include <fs/ntfs.h>
#include <fs/iso.h> #include <fs/iso.h>
#include <fs/pxe.h> #include <fs/pxe.h>
/* ui support */ /* UI support */
#include <ui/gui.h> #include <ui/gui.h>
#include <ui/minitui.h> #include <ui/minitui.h>
#include <ui/noui.h> #include <ui/noui.h>
#include <ui/tui.h> #include <ui/tui.h>
/* arch specific includes */ /* Arch specific includes */
#if defined(_M_IX86) || defined(_M_AMD64) #if defined(_M_IX86) || defined(_M_AMD64)
#include <arch/pc/hardware.h> #include <arch/pc/hardware.h>
#include <arch/pc/pcbios.h> #include <arch/pc/pcbios.h>

View file

@ -0,0 +1,9 @@
#pragma once
#ifdef _M_IX86
VOID NTAPI HalpInitializePciStubs(VOID);
VOID NTAPI HalpInitBusHandler(VOID);
#endif

View file

@ -19,55 +19,55 @@
#ifndef _M_ARM #ifndef _M_ARM
#ifdef _M_IX86
/* INCLUDES *******************************************************************/
#include <freeldr.h> #include <freeldr.h>
#include <debug.h> #include <debug.h>
#ifdef _M_IX86
#define LINUX_READ_CHUNK_SIZE 0x20000 // Read 128k at a time
DBG_DEFAULT_CHANNEL(LINUX); DBG_DEFAULT_CHANNEL(LINUX);
PLINUX_BOOTSECTOR LinuxBootSector = NULL; /* GLOBALS ********************************************************************/
PLINUX_SETUPSECTOR LinuxSetupSector = NULL;
ULONG SetupSectorSize = 0; #define LINUX_READ_CHUNK_SIZE 0x20000 // Read 128k at a time
BOOLEAN NewStyleLinuxKernel = FALSE;
ULONG LinuxKernelSize = 0; PLINUX_BOOTSECTOR LinuxBootSector = NULL;
ULONG LinuxInitrdSize = 0; PLINUX_SETUPSECTOR LinuxSetupSector = NULL;
CHAR LinuxKernelName[260]; ULONG SetupSectorSize = 0;
CHAR LinuxInitrdName[260]; BOOLEAN NewStyleLinuxKernel = FALSE;
BOOLEAN LinuxHasInitrd = FALSE; ULONG LinuxKernelSize = 0;
CHAR LinuxCommandLine[260] = ""; ULONG LinuxInitrdSize = 0;
ULONG LinuxCommandLineSize = 0; CHAR LinuxKernelName[260];
PVOID LinuxKernelLoadAddress = NULL; CHAR LinuxInitrdName[260];
PVOID LinuxInitrdLoadAddress = NULL; BOOLEAN LinuxHasInitrd = FALSE;
CHAR LinuxBootDescription[80]; CHAR LinuxCommandLine[260] = "";
CHAR LinuxBootPath[260] = ""; ULONG LinuxCommandLineSize = 0;
PVOID LinuxKernelLoadAddress = NULL;
PVOID LinuxInitrdLoadAddress = NULL;
CHAR LinuxBootDescription[80];
CHAR LinuxBootPath[260] = "";
/* FUNCTIONS ******************************************************************/
BOOLEAN RemoveQuotes(PCHAR QuotedString) BOOLEAN RemoveQuotes(PCHAR QuotedString)
{ {
CHAR TempString[200]; CHAR TempString[200];
PCHAR p; PCHAR p;
PSTR Start; PSTR Start;
// /* Skip spaces up to " */
// Skip spaces up to "
//
p = QuotedString; p = QuotedString;
while (*p == ' ' || *p == '"') while (*p == ' ' || *p == '"')
p++; p++;
Start = p; Start = p;
// /* Go up to next " */
// Go up to next "
//
while (*p != '"' && *p != ANSI_NULL) while (*p != '"' && *p != ANSI_NULL)
p++; p++;
*p = ANSI_NULL; *p = ANSI_NULL;
// /* Copy result */
// Copy result
//
strcpy(TempString, Start); strcpy(TempString, Start);
strcpy(QuotedString, TempString); strcpy(QuotedString, TempString);
@ -78,33 +78,27 @@ VOID
LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem, LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem,
IN USHORT OperatingSystemVersion) IN USHORT OperatingSystemVersion)
{ {
PCSTR SectionName = OperatingSystem->SystemPartition; PCSTR SectionName = OperatingSystem->SystemPartition;
PCSTR Description = OperatingSystem->LoadIdentifier; PCSTR Description = OperatingSystem->LoadIdentifier;
PFILE LinuxKernel = 0; PFILE LinuxKernel = 0;
PFILE LinuxInitrdFile = 0; PFILE LinuxInitrdFile = 0;
CHAR TempString[260]; CHAR TempString[260];
UiDrawBackdrop(); UiDrawBackdrop();
if (Description) if (Description)
{
sprintf(LinuxBootDescription, "Loading %s...", Description); sprintf(LinuxBootDescription, "Loading %s...", Description);
}
else else
{
strcpy(LinuxBootDescription, "Loading Linux..."); strcpy(LinuxBootDescription, "Loading Linux...");
}
UiDrawStatusText(LinuxBootDescription); UiDrawStatusText(LinuxBootDescription);
UiDrawProgressBarCenter(0, 100, LinuxBootDescription); UiDrawProgressBarCenter(0, 100, LinuxBootDescription);
// Parse the .ini file section /* Parse the .ini file section */
if (!LinuxParseIniSection(SectionName)) if (!LinuxParseIniSection(SectionName))
{
goto LinuxBootFailed; goto LinuxBootFailed;
}
// Open the kernel /* Open the kernel */
LinuxKernel = FsOpenFile(LinuxKernelName); LinuxKernel = FsOpenFile(LinuxKernelName);
if (!LinuxKernel) if (!LinuxKernel)
{ {
@ -113,7 +107,7 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem,
goto LinuxBootFailed; goto LinuxBootFailed;
} }
// Open the initrd file image (if necessary) /* Open the initrd file image (if necessary) */
if (LinuxHasInitrd) if (LinuxHasInitrd)
{ {
LinuxInitrdFile = FsOpenFile(LinuxInitrdName); LinuxInitrdFile = FsOpenFile(LinuxInitrdName);
@ -125,44 +119,34 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem,
} }
} }
// Read the boot sector /* Read the boot sector */
if (!LinuxReadBootSector(LinuxKernel)) if (!LinuxReadBootSector(LinuxKernel))
{
goto LinuxBootFailed; goto LinuxBootFailed;
}
// Read the setup sector /* Read the setup sector */
if (!LinuxReadSetupSector(LinuxKernel)) if (!LinuxReadSetupSector(LinuxKernel))
{
goto LinuxBootFailed; goto LinuxBootFailed;
}
// Calc kernel size /* Calc kernel size */
LinuxKernelSize = FsGetFileSize(LinuxKernel) - (512 + SetupSectorSize); LinuxKernelSize = FsGetFileSize(LinuxKernel) - (512 + SetupSectorSize);
// Get the file size /* Get the file size */
LinuxInitrdSize = FsGetFileSize(LinuxInitrdFile); LinuxInitrdSize = FsGetFileSize(LinuxInitrdFile);
// Read the kernel /* Read the kernel */
if (!LinuxReadKernel(LinuxKernel)) if (!LinuxReadKernel(LinuxKernel))
{
goto LinuxBootFailed; goto LinuxBootFailed;
}
// Read the initrd (if necessary) /* Read the initrd (if necessary) */
if (LinuxHasInitrd) if (LinuxHasInitrd)
{ {
if (!LinuxReadInitrd(LinuxInitrdFile)) if (!LinuxReadInitrd(LinuxInitrdFile))
{
goto LinuxBootFailed; goto LinuxBootFailed;
}
} }
// If the default root device is set to FLOPPY (0000h), change to /dev/fd0 (0200h) // If the default root device is set to FLOPPY (0000h), change to /dev/fd0 (0200h)
if (LinuxBootSector->RootDevice == 0x0000) if (LinuxBootSector->RootDevice == 0x0000)
{
LinuxBootSector->RootDevice = 0x0200; LinuxBootSector->RootDevice = 0x0200;
}
if (LinuxSetupSector->Version >= 0x0202) if (LinuxSetupSector->Version >= 0x0202)
{ {
@ -175,13 +159,9 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem,
} }
if (NewStyleLinuxKernel) if (NewStyleLinuxKernel)
{
LinuxSetupSector->TypeOfLoader = LINUX_LOADER_TYPE_FREELOADER; LinuxSetupSector->TypeOfLoader = LINUX_LOADER_TYPE_FREELOADER;
}
else else
{
LinuxSetupSector->LoadFlags = 0; LinuxSetupSector->LoadFlags = 0;
}
RtlCopyMemory((PVOID)0x90000, LinuxBootSector, 512); RtlCopyMemory((PVOID)0x90000, LinuxBootSector, 512);
RtlCopyMemory((PVOID)0x90200, LinuxSetupSector, SetupSectorSize); RtlCopyMemory((PVOID)0x90200, LinuxSetupSector, SetupSectorSize);
@ -192,42 +172,30 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem,
DiskStopFloppyMotor(); DiskStopFloppyMotor();
if (LinuxSetupSector->LoadFlags & LINUX_FLAG_LOAD_HIGH) if (LinuxSetupSector->LoadFlags & LINUX_FLAG_LOAD_HIGH)
{
BootNewLinuxKernel(); BootNewLinuxKernel();
}
else else
{
BootOldLinuxKernel(LinuxKernelSize); BootOldLinuxKernel(LinuxKernelSize);
}
LinuxBootFailed: LinuxBootFailed:
if (LinuxKernel) if (LinuxKernel)
{
FsCloseFile(LinuxKernel); FsCloseFile(LinuxKernel);
}
if (LinuxInitrdFile) if (LinuxInitrdFile)
{
FsCloseFile(LinuxInitrdFile); FsCloseFile(LinuxInitrdFile);
}
if (LinuxBootSector != NULL) if (LinuxBootSector != NULL)
{
MmFreeMemory(LinuxBootSector); MmFreeMemory(LinuxBootSector);
}
if (LinuxSetupSector != NULL) if (LinuxSetupSector != NULL)
{
MmFreeMemory(LinuxSetupSector); MmFreeMemory(LinuxSetupSector);
}
if (LinuxKernelLoadAddress != NULL) if (LinuxKernelLoadAddress != NULL)
{
MmFreeMemory(LinuxKernelLoadAddress); MmFreeMemory(LinuxKernelLoadAddress);
}
if (LinuxInitrdLoadAddress != NULL) if (LinuxInitrdLoadAddress != NULL)
{
MmFreeMemory(LinuxInitrdLoadAddress); MmFreeMemory(LinuxInitrdLoadAddress);
}
LinuxBootSector = NULL; LinuxBootSector = NULL;
LinuxSetupSector = NULL; LinuxSetupSector = NULL;
@ -243,13 +211,13 @@ LinuxBootFailed:
BOOLEAN LinuxParseIniSection(PCSTR SectionName) BOOLEAN LinuxParseIniSection(PCSTR SectionName)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
CHAR SettingName[260]; CHAR SettingName[260];
// Find all the message box settings and run them /* Find all the message box settings and run them */
UiShowMessageBoxesInSection(SectionName); UiShowMessageBoxesInSection(SectionName);
// Try to open the operating system section in the .ini file /* Try to open the operating system section in the .ini file */
if (!IniOpenSection(SectionName, &SectionId)) if (!IniOpenSection(SectionName, &SectionId))
{ {
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName);
@ -263,20 +231,20 @@ BOOLEAN LinuxParseIniSection(PCSTR SectionName)
return FALSE; return FALSE;
} }
// Get the kernel name /* Get the kernel name */
if (!IniReadSettingByName(SectionId, "Kernel", LinuxKernelName, sizeof(LinuxKernelName))) if (!IniReadSettingByName(SectionId, "Kernel", LinuxKernelName, sizeof(LinuxKernelName)))
{ {
UiMessageBox("Linux kernel filename not specified for selected OS!"); UiMessageBox("Linux kernel filename not specified for selected OS!");
return FALSE; return FALSE;
} }
// Get the initrd name /* Get the initrd name */
if (IniReadSettingByName(SectionId, "Initrd", LinuxInitrdName, sizeof(LinuxInitrdName))) if (IniReadSettingByName(SectionId, "Initrd", LinuxInitrdName, sizeof(LinuxInitrdName)))
{ {
LinuxHasInitrd = TRUE; LinuxHasInitrd = TRUE;
} }
// Get the command line /* Get the command line */
if (IniReadSettingByName(SectionId, "CommandLine", LinuxCommandLine, sizeof(LinuxCommandLine))) if (IniReadSettingByName(SectionId, "CommandLine", LinuxCommandLine, sizeof(LinuxCommandLine)))
{ {
RemoveQuotes(LinuxCommandLine); RemoveQuotes(LinuxCommandLine);
@ -288,21 +256,17 @@ BOOLEAN LinuxParseIniSection(PCSTR SectionName)
BOOLEAN LinuxReadBootSector(PFILE LinuxKernelFile) BOOLEAN LinuxReadBootSector(PFILE LinuxKernelFile)
{ {
// Allocate memory for boot sector /* Allocate memory for boot sector */
LinuxBootSector = MmAllocateMemoryWithType(512, LoaderSystemCode); LinuxBootSector = MmAllocateMemoryWithType(512, LoaderSystemCode);
if (LinuxBootSector == NULL) if (LinuxBootSector == NULL)
{
return FALSE; return FALSE;
}
// Read linux boot sector /* Read linux boot sector */
FsSetFilePointer(LinuxKernelFile, 0); FsSetFilePointer(LinuxKernelFile, 0);
if (!FsReadFile(LinuxKernelFile, 512, NULL, LinuxBootSector)) if (!FsReadFile(LinuxKernelFile, 512, NULL, LinuxBootSector))
{
return FALSE; return FALSE;
}
// Check for validity /* Check for validity */
if (LinuxBootSector->BootFlag != LINUX_BOOT_SECTOR_MAGIC) if (LinuxBootSector->BootFlag != LINUX_BOOT_SECTOR_MAGIC)
{ {
UiMessageBox("Invalid boot sector magic (0xaa55)"); UiMessageBox("Invalid boot sector magic (0xaa55)");
@ -325,48 +289,36 @@ BOOLEAN LinuxReadBootSector(PFILE LinuxKernelFile)
BOOLEAN LinuxReadSetupSector(PFILE LinuxKernelFile) BOOLEAN LinuxReadSetupSector(PFILE LinuxKernelFile)
{ {
UCHAR TempLinuxSetupSector[512]; UCHAR TempLinuxSetupSector[512];
LinuxSetupSector = (PLINUX_SETUPSECTOR)TempLinuxSetupSector; LinuxSetupSector = (PLINUX_SETUPSECTOR)TempLinuxSetupSector;
// Read first linux setup sector /* Read first linux setup sector */
FsSetFilePointer(LinuxKernelFile, 512); FsSetFilePointer(LinuxKernelFile, 512);
if (!FsReadFile(LinuxKernelFile, 512, NULL, TempLinuxSetupSector)) if (!FsReadFile(LinuxKernelFile, 512, NULL, TempLinuxSetupSector))
{
return FALSE; return FALSE;
}
// Check the kernel version /* Check the kernel version */
if (!LinuxCheckKernelVersion()) if (!LinuxCheckKernelVersion())
{
return FALSE; return FALSE;
}
if (NewStyleLinuxKernel) if (NewStyleLinuxKernel)
{
SetupSectorSize = 512 * LinuxBootSector->SetupSectors; SetupSectorSize = 512 * LinuxBootSector->SetupSectors;
}
else else
{ SetupSectorSize = 512 * 4; // Always 4 setup sectors
SetupSectorSize = 4 * 512; // Always 4 setup sectors
}
// Allocate memory for setup sectors /* Allocate memory for setup sectors */
LinuxSetupSector = MmAllocateMemoryWithType(SetupSectorSize, LoaderSystemCode); LinuxSetupSector = MmAllocateMemoryWithType(SetupSectorSize, LoaderSystemCode);
if (LinuxSetupSector == NULL) if (LinuxSetupSector == NULL)
{
return FALSE; return FALSE;
}
// Copy over first setup sector /* Copy over first setup sector */
RtlCopyMemory(LinuxSetupSector, TempLinuxSetupSector, 512); RtlCopyMemory(LinuxSetupSector, TempLinuxSetupSector, 512);
// Read in the rest of the linux setup sectors /* Read in the rest of the linux setup sectors */
FsSetFilePointer(LinuxKernelFile, 1024); FsSetFilePointer(LinuxKernelFile, 1024);
if (!FsReadFile(LinuxKernelFile, SetupSectorSize - 512, NULL, (PVOID)((ULONG_PTR)LinuxSetupSector + 512))) if (!FsReadFile(LinuxKernelFile, SetupSectorSize - 512, NULL, (PVOID)((ULONG_PTR)LinuxSetupSector + 512)))
{
return FALSE; return FALSE;
}
// DbgDumpBuffer(DPRINT_LINUX, LinuxSetupSector, SetupSectorSize); // DbgDumpBuffer(DPRINT_LINUX, LinuxSetupSector, SetupSectorSize);
@ -391,14 +343,14 @@ BOOLEAN LinuxReadSetupSector(PFILE LinuxKernelFile)
BOOLEAN LinuxReadKernel(PFILE LinuxKernelFile) BOOLEAN LinuxReadKernel(PFILE LinuxKernelFile)
{ {
ULONG BytesLoaded; ULONG BytesLoaded;
CHAR StatusText[260]; CHAR StatusText[260];
PVOID LoadAddress; PVOID LoadAddress;
sprintf(StatusText, "Loading %s", LinuxKernelName); sprintf(StatusText, "Loading %s", LinuxKernelName);
UiDrawStatusText(StatusText); UiDrawStatusText(StatusText);
// Allocate memory for Linux kernel /* Allocate memory for Linux kernel */
LinuxKernelLoadAddress = MmAllocateMemoryAtAddress(LinuxKernelSize, (PVOID)LINUX_KERNEL_LOAD_ADDRESS, LoaderSystemCode); LinuxKernelLoadAddress = MmAllocateMemoryAtAddress(LinuxKernelSize, (PVOID)LINUX_KERNEL_LOAD_ADDRESS, LoaderSystemCode);
if (LinuxKernelLoadAddress != (PVOID)LINUX_KERNEL_LOAD_ADDRESS) if (LinuxKernelLoadAddress != (PVOID)LINUX_KERNEL_LOAD_ADDRESS)
{ {
@ -407,14 +359,12 @@ BOOLEAN LinuxReadKernel(PFILE LinuxKernelFile)
LoadAddress = LinuxKernelLoadAddress; LoadAddress = LinuxKernelLoadAddress;
// Read linux kernel to 0x100000 (1mb) /* Read linux kernel to 0x100000 (1mb) */
FsSetFilePointer(LinuxKernelFile, 512 + SetupSectorSize); FsSetFilePointer(LinuxKernelFile, 512 + SetupSectorSize);
for (BytesLoaded=0; BytesLoaded<LinuxKernelSize; ) for (BytesLoaded=0; BytesLoaded<LinuxKernelSize; )
{ {
if (!FsReadFile(LinuxKernelFile, LINUX_READ_CHUNK_SIZE, NULL, LoadAddress)) if (!FsReadFile(LinuxKernelFile, LINUX_READ_CHUNK_SIZE, NULL, LoadAddress))
{
return FALSE; return FALSE;
}
BytesLoaded += LINUX_READ_CHUNK_SIZE; BytesLoaded += LINUX_READ_CHUNK_SIZE;
LoadAddress = (PVOID)((ULONG_PTR)LoadAddress + LINUX_READ_CHUNK_SIZE); LoadAddress = (PVOID)((ULONG_PTR)LoadAddress + LINUX_READ_CHUNK_SIZE);
@ -427,25 +377,25 @@ BOOLEAN LinuxReadKernel(PFILE LinuxKernelFile)
BOOLEAN LinuxCheckKernelVersion(VOID) BOOLEAN LinuxCheckKernelVersion(VOID)
{ {
// Just assume old kernel until we find otherwise /* Just assume old kernel until we find otherwise */
NewStyleLinuxKernel = FALSE; NewStyleLinuxKernel = FALSE;
// Check for new style setup header /* Check for new style setup header */
if (LinuxSetupSector->SetupHeaderSignature != LINUX_SETUP_HEADER_ID) if (LinuxSetupSector->SetupHeaderSignature != LINUX_SETUP_HEADER_ID)
{ {
NewStyleLinuxKernel = FALSE; NewStyleLinuxKernel = FALSE;
} }
// Check for version below 2.0 /* Check for version below 2.0 */
else if (LinuxSetupSector->Version < 0x0200) else if (LinuxSetupSector->Version < 0x0200)
{ {
NewStyleLinuxKernel = FALSE; NewStyleLinuxKernel = FALSE;
} }
// Check for version 2.0 /* Check for version 2.0 */
else if (LinuxSetupSector->Version == 0x0200) else if (LinuxSetupSector->Version == 0x0200)
{ {
NewStyleLinuxKernel = TRUE; NewStyleLinuxKernel = TRUE;
} }
// Check for version 2.01+ /* Check for version 2.01+ */
else if (LinuxSetupSector->Version >= 0x0201) else if (LinuxSetupSector->Version >= 0x0201)
{ {
NewStyleLinuxKernel = TRUE; NewStyleLinuxKernel = TRUE;
@ -487,7 +437,7 @@ BOOLEAN LinuxReadInitrd(PFILE LinuxInitrdFile)
return FALSE; return FALSE;
} }
// Set the information in the setup struct /* Set the information in the setup struct */
LinuxSetupSector->RamdiskAddress = (ULONG)LinuxInitrdLoadAddress; LinuxSetupSector->RamdiskAddress = (ULONG)LinuxInitrdLoadAddress;
LinuxSetupSector->RamdiskSize = LinuxInitrdSize; LinuxSetupSector->RamdiskSize = LinuxInitrdSize;
@ -499,13 +449,11 @@ BOOLEAN LinuxReadInitrd(PFILE LinuxInitrdFile)
TRACE("InitrdAddressMax: 0x%x\n", LinuxSetupSector->InitrdAddressMax); TRACE("InitrdAddressMax: 0x%x\n", LinuxSetupSector->InitrdAddressMax);
} }
// Read in the ramdisk /* Read in the ramdisk */
for (BytesLoaded=0; BytesLoaded<LinuxInitrdSize; ) for (BytesLoaded=0; BytesLoaded<LinuxInitrdSize; )
{ {
if (!FsReadFile(LinuxInitrdFile, LINUX_READ_CHUNK_SIZE, NULL, (PVOID)LinuxInitrdLoadAddress)) if (!FsReadFile(LinuxInitrdFile, LINUX_READ_CHUNK_SIZE, NULL, (PVOID)LinuxInitrdLoadAddress))
{
return FALSE; return FALSE;
}
BytesLoaded += LINUX_READ_CHUNK_SIZE; BytesLoaded += LINUX_READ_CHUNK_SIZE;
LinuxInitrdLoadAddress = (PVOID)((ULONG_PTR)LinuxInitrdLoadAddress + LINUX_READ_CHUNK_SIZE); LinuxInitrdLoadAddress = (PVOID)((ULONG_PTR)LinuxInitrdLoadAddress + LINUX_READ_CHUNK_SIZE);

View file

@ -17,25 +17,29 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifdef _M_IX86
/* INCLUDES *******************************************************************/
#include <freeldr.h> #include <freeldr.h>
#ifdef _M_IX86 /* FUNCTIONS ******************************************************************/
VOID VOID
LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem, LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem,
IN USHORT OperatingSystemVersion) IN USHORT OperatingSystemVersion)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
PCSTR SectionName = OperatingSystem->SystemPartition; PCSTR SectionName = OperatingSystem->SystemPartition;
CHAR FileName[260]; CHAR FileName[260];
PFILE FilePointer; PFILE FilePointer;
ULONG BytesRead; ULONG BytesRead;
CHAR SettingName[80]; CHAR SettingName[80];
// Find all the message box settings and run them /* Find all the message box settings and run them */
UiShowMessageBoxesInSection(SectionName); UiShowMessageBoxesInSection(SectionName);
// Try to open the operating system section in the .ini file /* Try to open the operating system section in the .ini file */
if (!IniOpenSection(SectionName, &SectionId)) if (!IniOpenSection(SectionName, &SectionId))
{ {
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName);
@ -57,14 +61,14 @@ LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem,
return; return;
} }
// Read boot sector /* Read boot sector */
if (!FsReadFile(FilePointer, 512, &BytesRead, (void*)0x7c00) || (BytesRead != 512)) if (!FsReadFile(FilePointer, 512, &BytesRead, (void*)0x7c00) || (BytesRead != 512))
{ {
UiMessageBox("Unable to read boot sector."); UiMessageBox("Unable to read boot sector.");
return; return;
} }
// Check for validity /* Check for validity */
if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55) if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{ {
UiMessageBox("Invalid boot sector magic (0xaa55)"); UiMessageBox("Invalid boot sector magic (0xaa55)");
@ -72,15 +76,18 @@ LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem,
} }
UiUnInitialize("Booting..."); UiUnInitialize("Booting...");
// Don't stop the floppy drive motor when we
// are just booting a bootsector, or drive, or partition. /*
// If we were to stop the floppy motor then * Don't stop the floppy drive motor when we
// the BIOS wouldn't be informed and if the * are just booting a bootsector, or drive, or partition.
// next read is to a floppy then the BIOS will * If we were to stop the floppy motor then
// still think the motor is on and this will * the BIOS wouldn't be informed and if the
// result in a read error. * next read is to a floppy then the BIOS will
//DiskStopFloppyMotor(); * still think the motor is on and this will
//DisableA20(); * result in a read error.
*/
// DiskStopFloppyMotor();
// DisableA20();
ChainLoadBiosBootSectorCode(); ChainLoadBiosBootSectorCode();
} }
@ -88,18 +95,18 @@ VOID
LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem, LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem,
IN USHORT OperatingSystemVersion) IN USHORT OperatingSystemVersion)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
PCSTR SectionName = OperatingSystem->SystemPartition; PCSTR SectionName = OperatingSystem->SystemPartition;
CHAR SettingName[80]; CHAR SettingName[80];
CHAR SettingValue[80]; CHAR SettingValue[80];
PARTITION_TABLE_ENTRY PartitionTableEntry; PARTITION_TABLE_ENTRY PartitionTableEntry;
UCHAR DriveNumber; UCHAR DriveNumber;
ULONG PartitionNumber; ULONG PartitionNumber;
// Find all the message box settings and run them /* Find all the message box settings and run them */
UiShowMessageBoxesInSection(SectionName); UiShowMessageBoxesInSection(SectionName);
// Try to open the operating system section in the .ini file /* Try to open the operating system section in the .ini file */
if (!IniOpenSection(SectionName, &SectionId)) if (!IniOpenSection(SectionName, &SectionId))
{ {
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName);
@ -107,7 +114,7 @@ LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem,
return; return;
} }
// Read the boot drive /* Read the boot drive */
if (!IniReadSettingByName(SectionId, "BootDrive", SettingValue, sizeof(SettingValue))) if (!IniReadSettingByName(SectionId, "BootDrive", SettingValue, sizeof(SettingValue)))
{ {
UiMessageBox("Boot drive not specified for selected OS!"); UiMessageBox("Boot drive not specified for selected OS!");
@ -116,7 +123,7 @@ LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem,
DriveNumber = DriveMapGetBiosDriveNumber(SettingValue); DriveNumber = DriveMapGetBiosDriveNumber(SettingValue);
// Read the boot partition /* Read the boot partition */
if (!IniReadSettingByName(SectionId, "BootPartition", SettingValue, sizeof(SettingValue))) if (!IniReadSettingByName(SectionId, "BootPartition", SettingValue, sizeof(SettingValue)))
{ {
UiMessageBox("Boot partition not specified for selected OS!"); UiMessageBox("Boot partition not specified for selected OS!");
@ -125,21 +132,20 @@ LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem,
PartitionNumber = atoi(SettingValue); PartitionNumber = atoi(SettingValue);
// Get the partition table entry /* Get the partition table entry */
if (!DiskGetPartitionEntry(DriveNumber, PartitionNumber, &PartitionTableEntry)) if (!DiskGetPartitionEntry(DriveNumber, PartitionNumber, &PartitionTableEntry))
{ {
return; return;
} }
// Now try to read the partition boot sector /* Now try to read the partition boot sector. If this fails then abort. */
// If this fails then abort
if (!MachDiskReadLogicalSectors(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, 1, (PVOID)0x7C00)) if (!MachDiskReadLogicalSectors(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, 1, (PVOID)0x7C00))
{ {
UiMessageBox("Unable to read partition's boot sector."); UiMessageBox("Unable to read partition's boot sector.");
return; return;
} }
// Check for validity /* Check for validity */
if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55) if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{ {
UiMessageBox("Invalid boot sector magic (0xaa55)"); UiMessageBox("Invalid boot sector magic (0xaa55)");
@ -147,15 +153,18 @@ LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem,
} }
UiUnInitialize("Booting..."); UiUnInitialize("Booting...");
// Don't stop the floppy drive motor when we
// are just booting a bootsector, or drive, or partition. /*
// If we were to stop the floppy motor then * Don't stop the floppy drive motor when we
// the BIOS wouldn't be informed and if the * are just booting a bootsector, or drive, or partition.
// next read is to a floppy then the BIOS will * If we were to stop the floppy motor then
// still think the motor is on and this will * the BIOS wouldn't be informed and if the
// result in a read error. * next read is to a floppy then the BIOS will
//DiskStopFloppyMotor(); * still think the motor is on and this will
//DisableA20(); * result in a read error.
*/
// DiskStopFloppyMotor();
// DisableA20();
FrldrBootDrive = DriveNumber; FrldrBootDrive = DriveNumber;
ChainLoadBiosBootSectorCode(); ChainLoadBiosBootSectorCode();
} }
@ -164,16 +173,16 @@ VOID
LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem, LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem,
IN USHORT OperatingSystemVersion) IN USHORT OperatingSystemVersion)
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId;
PCSTR SectionName = OperatingSystem->SystemPartition; PCSTR SectionName = OperatingSystem->SystemPartition;
CHAR SettingName[80]; CHAR SettingName[80];
CHAR SettingValue[80]; CHAR SettingValue[80];
UCHAR DriveNumber; UCHAR DriveNumber;
// Find all the message box settings and run them /* Find all the message box settings and run them */
UiShowMessageBoxesInSection(SectionName); UiShowMessageBoxesInSection(SectionName);
// Try to open the operating system section in the .ini file /* Try to open the operating system section in the .ini file */
if (!IniOpenSection(SectionName, &SectionId)) if (!IniOpenSection(SectionName, &SectionId))
{ {
sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName);
@ -189,15 +198,14 @@ LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem,
DriveNumber = DriveMapGetBiosDriveNumber(SettingValue); DriveNumber = DriveMapGetBiosDriveNumber(SettingValue);
// Now try to read the boot sector (or mbr) /* Now try to read the boot sector (or mbr). If this fails then abort. */
// If this fails then abort
if (!MachDiskReadLogicalSectors(DriveNumber, 0, 1, (PVOID)0x7C00)) if (!MachDiskReadLogicalSectors(DriveNumber, 0, 1, (PVOID)0x7C00))
{ {
UiMessageBox("Unable to read boot sector"); UiMessageBox("Unable to read boot sector");
return; return;
} }
// Check for validity /* Check for validity */
if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55) if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{ {
UiMessageBox("Invalid boot sector magic (0xaa55)"); UiMessageBox("Invalid boot sector magic (0xaa55)");
@ -205,15 +213,18 @@ LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem,
} }
UiUnInitialize("Booting..."); UiUnInitialize("Booting...");
// Don't stop the floppy drive motor when we
// are just booting a bootsector, or drive, or partition. /*
// If we were to stop the floppy motor then * Don't stop the floppy drive motor when we
// the BIOS wouldn't be informed and if the * are just booting a bootsector, or drive, or partition.
// next read is to a floppy then the BIOS will * If we were to stop the floppy motor then
// still think the motor is on and this will * the BIOS wouldn't be informed and if the
// result in a read error. * next read is to a floppy then the BIOS will
//DiskStopFloppyMotor(); * still think the motor is on and this will
//DisableA20(); * result in a read error.
*/
// DiskStopFloppyMotor();
// DisableA20();
FrldrBootDrive = DriveNumber; FrldrBootDrive = DriveNumber;
ChainLoadBiosBootSectorCode(); ChainLoadBiosBootSectorCode();
} }