2 * This file is part of the coreboot project.
4 * Copyright (C) 2013 Google Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <arch/acpi.h>
19 #include <console/console.h>
20 #include <console/streams.h>
21 #include <cpu/x86/tsc.h>
22 #include <program_loading.h>
24 #include <stage_cache.h>
26 #include <soc/ramstage.h>
27 #include <soc/efi_wrapper.h>
29 static void ABI_X86
send_to_console(unsigned char b
)
34 static efi_wrapper_entry_t
load_refcode_from_cache(void)
38 printk(BIOS_DEBUG
, "refcode loading from cache.\n");
40 stage_cache_load_stage(STAGE_REFCODE
, &refcode
);
42 return (efi_wrapper_entry_t
)prog_entry(&refcode
);
45 static efi_wrapper_entry_t
load_reference_code(void)
48 PROG_INIT(ASSET_REFCODE
, CONFIG_CBFS_PREFIX
"/refcode");
49 struct rmod_stage_load refcode
= {
50 .cbmem_id
= CBMEM_ID_REFCODE
,
54 if (acpi_is_wakeup_s3()) {
55 return load_refcode_from_cache();
58 if (prog_locate(&prog
)) {
59 printk(BIOS_DEBUG
, "Couldn't locate reference code.\n");
63 if (rmodule_stage_load(&refcode
)) {
64 printk(BIOS_DEBUG
, "Error loading reference code.\n");
68 /* Cache loaded reference code. */
69 stage_cache_add(STAGE_REFCODE
, &prog
);
71 return prog_entry(&prog
);
74 void baytrail_run_reference_code(void)
77 efi_wrapper_entry_t entry
;
78 struct efi_wrapper_params wrp
= {
79 .version
= EFI_WRAPPER_VER
,
80 .console_out
= send_to_console
,
83 entry
= load_reference_code();
88 wrp
.tsc_ticks_per_microsecond
= tsc_freq_mhz();
90 /* Call into reference code. */
94 printk(BIOS_DEBUG
, "Reference code returned %d\n", ret
);