blob: 8cd7336a62c0815a37fa09720318f59549b3ae8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpi.h>
#include <cbmem.h>
#include <console/console.h>
#include <console/streams.h>
#include <cpu/x86/tsc.h>
#include <program_loading.h>
#include <rmodule.h>
#include <stage_cache.h>
#include <soc/ramstage.h>
#include <soc/efi_wrapper.h>
static void ABI_X86 send_to_console(unsigned char b)
{
console_tx_byte(b);
}
static efi_wrapper_entry_t load_reference_code(void)
{
if (resume_from_stage_cache()) {
struct prog prog;
stage_cache_load_stage(STAGE_REFCODE, &prog);
return prog_entry(&prog);
}
struct prog prog =
PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
struct rmod_stage_load refcode = {
.cbmem_id = CBMEM_ID_REFCODE,
.prog = &prog,
};
if (prog_locate(&prog)) {
printk(BIOS_DEBUG, "Couldn't locate reference code.\n");
return NULL;
}
if (rmodule_stage_load(&refcode)) {
printk(BIOS_DEBUG, "Error loading reference code.\n");
return NULL;
}
/* Cache loaded reference code. */
stage_cache_add(STAGE_REFCODE, &prog);
return prog_entry(&prog);
}
void baytrail_run_reference_code(void)
{
int ret;
efi_wrapper_entry_t entry;
struct efi_wrapper_params wrp = {
.version = EFI_WRAPPER_VER,
.console_out = send_to_console,
};
entry = load_reference_code();
if (entry == NULL)
return;
wrp.tsc_ticks_per_microsecond = tsc_freq_mhz();
/* Call into reference code. */
ret = entry(&wrp);
if (ret != 0) {
printk(BIOS_DEBUG, "Reference code returned %d\n", ret);
return;
}
}
|