blob: 78be422b083c3cfd983af201aadc2ff054fefc23 [file] [log] [blame]
Stefan Reinauer9aea04a2012-03-30 12:01:06 -07001/*
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#ifndef __CHROMEOS_H__
21#define __CHROMEOS_H__
22
Aaron Durbin790e3ad2014-01-27 15:08:27 -060023#include <stddef.h>
Aaron Durbinfd795622013-03-01 17:12:26 -060024#include <stdint.h>
Kyösti Mälkki5687fc92013-11-28 18:11:49 +020025#include <bootmode.h>
Aaron Durbin818e9282015-04-21 15:23:41 -050026#include <rules.h>
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070027#include "vboot_common.h"
28#include "vboot2/misc.h"
Aaron Durbinfd795622013-03-01 17:12:26 -060029
Aaron Durbin818e9282015-04-21 15:23:41 -050030#if ENV_ROMSTAGE
31void save_chromeos_gpios(void);
32#endif
33
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070034/* functions implemented in vbnv.c: */
35int get_recovery_mode_from_vbnv(void);
Bill Richardson0a405ba2012-06-26 16:33:45 -070036int vboot_wants_oprom(void);
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070037
Aaron Durbinfd795622013-03-01 17:12:26 -060038void read_vbnv(uint8_t *vbnv_copy);
39void save_vbnv(const uint8_t *vbnv_copy);
40
Duncan Laurie203e8ce2014-04-22 10:52:31 -070041#if CONFIG_CHROMEOS
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070042/* functions implemented in vboot.c */
43void init_chromeos(int bootmode);
David Hendricks739e6a82014-05-13 20:28:49 -070044
45/* functions implemented in elog.c */
46void elog_add_boot_reason(void);
Julius Werner105f5b72015-01-21 17:39:49 -080047
48/* functions implemented in watchdog.c */
49void elog_add_watchdog_reset(void);
50void reboot_from_watchdog(void);
Patrick Georgib69b05d2015-04-22 15:10:59 +020051
52int vboot_enable_developer(void);
53int vboot_enable_recovery(void);
54int vboot_skip_display_init(void);
Duncan Laurie203e8ce2014-04-22 10:52:31 -070055#else
56static inline void init_chromeos(int bootmode) { }
David Hendricks739e6a82014-05-13 20:28:49 -070057static inline void elog_add_boot_reason(void) { return; }
Julius Werner105f5b72015-01-21 17:39:49 -080058static inline void elog_add_watchdog_reset(void) { return; }
59static inline void reboot_from_watchdog(void) { return; }
Patrick Georgib69b05d2015-04-22 15:10:59 +020060static inline int vboot_skip_display_init(void) { return 0; }
Duncan Laurie203e8ce2014-04-22 10:52:31 -070061#endif /* CONFIG_CHROMEOS */
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070062
Aaron Durbin168b0f92013-10-10 20:58:57 -050063struct romstage_handoff;
Shawn Nematbakhsh229ad272014-03-14 13:57:32 -070064
Daisuke Nojiribcc1d422014-06-19 19:16:24 -070065#if CONFIG_VBOOT_VERIFY_FIRMWARE || CONFIG_VBOOT2_VERIFY_FIRMWARE
Aaron Durbindd32a312013-03-07 23:15:06 -060066/* Returns 0 on success < 0 on error. */
67int vboot_get_handoff_info(void **addr, uint32_t *size);
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070068void *vboot_get_payload(int *len);
69#else /* CONFIG_VBOOT_VERIFY_FIRMWARE || CONFIG_VBOOT2_VERIFY_FIRMWARE */
Aaron Durbin168b0f92013-10-10 20:58:57 -050070static inline void vboot_verify_firmware(struct romstage_handoff *h) {}
Aaron Durbine742dda2014-02-04 12:38:41 -060071static inline void *vboot_get_payload(int *len) { return NULL; }
72static inline int vboot_get_handoff_info(void **addr, uint32_t *size)
73{
74 return -1;
75}
Daisuke Nojiribcc1d422014-06-19 19:16:24 -070076#endif /* CONFIG_VBOOT_VERIFY_FIRMWARE || CONFIG_VBOOT2_VERIFY_FIRMWARE */
77
Shawn Nematbakhsh229ad272014-03-14 13:57:32 -070078int vboot_get_sw_write_protect(void);
Aaron Durbinfd795622013-03-01 17:12:26 -060079
Aaron Durbin06ece7d2014-02-14 00:30:04 -060080#include "gnvs.h"
81struct device;
82
Aaron Durbin59674d22014-03-05 17:25:22 -060083#if CONFIG_CHROMEOS_RAMOOPS
Aaron Durbin06ece7d2014-02-14 00:30:04 -060084void chromeos_ram_oops_init(chromeos_acpi_t *chromeos);
85#if CONFIG_CHROMEOS_RAMOOPS_DYNAMIC
86static inline void chromeos_reserve_ram_oops(struct device *dev, int idx) {}
87#else /* CONFIG_CHROMEOS_RAMOOPS_DYNAMIC */
88void chromeos_reserve_ram_oops(struct device *dev, int idx);
89#endif /* CONFIG_CHROMEOS_RAMOOPS_DYNAMIC */
90#else /* !CONFIG_CHROMEOS_RAMOOPS */
91static inline void chromeos_ram_oops_init(chromeos_acpi_t *chromeos) {}
92static inline void chromeos_reserve_ram_oops(struct device *dev, int idx) {}
93#endif /* CONFIG_CHROMEOS_RAMOOPS */
94
Vadim Bendebury318708d2014-10-23 16:02:51 -070095void cbmem_add_vpd_calibration_data(void);
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070096void vboot_reboot(void);
Vadim Bendebury318708d2014-10-23 16:02:51 -070097
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070098#endif /* __CHROMEOS_H__ */