3 * Copyright (C) 1998-2003 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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 ARC_DISK_SIGNATURE reactos_arc_disk_info
[32]; // ARC Disk Information
23 unsigned long reactos_disk_count
= 0;
24 char reactos_arc_hardware_data
[HW_MAX_ARC_HEAP_SIZE
] = {0};
25 char reactos_arc_strings
[32][256];
27 ULONG
GetDefaultOperatingSystem(OperatingSystemItem
* OperatingSystemList
, ULONG OperatingSystemCount
)
29 CHAR DefaultOSText
[80];
35 if (!IniOpenSection("FreeLoader", &SectionId
))
40 DefaultOSName
= CmdLineGetDefaultOS();
41 if (NULL
== DefaultOSName
)
43 if (IniReadSettingByName(SectionId
, "DefaultOS", DefaultOSText
, sizeof(DefaultOSText
)))
45 DefaultOSName
= DefaultOSText
;
49 if (NULL
!= DefaultOSName
)
51 for (Idx
=0; Idx
<OperatingSystemCount
; Idx
++)
53 if (_stricmp(DefaultOSName
, OperatingSystemList
[Idx
].SystemPartition
) == 0)
70 TimeOut
= CmdLineGetTimeOut();
76 if (!IniOpenSection("FreeLoader", &SectionId
))
81 if (IniReadSettingByName(SectionId
, "TimeOut", TimeOutText
, sizeof(TimeOutText
)))
83 TimeOut
= atoi(TimeOutText
);
93 BOOLEAN
MainBootMenuKeyPressFilter(ULONG KeyPress
)
95 if (KeyPress
== KEY_F8
)
102 // We didn't handle the key
108 CHAR SettingValue
[80];
111 ULONG OperatingSystemCount
;
112 OperatingSystemItem
* OperatingSystemList
;
113 PCSTR
*OperatingSystemDisplayNames
;
116 ULONG DefaultOperatingSystem
;
118 ULONG SelectedOperatingSystem
;
120 // FIXME: if possible, only detect and register ARC devices...
123 UiMessageBoxCritical("Error when detecting hardware");
128 // Load additional SCSI driver (if any)
129 if (LoadBootDeviceDriver() != ESUCCESS
)
131 UiMessageBoxCritical("Unable to load additional boot device driver");
135 if (!IniFileInitialize())
137 UiMessageBoxCritical("Error initializing .ini file");
141 if (!IniOpenSection("FreeLoader", &SectionId
))
143 UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
146 TimeOut
= GetTimeOut();
148 if (!UiInitialize(TRUE
))
150 UiMessageBoxCritical("Unable to initialize UI.");
154 OperatingSystemList
= InitOperatingSystemList(&OperatingSystemCount
);
155 if (!OperatingSystemList
)
157 UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
161 if (OperatingSystemCount
== 0)
163 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
167 DefaultOperatingSystem
= GetDefaultOperatingSystem(OperatingSystemList
, OperatingSystemCount
);
170 // Create list of display names
172 OperatingSystemDisplayNames
= MmHeapAlloc(sizeof(PCSTR
) * OperatingSystemCount
);
173 if (!OperatingSystemDisplayNames
)
177 for (i
= 0; i
< OperatingSystemCount
; i
++)
179 OperatingSystemDisplayNames
[i
] = OperatingSystemList
[i
].LoadIdentifier
;
183 // Find all the message box settings and run them
185 UiShowMessageBoxesInSection("FreeLoader");
190 // Redraw the backdrop
193 // Show the operating system list menu
194 if (!UiDisplayMenu("Please select the operating system to start:",
195 OperatingSystemDisplayNames
,
196 OperatingSystemCount
,
197 DefaultOperatingSystem
,
199 &SelectedOperatingSystem
,
201 MainBootMenuKeyPressFilter
))
203 UiMessageBox("Press ENTER to reboot.");
209 // Try to open the operating system section in the .ini file
210 SettingValue
[0] = ANSI_NULL
;
211 SectionName
= OperatingSystemList
[SelectedOperatingSystem
].SystemPartition
;
212 if (IniOpenSection(SectionName
, &SectionId
))
214 // Try to read the boot type
215 IniReadSettingByName(SectionId
, "BootType", BootType
, sizeof(BootType
));
218 BootType
[0] = ANSI_NULL
;
220 if (BootType
[0] == ANSI_NULL
&& SectionName
[0] != ANSI_NULL
)
222 // Try to infere boot type value
225 if (ArcOpen((CHAR
*)SectionName
, OpenReadOnly
, &FileId
) == ESUCCESS
)
228 strcpy(BootType
, "BootSector");
233 strcpy(BootType
, "Windows");
237 // Get OS setting value
238 IniOpenSection("Operating Systems", &SectionId
);
239 IniReadSettingByName(SectionId
, SectionName
, SettingValue
, sizeof(SettingValue
));
241 // Install the drive mapper according to this sections drive mappings
242 #if defined(_M_IX86) && !defined(_MSC_VER)
243 DriveMapMapDrivesInSection(SectionName
);
246 #ifdef FREELDR_REACTOS_SETUP
249 #elif defined(_M_IX86)
250 if (_stricmp(BootType
, "Windows") == 0)
252 LoadAndBootWindows(SectionName
, SettingValue
, 0);
254 else if (_stricmp(BootType
, "WindowsNT40") == 0)
256 LoadAndBootWindows(SectionName
, SettingValue
, _WIN32_WINNT_NT4
);
258 else if (_stricmp(BootType
, "Windows2003") == 0)
260 LoadAndBootWindows(SectionName
, SettingValue
, _WIN32_WINNT_WS03
);
262 else if (_stricmp(BootType
, "Linux") == 0)
264 LoadAndBootLinux(SectionName
, OperatingSystemDisplayNames
[SelectedOperatingSystem
]);
266 else if (_stricmp(BootType
, "BootSector") == 0)
268 LoadAndBootBootSector(SectionName
);
270 else if (_stricmp(BootType
, "Partition") == 0)
272 LoadAndBootPartition(SectionName
);
274 else if (_stricmp(BootType
, "Drive") == 0)
276 LoadAndBootDrive(SectionName
);
279 LoadAndBootWindows(SectionName
, SettingValue
, _WIN32_WINNT_WS03
);
284 UiUnInitialize("Rebooting...");