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
);
44 UCHAR SettingName
[80];
45 UCHAR SettingValue
[80];
47 ULONG OperatingSystemCount
;
48 PUCHAR
*OperatingSystemSectionNames
;
49 PUCHAR
*OperatingSystemDisplayNames
;
50 ULONG DefaultOperatingSystem
;
52 ULONG SelectedOperatingSystem
;
60 InitMemoryManager( (PVOID
) 0x20000 /* BaseAddress */, 0x70000 /* Length */);
64 printf("Press any key to reboot.\n");
69 if (!OpenSection("FreeLoader", &SectionId
))
71 printf("Section [FreeLoader] not found in freeldr.ini.\n");
76 if (!InitUserInterface())
78 printf("Press any key to reboot.\n");
83 if (!InitOperatingSystemList(&OperatingSystemSectionNames
, &OperatingSystemDisplayNames
, &OperatingSystemCount
))
85 MessageBox("Press ENTER to reboot.\n");
89 if (OperatingSystemCount
== 0)
91 MessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
95 DefaultOperatingSystem
= GetDefaultOperatingSystem(OperatingSystemSectionNames
, OperatingSystemCount
);
96 TimeOut
= GetTimeOut();
99 // Find all the message box settings and run them
101 ShowMessageBoxesInSection("FreeLoader");
105 // Show the operating system list menu
106 if (!DisplayMenu(OperatingSystemDisplayNames
, OperatingSystemCount
, DefaultOperatingSystem
, TimeOut
, &SelectedOperatingSystem
))
108 MessageBox("Press ENTER to reboot.\n");
112 // Try to open the operating system section in the .ini file
113 if (!OpenSection(OperatingSystemSectionNames
[SelectedOperatingSystem
], &SectionId
))
115 sprintf(SettingName
, "Section [%s] not found in freeldr.ini.\n", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
116 MessageBox(SettingName
);
120 // Try to read the boot type
121 if (!ReadSectionSettingByName(SectionId
, "BootType", SettingValue
, 80))
123 sprintf(SettingName
, "BootType= line not found in section [%s] in freeldr.ini.\n", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
124 MessageBox(SettingName
);
128 if (stricmp(SettingValue
, "ReactOS") == 0)
130 LoadAndBootReactOS(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
132 else if (stricmp(SettingValue
, "Linux") == 0)
134 MessageBox("Cannot boot this OS type yet!");
136 else if (stricmp(SettingValue
, "BootSector") == 0)
138 LoadAndBootBootSector(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
140 else if (stricmp(SettingValue
, "Partition") == 0)
142 LoadAndBootPartition(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
144 else if (stricmp(SettingValue
, "Drive") == 0)
146 LoadAndBootDrive(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
157 ULONG
GetDefaultOperatingSystem(PUCHAR OperatingSystemList
[], ULONG OperatingSystemCount
)
159 UCHAR DefaultOSText
[80];
164 if (!OpenSection("FreeLoader", &SectionId
))
169 if (ReadSectionSettingByName(SectionId
, "DefaultOS", DefaultOSText
, 80))
171 for (Idx
=0; Idx
<OperatingSystemCount
; Idx
++)
173 if (stricmp(DefaultOSText
, OperatingSystemList
[Idx
]) == 0)
184 LONG
GetTimeOut(VOID
)
186 UCHAR TimeOutText
[20];
190 if (!OpenSection("FreeLoader", &SectionId
))
195 if (ReadSectionSettingByName(SectionId
, "TimeOut", TimeOutText
, 20))
197 TimeOut
= atoi(TimeOutText
);