blob: cc3741f58352ecbd071df3fb4b47cf27d724d5fc [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 Biederman8ca8d762003-04-22 19:02:15 +000031#include <boot/tables.h>
Eric Biederman5899fd82003-04-24 06:25:08 +000032#include <device/device.h>
33#include <device/pci.h>
Eric Biederman9b4336c2003-07-19 04:28:22 +000034#include <delay.h>
Eric Biedermanb78c1972004-10-14 20:54:17 +000035#include <stdlib.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000036#include <part/hard_reset.h>
Eric Biederman6e53f502004-10-27 08:53:57 +000037#include <part/init_timer.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000038#include <boot/elf.h>
39
Li-Ta Lo3a812852004-12-03 22:39:34 +000040/**
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000041 * @brief Main function of the DRAM part of coreboot.
Li-Ta Lo3a812852004-12-03 22:39:34 +000042 *
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000043 * Coreboot is divided into Pre-DRAM part and DRAM part.
Li-Ta Lo3a812852004-12-03 22:39:34 +000044 *
45 *
46 * Device Enumeration:
47 * In the dev_enumerate() phase,
48 */
Eric Biederman8ca8d762003-04-22 19:02:15 +000049void hardwaremain(int boot_complete)
50{
Eric Biederman8ca8d762003-04-22 19:02:15 +000051 struct lb_memory *lb_mem;
Eric Biederman8ca8d762003-04-22 19:02:15 +000052
53 post_code(0x80);
Li-Ta Lo6a8745ae2004-05-13 20:39:07 +000054
Eric Biederman8ca8d762003-04-22 19:02:15 +000055 /* displayinit MUST PRECEDE ALL PRINTK! */
56 console_init();
57
58 post_code(0x39);
arch import user (historical)54d6b082005-07-06 17:17:41 +000059
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000060 printk_notice("coreboot-%s%s %s %s...\n",
61 coreboot_version, coreboot_extra_version, coreboot_build,
Li-Ta Lo3a812852004-12-03 22:39:34 +000062 (boot_complete)?"rebooting":"booting");
Eric Biederman8ca8d762003-04-22 19:02:15 +000063
64 post_code(0x40);
65
Eric Biederman8ca8d762003-04-22 19:02:15 +000066 /* If we have already booted attempt a hard reboot */
67 if (boot_complete) {
68 hard_reset();
69 }
Li-Ta Loe5266692004-03-23 21:28:05 +000070
Eric Biederman7003ba42004-10-16 06:20:29 +000071 /* FIXME: Is there a better way to handle this? */
72 init_timer();
Eric Biederman8ca8d762003-04-22 19:02:15 +000073
Eric Biederman018d8dd2004-11-04 11:04:33 +000074 /* Find the devices we don't have hard coded knowledge about. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000075 dev_enumerate();
76 post_code(0x66);
Eric Biederman018d8dd2004-11-04 11:04:33 +000077 /* Now compute and assign the bus resources. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000078 dev_configure();
79 post_code(0x88);
Eric Biederman018d8dd2004-11-04 11:04:33 +000080 /* Now actually enable devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000081 dev_enable();
Eric Biederman018d8dd2004-11-04 11:04:33 +000082 /* And of course initialize devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000083 dev_initialize();
84 post_code(0x89);
Eric Biederman8ca8d762003-04-22 19:02:15 +000085
Eric Biedermanb78c1972004-10-14 20:54:17 +000086 /* Now that we have collected all of our information
87 * write our configuration tables.
88 */
89 lb_mem = write_tables();
Eric Biederman8ca8d762003-04-22 19:02:15 +000090
Ed Swierkbe13dc72006-12-15 12:56:28 +000091#if CONFIG_FS_PAYLOAD == 1
Greg Watson9cfecd12004-03-17 17:10:32 +000092 filo(lb_mem);
93#else
Eric Biederman8ca8d762003-04-22 19:02:15 +000094 elfboot(lb_mem);
Greg Watson9cfecd12004-03-17 17:10:32 +000095#endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000096}
97