Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 9df9e939 | 2016-01-12 15:55:28 -0700 | [diff] [blame] | 2 | |
Patrick Rudolph | e563815 | 2018-12-09 10:48:59 +0100 | [diff] [blame] | 3 | #include <arch/boot/boot.h> |
Raul E Rangel | a96482a | 2021-09-10 16:41:00 -0600 | [diff] [blame] | 4 | #include <arch/cpu.h> |
Kyösti Mälkki | a48433d | 2018-06-07 06:31:43 +0300 | [diff] [blame] | 5 | #include <commonlib/helpers.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 6 | #include <console/console.h> |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 7 | #include <program_loading.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 8 | #include <ip_checksum.h> |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 9 | #include <symbols.h> |
Patrick Rudolph | e563815 | 2018-12-09 10:48:59 +0100 | [diff] [blame] | 10 | #include <assert.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 11 | |
Kyösti Mälkki | a48433d | 2018-06-07 06:31:43 +0300 | [diff] [blame] | 12 | int payload_arch_usable_ram_quirk(uint64_t start, uint64_t size) |
| 13 | { |
| 14 | if (start < 1 * MiB && (start + size) <= 1 * MiB) { |
| 15 | printk(BIOS_DEBUG, |
| 16 | "Payload being loaded at below 1MiB without region being marked as RAM usable.\n"); |
| 17 | return 1; |
| 18 | } |
| 19 | |
| 20 | return 0; |
| 21 | } |
| 22 | |
Aaron Durbin | b3847e6 | 2015-03-20 15:55:08 -0500 | [diff] [blame] | 23 | void arch_prog_run(struct prog *prog) |
| 24 | { |
Patrick Rudolph | adcf782 | 2020-08-27 20:50:18 +0200 | [diff] [blame] | 25 | #if ENV_RAMSTAGE && ENV_X86_64 |
Patrick Rudolph | e563815 | 2018-12-09 10:48:59 +0100 | [diff] [blame] | 26 | const uint32_t arg = pointer_to_uint32_safe(prog_entry_arg(prog)); |
| 27 | const uint32_t entry = pointer_to_uint32_safe(prog_entry(prog)); |
| 28 | |
| 29 | /* On x86 coreboot payloads expect to be called in protected mode */ |
| 30 | protected_mode_jump(entry, arg); |
| 31 | #else |
Patrick Rudolph | adcf782 | 2020-08-27 20:50:18 +0200 | [diff] [blame] | 32 | #if ENV_X86_64 |
Arthur Heymans | b7cc68a | 2019-10-19 22:56:44 +0200 | [diff] [blame] | 33 | void (*doit)(void *arg); |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 34 | #else |
Arthur Heymans | b7cc68a | 2019-10-19 22:56:44 +0200 | [diff] [blame] | 35 | /* Ensure the argument is pushed on the stack. */ |
| 36 | asmlinkage void (*doit)(void *arg); |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 37 | #endif |
Arthur Heymans | b7cc68a | 2019-10-19 22:56:44 +0200 | [diff] [blame] | 38 | doit = prog_entry(prog); |
| 39 | doit(prog_entry_arg(prog)); |
Patrick Rudolph | e563815 | 2018-12-09 10:48:59 +0100 | [diff] [blame] | 40 | #endif |
Aaron Durbin | b3847e6 | 2015-03-20 15:55:08 -0500 | [diff] [blame] | 41 | } |