blob: 15f7a5a5e5ba5a15330f5e5a66eff1c9117a78c3 [file] [log] [blame]
Kyösti Mälkki5687fc92013-11-28 18:11:49 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
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.
Kyösti Mälkki5687fc92013-11-28 18:11:49 +020014 */
15
Kyösti Mälkkiab56b3b2013-11-28 16:44:51 +020016#include <rules.h>
Kyösti Mälkki5687fc92013-11-28 18:11:49 +020017#include <bootmode.h>
Kyösti Mälkki5687fc92013-11-28 18:11:49 +020018#include <vendorcode/google/chromeos/chromeos.h>
Kyösti Mälkki5687fc92013-11-28 18:11:49 +020019
20#if CONFIG_BOOTMODE_STRAPS
21int developer_mode_enabled(void)
22{
23 if (get_developer_mode_switch())
24 return 1;
25#if CONFIG_VBOOT_VERIFY_FIRMWARE
26 if (vboot_enable_developer())
27 return 1;
28#endif
29 return 0;
30}
31
32/*
33 * This is called in multiple places and has to detect
34 * recovery mode triggered from the EC and via shared
35 * recovery reason set with crossystem.
36 *
37 * If shared recovery reason is set:
38 * - before VbInit then get_recovery_mode_from_vbnv() is true
39 * - after VbInit then vboot_enable_recovery() is true
40 *
41 * Otherwise the mainboard handler for get_recovery_mode_switch()
42 * will detect recovery mode initiated by the EC.
43 */
44int recovery_mode_enabled(void)
45{
46 if (get_recovery_mode_switch())
47 return 1;
48#if CONFIG_CHROMEOS
49 if (get_recovery_mode_from_vbnv())
50 return 1;
51#endif
52#if CONFIG_VBOOT_VERIFY_FIRMWARE
53 if (vboot_enable_recovery())
54 return 1;
55#endif
56 return 0;
57}
58#endif /* CONFIG_BOOTMODE_STRAPS */
Kyösti Mälkkiab56b3b2013-11-28 16:44:51 +020059
60#if ENV_RAMSTAGE
61static int gfx_init_done = -1;
62
63int gfx_get_init_done(void)
64{
65 if (gfx_init_done < 0)
66 return 0;
67 return gfx_init_done;
68}
69
70void gfx_set_init_done(int done)
71{
72 gfx_init_done = done;
73}
74#endif
Aaron Durbinbc98cc62015-09-02 09:21:36 -050075
76int display_init_required(void)
77{
78 /* For Chrome OS always honor vboot_skip_display_init(). */
79 if (IS_ENABLED(CONFIG_CHROMEOS))
80 return !vboot_skip_display_init();
81
82 /* By default always initialize display. */
83 return 1;
84}