2013-10-24 17:21:43 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
Remove address from GPLv2 headers
As per discussion with lawyers[tm], it's not a good idea to
shorten the license header too much - not for legal reasons
but because there are tools that look for them, and giving
them a standard pattern simplifies things.
However, we got confirmation that we don't have to update
every file ever added to coreboot whenever the FSF gets a
new lease, but can drop the address instead.
util/kconfig is excluded because that's imported code that
we may want to synchronize every now and then.
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} +
$ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} +
$ find * -type f
-a \! -name \*.patch \
-a \! -name \*_shipped \
-a \! -name LICENSE_GPL \
-a \! -name LGPL.txt \
-a \! -name COPYING \
-a \! -name DISCLAIMER \
-exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} +
Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/9233
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-03-26 15:17:45 +01:00
|
|
|
* Foundation, Inc.
|
2013-10-24 17:21:43 +02:00
|
|
|
*/
|
|
|
|
|
2013-12-12 19:29:48 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <arch/acpi.h>
|
2013-10-24 17:21:43 +02:00
|
|
|
#include <cbmem.h>
|
|
|
|
#include <console/console.h>
|
2015-03-28 02:53:30 +01:00
|
|
|
#include <console/streams.h>
|
2013-10-28 15:54:22 +01:00
|
|
|
#include <cpu/x86/tsc.h>
|
2015-03-28 03:17:22 +01:00
|
|
|
#include <program_loading.h>
|
2013-10-24 17:21:43 +02:00
|
|
|
#include <rmodule.h>
|
2015-03-07 06:17:33 +01:00
|
|
|
#include <stage_cache.h>
|
2015-03-28 02:53:30 +01:00
|
|
|
#if IS_ENABLED(CONFIG_CHROMEOS)
|
2013-12-13 22:05:24 +01:00
|
|
|
#include <vendorcode/google/chromeos/vboot_handoff.h>
|
2015-03-28 02:53:30 +01:00
|
|
|
#endif
|
2013-10-24 17:21:43 +02:00
|
|
|
|
2014-10-08 01:42:17 +02:00
|
|
|
#include <soc/ramstage.h>
|
|
|
|
#include <soc/efi_wrapper.h>
|
2013-10-24 17:21:43 +02:00
|
|
|
|
|
|
|
static void ABI_X86 send_to_console(unsigned char b)
|
|
|
|
{
|
|
|
|
console_tx_byte(b);
|
|
|
|
}
|
|
|
|
|
2013-12-12 19:29:48 +01:00
|
|
|
static efi_wrapper_entry_t load_refcode_from_cache(void)
|
|
|
|
{
|
2015-03-07 06:17:33 +01:00
|
|
|
struct prog refcode;
|
2013-12-12 19:29:48 +01:00
|
|
|
|
|
|
|
printk(BIOS_DEBUG, "refcode loading from cache.\n");
|
|
|
|
|
2015-03-07 06:17:33 +01:00
|
|
|
stage_cache_load_stage(STAGE_REFCODE, &refcode);
|
2013-12-12 19:29:48 +01:00
|
|
|
|
2015-03-07 06:17:33 +01:00
|
|
|
return (efi_wrapper_entry_t)prog_entry(&refcode);
|
2013-12-12 19:29:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cache_refcode(const struct rmod_stage_load *rsl)
|
|
|
|
{
|
2015-03-07 06:17:33 +01:00
|
|
|
stage_cache_add(STAGE_REFCODE, rsl->prog);
|
2013-12-12 19:29:48 +01:00
|
|
|
}
|
|
|
|
|
2015-03-28 02:53:30 +01:00
|
|
|
#if IS_ENABLED(CONFIG_CHROMEOS)
|
|
|
|
static int load_refcode_from_vboot(struct rmod_stage_load *refcode)
|
2013-12-12 19:29:48 +01:00
|
|
|
{
|
2015-03-28 02:53:30 +01:00
|
|
|
struct vboot_handoff *vboot_handoff;
|
|
|
|
const struct firmware_component *fwc;
|
|
|
|
struct cbfs_stage *stage;
|
|
|
|
|
|
|
|
vboot_handoff = cbmem_find(CBMEM_ID_VBOOT_HANDOFF);
|
|
|
|
fwc = &vboot_handoff->components[CONFIG_VBOOT_REFCODE_INDEX];
|
|
|
|
|
|
|
|
if (vboot_handoff == NULL ||
|
|
|
|
vboot_handoff->selected_firmware == VB_SELECT_FIRMWARE_READONLY ||
|
|
|
|
CONFIG_VBOOT_REFCODE_INDEX >= MAX_PARSED_FW_COMPONENTS ||
|
|
|
|
fwc->size == 0 || fwc->address == 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-12-13 22:05:24 +01:00
|
|
|
printk(BIOS_DEBUG, "refcode loading from vboot rw area.\n");
|
2015-03-28 02:53:30 +01:00
|
|
|
stage = (void *)(uintptr_t)fwc->address;
|
2013-12-13 22:05:24 +01:00
|
|
|
|
2015-03-28 03:17:22 +01:00
|
|
|
if (rmodule_stage_load(refcode, stage)) {
|
2013-12-13 22:05:24 +01:00
|
|
|
printk(BIOS_DEBUG, "Error loading reference code.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-03-28 02:53:30 +01:00
|
|
|
#else
|
|
|
|
static int load_refcode_from_vboot(struct rmod_stage_load *refcode)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
2013-12-13 22:05:24 +01:00
|
|
|
|
|
|
|
static int load_refcode_from_cbfs(struct rmod_stage_load *refcode)
|
|
|
|
{
|
|
|
|
printk(BIOS_DEBUG, "refcode loading from cbfs.\n");
|
|
|
|
|
2015-03-28 03:17:22 +01:00
|
|
|
if (rmodule_stage_load_from_cbfs(refcode)) {
|
2013-12-13 22:05:24 +01:00
|
|
|
printk(BIOS_DEBUG, "Error loading reference code.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static efi_wrapper_entry_t load_reference_code(void)
|
|
|
|
{
|
2015-03-28 03:17:22 +01:00
|
|
|
struct prog prog = {
|
|
|
|
.name = CONFIG_CBFS_PREFIX "/refcode",
|
|
|
|
};
|
2013-12-12 19:29:48 +01:00
|
|
|
struct rmod_stage_load refcode = {
|
|
|
|
.cbmem_id = CBMEM_ID_REFCODE,
|
2015-03-28 03:17:22 +01:00
|
|
|
.prog = &prog,
|
2013-12-12 19:29:48 +01:00
|
|
|
};
|
|
|
|
|
2014-06-19 18:50:51 +02:00
|
|
|
if (acpi_is_wakeup_s3()) {
|
2013-12-13 22:05:24 +01:00
|
|
|
return load_refcode_from_cache();
|
|
|
|
}
|
2013-12-12 19:29:48 +01:00
|
|
|
|
2015-05-12 23:45:56 +02:00
|
|
|
if (load_refcode_from_vboot(&refcode) &&
|
2015-03-28 02:53:30 +01:00
|
|
|
load_refcode_from_cbfs(&refcode))
|
|
|
|
return NULL;
|
2013-12-13 22:05:24 +01:00
|
|
|
|
|
|
|
/* Cache loaded reference code. */
|
2013-12-12 19:29:48 +01:00
|
|
|
cache_refcode(&refcode);
|
|
|
|
|
2015-03-28 03:17:22 +01:00
|
|
|
return prog_entry(&prog);
|
2013-12-12 19:29:48 +01:00
|
|
|
}
|
|
|
|
|
2013-10-24 17:21:43 +02:00
|
|
|
void baytrail_run_reference_code(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
efi_wrapper_entry_t entry;
|
|
|
|
struct efi_wrapper_params wrp = {
|
|
|
|
.version = EFI_WRAPPER_VER,
|
|
|
|
.console_out = send_to_console,
|
|
|
|
};
|
|
|
|
|
2013-12-13 22:05:24 +01:00
|
|
|
entry = load_reference_code();
|
2013-10-24 17:21:43 +02:00
|
|
|
|
2013-12-12 19:29:48 +01:00
|
|
|
if (entry == NULL)
|
|
|
|
return;
|
|
|
|
|
2013-10-28 15:54:22 +01:00
|
|
|
wrp.tsc_ticks_per_microsecond = tsc_freq_mhz();
|
2013-10-24 17:21:43 +02:00
|
|
|
|
|
|
|
/* Call into reference code. */
|
|
|
|
ret = entry(&wrp);
|
|
|
|
|
|
|
|
if (ret != 0) {
|
|
|
|
printk(BIOS_DEBUG, "Reference code returned %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|