3 * Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34 // Variable BootDrive moved to asmcode.S
35 //ULONG BootDrive = 0; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc.
36 ULONG BootPartition
= 0; // Boot Partition, 1-4
38 ULONG
GetDefaultOperatingSystem(PUCHAR OperatingSystemList
[], ULONG OperatingSystemCount
);
39 LONG
GetTimeOut(VOID
);
43 UCHAR SettingName
[80];
44 UCHAR SettingValue
[80];
46 ULONG OperatingSystemCount
;
47 PUCHAR
*OperatingSystemSectionNames
;
48 PUCHAR
*OperatingSystemDisplayNames
;
49 ULONG DefaultOperatingSystem
;
51 ULONG SelectedOperatingSystem
;
59 if (!MmInitializeMemoryManager())
61 printf("Press any key to reboot.\n");
66 if (!IniFileInitialize())
68 printf("Press any key to reboot.\n");
73 if (!IniOpenSection("FreeLoader", &SectionId
))
75 printf("Section [FreeLoader] not found in freeldr.ini.\n");
82 printf("Press any key to reboot.\n");
87 if (!InitOperatingSystemList(&OperatingSystemSectionNames
, &OperatingSystemDisplayNames
, &OperatingSystemCount
))
89 UiMessageBox("Press ENTER to reboot.\n");
93 if (OperatingSystemCount
== 0)
95 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
99 DefaultOperatingSystem
= GetDefaultOperatingSystem(OperatingSystemSectionNames
, OperatingSystemCount
);
100 TimeOut
= GetTimeOut();
103 // Find all the message box settings and run them
105 UiShowMessageBoxesInSection("FreeLoader");
109 // Redraw the backdrop
112 // Show the operating system list menu
113 if (!UiDisplayMenu(OperatingSystemDisplayNames
, OperatingSystemCount
, DefaultOperatingSystem
, TimeOut
, &SelectedOperatingSystem
))
115 UiMessageBox("Press ENTER to reboot.\n");
119 DefaultOperatingSystem
= SelectedOperatingSystem
;
121 // Try to open the operating system section in the .ini file
122 if (!IniOpenSection(OperatingSystemSectionNames
[SelectedOperatingSystem
], &SectionId
))
124 sprintf(SettingName
, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
125 UiMessageBox(SettingName
);
129 // Try to read the boot type
130 if (!IniReadSettingByName(SectionId
, "BootType", SettingValue
, 80))
132 sprintf(SettingName
, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
133 UiMessageBox(SettingName
);
137 if (stricmp(SettingValue
, "ReactOS") == 0)
139 LoadAndBootReactOS(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
141 else if (stricmp(SettingValue
, "Linux") == 0)
143 LoadAndBootLinux(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
145 else if (stricmp(SettingValue
, "BootSector") == 0)
147 LoadAndBootBootSector(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
149 else if (stricmp(SettingValue
, "Partition") == 0)
151 LoadAndBootPartition(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
153 else if (stricmp(SettingValue
, "Drive") == 0)
155 LoadAndBootDrive(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
162 VideoShowTextCursor();
166 ULONG
GetDefaultOperatingSystem(PUCHAR OperatingSystemList
[], ULONG OperatingSystemCount
)
168 UCHAR DefaultOSText
[80];
173 if (!IniOpenSection("FreeLoader", &SectionId
))
178 if (IniReadSettingByName(SectionId
, "DefaultOS", DefaultOSText
, 80))
180 for (Idx
=0; Idx
<OperatingSystemCount
; Idx
++)
182 if (stricmp(DefaultOSText
, OperatingSystemList
[Idx
]) == 0)
193 LONG
GetTimeOut(VOID
)
195 UCHAR TimeOutText
[20];
199 if (!IniOpenSection("FreeLoader", &SectionId
))
204 if (IniReadSettingByName(SectionId
, "TimeOut", TimeOutText
, 20))
206 TimeOut
= atoi(TimeOutText
);