* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+/* INCLUDES *******************************************************************/
+
#include <freeldr.h>
+#include <debug.h>
-ARC_DISK_SIGNATURE reactos_arc_disk_info[32]; // ARC Disk Information
-ULONG reactos_disk_count = 0;
-CHAR reactos_arc_strings[32][256];
+/* GLOBALS ********************************************************************/
typedef
VOID
OS_LOADING_METHOD Load;
} OSLoadingMethods[] =
{
-#ifdef FREELDR_REACTOS_SETUP
{"ReactOSSetup", 0 , LoadReactOSSetup },
-#endif
#ifdef _M_IX86
{"BootSector" , 0 , LoadAndBootBootSector},
{"WindowsNT40" , _WIN32_WINNT_NT4 , LoadAndBootWindows },
#endif
{"Windows2003" , _WIN32_WINNT_WS03, LoadAndBootWindows },
-
-// {"Not found" , 0 , NULL }
};
+/* FUNCTIONS ******************************************************************/
+
VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem)
{
ULONG_PTR SectionId;
CHAR BootType[80];
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))
{
- // Try to read the boot type
+ /* Try to read the boot type */
IniReadSettingByName(SectionId, "BootType", BootType, sizeof(BootType));
}
else
if (BootType[0] == ANSI_NULL && SectionName[0] != ANSI_NULL)
{
- // Try to infere the boot type value
+ /* Try to infer the boot type value */
#ifdef _M_IX86
ULONG FileId;
if (ArcOpen((PSTR)SectionName, OpenReadOnly, &FileId) == ESUCCESS)
}
}
- // 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)
DriveMapMapDrivesInSection(SectionName);
#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)
{
if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0)
ULONG GetDefaultOperatingSystem(OperatingSystemItem* OperatingSystemList, ULONG OperatingSystemCount)
{
- CHAR DefaultOSText[80];
- PCSTR DefaultOSName;
- ULONG_PTR SectionId;
- ULONG DefaultOS = 0;
- ULONG Idx;
+ CHAR DefaultOSText[80];
+ PCSTR DefaultOSName;
+ ULONG_PTR SectionId;
+ ULONG DefaultOS = 0;
+ ULONG Idx;
if (!IniOpenSection("FreeLoader", &SectionId))
- {
return 0;
- }
DefaultOSName = CmdLineGetDefaultOS();
- if (NULL == DefaultOSName)
+ if (DefaultOSName == NULL)
{
if (IniReadSettingByName(SectionId, "DefaultOS", DefaultOSText, sizeof(DefaultOSText)))
{
}
}
- 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)
{
ULONG_PTR SectionId;
TimeOut = CmdLineGetTimeOut();
- if (0 <= TimeOut)
- {
+ if (TimeOut >= 0)
return TimeOut;
- }
if (!IniOpenSection("FreeLoader", &SectionId))
- {
return -1;
- }
if (IniReadSettingByName(SectionId, "TimeOut", TimeOutText, sizeof(TimeOutText)))
- {
TimeOut = atoi(TimeOutText);
- }
else
- {
TimeOut = -1;
- }
return TimeOut;
}
if (KeyPress == KEY_F8)
{
DoOptionsMenu();
-
return TRUE;
}
- // We didn't handle the key
+ /* We didn't handle the key */
return FALSE;
}
VOID RunLoader(VOID)
{
- ULONG_PTR SectionId;
- ULONG OperatingSystemCount;
- OperatingSystemItem* OperatingSystemList;
- PCSTR* OperatingSystemDisplayNames;
- ULONG DefaultOperatingSystem;
- LONG TimeOut;
- ULONG SelectedOperatingSystem;
- ULONG i;
+ ULONG_PTR SectionId;
+ ULONG OperatingSystemCount;
+ OperatingSystemItem* OperatingSystemList;
+ PCSTR* OperatingSystemDisplayNames;
+ ULONG DefaultOperatingSystem;
+ LONG TimeOut;
+ ULONG SelectedOperatingSystem;
+ ULONG i;
if (!MachInitializeBootDevices())
{
- UiMessageBoxCritical("Error when detecting hardware");
+ UiMessageBoxCritical("Error when detecting hardware.");
return;
}
#ifdef _M_IX86
- // Load additional SCSI driver (if any)
+ /* Load additional SCSI driver (if any) */
if (LoadBootDeviceDriver() != ESUCCESS)
{
- UiMessageBoxCritical("Unable to load additional boot device driver");
+ UiMessageBoxCritical("Unable to load additional boot device drivers.");
}
#endif
if (!IniFileInitialize())
{
- UiMessageBoxCritical("Error initializing .ini file");
+ UiMessageBoxCritical("Error initializing .ini file.");
return;
}
+ /* Debugger main initialization */
+ DebugInit(TRUE);
+
if (!IniOpenSection("FreeLoader", &SectionId))
{
UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
return;
}
+
TimeOut = GetTimeOut();
+ /* UI main initialization */
if (!UiInitialize(TRUE))
{
UiMessageBoxCritical("Unable to initialize UI.");
if (!OperatingSystemList)
{
UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
- goto reboot;
+ goto Reboot;
}
if (OperatingSystemCount == 0)
{
UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
- goto reboot;
+ goto Reboot;
}
DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemList, OperatingSystemCount);
- //
- // Create list of display names
- //
- OperatingSystemDisplayNames = MmHeapAlloc(sizeof(PCSTR) * OperatingSystemCount);
+ /* Create list of display names */
+ OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
if (!OperatingSystemDisplayNames)
- {
- goto reboot;
- }
+ goto Reboot;
+
for (i = 0; i < OperatingSystemCount; i++)
{
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");
for (;;)
{
- // Redraw the backdrop
+ /* Redraw the backdrop */
UiDrawBackdrop();
- // Show the operating system list menu
+ /* Show the operating system list menu */
if (!UiDisplayMenu("Please select the operating system to start:",
"For troubleshooting and advanced startup options for "
"ReactOS, press F8.",
MainBootMenuKeyPressFilter))
{
UiMessageBox("Press ENTER to reboot.");
- goto reboot;
+ goto Reboot;
}
TimeOut = -1;
- // Load the chosen operating system
+ /* Load the chosen operating system */
LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
}
-reboot:
+Reboot:
UiUnInitialize("Rebooting...");
return;
}