Documentation: Fix sphinx configuration
[coreboot.git] / src / include / rmodule.h
blob1925dcc951c2e9a8aa2a94024eeeb678b7b2da2f
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 <string.h>
8 #include <commonlib/rmodule-defs.h>
10 enum {
11 RMODULE_TYPE_SMM,
12 RMODULE_TYPE_SIPI_VECTOR,
13 RMODULE_TYPE_STAGE,
14 RMODULE_TYPE_VBOOT,
17 struct rmodule;
19 /* Public API for loading rmdoules. */
20 int rmodule_parse(void *ptr, struct rmodule *m);
21 void *rmodule_parameters(const struct rmodule *m);
22 void *rmodule_entry(const struct rmodule *m);
23 int rmodule_entry_offset(const struct rmodule *m);
24 int rmodule_memory_size(const struct rmodule *m);
25 int rmodule_load(void *loc, struct rmodule *m);
26 int rmodule_load_alignment(const struct rmodule *m);
27 /* rmodule_calc_region() calculates the region size, offset to place an
28 * rmodule in memory, and load address offset based off of a region allocator
29 * with an alignment of region_alignment. This function helps place an rmodule
30 * in the same location in RAM it will run from. The offset to place the
31 * rmodule into the region allocated of size region_size is returned. The
32 * load_offset is the address to load and relocate the rmodule.
33 * region_alignment must be a power of 2. */
34 int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
35 size_t *region_size, int *load_offset);
37 /* Support for loading rmodule stages. This API is only available when
38 * using dynamic cbmem because it uses the dynamic cbmem API to obtain
39 * the backing store region for the stage. */
40 struct prog;
42 struct rmod_stage_load {
43 uint32_t cbmem_id;
44 struct prog *prog;
45 void *params;
48 /* Both of the following functions return 0 on success, -1 on error. */
49 int rmodule_stage_load(struct rmod_stage_load *rsl);
51 struct rmodule {
52 void *location;
53 struct rmodule_header *header;
54 const void *payload;
55 int payload_size;
56 void *relocations;
59 #if CONFIG(RELOCATABLE_MODULES)
60 /* Rmodules have an entry point of named _start. */
61 #define RMODULE_ENTRY(entry_) \
62 void _start(void *) __attribute__((alias(STRINGIFY(entry_))))
63 #else
64 #define RMODULE_ENTRY(entry_)
65 #endif
67 #endif /* RMODULE_H */