blob: c22754fe2812f44f208e178e7dcf8511ebb3dc46 [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
28
29#include <console/console.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000030#include <version.h>
Eric Biederman5899fd82003-04-24 06:25:08 +000031#include <device/device.h>
32#include <device/pci.h>
Eric Biederman9b4336c2003-07-19 04:28:22 +000033#include <delay.h>
Eric Biedermanb78c1972004-10-14 20:54:17 +000034#include <stdlib.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000035#include <part/hard_reset.h>
Eric Biederman6e53f502004-10-27 08:53:57 +000036#include <part/init_timer.h>
Stefan Reinauer7e9771c2009-04-22 08:17:38 +000037#include <boot/tables.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000038#include <boot/elf.h>
Peter Stuge483b7bb2009-04-14 07:40:01 +000039#include <cbfs.h>
Stefan Reinauer7e9771c2009-04-22 08:17:38 +000040#if HAVE_ACPI_RESUME
Rudolf Mareka572f832009-04-13 17:57:44 +000041#include <arch/acpi.h>
Stefan Reinauer3935b192009-04-14 06:38:15 +000042#endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000043
Li-Ta Lo3a812852004-12-03 22:39:34 +000044/**
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000045 * @brief Main function of the DRAM part of coreboot.
Li-Ta Lo3a812852004-12-03 22:39:34 +000046 *
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000047 * Coreboot is divided into Pre-DRAM part and DRAM part.
Li-Ta Lo3a812852004-12-03 22:39:34 +000048 *
49 *
50 * Device Enumeration:
51 * In the dev_enumerate() phase,
52 */
Rudolf Mareka572f832009-04-13 17:57:44 +000053
Eric Biederman8ca8d762003-04-22 19:02:15 +000054void hardwaremain(int boot_complete)
55{
Eric Biederman8ca8d762003-04-22 19:02:15 +000056 struct lb_memory *lb_mem;
Eric Biederman8ca8d762003-04-22 19:02:15 +000057
58 post_code(0x80);
Li-Ta Lo6a8745ae2004-05-13 20:39:07 +000059
Eric Biederman8ca8d762003-04-22 19:02:15 +000060 /* displayinit MUST PRECEDE ALL PRINTK! */
61 console_init();
62
63 post_code(0x39);
arch import user (historical)54d6b082005-07-06 17:17:41 +000064
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000065 printk_notice("coreboot-%s%s %s %s...\n",
66 coreboot_version, coreboot_extra_version, coreboot_build,
Li-Ta Lo3a812852004-12-03 22:39:34 +000067 (boot_complete)?"rebooting":"booting");
Eric Biederman8ca8d762003-04-22 19:02:15 +000068
69 post_code(0x40);
70
Eric Biederman8ca8d762003-04-22 19:02:15 +000071 /* If we have already booted attempt a hard reboot */
72 if (boot_complete) {
73 hard_reset();
74 }
Li-Ta Loe5266692004-03-23 21:28:05 +000075
Eric Biederman7003ba42004-10-16 06:20:29 +000076 /* FIXME: Is there a better way to handle this? */
77 init_timer();
Eric Biederman8ca8d762003-04-22 19:02:15 +000078
Eric Biederman018d8dd2004-11-04 11:04:33 +000079 /* Find the devices we don't have hard coded knowledge about. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000080 dev_enumerate();
81 post_code(0x66);
Eric Biederman018d8dd2004-11-04 11:04:33 +000082 /* Now compute and assign the bus resources. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000083 dev_configure();
84 post_code(0x88);
Eric Biederman018d8dd2004-11-04 11:04:33 +000085 /* Now actually enable devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000086 dev_enable();
Eric Biederman018d8dd2004-11-04 11:04:33 +000087 /* And of course initialize devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000088 dev_initialize();
89 post_code(0x89);
Eric Biederman8ca8d762003-04-22 19:02:15 +000090
Rudolf Mareka572f832009-04-13 17:57:44 +000091#if HAVE_ACPI_RESUME == 1
Stefan Reinauer7e9771c2009-04-22 08:17:38 +000092 suspend_resume();
93 post_code(0x8a);
Rudolf Mareka572f832009-04-13 17:57:44 +000094#endif
95
Eric Biedermanb78c1972004-10-14 20:54:17 +000096 /* Now that we have collected all of our information
97 * write our configuration tables.
98 */
99 lb_mem = write_tables();
Peter Stuge483b7bb2009-04-14 07:40:01 +0000100#if CONFIG_CBFS == 1
Stefan Reinauer61dc06c2009-04-01 13:54:16 +0000101# if USE_FALLBACK_IMAGE == 1
Peter Stuge483b7bb2009-04-14 07:40:01 +0000102 void (*pl)(void) = cbfs_load_payload(lb_mem, "fallback/payload");
Stefan Reinauer61dc06c2009-04-01 13:54:16 +0000103# else
Peter Stuge483b7bb2009-04-14 07:40:01 +0000104 void (*pl)(void) = cbfs_load_payload(lb_mem, "normal/payload");
Stefan Reinauer61dc06c2009-04-01 13:54:16 +0000105# endif
Ronald G. Minnichae631262009-04-01 10:48:39 +0000106#endif
107
Stefan Reinauer61dc06c2009-04-01 13:54:16 +0000108#if CONFIG_FS_PAYLOAD == 1
109#warning "CONFIG_FS_PAYLOAD is deprecated."
110 filo(lb_mem);
111#else
112#warning "elfboot will soon be deprecated."
Ronald G. Minnichae631262009-04-01 10:48:39 +0000113 elfboot(lb_mem);
Stefan Reinauer61dc06c2009-04-01 13:54:16 +0000114#endif
115 printk_err("Boot failed.\n");
Eric Biederman8ca8d762003-04-22 19:02:15 +0000116}
117