[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / options.c
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
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.
9 *
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.
14 *
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.
18 */
19
20 #include <freeldr.h>
21 #include <debug.h>
22
23 PCSTR OptionsMenuList[] =
24 {
25 "Safe Mode",
26 "Safe Mode with Networking",
27 "Safe Mode with Command Prompt",
28
29 NULL,
30
31 "Enable Boot Logging",
32 "Enable VGA Mode",
33 "Last Known Good Configuration",
34 "Directory Services Restore Mode",
35 "Debugging Mode",
36 "FreeLdr debugging",
37
38 NULL,
39
40 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
41 "Custom Boot",
42 #endif
43 #ifdef HAS_OPTION_MENU_REBOOT
44 "Reboot",
45 #endif
46 };
47
48 PCSTR FrldrDbgMsg = "Enable FreeLdr debug channels\n"
49 "Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n"
50 "level can be one of: trace,warn,fixme,err\n"
51 " if the level is ommited all levels\n"
52 " are enabled for the specified channel\n"
53 "# can be either + or -\n"
54 "channel can be one of the following:\n"
55 " all,warning,memory,filesystem,inifile,ui,disk,cache,registry,\n"
56 " reactos,linux,hwdetect,windows,peloader,scsiport,heap\n"
57 "Examples:\n"
58 " trace+windows,trace+reactos\n"
59 " +hwdetect,err-disk\n"
60 " +peloader\n"
61 "NOTE: all letters must be lowercase, no spaces allowed.";
62
63 enum OptionMenuItems
64 {
65 SAFE_MODE = 0,
66 SAFE_MODE_WITH_NETWORKING = 1,
67 SAFE_MODE_WITH_COMMAND_PROMPT = 2,
68
69 SEPARATOR1 = 3,
70
71 ENABLE_BOOT_LOGGING = 4,
72 ENABLE_VGA_MODE = 5,
73 LAST_KNOWN_GOOD_CONFIGURATION = 6,
74 DIRECTORY_SERVICES_RESTORE_MODE = 7,
75 DEBUGGING_MODE = 8,
76 FREELDR_DEBUGGING = 9,
77
78 SEPARATOR2 = 10,
79
80 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
81 CUSTOM_BOOT = 11,
82 #endif
83 #ifdef HAS_OPTION_MENU_REBOOT
84 REBOOT = 12,
85 #endif
86 };
87
88 ULONG OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
89
90 BOOLEAN SafeMode = FALSE;
91 BOOLEAN SafeModeWithNetworking = FALSE;
92 BOOLEAN SafeModeWithCommandPrompt = FALSE;
93 BOOLEAN BootLogging = FALSE;
94 BOOLEAN VgaMode = FALSE;
95 BOOLEAN LastKnownGoodConfiguration = FALSE;
96 BOOLEAN DirectoryServicesRepairMode = FALSE;
97 BOOLEAN DebuggingMode = FALSE;
98
99 VOID DoOptionsMenu(VOID)
100 {
101 ULONG SelectedMenuItem;
102 CHAR DebugChannelString[100];
103
104 if (!UiDisplayMenu("Select an option:", "",
105 OptionsMenuList,
106 OptionsMenuItemCount,
107 0, -1,
108 &SelectedMenuItem,
109 TRUE,
110 NULL))
111 {
112 // The user pressed ESC
113 return;
114 }
115
116 // Clear the backdrop
117 UiDrawBackdrop();
118
119 switch (SelectedMenuItem)
120 {
121 case SAFE_MODE:
122 SafeMode = TRUE;
123 BootLogging = TRUE;
124 break;
125 case SAFE_MODE_WITH_NETWORKING:
126 SafeModeWithNetworking = TRUE;
127 BootLogging = TRUE;
128 break;
129 case SAFE_MODE_WITH_COMMAND_PROMPT:
130 SafeModeWithCommandPrompt = TRUE;
131 BootLogging = TRUE;
132 break;
133 //case SEPARATOR1:
134 // break;
135 case ENABLE_BOOT_LOGGING:
136 BootLogging = TRUE;
137 break;
138 case ENABLE_VGA_MODE:
139 VgaMode = TRUE;
140 break;
141 case LAST_KNOWN_GOOD_CONFIGURATION:
142 LastKnownGoodConfiguration = TRUE;
143 break;
144 case DIRECTORY_SERVICES_RESTORE_MODE:
145 DirectoryServicesRepairMode = TRUE;
146 break;
147 case DEBUGGING_MODE:
148 DebuggingMode = TRUE;
149 break;
150 case FREELDR_DEBUGGING:
151 DebugChannelString[0]=0;
152 if (UiEditBox(FrldrDbgMsg, DebugChannelString, 100))
153 DbgParseDebugChannels(DebugChannelString);
154 break;
155 //case SEPARATOR2:
156 // break;
157 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
158 case CUSTOM_BOOT:
159 OptionMenuCustomBoot();
160 break;
161 #endif
162 #ifdef HAS_OPTION_MENU_REBOOT
163 case REBOOT:
164 OptionMenuReboot();
165 break;
166 #endif
167 }
168 }
169
170 VOID AppendBootTimeOptions(PCHAR BootOptions)
171 {
172 if (SafeMode)
173 strcat(BootOptions, " /SAFEBOOT:MINIMAL /SOS"); //FIXME: NOGUIBOOT should also be specified
174
175 if (SafeModeWithNetworking)
176 strcat(BootOptions, " /SAFEBOOT:NETWORK /SOS"); //FIXME: NOGUIBOOT should also be specified
177
178 if (SafeModeWithCommandPrompt)
179 strcat(BootOptions, " /SAFEBOOT:MINIMAL(ALTERNATESHELL) /SOS"); //FIXME: NOGUIBOOT should also be specified
180
181 if (BootLogging)
182 strcat(BootOptions, " /BOOTLOG");
183
184 if (VgaMode)
185 strcat(BootOptions, " /BASEVIDEO");
186
187 if (LastKnownGoodConfiguration)
188 DbgPrint("Last known good configuration is not supported yet!\n");
189
190 if (DirectoryServicesRepairMode)
191 strcat(BootOptions, " /SAFEBOOT:DSREPAIR /SOS");
192
193 if (DebuggingMode)
194 strcat(BootOptions, " /DEBUG");
195 }