Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | This software and ancillary information (herein called SOFTWARE ) |
| 3 | called LinuxBIOS is made available under the terms described |
| 4 | here. The SOFTWARE has been approved for release with associated |
| 5 | LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has |
| 6 | been authored by an employee or employees of the University of |
| 7 | California, operator of the Los Alamos National Laboratory under |
| 8 | Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The |
| 9 | U.S. Government has rights to use, reproduce, and distribute this |
| 10 | SOFTWARE. The public may copy, distribute, prepare derivative works |
| 11 | and publicly display this SOFTWARE without charge, provided that this |
| 12 | Notice and any statement of authorship are reproduced on all copies. |
| 13 | Neither the Government nor the University makes any warranty, express |
| 14 | or implied, or assumes any liability or responsibility for the use of |
| 15 | this SOFTWARE. If SOFTWARE is modified to produce derivative works, |
| 16 | such modified SOFTWARE should be clearly marked, so as not to confuse |
| 17 | it 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 Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 25 | * C Bootstrap code for the coreboot |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | |
| 29 | #include <console/console.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 30 | #include <version.h> |
Eric Biederman | 5899fd8 | 2003-04-24 06:25:08 +0000 | [diff] [blame] | 31 | #include <device/device.h> |
| 32 | #include <device/pci.h> |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 33 | #include <delay.h> |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 34 | #include <stdlib.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 35 | #include <part/hard_reset.h> |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame] | 36 | #include <part/init_timer.h> |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 37 | #include <boot/tables.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 38 | #include <boot/elf.h> |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 39 | #include <cbfs.h> |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 40 | #if HAVE_ACPI_RESUME |
Rudolf Marek | a572f83 | 2009-04-13 17:57:44 +0000 | [diff] [blame] | 41 | #include <arch/acpi.h> |
Stefan Reinauer | 3935b19 | 2009-04-14 06:38:15 +0000 | [diff] [blame] | 42 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 43 | |
Li-Ta Lo | 3a81285 | 2004-12-03 22:39:34 +0000 | [diff] [blame] | 44 | /** |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 45 | * @brief Main function of the DRAM part of coreboot. |
Li-Ta Lo | 3a81285 | 2004-12-03 22:39:34 +0000 | [diff] [blame] | 46 | * |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 47 | * Coreboot is divided into Pre-DRAM part and DRAM part. |
Li-Ta Lo | 3a81285 | 2004-12-03 22:39:34 +0000 | [diff] [blame] | 48 | * |
| 49 | * |
| 50 | * Device Enumeration: |
| 51 | * In the dev_enumerate() phase, |
| 52 | */ |
Rudolf Marek | a572f83 | 2009-04-13 17:57:44 +0000 | [diff] [blame] | 53 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 54 | void hardwaremain(int boot_complete) |
| 55 | { |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 56 | struct lb_memory *lb_mem; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 57 | |
| 58 | post_code(0x80); |
Li-Ta Lo | 6a8745ae | 2004-05-13 20:39:07 +0000 | [diff] [blame] | 59 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 60 | /* displayinit MUST PRECEDE ALL PRINTK! */ |
| 61 | console_init(); |
| 62 | |
| 63 | post_code(0x39); |
arch import user (historical) | 54d6b08 | 2005-07-06 17:17:41 +0000 | [diff] [blame] | 64 | |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 65 | printk_notice("coreboot-%s%s %s %s...\n", |
| 66 | coreboot_version, coreboot_extra_version, coreboot_build, |
Li-Ta Lo | 3a81285 | 2004-12-03 22:39:34 +0000 | [diff] [blame] | 67 | (boot_complete)?"rebooting":"booting"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 68 | |
| 69 | post_code(0x40); |
| 70 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 71 | /* If we have already booted attempt a hard reboot */ |
| 72 | if (boot_complete) { |
| 73 | hard_reset(); |
| 74 | } |
Li-Ta Lo | e526669 | 2004-03-23 21:28:05 +0000 | [diff] [blame] | 75 | |
Eric Biederman | 7003ba4 | 2004-10-16 06:20:29 +0000 | [diff] [blame] | 76 | /* FIXME: Is there a better way to handle this? */ |
| 77 | init_timer(); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 78 | |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 79 | /* Find the devices we don't have hard coded knowledge about. */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 80 | dev_enumerate(); |
| 81 | post_code(0x66); |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 82 | /* Now compute and assign the bus resources. */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 83 | dev_configure(); |
| 84 | post_code(0x88); |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 85 | /* Now actually enable devices on the bus */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 86 | dev_enable(); |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 87 | /* And of course initialize devices on the bus */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 88 | dev_initialize(); |
| 89 | post_code(0x89); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 90 | |
Rudolf Marek | a572f83 | 2009-04-13 17:57:44 +0000 | [diff] [blame] | 91 | #if HAVE_ACPI_RESUME == 1 |
Stefan Reinauer | 7e9771c | 2009-04-22 08:17:38 +0000 | [diff] [blame] | 92 | suspend_resume(); |
| 93 | post_code(0x8a); |
Rudolf Marek | a572f83 | 2009-04-13 17:57:44 +0000 | [diff] [blame] | 94 | #endif |
| 95 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 96 | /* Now that we have collected all of our information |
| 97 | * write our configuration tables. |
| 98 | */ |
| 99 | lb_mem = write_tables(); |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 100 | #if CONFIG_CBFS == 1 |
Stefan Reinauer | 61dc06c | 2009-04-01 13:54:16 +0000 | [diff] [blame] | 101 | # if USE_FALLBACK_IMAGE == 1 |
Myles Watson | fa12b67 | 2009-04-30 22:45:41 +0000 | [diff] [blame] | 102 | cbfs_load_payload(lb_mem, "fallback/payload"); |
Stefan Reinauer | 61dc06c | 2009-04-01 13:54:16 +0000 | [diff] [blame] | 103 | # else |
Myles Watson | fa12b67 | 2009-04-30 22:45:41 +0000 | [diff] [blame] | 104 | cbfs_load_payload(lb_mem, "normal/payload"); |
Stefan Reinauer | 61dc06c | 2009-04-01 13:54:16 +0000 | [diff] [blame] | 105 | # endif |
Patrick Georgi | 12aba82 | 2009-04-30 07:07:22 +0000 | [diff] [blame] | 106 | #else |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 107 | |
Stefan Reinauer | 61dc06c | 2009-04-01 13:54:16 +0000 | [diff] [blame] | 108 | #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. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 113 | elfboot(lb_mem); |
Stefan Reinauer | 61dc06c | 2009-04-01 13:54:16 +0000 | [diff] [blame] | 114 | #endif |
Patrick Georgi | 12aba82 | 2009-04-30 07:07:22 +0000 | [diff] [blame] | 115 | #endif |
Stefan Reinauer | 61dc06c | 2009-04-01 13:54:16 +0000 | [diff] [blame] | 116 | printk_err("Boot failed.\n"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 117 | } |
| 118 | |