summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-02-08 17:05:36 -0600
committerRonald G. Minnich <rminnich@gmail.com>2013-03-21 17:53:20 +0100
commite8c866ad45d80de768c9422474449e171d133575 (patch)
tree7e302c3f0378fe87fa5c967d23f3059c0347ae4f /src/include
parent426ce4192bd127ceaab52d94468b66d718608572 (diff)
rmodule: add ability to calculate module placement
There is a need to calculate the proper placement for an rmodule in memory. e.g. loading a compressed rmodule from flash into ram can be an issue. Determining the placement is hard since the header is not readable until it is decompressed so choosing the wrong location may require a memmove() after decompression. This patch provides a function to perform this calculation by finding region below a given address while making an assumption on the size of the rmodule header.. Change-Id: I2703438f58ae847ed6e80b58063ff820fbcfcbc0 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/2788 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/rmodule.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/include/rmodule.h b/src/include/rmodule.h
index 5300c63766..2d8fc0fdc8 100644
--- a/src/include/rmodule.h
+++ b/src/include/rmodule.h
@@ -20,6 +20,7 @@
#define RMODULE_H
#include <stdint.h>
+#include <stddef.h>
#define RMODULE_MAGIC 0xf8fe
#define RMODULE_VERSION_1 1
@@ -40,6 +41,13 @@ int rmodule_entry_offset(const struct rmodule *m);
int rmodule_memory_size(const struct rmodule *m);
int rmodule_load(void *loc, struct rmodule *m);
int rmodule_load_alignment(const struct rmodule *m);
+/* Returns the an aligned pointer that reflects a region used below addr
+ * based on the rmodule_size. i.e. the returned pointer up to addr is memory
+ * that may be utilized by the rmodule. program_start and rmodule_start
+ * are pointers updated to reflect where the rmodule program starts and where
+ * the rmodule (including header) should be placed respectively. */
+void *rmodule_find_region_below(void *addr, size_t rmodule_size,
+ void **program_start, void **rmodule_start);
#define FIELD_ENTRY(x_) ((u32)&x_)
#define RMODULE_HEADER(entry_, type_) \