Aaron Durbin (adurbin(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10261
-gerrit
commit e262b6e6bcd293c8fad511e837c7a6b3bb2772f5
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Tue May 19 16:25:20 2015 -0500
prog_loading: add region_device representing memory
One can remove the struct buffer_area and use the region_device
embedded in the struct prog to represent the in-memory loaded
program. Do this by introducing a addrspace_32bit mem_region_device
that can have region_device operations performed on it. The
addrspace_32bit name was chosen to make it explicit that 32-bits
of address space is supported at the max.
Change-Id: Ifffa0ef301141de940e54581b5a7b6cd81311ead
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/include/program_loading.h | 34 ++++++++++++++++++----------------
src/lib/prog_loaders.c | 3 +++
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index 05f5e3e..d8e7de3 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -34,11 +34,6 @@ enum {
* set on the last segment loaded. */
void arch_segment_loaded(uintptr_t start, size_t size, int flags);
-struct buffer_area {
- void *data;
- size_t size;
-};
-
enum prog_type {
PROG_VERSTAGE,
PROG_ROMSTAGE,
@@ -51,28 +46,27 @@ enum prog_type {
struct prog {
enum prog_type type;
const char *name;
- /* Source of program content to load. */
+ /* Source of program content to load. After loading program it
+ * represents the memory region of the stages and payload. For
+ * achitectures that use a bounce buffer then it would represent
+ * the bounce buffer. */
struct region_device rdev;
- /* The area can mean different things depending on what type the
- * program is. A stage after being loaded reflects the memory occupied
- * by the program, Since payloads are multi-segment one can't express
- * the memory layout with one range. Instead this field is updated
- * to reflect the bounce buffer used. */
- struct buffer_area area;
/* Entry to program with optional argument. It's up to the architecture
* to decide if argument is passed. */
void (*entry)(void *);
void *arg;
};
+/* Only valid for loaded programs. */
static inline size_t prog_size(const struct prog *prog)
{
- return prog->area.size;
+ return region_device_sz(&prog->rdev);
}
+/* Only valid for loaded programs. */
static inline void *prog_start(const struct prog *prog)
{
- return prog->area.data;
+ return rdev_mmap_full(&prog->rdev);
}
static inline void *prog_entry(const struct prog *prog)
@@ -85,10 +79,18 @@ static inline void *prog_entry_arg(const struct prog *prog)
return prog->arg;
}
+/* 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)
+{
+ rdev_chain(&prog->rdev, &addrspace_32bit.rdev, ptr, size);
+}
+
static inline void prog_set_area(struct prog *prog, void *start, size_t size)
{
- prog->area.data = start;
- prog->area.size = size;
+ prog_memory_init(prog, (uintptr_t)start, size);
}
static inline void prog_set_entry(struct prog *prog, void *e, void *arg)
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c
index 881cd99..7799994 100644
--- a/src/lib/prog_loaders.c
+++ b/src/lib/prog_loaders.c
@@ -35,6 +35,9 @@
#include <symbols.h>
#include <timestamp.h>
+/* Only can represent up to 1 byte less than size_t. */
+const struct mem_region_device addrspace_32bit = MEM_REGION_DEV_INIT(0, ~0UL);
+
#define DEFAULT_CBFS_LOADER_PRESENT \
(!ENV_VERSTAGE || (ENV_VERSTAGE && !CONFIG_RETURN_FROM_VERSTAGE))
the following patch was just integrated into master:
commit b4ae5fd107248a51e63474c67afc092d521358c1
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Tue May 19 15:51:47 2015 -0500
riscv: enable function and data sections
Every other arch we support has these options enabled.
Enable it to make everything a lot easier in compiling common
code.
Change-Id: I86205468bbd793fbd377e471a1d32be617af5302
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
Reviewed-on: http://review.coreboot.org/10258
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones(a)se-eng.com>
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
See http://review.coreboot.org/10258 for details.
-gerrit