blob: 9b14c1efd88ade863797694765c593eca66eb777 [file] [log] [blame]
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05001/*
2 * This file is part of the coreboot project.
3 *
Duncan Lauried8c4f2b2014-04-22 10:46:06 -07004 * Copyright (C) 2014 Google Inc.
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05005 *
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.
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050014 */
15
Duncan Lauried8c4f2b2014-04-22 10:46:06 -070016#ifndef _COMMON_MRC_CACHE_H_
17#define _COMMON_MRC_CACHE_H_
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050018
19#include <stddef.h>
20#include <stdint.h>
21
22/* Wrapper object to save MRC information. */
23struct mrc_saved_data {
24 uint32_t signature;
25 uint32_t size;
26 uint32_t checksum;
Aaron Durbinbc6e7c02015-12-09 15:04:49 -060027 uint32_t version;
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050028 uint8_t data[0];
29} __attribute__((packed));
30
31/* Locate the most recently saved MRC data. */
32int mrc_cache_get_current(const struct mrc_saved_data **cache);
Aaron Durbinbc6e7c02015-12-09 15:04:49 -060033int mrc_cache_get_current_with_version(const struct mrc_saved_data **cache,
34 uint32_t version);
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050035
36/* Stash the resulting MRC data to be saved in non-volatile storage later. */
Alexandru Gagniuc1116fa82016-03-04 14:38:19 -080037int mrc_cache_stash_data(const void *data, size_t size);
38int mrc_cache_stash_data_with_version(const void *data, size_t size,
Aaron Durbinbc6e7c02015-12-09 15:04:49 -060039 uint32_t version);
Duncan Lauried8c4f2b2014-04-22 10:46:06 -070040
41#endif /* _COMMON_MRC_CACHE_H_ */