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
;
61 if (!IniFileInitialize())
63 printf("Press any key to reboot.\n");
68 if (!IniOpenSection("FreeLoader", &SectionId
))
70 printf("Section [FreeLoader] not found in freeldr.ini.\n");
75 if (!InitUserInterface())
77 printf("Press any key to reboot.\n");
82 if (!InitOperatingSystemList(&OperatingSystemSectionNames
, &OperatingSystemDisplayNames
, &OperatingSystemCount
))
84 MessageBox("Press ENTER to reboot.\n");
88 if (OperatingSystemCount
== 0)
90 MessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
94 DefaultOperatingSystem
= GetDefaultOperatingSystem(OperatingSystemSectionNames
, OperatingSystemCount
);
95 TimeOut
= GetTimeOut();
98 // Find all the message box settings and run them
100 ShowMessageBoxesInSection("FreeLoader");
104 // Show the operating system list menu
105 if (!DisplayMenu(OperatingSystemDisplayNames
, OperatingSystemCount
, DefaultOperatingSystem
, TimeOut
, &SelectedOperatingSystem
))
107 MessageBox("Press ENTER to reboot.\n");
111 // Try to open the operating system section in the .ini file
112 if (!IniOpenSection(OperatingSystemSectionNames
[SelectedOperatingSystem
], &SectionId
))
114 sprintf(SettingName
, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
115 MessageBox(SettingName
);
119 // Try to read the boot type
120 if (!IniReadSettingByName(SectionId
, "BootType", SettingValue
, 80))
122 sprintf(SettingName
, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
123 MessageBox(SettingName
);
127 if (stricmp(SettingValue
, "ReactOS") == 0)
129 LoadAndBootReactOS(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
131 else if (stricmp(SettingValue
, "Linux") == 0)
133 MessageBox("Cannot boot this OS type yet!");
135 else if (stricmp(SettingValue
, "BootSector") == 0)
137 LoadAndBootBootSector(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
139 else if (stricmp(SettingValue
, "Partition") == 0)
141 LoadAndBootPartition(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
143 else if (stricmp(SettingValue
, "Drive") == 0)
145 LoadAndBootDrive(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
156 ULONG
GetDefaultOperatingSystem(PUCHAR OperatingSystemList
[], ULONG OperatingSystemCount
)
158 UCHAR DefaultOSText
[80];
163 if (!IniOpenSection("FreeLoader", &SectionId
))
168 if (IniReadSettingByName(SectionId
, "DefaultOS", DefaultOSText
, 80))
170 for (Idx
=0; Idx
<OperatingSystemCount
; Idx
++)
172 if (stricmp(DefaultOSText
, OperatingSystemList
[Idx
]) == 0)
183 LONG
GetTimeOut(VOID
)
185 UCHAR TimeOutText
[20];
189 if (!IniOpenSection("FreeLoader", &SectionId
))
194 if (IniReadSettingByName(SectionId
, "TimeOut", TimeOutText
, 20))
196 TimeOut
= atoi(TimeOutText
);