1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <console/streams.h>
6 #include <cpu/x86/tsc.h>
7 #include <program_loading.h>
9 #include <stage_cache.h>
11 #include <soc/ramstage.h>
12 #include <soc/efi_wrapper.h>
14 static void ABI_X86
send_to_console(unsigned char b
)
19 static efi_wrapper_entry_t
load_reference_code(void)
21 if (resume_from_stage_cache()) {
23 stage_cache_load_stage(STAGE_REFCODE
, &prog
);
24 return prog_entry(&prog
);
28 PROG_INIT(PROG_REFCODE
, CONFIG_CBFS_PREFIX
"/refcode");
29 struct rmod_stage_load refcode
= {
30 .cbmem_id
= CBMEM_ID_REFCODE
,
34 if (rmodule_stage_load(&refcode
)) {
35 printk(BIOS_DEBUG
, "Error loading reference code.\n");
39 /* Cache loaded reference code. */
40 stage_cache_add(STAGE_REFCODE
, &prog
);
42 return prog_entry(&prog
);
45 void baytrail_run_reference_code(void)
48 efi_wrapper_entry_t entry
;
49 struct efi_wrapper_params wrp
= {
50 .version
= EFI_WRAPPER_VER
,
51 .console_out
= send_to_console
,
54 entry
= load_reference_code();
59 wrp
.tsc_ticks_per_microsecond
= tsc_freq_mhz();
61 /* Call into reference code. */
65 printk(BIOS_DEBUG
, "Reference code returned %d\n", ret
);