blob: 777a0b7d904a00e5b96730a3cb86a2f462f0f05a [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>
Kyösti Mälkkia48433d2018-06-07 06:31:43 +03004#include <commonlib/helpers.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +00005#include <console/console.h>
Aaron Durbin04654a22015-03-17 11:43:44 -05006#include <program_loading.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +00007#include <ip_checksum.h>
Julius Wernerec5e5e02014-08-20 15:29:56 -07008#include <symbols.h>
Patrick Rudolphe5638152018-12-09 10:48:59 +01009#include <assert.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000010
Kyösti Mälkkia48433d2018-06-07 06:31:43 +030011int payload_arch_usable_ram_quirk(uint64_t start, uint64_t size)
12{
13 if (start < 1 * MiB && (start + size) <= 1 * MiB) {
14 printk(BIOS_DEBUG,
15 "Payload being loaded at below 1MiB without region being marked as RAM usable.\n");
16 return 1;
17 }
18
19 return 0;
20}
21
Aaron Durbinb3847e62015-03-20 15:55:08 -050022void arch_prog_run(struct prog *prog)
23{
Patrick Rudolphe5638152018-12-09 10:48:59 +010024#if ENV_RAMSTAGE && defined(__x86_64__)
25 const uint32_t arg = pointer_to_uint32_safe(prog_entry_arg(prog));
26 const uint32_t entry = pointer_to_uint32_safe(prog_entry(prog));
27
28 /* On x86 coreboot payloads expect to be called in protected mode */
29 protected_mode_jump(entry, arg);
30#else
Stefan Reinauer96938852015-06-18 01:23:48 -070031#ifdef __x86_64__
Arthur Heymansb7cc68a2019-10-19 22:56:44 +020032 void (*doit)(void *arg);
Stefan Reinauer96938852015-06-18 01:23:48 -070033#else
Arthur Heymansb7cc68a2019-10-19 22:56:44 +020034 /* Ensure the argument is pushed on the stack. */
35 asmlinkage void (*doit)(void *arg);
Stefan Reinauer96938852015-06-18 01:23:48 -070036#endif
Arthur Heymansb7cc68a2019-10-19 22:56:44 +020037 doit = prog_entry(prog);
38 doit(prog_entry_arg(prog));
Patrick Rudolphe5638152018-12-09 10:48:59 +010039#endif
Aaron Durbinb3847e62015-03-20 15:55:08 -050040}