diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-03-20 16:37:12 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@google.com> | 2015-04-03 14:53:11 +0200 |
commit | ce9efe061a23bc3e3d2a4c17cf29692ce6f9eb53 (patch) | |
tree | 4c7715b3d7869bb3282751f536450e653dc83dbe /src/lib | |
parent | b3847e64242228166976f425cd42331db7857551 (diff) | |
download | coreboot-ce9efe061a23bc3e3d2a4c17cf29692ce6f9eb53.tar.xz |
program loading: unify on struct prog
Instead of having different structures for loading
ramstage and payload align to using struct prog.
This also removes arch_payload_run() in favor of
the prog_run() interface.
Change-Id: I31483096094eacc713a7433811cd69cc5621c43e
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/8849
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/loaders/cbfs_payload_loader.c | 10 | ||||
-rw-r--r-- | src/lib/loaders/cbfs_ramstage_loader.c | 4 | ||||
-rw-r--r-- | src/lib/loaders/load_and_run_payload.c | 35 | ||||
-rw-r--r-- | src/lib/loaders/load_and_run_ramstage.c | 12 | ||||
-rw-r--r-- | src/lib/selfboot.c | 15 |
5 files changed, 36 insertions, 40 deletions
diff --git a/src/lib/loaders/cbfs_payload_loader.c b/src/lib/loaders/cbfs_payload_loader.c index 609d1232e1..3928613e73 100644 --- a/src/lib/loaders/cbfs_payload_loader.c +++ b/src/lib/loaders/cbfs_payload_loader.c @@ -20,24 +20,24 @@ #include <cbfs.h> #include <program_loading.h> -static int cbfs_locate_payload(struct payload *payload) +static int cbfs_locate_payload(struct prog *payload) { void *buffer; size_t size; const int type = CBFS_TYPE_PAYLOAD; - buffer = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, payload->prog.name, + buffer = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, payload->name, type, &size); if (buffer == NULL) return -1; - prog_set_area(&payload->prog, buffer, size); + prog_set_area(payload, buffer, size); return 0; } -const struct payload_loader_ops cbfs_payload_loader = { +const struct prog_loader_ops cbfs_payload_loader = { .name = "CBFS", - .locate = cbfs_locate_payload, + .prepare = cbfs_locate_payload, }; diff --git a/src/lib/loaders/cbfs_ramstage_loader.c b/src/lib/loaders/cbfs_ramstage_loader.c index 27be88ef7a..e565329616 100644 --- a/src/lib/loaders/cbfs_ramstage_loader.c +++ b/src/lib/loaders/cbfs_ramstage_loader.c @@ -54,7 +54,7 @@ static int cbfs_load_ramstage(struct prog *ramstage) #endif /* CONFIG_RELOCATABLE_RAMSTAGE */ -const struct ramstage_loader_ops cbfs_ramstage_loader = { +const struct prog_loader_ops cbfs_ramstage_loader = { .name = "CBFS", - .load = cbfs_load_ramstage, + .prepare = cbfs_load_ramstage, }; diff --git a/src/lib/loaders/load_and_run_payload.c b/src/lib/loaders/load_and_run_payload.c index e3208a9feb..6c42a589d2 100644 --- a/src/lib/loaders/load_and_run_payload.c +++ b/src/lib/loaders/load_and_run_payload.c @@ -26,24 +26,22 @@ #include <program_loading.h> #include <timestamp.h> -extern const struct payload_loader_ops vboot_payload_loader; -extern const struct payload_loader_ops cbfs_payload_loader; +extern const struct prog_loader_ops vboot_payload_loader; +extern const struct prog_loader_ops cbfs_payload_loader; -static const struct payload_loader_ops *payload_ops[] = { +static const struct prog_loader_ops *payload_ops[] = { #if CONFIG_VBOOT_VERIFY_FIRMWARE &vboot_payload_loader, #endif &cbfs_payload_loader, }; -static struct payload global_payload = { - .prog = { - .name = CONFIG_CBFS_PREFIX "/payload", - .type = PROG_PAYLOAD, - }, +static struct prog global_payload = { + .name = CONFIG_CBFS_PREFIX "/payload", + .type = PROG_PAYLOAD, }; -void __attribute__((weak)) mirror_payload(struct payload *payload) +void __attribute__((weak)) mirror_payload(struct prog *payload) { return; } @@ -51,19 +49,18 @@ void __attribute__((weak)) mirror_payload(struct payload *payload) void payload_load(void) { int i; - const struct payload_loader_ops *ops; - struct payload *payload = &global_payload; - struct prog * prog = &payload->prog; + const struct prog_loader_ops *ops; + struct prog *payload = &global_payload; for (i = 0; i < ARRAY_SIZE(payload_ops); i++) { ops = payload_ops[i]; - if (ops->locate(payload) < 0) { + if (ops->prepare(payload) < 0) { printk(BIOS_DEBUG, "%s: could not locate payload.\n", ops->name); continue; } printk(BIOS_DEBUG, "%s: located payload @ %p, %zu bytes.\n", - ops->name, prog_start(prog), prog_size(prog)); + ops->name, prog_start(payload), prog_size(payload)); break; } @@ -73,23 +70,23 @@ void payload_load(void) mirror_payload(payload); /* Pass cbtables to payload if architecture desires it. */ - prog_set_entry(&payload->prog, selfload(payload), + prog_set_entry(payload, selfload(payload), cbmem_find(CBMEM_ID_CBTABLE)); out: - if (prog_entry(&payload->prog) == NULL) + if (prog_entry(payload) == NULL) die("Payload not loaded.\n"); } void payload_run(void) { - struct payload *payload = &global_payload; + struct prog *payload = &global_payload; /* Reset to booting from this image as late as possible */ boot_successful(); printk(BIOS_DEBUG, "Jumping to boot code at %p(%p)\n", - prog_entry(&payload->prog), prog_entry_arg(&payload->prog)); + prog_entry(payload), prog_entry_arg(payload)); post_code(POST_ENTER_ELF_BOOT); timestamp_add_now(TS_SELFBOOT_JUMP); @@ -99,5 +96,5 @@ void payload_run(void) */ checkstack(_estack, 0); - arch_payload_run(payload); + prog_run(payload); } diff --git a/src/lib/loaders/load_and_run_ramstage.c b/src/lib/loaders/load_and_run_ramstage.c index 9067a28dc6..b3728a17cf 100644 --- a/src/lib/loaders/load_and_run_ramstage.c +++ b/src/lib/loaders/load_and_run_ramstage.c @@ -25,10 +25,10 @@ #include <romstage_handoff.h> #include <timestamp.h> -extern const struct ramstage_loader_ops cbfs_ramstage_loader; -extern const struct ramstage_loader_ops vboot_ramstage_loader; +extern const struct prog_loader_ops cbfs_ramstage_loader; +extern const struct prog_loader_ops vboot_ramstage_loader; -static const struct ramstage_loader_ops *loaders[] = { +static const struct prog_loader_ops *loaders[] = { #if CONFIG_VBOOT_VERIFY_FIRMWARE &vboot_ramstage_loader, #endif @@ -36,12 +36,12 @@ static const struct ramstage_loader_ops *loaders[] = { }; static void -load_ramstage(const struct ramstage_loader_ops *ops, +load_ramstage(const struct prog_loader_ops *ops, struct romstage_handoff *handoff, struct prog *ramstage) { timestamp_add_now(TS_START_COPYRAM); - if (ops->load(ramstage)) + if (ops->prepare(ramstage)) return; cache_loaded_ramstage(handoff, ramstage); @@ -68,7 +68,7 @@ static void run_ramstage_from_resume(struct romstage_handoff *handoff, void run_ramstage(void) { struct romstage_handoff *handoff; - const struct ramstage_loader_ops *ops; + const struct prog_loader_ops *ops; int i; struct prog ramstage = { .name = CONFIG_CBFS_PREFIX "/ramstage", diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c index 164dce90de..bd4c1690ac 100644 --- a/src/lib/selfboot.c +++ b/src/lib/selfboot.c @@ -214,13 +214,13 @@ static int relocate_segment(unsigned long buffer, struct segment *seg) static int build_self_segment_list( struct segment *head, - struct payload *payload, uintptr_t *entry) + struct prog *payload, uintptr_t *entry) { struct segment *new; struct segment *ptr; struct cbfs_payload_segment *segment, *first_segment; struct cbfs_payload *cbfs_payload; - cbfs_payload = prog_start(&payload->prog); + cbfs_payload = prog_start(payload); memset(head, 0, sizeof(*head)); head->next = head->prev = head; first_segment = segment = &cbfs_payload->segments; @@ -311,7 +311,7 @@ static int build_self_segment_list( static int load_self_segments( struct segment *head, - struct payload *payload) + struct prog *payload) { struct segment *ptr; struct segment *last_non_empty; @@ -365,10 +365,6 @@ static int load_self_segments( return 0; } - /* Update the payload's bounce buffer data used when loading. */ - payload->bounce.data = (void *)(uintptr_t)bounce_buffer; - payload->bounce.size = bounce_size; - for(ptr = head->next; ptr != head; ptr = ptr->next) { unsigned char *dest, *src; printk(BIOS_DEBUG, "Loading Segment: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n", @@ -454,10 +450,13 @@ static int load_self_segments( } } + /* Update the payload's area with the bounce buffer information. */ + prog_set_area(payload, (void *)(uintptr_t)bounce_buffer, bounce_size); + return 1; } -void *selfload(struct payload *payload) +void *selfload(struct prog *payload) { uintptr_t entry = 0; struct segment head; |