Aaron Durbin | ae5d83e | 2013-10-24 10:21:43 -0500 | [diff] [blame^] | 1 | /* |
| 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> |
| 22 | #include <rmodule.h> |
| 23 | |
| 24 | #include <baytrail/ramstage.h> |
| 25 | #include <baytrail/efi_wrapper.h> |
| 26 | |
| 27 | static void ABI_X86 send_to_console(unsigned char b) |
| 28 | { |
| 29 | console_tx_byte(b); |
| 30 | } |
| 31 | |
| 32 | void baytrail_run_reference_code(void) |
| 33 | { |
| 34 | int ret; |
| 35 | efi_wrapper_entry_t entry; |
| 36 | struct efi_wrapper_params wrp = { |
| 37 | .version = EFI_WRAPPER_VER, |
| 38 | .console_out = send_to_console, |
| 39 | }; |
| 40 | struct rmod_stage_load refcode = { |
| 41 | .cbmem_id = CBMEM_ID_REFCODE, |
| 42 | .name = CONFIG_CBFS_PREFIX "/refcode", |
| 43 | }; |
| 44 | |
| 45 | if (rmodule_stage_load_from_cbfs(&refcode) || refcode.entry == NULL) { |
| 46 | printk(BIOS_DEBUG, "Error loading reference code.\n"); |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | entry = refcode.entry; |
| 51 | |
| 52 | /* Call into reference code. */ |
| 53 | ret = entry(&wrp); |
| 54 | |
| 55 | if (ret != 0) { |
| 56 | printk(BIOS_DEBUG, "Reference code returned %d\n", ret); |
| 57 | return; |
| 58 | } |
| 59 | } |
| 60 | |