2003-04-22 21:02:15 +02:00
|
|
|
/*
|
|
|
|
This software and ancillary information (herein called SOFTWARE )
|
|
|
|
called LinuxBIOS is made available under the terms described
|
|
|
|
here. The SOFTWARE has been approved for release with associated
|
|
|
|
LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
|
|
|
|
been authored by an employee or employees of the University of
|
|
|
|
California, operator of the Los Alamos National Laboratory under
|
|
|
|
Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
|
|
|
|
U.S. Government has rights to use, reproduce, and distribute this
|
|
|
|
SOFTWARE. The public may copy, distribute, prepare derivative works
|
|
|
|
and publicly display this SOFTWARE without charge, provided that this
|
|
|
|
Notice and any statement of authorship are reproduced on all copies.
|
|
|
|
Neither the Government nor the University makes any warranty, express
|
|
|
|
or implied, or assumes any liability or responsibility for the use of
|
|
|
|
this SOFTWARE. If SOFTWARE is modified to produce derivative works,
|
|
|
|
such modified SOFTWARE should be clearly marked, so as not to confuse
|
|
|
|
it with the version available from LANL.
|
|
|
|
*/
|
|
|
|
/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
|
|
|
|
* rminnich@lanl.gov
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2008-01-18 16:08:58 +01:00
|
|
|
* C Bootstrap code for the coreboot
|
2003-04-22 21:02:15 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <console/console.h>
|
|
|
|
#include <version.h>
|
2003-04-24 08:25:08 +02:00
|
|
|
#include <device/device.h>
|
|
|
|
#include <device/pci.h>
|
2003-07-19 06:28:22 +02:00
|
|
|
#include <delay.h>
|
2004-10-14 22:54:17 +02:00
|
|
|
#include <stdlib.h>
|
2010-02-22 07:09:43 +01:00
|
|
|
#include <reset.h>
|
2009-04-22 10:17:38 +02:00
|
|
|
#include <boot/tables.h>
|
2003-04-22 21:02:15 +02:00
|
|
|
#include <boot/elf.h>
|
2009-04-14 09:40:01 +02:00
|
|
|
#include <cbfs.h>
|
2012-06-13 01:29:32 +02:00
|
|
|
#include <lib.h>
|
2009-06-30 17:17:49 +02:00
|
|
|
#if CONFIG_HAVE_ACPI_RESUME
|
2009-04-13 19:57:44 +02:00
|
|
|
#include <arch/acpi.h>
|
2009-04-14 08:38:15 +02:00
|
|
|
#endif
|
2009-10-26 18:04:28 +01:00
|
|
|
#if CONFIG_WRITE_HIGH_TABLES
|
|
|
|
#include <cbmem.h>
|
|
|
|
#endif
|
2011-11-04 20:31:58 +01:00
|
|
|
#include <timestamp.h>
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2004-12-03 23:39:34 +01:00
|
|
|
/**
|
2009-10-26 18:04:28 +01:00
|
|
|
* @brief Main function of the RAM part of coreboot.
|
2004-12-03 23:39:34 +01:00
|
|
|
*
|
2010-04-27 08:56:47 +02:00
|
|
|
* Coreboot is divided into Pre-RAM part and RAM part.
|
|
|
|
*
|
2004-12-03 23:39:34 +01:00
|
|
|
* Device Enumeration:
|
2010-04-27 08:56:47 +02:00
|
|
|
* In the dev_enumerate() phase,
|
2004-12-03 23:39:34 +01:00
|
|
|
*/
|
2009-04-13 19:57:44 +02:00
|
|
|
|
2009-10-27 15:29:29 +01:00
|
|
|
void hardwaremain(int boot_complete);
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
void hardwaremain(int boot_complete)
|
|
|
|
{
|
|
|
|
struct lb_memory *lb_mem;
|
2012-04-24 16:01:24 +02:00
|
|
|
#if CONFIG_COLLECT_TIMESTAMPS
|
2011-11-04 20:31:58 +01:00
|
|
|
tsc_t timestamps[6];
|
|
|
|
timestamps[0] = rdtsc();
|
2012-04-24 16:01:24 +02:00
|
|
|
#endif
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_ENTRY_RAMSTAGE);
|
2004-05-13 22:39:07 +02:00
|
|
|
|
2009-10-26 18:04:28 +01:00
|
|
|
/* console_init() MUST PRECEDE ALL printk()! */
|
2003-04-22 21:02:15 +02:00
|
|
|
console_init();
|
2010-04-27 08:56:47 +02:00
|
|
|
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_CONSOLE_READY);
|
2005-07-06 19:17:41 +02:00
|
|
|
|
2010-04-27 08:56:47 +02:00
|
|
|
printk(BIOS_NOTICE, "coreboot-%s%s %s %s...\n",
|
2008-01-18 16:08:58 +01:00
|
|
|
coreboot_version, coreboot_extra_version, coreboot_build,
|
2004-12-03 23:39:34 +01:00
|
|
|
(boot_complete)?"rebooting":"booting");
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_CONSOLE_BOOT_MSG);
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
/* If we have already booted attempt a hard reboot */
|
|
|
|
if (boot_complete) {
|
|
|
|
hard_reset();
|
|
|
|
}
|
2004-03-23 22:28:05 +01:00
|
|
|
|
2004-10-16 08:20:29 +02:00
|
|
|
/* FIXME: Is there a better way to handle this? */
|
2010-04-27 08:56:47 +02:00
|
|
|
init_timer();
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2012-04-24 16:01:24 +02:00
|
|
|
#if CONFIG_COLLECT_TIMESTAMPS
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamps[1] = rdtsc();
|
2012-04-24 16:01:24 +02:00
|
|
|
#endif
|
2004-11-04 12:04:33 +01:00
|
|
|
/* Find the devices we don't have hard coded knowledge about. */
|
2003-04-22 21:02:15 +02:00
|
|
|
dev_enumerate();
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_DEVICE_ENUMERATION_COMPLETE);
|
2011-11-04 20:31:58 +01:00
|
|
|
|
2012-04-24 16:01:24 +02:00
|
|
|
#if CONFIG_COLLECT_TIMESTAMPS
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamps[2] = rdtsc();
|
2012-04-24 16:01:24 +02:00
|
|
|
#endif
|
2004-11-04 12:04:33 +01:00
|
|
|
/* Now compute and assign the bus resources. */
|
2003-04-22 21:02:15 +02:00
|
|
|
dev_configure();
|
2011-04-11 22:17:22 +02:00
|
|
|
post_code(POST_DEVICE_CONFIGURATION_COMPLETE);
|
2011-11-04 20:31:58 +01:00
|
|
|
|
2012-04-24 16:01:24 +02:00
|
|
|
#if CONFIG_COLLECT_TIMESTAMPS
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamps[3] = rdtsc();
|
2012-04-24 16:01:24 +02:00
|
|
|
#endif
|
2004-11-04 12:04:33 +01:00
|
|
|
/* Now actually enable devices on the bus */
|
2003-04-22 21:02:15 +02:00
|
|
|
dev_enable();
|
2012-08-07 22:14:20 +02:00
|
|
|
post_code(POST_DEVICES_ENABLED);
|
2011-11-04 20:31:58 +01:00
|
|
|
|
2012-04-24 16:01:24 +02:00
|
|
|
#if CONFIG_COLLECT_TIMESTAMPS
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamps[4] = rdtsc();
|
2012-04-24 16:01:24 +02:00
|
|
|
#endif
|
2004-11-04 12:04:33 +01:00
|
|
|
/* And of course initialize devices on the bus */
|
2003-04-22 21:02:15 +02:00
|
|
|
dev_initialize();
|
2012-08-07 22:14:20 +02:00
|
|
|
post_code(POST_DEVICES_INITIALIZED);
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2012-04-24 16:01:24 +02:00
|
|
|
#if CONFIG_COLLECT_TIMESTAMPS
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamps[5] = rdtsc();
|
2012-04-24 16:01:24 +02:00
|
|
|
#endif
|
|
|
|
|
Clean up #ifs
Replace #if CONFIG_FOO==1 with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1[[:space:]]*\$,#if \1," {} +
Replace #if (CONFIG_FOO==1) with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1)[[:space:]]*\$,#if \1," {} +
Replace #if CONFIG_FOO==0 with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0[[:space:]]*\$,#if \!\1," {} +
Replace #if (CONFIG_FOO==0) with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0)[[:space:]]*\$,#if \!\1," {} +
(and some manual changes to fix false positives)
Change-Id: Iac6ca7605a5f99885258cf1a9a2473a92de27c42
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/1004
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Martin Roth <martin@se-eng.com>
2012-05-05 15:29:32 +02:00
|
|
|
#if CONFIG_WRITE_HIGH_TABLES
|
2009-10-26 18:04:28 +01:00
|
|
|
cbmem_initialize();
|
2011-09-30 20:16:49 +02:00
|
|
|
#if CONFIG_CONSOLE_CBMEM
|
|
|
|
cbmemc_reinit();
|
|
|
|
#endif
|
2009-10-26 18:04:28 +01:00
|
|
|
#endif
|
Clean up #ifs
Replace #if CONFIG_FOO==1 with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1[[:space:]]*\$,#if \1," {} +
Replace #if (CONFIG_FOO==1) with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1)[[:space:]]*\$,#if \1," {} +
Replace #if CONFIG_FOO==0 with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0[[:space:]]*\$,#if \!\1," {} +
Replace #if (CONFIG_FOO==0) with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0)[[:space:]]*\$,#if \!\1," {} +
(and some manual changes to fix false positives)
Change-Id: Iac6ca7605a5f99885258cf1a9a2473a92de27c42
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/1004
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Martin Roth <martin@se-eng.com>
2012-05-05 15:29:32 +02:00
|
|
|
#if CONFIG_HAVE_ACPI_RESUME
|
2009-04-22 10:17:38 +02:00
|
|
|
suspend_resume();
|
|
|
|
post_code(0x8a);
|
2009-04-13 19:57:44 +02:00
|
|
|
#endif
|
|
|
|
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamp_add(TS_START_RAMSTAGE, timestamps[0]);
|
|
|
|
timestamp_add(TS_DEVICE_ENUMERATE, timestamps[1]);
|
|
|
|
timestamp_add(TS_DEVICE_CONFIGURE, timestamps[2]);
|
|
|
|
timestamp_add(TS_DEVICE_ENABLE, timestamps[3]);
|
|
|
|
timestamp_add(TS_DEVICE_INITIALIZE, timestamps[4]);
|
|
|
|
timestamp_add(TS_DEVICE_DONE, timestamps[5]);
|
2012-05-10 21:15:18 +02:00
|
|
|
timestamp_add_now(TS_CBMEM_POST);
|
|
|
|
|
2012-09-22 14:52:24 +02:00
|
|
|
#if CONFIG_WRITE_HIGH_TABLES
|
2012-05-10 21:15:18 +02:00
|
|
|
if (cbmem_post_handling)
|
|
|
|
cbmem_post_handling();
|
2012-09-22 14:52:24 +02:00
|
|
|
#endif
|
2012-05-10 21:15:18 +02:00
|
|
|
|
2011-11-04 20:31:58 +01:00
|
|
|
timestamp_add_now(TS_WRITE_TABLES);
|
|
|
|
|
2004-10-14 22:54:17 +02:00
|
|
|
/* Now that we have collected all of our information
|
|
|
|
* write our configuration tables.
|
|
|
|
*/
|
|
|
|
lb_mem = write_tables();
|
2011-11-04 20:31:58 +01:00
|
|
|
|
|
|
|
timestamp_add_now(TS_LOAD_PAYLOAD);
|
2012-06-13 01:29:32 +02:00
|
|
|
|
|
|
|
void *payload;
|
|
|
|
payload = cbfs_load_payload(lb_mem, CONFIG_CBFS_PREFIX "/payload");
|
|
|
|
if (! payload)
|
|
|
|
die("Could not find a payload\n");
|
|
|
|
|
|
|
|
printk(BIOS_DEBUG, "Got a payload\n");
|
|
|
|
/* Before we go off to run the payload, see if
|
|
|
|
* we stayed within our bounds.
|
|
|
|
*/
|
|
|
|
checkstack(&_estack, 0);
|
|
|
|
|
|
|
|
selfboot(lb_mem, payload);
|
|
|
|
printk(BIOS_EMERG, "Boot failed");
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|
|
|
|
|