tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / soc / intel / baytrail / refcode.c
blob3a72a8f84a135638c52ec68192040d85807f179f
1 /*
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.
16 #include <string.h>
17 #include <arch/acpi.h>
18 #include <cbmem.h>
19 #include <console/console.h>
20 #include <console/streams.h>
21 #include <cpu/x86/tsc.h>
22 #include <program_loading.h>
23 #include <rmodule.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)
31 console_tx_byte(b);
34 static efi_wrapper_entry_t load_refcode_from_cache(void)
36 struct prog refcode;
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)
47 struct prog prog =
48 PROG_INIT(ASSET_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
49 struct rmod_stage_load refcode = {
50 .cbmem_id = CBMEM_ID_REFCODE,
51 .prog = &prog,
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");
60 return NULL;
63 if (rmodule_stage_load(&refcode)) {
64 printk(BIOS_DEBUG, "Error loading reference code.\n");
65 return NULL;
68 /* Cache loaded reference code. */
69 stage_cache_add(STAGE_REFCODE, &prog);
71 return prog_entry(&prog);
74 void baytrail_run_reference_code(void)
76 int ret;
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();
85 if (entry == NULL)
86 return;
88 wrp.tsc_ticks_per_microsecond = tsc_freq_mhz();
90 /* Call into reference code. */
91 ret = entry(&wrp);
93 if (ret != 0) {
94 printk(BIOS_DEBUG, "Reference code returned %d\n", ret);
95 return;