blob: 686b09576fbec249cc96383de33b7ea454514037 [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001/*
2This software and ancillary information (herein called SOFTWARE )
3called LinuxBIOS is made available under the terms described
4here. The SOFTWARE has been approved for release with associated
5LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
6been authored by an employee or employees of the University of
7California, operator of the Los Alamos National Laboratory under
8Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
9U.S. Government has rights to use, reproduce, and distribute this
10SOFTWARE. The public may copy, distribute, prepare derivative works
11and publicly display this SOFTWARE without charge, provided that this
12Notice and any statement of authorship are reproduced on all copies.
13Neither the Government nor the University makes any warranty, express
14or implied, or assumes any liability or responsibility for the use of
15this SOFTWARE. If SOFTWARE is modified to produce derivative works,
16such modified SOFTWARE should be clearly marked, so as not to confuse
17it with the version available from LANL.
18 */
19/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
20 * rminnich@lanl.gov
21 */
22
23
24/*
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000025 * C Bootstrap code for the coreboot
Eric Biederman8ca8d762003-04-22 19:02:15 +000026 */
27
Eric Biederman8ca8d762003-04-22 19:02:15 +000028#include <console/console.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000029#include <version.h>
Eric Biederman5899fd82003-04-24 06:25:08 +000030#include <device/device.h>
31#include <device/pci.h>
Eric Biederman9b4336c2003-07-19 04:28:22 +000032#include <delay.h>
Eric Biedermanb78c1972004-10-14 20:54:17 +000033#include <stdlib.h>
Stefan Reinauerde3206a2010-02-22 06:09:43 +000034#include <reset.h>
Stefan Reinauer7e9771c2009-04-22 08:17:38 +000035#include <boot/tables.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000036#include <boot/elf.h>
Peter Stuge483b7bb2009-04-14 07:40:01 +000037#include <cbfs.h>
Stefan Reinauer08670622009-06-30 15:17:49 +000038#if CONFIG_HAVE_ACPI_RESUME
Rudolf Mareka572f832009-04-13 17:57:44 +000039#include <arch/acpi.h>
Stefan Reinauer3935b192009-04-14 06:38:15 +000040#endif
Stefan Reinauer3b314022009-10-26 17:04:28 +000041#if CONFIG_WRITE_HIGH_TABLES
42#include <cbmem.h>
43#endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000044
Li-Ta Lo3a812852004-12-03 22:39:34 +000045/**
Stefan Reinauer3b314022009-10-26 17:04:28 +000046 * @brief Main function of the RAM part of coreboot.
Li-Ta Lo3a812852004-12-03 22:39:34 +000047 *
Stefan Reinauer3b314022009-10-26 17:04:28 +000048 * Coreboot is divided into Pre-RAM part and RAM part.
Li-Ta Lo3a812852004-12-03 22:39:34 +000049 *
50 * Device Enumeration:
51 * In the dev_enumerate() phase,
52 */
Rudolf Mareka572f832009-04-13 17:57:44 +000053
Maciej Pijankaea921852009-10-27 14:29:29 +000054void hardwaremain(int boot_complete);
55
Eric Biederman8ca8d762003-04-22 19:02:15 +000056void hardwaremain(int boot_complete)
57{
Eric Biederman8ca8d762003-04-22 19:02:15 +000058 struct lb_memory *lb_mem;
Eric Biederman8ca8d762003-04-22 19:02:15 +000059
60 post_code(0x80);
Li-Ta Lo6a8745ae2004-05-13 20:39:07 +000061
Stefan Reinauer3b314022009-10-26 17:04:28 +000062 /* console_init() MUST PRECEDE ALL printk()! */
Eric Biederman8ca8d762003-04-22 19:02:15 +000063 console_init();
64
65 post_code(0x39);
arch import user (historical)54d6b082005-07-06 17:17:41 +000066
Stefan Reinauer0001a7f2009-07-21 21:25:45 +000067 printk(BIOS_NOTICE, "coreboot-%s%s %s %s...\n",
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000068 coreboot_version, coreboot_extra_version, coreboot_build,
Li-Ta Lo3a812852004-12-03 22:39:34 +000069 (boot_complete)?"rebooting":"booting");
Eric Biederman8ca8d762003-04-22 19:02:15 +000070
71 post_code(0x40);
72
Eric Biederman8ca8d762003-04-22 19:02:15 +000073 /* If we have already booted attempt a hard reboot */
74 if (boot_complete) {
75 hard_reset();
76 }
Li-Ta Loe5266692004-03-23 21:28:05 +000077
Eric Biederman7003ba42004-10-16 06:20:29 +000078 /* FIXME: Is there a better way to handle this? */
79 init_timer();
Eric Biederman8ca8d762003-04-22 19:02:15 +000080
Eric Biederman018d8dd2004-11-04 11:04:33 +000081 /* Find the devices we don't have hard coded knowledge about. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000082 dev_enumerate();
83 post_code(0x66);
Eric Biederman018d8dd2004-11-04 11:04:33 +000084 /* Now compute and assign the bus resources. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000085 dev_configure();
86 post_code(0x88);
Eric Biederman018d8dd2004-11-04 11:04:33 +000087 /* Now actually enable devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000088 dev_enable();
Eric Biederman018d8dd2004-11-04 11:04:33 +000089 /* And of course initialize devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000090 dev_initialize();
91 post_code(0x89);
Eric Biederman8ca8d762003-04-22 19:02:15 +000092
Stefan Reinauer3b314022009-10-26 17:04:28 +000093#if CONFIG_WRITE_HIGH_TABLES == 1
94 cbmem_initialize();
95#endif
Stefan Reinauer08670622009-06-30 15:17:49 +000096#if CONFIG_HAVE_ACPI_RESUME == 1
Stefan Reinauer7e9771c2009-04-22 08:17:38 +000097 suspend_resume();
98 post_code(0x8a);
Rudolf Mareka572f832009-04-13 17:57:44 +000099#endif
100
Eric Biedermanb78c1972004-10-14 20:54:17 +0000101 /* Now that we have collected all of our information
102 * write our configuration tables.
103 */
104 lb_mem = write_tables();
Patrick Georgi4b8a2412010-02-09 19:35:16 +0000105 cbfs_load_payload(lb_mem, CONFIG_CBFS_PREFIX "/payload");
Stefan Reinauer0001a7f2009-07-21 21:25:45 +0000106 printk(BIOS_ERR, "Boot failed.\n");
Eric Biederman8ca8d762003-04-22 19:02:15 +0000107}
108