xref: /haiku/src/system/boot/platform/bios_ia32/menu.cpp (revision c237c4ce593ee823d9867fd997e51e4c447f5623)
1 /*
2  * Copyright 2004-2010, Axel Dörfler, axeld@pinc-software.de.
3  * Copyright 2011, Rene Gollent, rene@gollent.com.
4  * Distributed under the terms of the MIT License.
5  */
6 
7 
8 #include "smp.h"
9 #include "video.h"
10 
11 #include <boot/menu.h>
12 #include <boot/platform/generic/text_menu.h>
13 #include <safemode.h>
14 
15 
16 static void
17 warm_reboot(char key)
18 {
19 	asm("	cli						;"
20 		"	movl	$0x11, %eax		;"
21 		"	movl	%eax, %cr0		;"
22 		"	movl	$0x0, %eax		;"
23 		"	movl	%eax, %cr3		;"
24 		"	movl	$0x200, %eax	;"
25 		"	movl	%eax, %cr4		;"
26 		"	lidt	saved_idt		;"
27 		"	call	switch_to_real_mode	;"
28 		"	int	$0x19				;"
29 		"	.p2align 4				;"
30 		"saved_idt:					;"
31 		"	.short	0x7ff			;"
32 		"	.long	0x0				;"
33 		"	.long	0x0				;");
34 }
35 
36 
37 void
38 platform_add_menus(Menu* menu)
39 {
40 	MenuItem* item;
41 
42 	switch (menu->Type()) {
43 		case MAIN_MENU:
44 			item = new(std::nothrow) MenuItem("Select screen resolution",
45 				video_mode_menu());
46 			if (item != NULL) {
47 				menu->AddItem(item);
48 				item->SetTarget(video_mode_hook);
49 				item->SetShortcut('v');
50 			}
51 
52 			menu->AddShortcut('w', warm_reboot);
53 			break;
54 
55 		case SAFE_MODE_MENU:
56 			item = new(std::nothrow) MenuItem("Use fail-safe graphics driver");
57 			if (item != NULL) {
58 				menu->AddItem(item);
59 				item->SetType(MENU_ITEM_MARKABLE);
60 				item->SetData(B_SAFEMODE_FAIL_SAFE_VIDEO_MODE);
61 				item->SetHelpText("The system will use VESA mode "
62 					"and won't try to use any video graphics drivers.");
63 			}
64 
65 			smp_add_safemode_menus(menu);
66 
67 			item = new(std::nothrow) MenuItem("Don't call the BIOS");
68 			if (item != NULL) {
69 				menu->AddItem(item);
70 				item->SetHelpText("Stops the system from calling BIOS "
71 					"functions.");
72 				item->SetType(MENU_ITEM_MARKABLE);
73 			}
74 
75 			item = new(std::nothrow) MenuItem("Disable APM");
76 			if (item != NULL) {
77 				menu->AddItem(item);
78 				item->SetType(MENU_ITEM_MARKABLE);
79 				item->SetData(B_SAFEMODE_DISABLE_APM);
80 				item->SetHelpText("Disables Advanced Power Management hardware "
81 					"support, overriding the APM setting in the kernel "
82 					"settings file.");
83 			}
84 
85 			item = new(std::nothrow) MenuItem("Disable ACPI");
86 			if (item != NULL) {
87 				menu->AddItem(item);
88 				item->SetType(MENU_ITEM_MARKABLE);
89 				item->SetData(B_SAFEMODE_DISABLE_ACPI);
90 				item->SetHelpText("Disables Advanced Configuration and Power "
91 					"Interface hardware support, overriding the ACPI setting "
92 					"in the kernel settings file.");
93 			}
94 			break;
95 
96 		default:
97 			break;
98 	}
99 }
100 
101 
102 void
103 platform_update_menu_item(Menu* menu, MenuItem* item)
104 {
105 	platform_generic_update_text_menu_item(menu, item);
106 }
107 
108 
109 void
110 platform_run_menu(Menu* menu)
111 {
112 	platform_generic_run_text_menu(menu);
113 }
114 
115 
116 size_t
117 platform_get_user_input_text(Menu* menu, MenuItem* item, char* buffer,
118 	size_t bufferSize)
119 {
120 	return platform_generic_get_user_input_text(menu, item, buffer,
121 		bufferSize);
122 }
123