summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-09-03 21:17:20 -0700
committerPatrick Georgi <pgeorgi@google.com>2021-03-17 08:05:51 +0000
commit2e973942bc34ff2d7b110ba35bf3cda987838907 (patch)
tree95a3c6d99491ab15a4d2c677f17edcfb5005d54d /src/include
parent8e15e91dc4f397371c5ce04a4945945468059953 (diff)
downloadcoreboot-2e973942bc34ff2d7b110ba35bf3cda987838907.tar.xz
program_loading: Replace prog_rdev() with raw start pointer and size
Since prog_locate() was eliminated, prog_rdev() only ever represents the loaded program in memory now. Using the rdev API for this is unnecessary if we know that the "device" is always just memory. This patch changes it to be represented by a simple pointer and size. Since some code still really wants this to be an rdev, introduce a prog_chain_rdev() helper to translate back to that if necessary. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: If7c0f1c5698fa0c326e23c553ea0fe928b25d202 Reviewed-on: https://review.coreboot.org/c/coreboot/+/46483 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/program_loading.h34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index bb4f6ea1d2..d01eff64d8 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -41,17 +41,13 @@ void arch_segment_loaded(uintptr_t start, size_t size, int flags);
/* Representation of a program. */
struct prog {
- /* The region_device represents the memory region of the stages and
- * payload. For architectures that use a bounce buffer
- * then it would represent the bounce buffer. */
enum prog_type type;
enum cbfs_type cbfs_type;
const char *name;
- struct region_device rdev;
- /* Entry to program with optional argument. It's up to the architecture
- * to decide if argument is passed. */
- void (*entry)(void *);
- void *arg;
+ void *start; /* Program start in memory. */
+ size_t size; /* Program size in memory (including BSS). */
+ void (*entry)(void *); /* Function pointer to entry point. */
+ void *arg; /* Optional argument (only valid for some archs). */
};
#define PROG_INIT(type_, name_) \
@@ -75,21 +71,14 @@ static inline enum cbfs_type prog_cbfs_type(const struct prog *prog)
return prog->cbfs_type;
}
-static inline struct region_device *prog_rdev(struct prog *prog)
-{
- return &prog->rdev;
-}
-
-/* Only valid for loaded programs. */
static inline size_t prog_size(const struct prog *prog)
{
- return region_device_sz(&prog->rdev);
+ return prog->size;
}
-/* Only valid for loaded programs. */
static inline void *prog_start(const struct prog *prog)
{
- return rdev_mmap_full(&prog->rdev);
+ return prog->start;
}
static inline void *prog_entry(const struct prog *prog)
@@ -105,15 +94,18 @@ static inline void *prog_entry_arg(const struct prog *prog)
/* region_device representing the 32-bit flat address space. */
extern const struct mem_region_device addrspace_32bit;
-static inline void prog_memory_init(struct prog *prog, uintptr_t ptr,
- size_t size)
+/* Can be used to get an rdev representation of program area in memory. */
+static inline void prog_chain_rdev(const struct prog *prog,
+ struct region_device *rdev_out)
{
- rdev_chain(&prog->rdev, &addrspace_32bit.rdev, ptr, size);
+ rdev_chain(rdev_out, &addrspace_32bit.rdev,
+ (uintptr_t)prog->start, prog->size);
}
static inline void prog_set_area(struct prog *prog, void *start, size_t size)
{
- prog_memory_init(prog, (uintptr_t)start, size);
+ prog->start = start;
+ prog->size = size;
}
static inline void prog_set_entry(struct prog *prog, void *e, void *arg)