blob: c50ec0e1f16ab3c8257bbc74c5234777e9c110e7 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth9df9e9392016-01-12 15:55:28 -07002
Patrick Rudolphe5638152018-12-09 10:48:59 +01003#include <arch/boot/boot.h>
Raul E Rangela96482a2021-09-10 16:41:00 -06004#include <arch/cpu.h>
Kyösti Mälkkia48433d2018-06-07 06:31:43 +03005#include <commonlib/helpers.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +00006#include <console/console.h>
Aaron Durbin04654a22015-03-17 11:43:44 -05007#include <program_loading.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +00008#include <ip_checksum.h>
Julius Wernerec5e5e02014-08-20 15:29:56 -07009#include <symbols.h>
Patrick Rudolphe5638152018-12-09 10:48:59 +010010#include <assert.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000011
Kyösti Mälkkia48433d2018-06-07 06:31:43 +030012int 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 Durbinb3847e62015-03-20 15:55:08 -050023void arch_prog_run(struct prog *prog)
24{
Patrick Rudolphadcf7822020-08-27 20:50:18 +020025#if ENV_RAMSTAGE && ENV_X86_64
Patrick Rudolphe5638152018-12-09 10:48:59 +010026 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 Rudolphadcf7822020-08-27 20:50:18 +020032#if ENV_X86_64
Arthur Heymansb7cc68a2019-10-19 22:56:44 +020033 void (*doit)(void *arg);
Stefan Reinauer96938852015-06-18 01:23:48 -070034#else
Arthur Heymansb7cc68a2019-10-19 22:56:44 +020035 /* Ensure the argument is pushed on the stack. */
36 asmlinkage void (*doit)(void *arg);
Stefan Reinauer96938852015-06-18 01:23:48 -070037#endif
Arthur Heymansb7cc68a2019-10-19 22:56:44 +020038 doit = prog_entry(prog);
39 doit(prog_entry_arg(prog));
Patrick Rudolphe5638152018-12-09 10:48:59 +010040#endif
Aaron Durbinb3847e62015-03-20 15:55:08 -050041}