dc6e85c080d5c11f7a4b768cce18359977c678aa
[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 "SEPARATOR",
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 "SEPARATOR",
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\n";
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(OptionsMenuList, OptionsMenuItemCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
105 {
106 // The user pressed ESC
107 return;
108 }
109
110 // Clear the backdrop
111 UiDrawBackdrop();
112
113 switch (SelectedMenuItem)
114 {
115 case SAFE_MODE:
116 SafeMode = TRUE;
117 BootLogging = TRUE;
118 break;
119 case SAFE_MODE_WITH_NETWORKING:
120 SafeModeWithNetworking = TRUE;
121 BootLogging = TRUE;
122 break;
123 case SAFE_MODE_WITH_COMMAND_PROMPT:
124 SafeModeWithCommandPrompt = TRUE;
125 BootLogging = TRUE;
126 break;
127 //case SEPARATOR1:
128 // break;
129 case ENABLE_BOOT_LOGGING:
130 BootLogging = TRUE;
131 break;
132 case ENABLE_VGA_MODE:
133 VgaMode = TRUE;
134 break;
135 case LAST_KNOWN_GOOD_CONFIGURATION:
136 LastKnownGoodConfiguration = TRUE;
137 break;
138 case DIRECTORY_SERVICES_RESTORE_MODE:
139 DirectoryServicesRepairMode = TRUE;
140 break;
141 case DEBUGGING_MODE:
142 DebuggingMode = TRUE;
143 break;
144 case FREELDR_DEBUGGING:
145 DebugChannelString[0]=0;
146 if(UiEditBox(FrldrDbgMsg, DebugChannelString, 100))
147 DbgParseDebugChannels(DebugChannelString);
148 break;
149 //case SEPARATOR2:
150 // break;
151 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
152 case CUSTOM_BOOT:
153 OptionMenuCustomBoot();
154 break;
155 #endif
156 #ifdef HAS_OPTION_MENU_REBOOT
157 case REBOOT:
158 OptionMenuReboot();
159 break;
160 #endif
161 }
162 }
163
164 VOID AppendBootTimeOptions(PCHAR BootOptions)
165 {
166 if (SafeMode)
167 strcat(BootOptions, " /SAFEBOOT:MINIMAL /SOS"); //FIXME: NOGUIBOOT should also be specified
168
169 if (SafeModeWithNetworking)
170 strcat(BootOptions, " /SAFEBOOT:NETWORK /SOS"); //FIXME: NOGUIBOOT should also be specified
171
172 if (SafeModeWithCommandPrompt)
173 strcat(BootOptions, " /SAFEBOOT:MINIMAL(ALTERNATESHELL) /SOS"); //FIXME: NOGUIBOOT should also be specified
174
175 if (BootLogging)
176 strcat(BootOptions, " /BOOTLOG");
177
178 if (VgaMode)
179 strcat(BootOptions, " /BASEVIDEO");
180
181 if (LastKnownGoodConfiguration)
182 DbgPrint("Last known good configuration is not supported yet!\n");
183
184 if (DirectoryServicesRepairMode)
185 strcat(BootOptions, " /SAFEBOOT:DSREPAIR /SOS");
186
187 if (DebuggingMode)
188 strcat(BootOptions, " /DEBUG");
189 }