blob: 8d9b095177773d9ed75a50e6c20f2f57e3d7f635 [file] [log] [blame]
Aaron Durbin75e29742013-10-10 20:37:04 -05001/*
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 Durbinbe251292013-12-12 10:10:52 -080023#include <stddef.h>
24#include <stdint.h>
Aaron Durbin75e29742013-10-10 20:37:04 -050025
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
35struct 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. */
44struct ramstage_cache *ramstage_cache_location(long *size);
45/* Chipset/Board function called when cache is invalid on resume. */
46void ramstage_cache_invalid(struct ramstage_cache *cache);
47
Aaron Durbinbe251292013-12-12 10:10:52 -080048static inline int ramstage_cache_is_valid(const struct ramstage_cache *c)
49{
50 return (c != NULL && c->magic == RAMSTAGE_CACHE_MAGIC);
51}
52
Aaron Durbin75e29742013-10-10 20:37:04 -050053#endif /* _RAMSTAGE_CACHE_ */