summaryrefslogtreecommitdiff
path: root/src/lib/selfboot.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-02-08 17:28:04 -0600
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-03-21 22:28:28 +0100
commit8e4a355773cc64a89b3fc4d79981cfb02bda7e66 (patch)
tree01a9e6d5fc66568fd5c318e5edf17d47e73f65e8 /src/lib/selfboot.c
parent43e4a80a92bf00540e4d9b0734eb53f32044226f (diff)
downloadcoreboot-8e4a355773cc64a89b3fc4d79981cfb02bda7e66.tar.xz
coreboot: introduce CONFIG_RELOCATABLE_RAMSTAGE
This patch adds an option to build the ramstage as a reloctable binary. It uses the rmodule library for the relocation. The main changes consist of the following: 1. The ramstage is loaded just under the cmbem space. 2. Payloads cannot be loaded over where ramstage is loaded. If a payload is attempted to load where the relocatable ramstage resides the load is aborted. 3. The memory occupied by the ramstage is reserved from the OS's usage using the romstage_handoff structure stored in cbmem. This region is communicated to ramstage by an CBMEM_ID_ROMSTAGE_INFO entry in cbmem. 4. There is no need to reserve cbmem space for the OS controlled memory for the resume path because the ramsage region has been reserved in #3. 5. Since no memory needs to be preserved in the wake path, the loading and begin of execution of a elf payload is straight forward. Change-Id: Ia66cf1be65c29fa25ca7bd9ea6c8f11d7eee05f5 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/2792 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@google.com>
Diffstat (limited to 'src/lib/selfboot.c')
-rw-r--r--src/lib/selfboot.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c
index f32bb814fb..f933142144 100644
--- a/src/lib/selfboot.c
+++ b/src/lib/selfboot.c
@@ -78,6 +78,16 @@ struct segment {
static unsigned long bounce_size, bounce_buffer;
+#if CONFIG_RELOCATABLE_RAMSTAGE
+static void get_bounce_buffer(struct lb_memory *mem, unsigned long req_size)
+{
+ /* When the ramstage is relocatable there is no need for a bounce
+ * buffer. All payloads should not overlap the ramstage.
+ */
+ bounce_buffer = ~0UL;
+ bounce_size = 0;
+}
+#else
static void get_bounce_buffer(struct lb_memory *mem, unsigned long req_size)
{
unsigned long lb_size;
@@ -114,6 +124,7 @@ static void get_bounce_buffer(struct lb_memory *mem, unsigned long req_size)
bounce_buffer = buffer;
bounce_size = req_size;
}
+#endif /* CONFIG_RELOCATABLE_RAMSTAGE */
static int valid_area(struct lb_memory *mem, unsigned long buffer,
unsigned long start, unsigned long len)
@@ -394,8 +405,13 @@ static int load_self_segments(
for(ptr = head->next; ptr != head; ptr = ptr->next) {
if (!overlaps_coreboot(ptr))
continue;
+#if CONFIG_RELOCATABLE_RAMSTAGE
+ /* payloads are required to not overlap ramstage. */
+ return 0;
+#else
if (ptr->s_dstaddr + ptr->s_memsz > bounce_high)
bounce_high = ptr->s_dstaddr + ptr->s_memsz;
+#endif
}
get_bounce_buffer(mem, bounce_high - lb_start);
if (!bounce_buffer) {