Aaron Durbin | 75e2974 | 2013-10-10 20:37:04 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 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 | * 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 _RAMSTAGE_CACHE_ |
| 21 | #define _RAMSTAGE_CACHE_ |
| 22 | |
Aaron Durbin | be25129 | 2013-12-12 10:10:52 -0800 | [diff] [blame] | 23 | #include <stddef.h> |
| 24 | #include <stdint.h> |
Aaron Durbin | 75e2974 | 2013-10-10 20:37:04 -0500 | [diff] [blame] | 25 | |
| 26 | /* This structure is saved along with the relocated ramstage program when |
| 27 | * CONFIG_RELOCATED_RAMSTAGE is employed. For x86, it can used to protect |
| 28 | * the integrity of the ramstage program on S3 resume by saving a copy of |
| 29 | * the relocated ramstage in SMM space with the assumption that the SMM region |
| 30 | * cannot be altered from the OS. The magic value just serves as a quick sanity |
| 31 | * check. */ |
| 32 | |
| 33 | #define RAMSTAGE_CACHE_MAGIC 0xf3c3a02a |
| 34 | |
| 35 | struct ramstage_cache { |
| 36 | uint32_t magic; |
| 37 | uint32_t entry_point; |
| 38 | uint32_t load_address; |
| 39 | uint32_t size; |
| 40 | char program[0]; |
| 41 | } __attribute__((packed)); |
| 42 | |
| 43 | /* Chipset/Board function for obtaining cache location and size. */ |
| 44 | struct ramstage_cache *ramstage_cache_location(long *size); |
| 45 | /* Chipset/Board function called when cache is invalid on resume. */ |
| 46 | void ramstage_cache_invalid(struct ramstage_cache *cache); |
| 47 | |
Aaron Durbin | be25129 | 2013-12-12 10:10:52 -0800 | [diff] [blame] | 48 | static inline int ramstage_cache_is_valid(const struct ramstage_cache *c) |
| 49 | { |
| 50 | return (c != NULL && c->magic == RAMSTAGE_CACHE_MAGIC); |
| 51 | } |
| 52 | |
Aaron Durbin | 75e2974 | 2013-10-10 20:37:04 -0500 | [diff] [blame] | 53 | #endif /* _RAMSTAGE_CACHE_ */ |