blob: 9b5aa6790e73cc2e10a49d8d38476dc7db99b2e0 [file] [log] [blame]
Aaron Durbinae5d83e2013-10-24 10:21:43 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 *
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.
9 *
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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <cbmem.h>
21#include <console/console.h>
Aaron Durbin8fa62832013-10-28 09:54:22 -050022#include <cpu/x86/tsc.h>
Aaron Durbinae5d83e2013-10-24 10:21:43 -050023#include <rmodule.h>
24
25#include <baytrail/ramstage.h>
26#include <baytrail/efi_wrapper.h>
27
28static void ABI_X86 send_to_console(unsigned char b)
29{
30 console_tx_byte(b);
31}
32
33void baytrail_run_reference_code(void)
34{
35 int ret;
36 efi_wrapper_entry_t entry;
37 struct efi_wrapper_params wrp = {
38 .version = EFI_WRAPPER_VER,
39 .console_out = send_to_console,
40 };
41 struct rmod_stage_load refcode = {
42 .cbmem_id = CBMEM_ID_REFCODE,
43 .name = CONFIG_CBFS_PREFIX "/refcode",
44 };
45
46 if (rmodule_stage_load_from_cbfs(&refcode) || refcode.entry == NULL) {
47 printk(BIOS_DEBUG, "Error loading reference code.\n");
48 return;
49 }
50
Aaron Durbin8fa62832013-10-28 09:54:22 -050051 wrp.tsc_ticks_per_microsecond = tsc_freq_mhz();
Aaron Durbinae5d83e2013-10-24 10:21:43 -050052 entry = refcode.entry;
53
54 /* Call into reference code. */
55 ret = entry(&wrp);
56
57 if (ret != 0) {
58 printk(BIOS_DEBUG, "Reference code returned %d\n", ret);
59 return;
60 }
61}
62