From 59b8f275c21ccbd08019cc7d9f0b63671de6586a Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 26 Apr 2018 09:53:16 +0200 Subject: lib/prog_loaders: Move argument selection into selfload Set the payload argument in selfload, as other (non self) payloads, are going to set a different argument. Change-Id: I994f604fc4501e0e3b00165819f796b1b8275d8c Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/25861 Reviewed-by: Julius Werner Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/arch/arm64/arm_tf.c | 4 ++-- src/include/program_loading.h | 4 ++-- src/lib/prog_loaders.c | 5 ++--- src/lib/selfboot.c | 11 +++++++---- 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/arch/arm64/arm_tf.c b/src/arch/arm64/arm_tf.c index a172d42ab3..88416ea27d 100644 --- a/src/arch/arm64/arm_tf.c +++ b/src/arch/arm64/arm_tf.c @@ -51,9 +51,9 @@ void arm_tf_run_bl31(u64 payload_entry, u64 payload_arg0, u64 payload_spsr) if (prog_locate(&bl31)) die("BL31 not found"); - bl31_entry = selfload(&bl31, false); - if (!bl31_entry) + if (!selfload(&bl31, false)) die("BL31 load failed"); + bl31_entry = prog_entry(&bl31); SET_PARAM_HEAD(&bl31_params, PARAM_BL31, VERSION_1, 0); diff --git a/src/include/program_loading.h b/src/include/program_loading.h index 3cf1687ffa..482c8b8995 100644 --- a/src/include/program_loading.h +++ b/src/include/program_loading.h @@ -202,10 +202,10 @@ void mirror_payload(struct prog *payload); /* * Set check_regions to true to check that the payload targets usable memory. * With this flag set, if it does not, the load will fail and this function - * will return NULL. + * will return false. On successful payload loading this functions return true. * * Defined in src/lib/selfboot.c */ -void *selfload(struct prog *payload, bool check_regions); +bool selfload(struct prog *payload, bool check_regions); #endif /* PROGRAM_LOADING_H */ diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index 04b573e5ee..6811eb0001 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -30,6 +30,7 @@ #include #include #include +#include /* Only can represent up to 1 byte less than size_t. */ const struct mem_region_device addrspace_32bit = @@ -182,9 +183,7 @@ void payload_load(void) mirror_payload(payload); - /* Pass cbtables to payload if architecture desires it. */ - prog_set_entry(payload, selfload(payload, true), - cbmem_find(CBMEM_ID_CBTABLE)); + selfload(payload, true); out: if (prog_entry(payload) == NULL) diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c index 4046649522..a79f61d485 100644 --- a/src/lib/selfboot.c +++ b/src/lib/selfboot.c @@ -28,6 +28,7 @@ #include #include #include +#include static const unsigned long lb_start = (unsigned long)&_program; static const unsigned long lb_end = (unsigned long)&_eprogram; @@ -520,7 +521,7 @@ static int load_self_segments(struct segment *head, struct prog *payload, return 1; } -void *selfload(struct prog *payload, bool check_regions) +bool selfload(struct prog *payload, bool check_regions) { uintptr_t entry = 0; struct segment head; @@ -529,7 +530,7 @@ void *selfload(struct prog *payload, bool check_regions) data = rdev_mmap_full(prog_rdev(payload)); if (data == NULL) - return NULL; + return false; /* Preprocess the self segments */ if (!build_self_segment_list(&head, data, &entry)) @@ -546,9 +547,11 @@ void *selfload(struct prog *payload, bool check_regions) /* Update the payload's area with the bounce buffer information. */ prog_set_area(payload, (void *)(uintptr_t)bounce_buffer, bounce_size); - return (void *)entry; + /* Pass cbtables to payload if architecture desires it. */ + prog_set_entry(payload, (void *)entry, cbmem_find(CBMEM_ID_CBTABLE)); + return true; out: rdev_munmap(prog_rdev(payload), data); - return NULL; + return false; } -- cgit v1.2.3