blob: a2f0b4c9781d9937b3d5f8f88052029048da8f28 [file] [log] [blame]
Duncan Laurie88b28ad2016-01-25 17:13:27 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Google Inc.
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
Furquan Shaikh2a12e2e2016-07-25 11:48:03 -070016#ifndef __VBOOT_VBNV_H__
17#define __VBOOT_VBNV_H__
Duncan Laurie88b28ad2016-01-25 17:13:27 -080018
19#include <types.h>
20
21/* Generic functions */
Furquan Shaikhbe87f732016-06-29 11:26:27 -070022void read_vbnv(uint8_t *vbnv_copy);
Duncan Laurie88b28ad2016-01-25 17:13:27 -080023void save_vbnv(const uint8_t *vbnv_copy);
24int verify_vbnv(uint8_t *vbnv_copy);
Hung-Te Linfe2fc832016-12-29 20:59:37 +080025void regen_vbnv_crc(uint8_t *vbnv_copy);
Duncan Laurie88b28ad2016-01-25 17:13:27 -080026int get_recovery_mode_from_vbnv(void);
27void set_recovery_mode_into_vbnv(int recovery_reason);
Furquan Shaikh37c721d2018-04-25 18:13:03 -070028
29/* Read the USB Device Controller(UDC) enable flag from VBNV. */
30int vbnv_udc_enable_flag(void);
31
Aaron Durbin118a84f2017-09-15 11:15:07 -060032/* Initialize and read vbnv. This is used in the main vboot logic path. */
33void vbnv_init(uint8_t *vbnv_copy);
Aaron Durbinfe265a12017-09-15 11:17:38 -060034/* Reset vbnv snapshot to a known state. */
35void vbnv_reset(uint8_t *vbnv_copy);
Duncan Laurie88b28ad2016-01-25 17:13:27 -080036
37/* CMOS backend */
Aaron Durbin0990fbf2017-09-15 15:23:04 -060038/* Initialize the vbnv cmos backing store. The vbnv_copy pointer is used for
39 optional temporary storage in the init function. */
40void vbnv_init_cmos(uint8_t *vbnv_copy);
41/* Return non-zero if cmos power was lost. */
42int vbnv_cmos_failed(void);
Duncan Laurie88b28ad2016-01-25 17:13:27 -080043void read_vbnv_cmos(uint8_t *vbnv_copy);
44void save_vbnv_cmos(const uint8_t *vbnv_copy);
Duncan Laurie88b28ad2016-01-25 17:13:27 -080045
46/* Flash backend */
47void read_vbnv_flash(uint8_t *vbnv_copy);
48void save_vbnv_flash(const uint8_t *vbnv_copy);
49
50/* EC backend */
51void read_vbnv_ec(uint8_t *vbnv_copy);
52void save_vbnv_ec(const uint8_t *vbnv_copy);
53
Furquan Shaikh2a12e2e2016-07-25 11:48:03 -070054#endif /* __VBOOT_VBNV_H__ */