diff options
author | Ronald G. Minnich <rminnich@gmail.com> | 2018-08-13 15:24:30 -0700 |
---|---|---|
committer | Philipp Deppenwiese <zaolin.daisuki@gmail.com> | 2018-09-01 17:16:04 +0000 |
commit | 4cea3a19f886cf8154af235fb233dc35cd60d0ea (patch) | |
tree | 81ce8a7524ecf596306847f4fbbb560b7c9d156f /src/lib/prog_loaders.c | |
parent | aef592d9b66aa18d83b0a211ead26013ff1f7d98 (diff) | |
download | coreboot-rampayload.tar.gz coreboot-rampayload.tar.bz2 coreboot-rampayload.zip |
Add support for ram payloadsrampayload
This is enabled by CONFIG_RAMPAYLOAD.
The code will look for a ram payload and, if it is found, try
to run it. If the load fails or the payload returns it will
continue with ramstage.
We also include a new payload, linuxcheck, which is intended
to verify that linux can be loaded and run, e.g. as a LinuxBoot
payload. Currently, it fails.
This does not yet work but it makes sense as a foundation on which
to build. For one thing, we need to build at least a few tables
for Linux. The goal for LinuxBoot is to build as few as possible.
To test with linuxcheck (linux is not even close to working):
cd payloads/linuxcheck/
cp x86config .config
make
cd ../..
make
./build/cbfstool build/coreboot.rom add-payload -n fallback/rampayload -f payloads/linuxcheck/linuxcheck.elf
qemu-system-x86_64 -nographic -m 8192 -bios build/coreboot.rom -monitor /dev/pts/$1 -s
We need to change the payload menu so we can add a rampayload but it's a bit
tricky as written, so that must come later.
Note that I'm still creating a special purpose romselfboot. The idea of
merging romselfboot and selfboot is probably a good idea -- in the future.
I think until we know how this should look, such a merge is premature.
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Change-Id: I8199aae6776f6dee969b370b0e6a41ef96e854d8
clang-formatted-by: Ronald G. Minnich
Reviewed-on: https://review.coreboot.org/28402
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Tested-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'src/lib/prog_loaders.c')
-rw-r--r-- | src/lib/prog_loaders.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index 1c192d1f8b64..901356f53334 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -77,9 +77,13 @@ fail: } void __weak stage_cache_add(int stage_id, - const struct prog *stage) {} + const struct prog *stage) +{ +} void __weak stage_cache_load_stage(int stage_id, - struct prog *stage) {} + struct prog *stage) +{ +} static void ramstage_cache_invalid(void) { @@ -138,9 +142,7 @@ void run_ramstage(void) * Only x86 systems using ramstage stage cache currently take the same * firmware path on resume. */ - if (IS_ENABLED(CONFIG_ARCH_X86) && - !IS_ENABLED(CONFIG_NO_STAGE_CACHE) && - IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)) + if (IS_ENABLED(CONFIG_ARCH_X86) && !IS_ENABLED(CONFIG_NO_STAGE_CACHE) && IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)) run_ramstage_from_resume(&ramstage); if (prog_locate(&ramstage)) @@ -165,6 +167,30 @@ fail: die("Ramstage was not loaded!\n"); } +/* run_ramprog tries to run CONFIG_CBFS_PREFIX "/rampayload" + * and returns on failure (or if, unlikely, the payload returns). + * It does not die, which allows us to run the ramstage. */ +void run_ramprog(void) +{ + struct prog rampayload = PROG_INIT(PROG_PAYLOAD, + CONFIG_CBFS_PREFIX "/rampayload"); + timestamp_add_now(TS_END_ROMSTAGE); + if (prog_locate(&rampayload)) { + printk(BIOS_ERR, + "Can't find %s\n", CONFIG_CBFS_PREFIX "/rampayload"); + return; + } + + if (!selfload(&rampayload, 0)) { + printk(BIOS_ERR, + "Can't load %s\n", CONFIG_CBFS_PREFIX "/rampayload"); + return; + } + prog_run(&rampayload); + printk(BIOS_ERR, "rampayload %s returns\n", + CONFIG_CBFS_PREFIX "/rampayload"); +} + #ifdef __RAMSTAGE__ // gc-sections should take care of this static struct prog global_payload = @@ -212,7 +238,7 @@ void payload_run(void) boot_successful(); printk(BIOS_DEBUG, "Jumping to boot code at %p(%p)\n", - prog_entry(payload), prog_entry_arg(payload)); + prog_entry(payload), prog_entry_arg(payload)); post_code(POST_ENTER_ELF_BOOT); |