Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2015 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. |
Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef _STAGE_CACHE_H_ |
| 17 | #define _STAGE_CACHE_H_ |
| 18 | |
| 19 | #include <stddef.h> |
| 20 | #include <stdint.h> |
| 21 | #include <program_loading.h> |
| 22 | |
Marshall Dawson | 8d6e0e0 | 2018-01-30 15:33:23 -0700 | [diff] [blame] | 23 | /* Types of stages that may be stored in stage cache */ |
Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 24 | enum { |
| 25 | STAGE_RAMSTAGE, |
| 26 | STAGE_REFCODE, |
Aaron Durbin | d008413 | 2016-11-29 15:52:08 -0600 | [diff] [blame] | 27 | STAGE_POSTCAR, |
Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 28 | }; |
| 29 | |
Marshall Dawson | 8d6e0e0 | 2018-01-30 15:33:23 -0700 | [diff] [blame] | 30 | /* Types of raw data that may be stored in stage cache */ |
| 31 | enum { |
| 32 | STAGE_S3_DATA, |
| 33 | }; |
| 34 | |
Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 35 | /* Cache the loaded stage provided according to the parameters. */ |
Aaron Durbin | 54546c9 | 2015-08-05 00:52:13 -0500 | [diff] [blame] | 36 | void stage_cache_add(int stage_id, const struct prog *stage); |
Marshall Dawson | 8d6e0e0 | 2018-01-30 15:33:23 -0700 | [diff] [blame] | 37 | /* Cache non-specific data or code. */ |
| 38 | void stage_cache_add_raw(int stage_id, const void *base, const size_t size); |
| 39 | /* Get a pointer to cached raw data and its size. */ |
| 40 | void stage_cache_get_raw(int stage_id, void **base, size_t *size); |
Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 41 | /* Load the cached stage at given location returning the stage entry point. */ |
| 42 | void stage_cache_load_stage(int stage_id, struct prog *stage); |
| 43 | /* Fill in parameters for the external stage cache, if utilized. */ |
| 44 | void stage_cache_external_region(void **base, size_t *size); |
| 45 | |
| 46 | /* Metadata associated with each stage. */ |
| 47 | struct stage_cache { |
| 48 | uint64_t load_addr; |
| 49 | uint64_t entry_addr; |
Kyösti Mälkki | d87e4b3 | 2017-09-05 22:43:05 +0300 | [diff] [blame] | 50 | uint64_t arg; |
Aaron Durbin | bd74a4b | 2015-03-06 23:17:33 -0600 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | #endif /* _STAGE_CACHE_H_ */ |