Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [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. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <stddef.h> |
| 21 | #include <string.h> |
| 22 | #include "chromeos.h" |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 23 | #include <boot/coreboot_tables.h> |
| 24 | #include <cbfs.h> |
| 25 | #include <cbmem.h> |
| 26 | #include <console/console.h> |
Daisuke Nojiri | 24d4dae | 2015-02-03 14:44:55 -0800 | [diff] [blame] | 27 | #include "vboot_handoff.h" |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 28 | |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 29 | static int vboot_enable_developer(void) |
| 30 | { |
| 31 | struct vboot_handoff *vbho; |
| 32 | |
| 33 | vbho = cbmem_find(CBMEM_ID_VBOOT_HANDOFF); |
| 34 | |
| 35 | if (vbho == NULL) { |
| 36 | printk(BIOS_ERR, "%s: Couldn't find vboot_handoff structure!\n", |
| 37 | __func__); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | return !!(vbho->init_params.out_flags & VB_INIT_OUT_ENABLE_DEVELOPER); |
| 42 | } |
| 43 | |
| 44 | static int vboot_enable_recovery(void) |
| 45 | { |
| 46 | struct vboot_handoff *vbho; |
| 47 | |
| 48 | vbho = cbmem_find(CBMEM_ID_VBOOT_HANDOFF); |
| 49 | |
| 50 | if (vbho == NULL) |
| 51 | return 0; |
| 52 | |
| 53 | return !!(vbho->init_params.out_flags & VB_INIT_OUT_ENABLE_RECOVERY); |
| 54 | } |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 55 | |
| 56 | int vboot_skip_display_init(void) |
| 57 | { |
| 58 | struct vboot_handoff *vbho; |
| 59 | |
| 60 | vbho = cbmem_find(CBMEM_ID_VBOOT_HANDOFF); |
| 61 | |
| 62 | if (vbho == NULL) |
| 63 | return 0; |
| 64 | |
| 65 | return !(vbho->init_params.out_flags & VB_INIT_OUT_ENABLE_DISPLAY); |
| 66 | } |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 67 | |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 68 | int __attribute__((weak)) clear_recovery_mode_switch(void) |
| 69 | { |
| 70 | // Can be implemented by a mainboard |
| 71 | return 0; |
| 72 | } |
| 73 | |
Julius Werner | 015f0ae | 2014-09-15 22:10:33 -0700 | [diff] [blame] | 74 | #ifdef __ROMSTAGE__ |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 75 | void __attribute__((weak)) save_chromeos_gpios(void) |
| 76 | { |
| 77 | // Can be implemented by a mainboard |
| 78 | } |
| 79 | |
| 80 | int __attribute((weak)) vboot_get_sw_write_protect(void) |
| 81 | { |
| 82 | // Can be implemented by a platform / mainboard |
| 83 | return 0; |
| 84 | } |
| 85 | #endif |