selfboot: Add support for selfload in romstage

Since bootmem is not available in romstage, calls to bootmem APIs need
to be compile-time eliminated in order to avoid linker error:

     undefined reference to `bootmem_region_targets_type

BUG=None
BRANCH=None
TEST=./util/abuild/abuild -p none -t GOOGLE_HEROBRINE -x -a -B
     cherry-picked on top of CB:49392 and verified successful
     compilation.

Change-Id: I8dfa2f2079a9a2859114c53c22bf7ef466ac2ad9
Signed-off-by: Shelley Chen <shchen@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55865
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Shelley Chen 2021-06-25 14:39:18 -07:00 committed by Julius Werner
parent a6b60ebedb
commit 2033afa682
1 changed files with 8 additions and 0 deletions

View File

@ -34,6 +34,14 @@ static void cbfs_decode_payload_segment(struct cbfs_payload_segment *segment,
static int segment_targets_type(void *dest, unsigned long memsz, static int segment_targets_type(void *dest, unsigned long memsz,
enum bootmem_type dest_type) enum bootmem_type dest_type)
{ {
/* No bootmem to check in earlier stages, caller should not use
selfload_check(). */
if (!ENV_RAMSTAGE) {
printk(BIOS_ERR,
"Callers not supposed to call selfload_check() in romstage");
return 0;
}
uintptr_t d = (uintptr_t) dest; uintptr_t d = (uintptr_t) dest;
if (bootmem_region_targets_type(d, memsz, dest_type)) if (bootmem_region_targets_type(d, memsz, dest_type))
return 1; return 1;