3 * Copyright (C) 1999, 2000, 2001 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.
23 #include "reactos/reactos.h"
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 PUCHAR ScreenBuffer
= (PUCHAR
)(SCREENBUFFER
); // Save buffer for screen contents
39 ULONG CursorXPos
= 0; // Cursor's X Position
40 ULONG CursorYPos
= 0; // Cursor's Y Position
42 ULONG
GetDefaultOperatingSystem(PUCHAR OperatingSystemList
[], ULONG OperatingSystemCount
);
43 LONG
GetTimeOut(VOID
);
48 UCHAR SettingName
[80];
49 UCHAR SettingValue
[80];
51 ULONG OperatingSystemCount
;
52 PUCHAR
*OperatingSystemSectionNames
;
53 PUCHAR
*OperatingSystemDisplayNames
;
54 ULONG DefaultOperatingSystem
;
56 ULONG SelectedOperatingSystem
;
60 CursorXPos
= (ULONG
) *((PUCHAR
)(SCREENXCOORD
));
61 CursorYPos
= (ULONG
) *((PUCHAR
)(SCREENYCOORD
));
67 InitMemoryManager( (PVOID
) 0x20000 /* BaseAddress */, 0x70000 /* Length */);
71 printf("Press any key to reboot.\n");
76 if (!OpenSection("FreeLoader", &SectionId
))
78 printf("Section [FreeLoader] not found in freeldr.ini.\n");
83 if (!InitUserInterface())
85 printf("Press any key to reboot.\n");
90 if (!InitOperatingSystemList(&OperatingSystemSectionNames
, &OperatingSystemDisplayNames
, &OperatingSystemCount
))
92 MessageBox("Press ENTER to reboot.\n");
96 if (OperatingSystemCount
== 0)
98 MessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
102 DefaultOperatingSystem
= GetDefaultOperatingSystem(OperatingSystemSectionNames
, OperatingSystemCount
);
103 TimeOut
= GetTimeOut();
106 // Find all the message box settings and run them
108 for (Idx
=0; Idx
<GetNumSectionItems(SectionId
); Idx
++)
110 ReadSectionSettingByNumber(SectionId
, Idx
, SettingName
, 80, SettingValue
, 80);
112 if (stricmp(SettingName
, "MessageBox") == 0)
114 MessageBox(SettingValue
);
116 else if (stricmp(SettingName
, "MessageLine") == 0)
118 MessageLine(SettingValue
);
124 if (!DisplayMenu(OperatingSystemDisplayNames
, OperatingSystemCount
, DefaultOperatingSystem
, TimeOut
, &SelectedOperatingSystem
))
126 MessageBox("Press ENTER to reboot.\n");
130 LoadAndBootReactOS(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
132 /*switch (OSList[nOSToBoot].nOSType)
135 LoadAndBootReactOS(OSList[nOSToBoot].name);
138 MessageBox("Cannot boot this OS type yet!");
140 case OSTYPE_BOOTSECTOR:
141 LoadAndBootBootSector(nOSToBoot);
143 case OSTYPE_PARTITION:
144 LoadAndBootPartition(nOSToBoot);
147 LoadAndBootDrive(nOSToBoot);
154 RestoreScreen(ScreenBuffer
);
156 gotoxy(CursorXPos
, CursorYPos
);
160 ULONG
GetDefaultOperatingSystem(PUCHAR OperatingSystemList
[], ULONG OperatingSystemCount
)
162 UCHAR DefaultOSText
[80];
167 if (!OpenSection("FreeLoader", &SectionId
))
172 if (ReadSectionSettingByName(SectionId
, "DefaultOS", DefaultOSText
, 80))
174 for (Idx
=0; Idx
<OperatingSystemCount
; Idx
++)
176 if (stricmp(DefaultOSText
, OperatingSystemList
[Idx
]) == 0)
191 LONG
GetTimeOut(VOID
)
193 UCHAR TimeOutText
[20];
197 if (!OpenSection("FreeLoader", &SectionId
))
202 if (ReadSectionSettingByName(SectionId
, "TimeOut", TimeOutText
, 20))
204 TimeOut
= atoi(TimeOutText
);