aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2011-11-07 12:43:03 -0800
committerPatrick Georgi <patrick@georgi-clan.de>2011-11-08 12:25:26 +0100
commit19436298711a73d51fa54c76f6004703d25488a5 (patch)
tree229032d089222e053d2b17a252454192e59ab82c
parentdf073cb439b2acbe1d578f94be20ef983193b128 (diff)
selfboot: cleanup
- move cbfs_load_payload to the end so we can drop the prototype - move lb_start and lb_end to the beginning so they can be used in other functions. - drop two unused function declarations - break a 80+ characters line - fix a comment Change-Id: I460aa1e2ccf9d95ac12233af001076f73ab0268e Signed-off-by: Stefan Reinauer <reinauer@google.com> Reviewed-on: http://review.coreboot.org/424 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
-rw-r--r--src/boot/selfboot.c69
1 files changed, 29 insertions, 40 deletions
diff --git a/src/boot/selfboot.c b/src/boot/selfboot.c
index cdb1fa1bd7..573dd5ee5a 100644
--- a/src/boot/selfboot.c
+++ b/src/boot/selfboot.c
@@ -31,15 +31,18 @@
#include <cbfs.h>
#include <lib.h>
-/* Maximum physical address we can use for the coreboot bounce buffer.
- */
+/* Maximum physical address we can use for the coreboot bounce buffer. */
#ifndef MAX_ADDR
#define MAX_ADDR -1UL
#endif
+/* from coreboot_ram.ld: */
extern unsigned char _ram_seg;
extern unsigned char _eram_seg;
+static const unsigned long lb_start = (unsigned long)&_ram_seg;
+static const unsigned long lb_end = (unsigned long)&_eram_seg;
+
struct segment {
struct segment *next;
struct segment *prev;
@@ -52,36 +55,6 @@ struct segment {
int compression;
};
-struct verify_callback {
- struct verify_callback *next;
- int (*callback)(struct verify_callback *vcb,
- Elf_ehdr *ehdr, Elf_phdr *phdr, struct segment *head);
- unsigned long desc_offset;
- unsigned long desc_addr;
-};
-
-struct ip_checksum_vcb {
- struct verify_callback data;
- unsigned short ip_checksum;
-};
-
-static int selfboot(struct lb_memory *mem, struct cbfs_payload *payload);
-
-void * cbfs_load_payload(struct lb_memory *lb_mem, const char *name)
-{
- struct cbfs_payload *payload;
-
- payload = (struct cbfs_payload *)cbfs_find_file(name, CBFS_TYPE_PAYLOAD);
- if (payload == NULL)
- return (void *) -1;
- printk(BIOS_DEBUG, "Got a payload\n");
-
- selfboot(lb_mem, payload);
- printk(BIOS_EMERG, "SELFBOOT RETURNED!\n");
-
- return (void *) -1;
-}
-
/* The problem:
* Static executables all want to share the same addresses
* in memory because only a few addresses are reliably present on
@@ -100,7 +73,6 @@ void * cbfs_load_payload(struct lb_memory *lb_mem, const char *name)
* - Coreboot is preserved, so it can be returned to.
* - The implementation is still relatively simple,
* and much simpler than the general case implemented in kexec.
- *
*/
static unsigned long bounce_size, bounce_buffer;
@@ -111,10 +83,12 @@ static void get_bounce_buffer(struct lb_memory *mem, unsigned long req_size)
unsigned long mem_entries;
unsigned long buffer;
int i;
- lb_size = (unsigned long)(&_eram_seg - &_ram_seg);
- /* Double coreboot size so I have somewhere to place a copy to return to */
+ lb_size = lb_end - lb_start;
+ /* Plus coreboot size so I have somewhere
+ * to place a copy to return to.
+ */
lb_size = req_size + lb_size;
- mem_entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
+ mem_entries = (mem->size - sizeof(*mem)) / sizeof(mem->map[0]);
buffer = 0;
for(i = 0; i < mem_entries; i++) {
unsigned long mstart, mend;
@@ -149,7 +123,8 @@ static int valid_area(struct lb_memory *mem, unsigned long buffer,
*/
int i;
unsigned long end = start + len;
- unsigned long mem_entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
+ unsigned long mem_entries = (mem->size - sizeof(*mem)) /
+ sizeof(mem->map[0]);
/* See if I conflict with the bounce buffer */
if (end >= buffer) {
@@ -194,8 +169,6 @@ static int valid_area(struct lb_memory *mem, unsigned long buffer,
return 1;
}
-static const unsigned long lb_start = (unsigned long)&_ram_seg;
-static const unsigned long lb_end = (unsigned long)&_eram_seg;
static int overlaps_coreboot(struct segment *seg)
{
@@ -211,7 +184,8 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
* to load onto the bounce buffer instead.
*/
/* ret: 1 : A new segment is inserted before the seg.
- * 0 : A new segment is inserted after the seg, or no new one. */
+ * 0 : A new segment is inserted after the seg, or no new one.
+ */
unsigned long start, middle, end, ret = 0;
printk(BIOS_SPEW, "lb: [0x%016lx, 0x%016lx)\n",
@@ -559,3 +533,18 @@ static int selfboot(struct lb_memory *mem, struct cbfs_payload *payload)
return 0;
}
+void *cbfs_load_payload(struct lb_memory *lb_mem, const char *name)
+{
+ struct cbfs_payload *payload;
+
+ payload = (struct cbfs_payload *)cbfs_find_file(name, CBFS_TYPE_PAYLOAD);
+ if (payload == NULL)
+ return (void *) -1;
+ printk(BIOS_DEBUG, "Got a payload\n");
+
+ selfboot(lb_mem, payload);
+ printk(BIOS_EMERG, "SELFBOOT RETURNED!\n");
+
+ return (void *) -1;
+}
+