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>
This commit is contained in:
Aaron Durbin
2013-02-08 17:05:36 -06:00
committed by Ronald G. Minnich
parent 426ce4192b
commit e8c866ad45
2 changed files with 59 additions and 0 deletions

View File

@@ -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_) \