blob: c7048ddcd81bf32b855af6feba2020218c7b323e [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
Patrick Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070018 */
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
David Hendricks739e6a82014-05-13 20:28:49 -070042/* functions implemented in elog.c */
43void elog_add_boot_reason(void);
Julius Werner105f5b72015-01-21 17:39:49 -080044
45/* functions implemented in watchdog.c */
46void elog_add_watchdog_reset(void);
47void reboot_from_watchdog(void);
Patrick Georgib69b05d2015-04-22 15:10:59 +020048
49int vboot_enable_developer(void);
50int vboot_enable_recovery(void);
51int vboot_skip_display_init(void);
Duncan Laurie203e8ce2014-04-22 10:52:31 -070052#else
David Hendricks739e6a82014-05-13 20:28:49 -070053static inline void elog_add_boot_reason(void) { return; }
Julius Werner105f5b72015-01-21 17:39:49 -080054static inline void elog_add_watchdog_reset(void) { return; }
55static inline void reboot_from_watchdog(void) { return; }
Patrick Georgib69b05d2015-04-22 15:10:59 +020056static inline int vboot_skip_display_init(void) { return 0; }
Duncan Laurie203e8ce2014-04-22 10:52:31 -070057#endif /* CONFIG_CHROMEOS */
Stefan Reinauer9aea04a2012-03-30 12:01:06 -070058
Aaron Durbin168b0f92013-10-10 20:58:57 -050059struct romstage_handoff;
Shawn Nematbakhsh229ad272014-03-14 13:57:32 -070060
Aaron Durbin1124cec2015-04-22 10:41:42 -050061#if CONFIG_VBOOT_VERIFY_FIRMWARE
Aaron Durbindd32a312013-03-07 23:15:06 -060062/* Returns 0 on success < 0 on error. */
63int vboot_get_handoff_info(void **addr, uint32_t *size);
Aaron Durbin1124cec2015-04-22 10:41:42 -050064#else /* CONFIG_VBOOT_VERIFY_FIRMWARE */
Aaron Durbine742dda2014-02-04 12:38:41 -060065static inline int vboot_get_handoff_info(void **addr, uint32_t *size)
66{
67 return -1;
68}
Aaron Durbin1124cec2015-04-22 10:41:42 -050069#endif /* CONFIG_VBOOT_VERIFY_FIRMWARE */
Daisuke Nojiribcc1d422014-06-19 19:16:24 -070070
Shawn Nematbakhsh229ad272014-03-14 13:57:32 -070071int vboot_get_sw_write_protect(void);
Aaron Durbinfd795622013-03-01 17:12:26 -060072
Aaron Durbin06ece7d2014-02-14 00:30:04 -060073#include "gnvs.h"
74struct device;
75
Aaron Durbin59674d22014-03-05 17:25:22 -060076#if CONFIG_CHROMEOS_RAMOOPS
Aaron Durbin06ece7d2014-02-14 00:30:04 -060077void chromeos_ram_oops_init(chromeos_acpi_t *chromeos);
78#if CONFIG_CHROMEOS_RAMOOPS_DYNAMIC
79static inline void chromeos_reserve_ram_oops(struct device *dev, int idx) {}
80#else /* CONFIG_CHROMEOS_RAMOOPS_DYNAMIC */
81void chromeos_reserve_ram_oops(struct device *dev, int idx);
82#endif /* CONFIG_CHROMEOS_RAMOOPS_DYNAMIC */
83#else /* !CONFIG_CHROMEOS_RAMOOPS */
84static inline void chromeos_ram_oops_init(chromeos_acpi_t *chromeos) {}
85static inline void chromeos_reserve_ram_oops(struct device *dev, int idx) {}
86#endif /* CONFIG_CHROMEOS_RAMOOPS */
87
Vadim Bendebury318708d2014-10-23 16:02:51 -070088void cbmem_add_vpd_calibration_data(void);
Vadim Bendeburyc83687d2015-04-10 17:50:11 -070089void vboot_reboot(void);
Vadim Bendebury318708d2014-10-23 16:02:51 -070090
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070091#endif /* __CHROMEOS_H__ */