1e2e1558aSJessica Hamilton/*
2e2e1558aSJessica Hamilton * Copyright 2016 Haiku, Inc. All rights reserved.
3e2e1558aSJessica Hamilton * Distributed under the terms of the MIT License.
4e2e1558aSJessica Hamilton */
5e2e1558aSJessica Hamilton
6e2e1558aSJessica Hamilton
7e2e1558aSJessica Hamilton#include <boot/menu.h>
8e2e1558aSJessica Hamilton#include <boot/platform/generic/text_menu.h>
998a4ebbeSAugustin Cavalier#include <safemode.h>
10e2e1558aSJessica Hamilton
11e2e1558aSJessica Hamilton#include "efi_platform.h"
12445b080eSJessica Hamilton#include "video.h"
1398a4ebbeSAugustin Cavalier#include "smp.h"
14e2e1558aSJessica Hamilton
15e2e1558aSJessica Hamilton
16e2e1558aSJessica Hamiltonvoid
17e2e1558aSJessica Hamiltonplatform_add_menus(Menu *menu)
18e2e1558aSJessica Hamilton{
19445b080eSJessica Hamilton	MenuItem *item;
20445b080eSJessica Hamilton
21445b080eSJessica Hamilton	switch (menu->Type()) {
22445b080eSJessica Hamilton		case MAIN_MENU:
23445b080eSJessica Hamilton			item = new(std::nothrow)MenuItem("Select video mode", video_mode_menu());
24445b080eSJessica Hamilton			if (item != NULL) {
25445b080eSJessica Hamilton				menu->AddItem(item);
26445b080eSJessica Hamilton				item->SetTarget(video_mode_hook);
27445b080eSJessica Hamilton				item->SetShortcut('v');
28445b080eSJessica Hamilton			}
29445b080eSJessica Hamilton
30445b080eSJessica Hamilton			break;
3198a4ebbeSAugustin Cavalier
3298a4ebbeSAugustin Cavalier		case SAFE_MODE_MENU:
3398a4ebbeSAugustin Cavalier			item = new(std::nothrow) MenuItem("Use fail-safe graphics driver");
3498a4ebbeSAugustin Cavalier			if (item != NULL) {
3598a4ebbeSAugustin Cavalier				menu->AddItem(item);
3698a4ebbeSAugustin Cavalier				item->SetType(MENU_ITEM_MARKABLE);
3798a4ebbeSAugustin Cavalier				item->SetData(B_SAFEMODE_FAIL_SAFE_VIDEO_MODE);
3898a4ebbeSAugustin Cavalier				item->SetHelpText("The system will use VESA mode "
3998a4ebbeSAugustin Cavalier					"and won't try to use any video graphics drivers.");
4098a4ebbeSAugustin Cavalier			}
4198a4ebbeSAugustin Cavalier
4298a4ebbeSAugustin Cavalier			smp_add_safemode_menus(menu);
4398a4ebbeSAugustin Cavalier
4498a4ebbeSAugustin Cavalier			item = new(std::nothrow) MenuItem("Disable ACPI");
4598a4ebbeSAugustin Cavalier			if (item != NULL) {
4698a4ebbeSAugustin Cavalier				menu->AddItem(item);
4798a4ebbeSAugustin Cavalier				item->SetType(MENU_ITEM_MARKABLE);
4898a4ebbeSAugustin Cavalier				item->SetData(B_SAFEMODE_DISABLE_ACPI);
4998a4ebbeSAugustin Cavalier				item->SetHelpText("Disables Advanced Configuration and Power "
5098a4ebbeSAugustin Cavalier					"Interface hardware support, overriding the ACPI setting "
5198a4ebbeSAugustin Cavalier					"in the kernel settings file.");
5298a4ebbeSAugustin Cavalier			}
5398a4ebbeSAugustin Cavalier			break;
5498a4ebbeSAugustin Cavalier
55445b080eSJessica Hamilton		default:
56445b080eSJessica Hamilton			break;
57445b080eSJessica Hamilton	}
58e2e1558aSJessica Hamilton}
59e2e1558aSJessica Hamilton
60e2e1558aSJessica Hamilton
61e2e1558aSJessica Hamiltonvoid
62e2e1558aSJessica Hamiltonplatform_update_menu_item(Menu *menu, MenuItem *item)
63e2e1558aSJessica Hamilton{
64e2e1558aSJessica Hamilton	platform_generic_update_text_menu_item(menu, item);
65e2e1558aSJessica Hamilton}
66e2e1558aSJessica Hamilton
67e2e1558aSJessica Hamilton
68e2e1558aSJessica Hamiltonvoid
69e2e1558aSJessica Hamiltonplatform_run_menu(Menu *menu)
70e2e1558aSJessica Hamilton{
71e2e1558aSJessica Hamilton	platform_generic_run_text_menu(menu);
72e2e1558aSJessica Hamilton}
73e2e1558aSJessica Hamilton
74e2e1558aSJessica Hamilton
75e2e1558aSJessica Hamiltonsize_t
76e2e1558aSJessica Hamiltonplatform_get_user_input_text(Menu *menu, MenuItem *item, char *buffer,
77e2e1558aSJessica Hamilton	size_t bufferSize)
78e2e1558aSJessica Hamilton{
79e2e1558aSJessica Hamilton	return platform_generic_get_user_input_text(menu, item, buffer,
80e2e1558aSJessica Hamilton		bufferSize);
81e2e1558aSJessica Hamilton}
82