Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Duncan Laurie | d8c4f2b | 2014-04-22 10:46:06 -0700 | [diff] [blame] | 4 | * Copyright (C) 2014 Google Inc. |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 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. |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
Duncan Laurie | d8c4f2b | 2014-04-22 10:46:06 -0700 | [diff] [blame] | 16 | #ifndef _COMMON_MRC_CACHE_H_ |
| 17 | #define _COMMON_MRC_CACHE_H_ |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 18 | |
| 19 | #include <stddef.h> |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | /* Wrapper object to save MRC information. */ |
| 23 | struct mrc_saved_data { |
| 24 | uint32_t signature; |
| 25 | uint32_t size; |
| 26 | uint32_t checksum; |
Aaron Durbin | bc6e7c0 | 2015-12-09 15:04:49 -0600 | [diff] [blame] | 27 | uint32_t version; |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 28 | uint8_t data[0]; |
| 29 | } __attribute__((packed)); |
| 30 | |
| 31 | /* Locate the most recently saved MRC data. */ |
| 32 | int mrc_cache_get_current(const struct mrc_saved_data **cache); |
Aaron Durbin | bc6e7c0 | 2015-12-09 15:04:49 -0600 | [diff] [blame] | 33 | int mrc_cache_get_current_with_version(const struct mrc_saved_data **cache, |
| 34 | uint32_t version); |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 35 | |
| 36 | /* Stash the resulting MRC data to be saved in non-volatile storage later. */ |
Alexandru Gagniuc | 1116fa8 | 2016-03-04 14:38:19 -0800 | [diff] [blame] | 37 | int mrc_cache_stash_data(const void *data, size_t size); |
| 38 | int mrc_cache_stash_data_with_version(const void *data, size_t size, |
Aaron Durbin | bc6e7c0 | 2015-12-09 15:04:49 -0600 | [diff] [blame] | 39 | uint32_t version); |
Duncan Laurie | d8c4f2b | 2014-04-22 10:46:06 -0700 | [diff] [blame] | 40 | |
| 41 | #endif /* _COMMON_MRC_CACHE_H_ */ |