blob: ba8827dad61f08aef1a06b1e4d190b660d64322e [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbinbd74a4b2015-03-06 23:17:33 -06002
3#ifndef _STAGE_CACHE_H_
4#define _STAGE_CACHE_H_
5
6#include <stddef.h>
7#include <stdint.h>
8#include <program_loading.h>
9
Marshall Dawson8d6e0e02018-01-30 15:33:23 -070010/* Types of stages that may be stored in stage cache */
Aaron Durbinbd74a4b2015-03-06 23:17:33 -060011enum {
12 STAGE_RAMSTAGE,
13 STAGE_REFCODE,
Aaron Durbind0084132016-11-29 15:52:08 -060014 STAGE_POSTCAR,
Aaron Durbinbd74a4b2015-03-06 23:17:33 -060015};
16
Marshall Dawson8d6e0e02018-01-30 15:33:23 -070017/* Types of raw data that may be stored in stage cache */
18enum {
19 STAGE_S3_DATA,
20};
21
Kyösti Mälkki0a4457f2019-08-01 20:29:14 +030022#if CONFIG(TSEG_STAGE_CACHE) || CONFIG(CBMEM_STAGE_CACHE)
Aaron Durbinbd74a4b2015-03-06 23:17:33 -060023/* Cache the loaded stage provided according to the parameters. */
Aaron Durbin54546c92015-08-05 00:52:13 -050024void stage_cache_add(int stage_id, const struct prog *stage);
Subrata Banik90f750b2019-06-11 17:52:06 +053025/* Load the cached stage at given location returning the stage entry point. */
26void stage_cache_load_stage(int stage_id, struct prog *stage);
Marshall Dawson8d6e0e02018-01-30 15:33:23 -070027/* Cache non-specific data or code. */
28void stage_cache_add_raw(int stage_id, const void *base, const size_t size);
29/* Get a pointer to cached raw data and its size. */
30void stage_cache_get_raw(int stage_id, void **base, size_t *size);
Kyösti Mälkkic47c6402019-08-01 08:56:35 +030031
32#else /* CONFIG_NO_STAGE_CACHE */
33
34static inline void stage_cache_add(int stage_id, const struct prog *stage) {}
35static inline void stage_cache_load_stage(int stage_id, struct prog *stage) {}
36static inline void stage_cache_add_raw(int stage_id, const void *base, const size_t size) {}
37static inline void stage_cache_get_raw(int stage_id, void **base, size_t *size) {}
38
39#endif
40
Aaron Durbinbd74a4b2015-03-06 23:17:33 -060041/* Fill in parameters for the external stage cache, if utilized. */
42void stage_cache_external_region(void **base, size_t *size);
43
44/* Metadata associated with each stage. */
45struct stage_cache {
46 uint64_t load_addr;
47 uint64_t entry_addr;
Kyösti Mälkkid87e4b32017-09-05 22:43:05 +030048 uint64_t arg;
Aaron Durbinbd74a4b2015-03-06 23:17:33 -060049};
50
51#endif /* _STAGE_CACHE_H_ */