Kyösti Mälkki | 5687fc9 | 2013-11-28 18:11:49 +0200 | [diff] [blame] | 1 | /* |
| 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älkki | 5687fc9 | 2013-11-28 18:11:49 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
Kyösti Mälkki | ab56b3b | 2013-11-28 16:44:51 +0200 | [diff] [blame] | 16 | #include <rules.h> |
Kyösti Mälkki | 5687fc9 | 2013-11-28 18:11:49 +0200 | [diff] [blame] | 17 | #include <bootmode.h> |
Kyösti Mälkki | 5687fc9 | 2013-11-28 18:11:49 +0200 | [diff] [blame] | 18 | #include <vendorcode/google/chromeos/chromeos.h> |
Kyösti Mälkki | 5687fc9 | 2013-11-28 18:11:49 +0200 | [diff] [blame] | 19 | |
| 20 | #if CONFIG_BOOTMODE_STRAPS |
| 21 | int 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 | */ |
| 44 | int 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älkki | ab56b3b | 2013-11-28 16:44:51 +0200 | [diff] [blame] | 59 | |
| 60 | #if ENV_RAMSTAGE |
| 61 | static int gfx_init_done = -1; |
| 62 | |
| 63 | int gfx_get_init_done(void) |
| 64 | { |
| 65 | if (gfx_init_done < 0) |
| 66 | return 0; |
| 67 | return gfx_init_done; |
| 68 | } |
| 69 | |
| 70 | void gfx_set_init_done(int done) |
| 71 | { |
| 72 | gfx_init_done = done; |
| 73 | } |
| 74 | #endif |
Aaron Durbin | bc98cc6 | 2015-09-02 09:21:36 -0500 | [diff] [blame] | 75 | |
| 76 | int 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 | } |