soc/intel/ptl: Update ME specification version to 21
[coreboot.git] / src / include / rmodule.h
blob72faecced70073de7e82cc347f3c1f3115cb24ea
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef RMODULE_H
3 #define RMODULE_H
5 #include <stdint.h>
6 #include <stddef.h>
7 #include <commonlib/rmodule-defs.h>
9 enum {
10 RMODULE_TYPE_SMM,
11 RMODULE_TYPE_SIPI_VECTOR,
12 RMODULE_TYPE_STAGE,
13 RMODULE_TYPE_VBOOT,
16 struct rmodule;
18 /* Public API for loading rmodules. */
19 int rmodule_parse(void *ptr, struct rmodule *m);
20 void *rmodule_parameters(const struct rmodule *m);
21 void *rmodule_entry(const struct rmodule *m);
22 int rmodule_entry_offset(const struct rmodule *m);
23 int rmodule_memory_size(const struct rmodule *m);
24 int rmodule_load(void *loc, struct rmodule *m);
25 int rmodule_load_alignment(const struct rmodule *m);
26 /* rmodule_calc_region() calculates the region size, offset to place an
27 * rmodule in memory, and load address offset based off of a region allocator
28 * with an alignment of region_alignment. This function helps place an rmodule
29 * in the same location in RAM it will run from. The offset to place the
30 * rmodule into the region allocated of size region_size is returned. The
31 * load_offset is the address to load and relocate the rmodule.
32 * region_alignment must be a power of 2. */
33 int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
34 size_t *region_size, int *load_offset);
36 /* Support for loading rmodule stages. This API is only available when
37 * using dynamic cbmem because it uses the dynamic cbmem API to obtain
38 * the backing store region for the stage. */
39 struct prog;
41 struct rmod_stage_load {
42 uint32_t cbmem_id;
43 struct prog *prog;
44 void *params;
47 /* Both of the following functions return 0 on success, -1 on error. */
48 int rmodule_stage_load(struct rmod_stage_load *rsl);
50 struct rmodule {
51 void *location;
52 struct rmodule_header *header;
53 const void *payload;
54 int payload_size;
55 void *relocations;
58 #if CONFIG(RELOCATABLE_MODULES)
59 /* Rmodules have an entry point of named _start. */
60 #define RMODULE_ENTRY(entry_) \
61 void _start(void *) __attribute__((alias(STRINGIFY(entry_))))
62 #else
63 #define RMODULE_ENTRY(entry_)
64 #endif
66 #endif /* RMODULE_H */