soc/intel/denverton_ns: Remove unused memcpy_s function
[coreboot2.git] / src / soc / intel / baytrail / refcode.c
blob94adfa134d4bdf50aff3ad4010ad2a562eb82980
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cbmem.h>
4 #include <console/console.h>
5 #include <console/streams.h>
6 #include <cpu/x86/tsc.h>
7 #include <program_loading.h>
8 #include <rmodule.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)
16 console_tx_byte(b);
19 static efi_wrapper_entry_t load_reference_code(void)
21 if (resume_from_stage_cache()) {
22 struct prog prog;
23 stage_cache_load_stage(STAGE_REFCODE, &prog);
24 return prog_entry(&prog);
27 struct prog prog =
28 PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
29 struct rmod_stage_load refcode = {
30 .cbmem_id = CBMEM_ID_REFCODE,
31 .prog = &prog,
34 if (rmodule_stage_load(&refcode)) {
35 printk(BIOS_DEBUG, "Error loading reference code.\n");
36 return NULL;
39 /* Cache loaded reference code. */
40 stage_cache_add(STAGE_REFCODE, &prog);
42 return prog_entry(&prog);
45 void baytrail_run_reference_code(void)
47 int ret;
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();
56 if (entry == NULL)
57 return;
59 wrp.tsc_ticks_per_microsecond = tsc_freq_mhz();
61 /* Call into reference code. */
62 ret = entry(&wrp);
64 if (ret != 0) {
65 printk(BIOS_DEBUG, "Reference code returned %d\n", ret);
66 return;