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 | /* |
| 25 | * C Bootstrap code for the LinuxBIOS |
| 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 | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 31 | #include <boot/tables.h> |
Eric Biederman | 5899fd8 | 2003-04-24 06:25:08 +0000 | [diff] [blame] | 32 | #include <device/device.h> |
| 33 | #include <device/pci.h> |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 34 | #include <delay.h> |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 35 | #include <stdlib.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 36 | #include <part/hard_reset.h> |
Eric Biederman | 6e53f50 | 2004-10-27 08:53:57 +0000 | [diff] [blame^] | 37 | #include <part/init_timer.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 38 | #include <boot/elf.h> |
| 39 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 40 | void hardwaremain(int boot_complete) |
| 41 | { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 42 | /* the order here is a bit tricky. We don't want to do much of |
| 43 | * anything that uses config registers until after PciAllocateResources |
| 44 | * since that function also figures out what kind of config strategy |
| 45 | * to use (type 1 or type 2). |
| 46 | * so we turn on cache, then worry about PCI setup, then do other |
| 47 | * things, so that the other work can use the PciRead* and PciWrite* |
| 48 | * functions. |
| 49 | */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 50 | struct lb_memory *lb_mem; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 51 | |
| 52 | post_code(0x80); |
Li-Ta Lo | 6a8745ae | 2004-05-13 20:39:07 +0000 | [diff] [blame] | 53 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 54 | /* displayinit MUST PRECEDE ALL PRINTK! */ |
| 55 | console_init(); |
| 56 | |
| 57 | post_code(0x39); |
| 58 | printk_notice("LinuxBIOS-%s%s %s %s...\n", |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 59 | linuxbios_version, linuxbios_extra_version, linuxbios_build, |
| 60 | (boot_complete)?"rebooting":"booting"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 61 | |
| 62 | post_code(0x40); |
| 63 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 64 | /* If we have already booted attempt a hard reboot */ |
| 65 | if (boot_complete) { |
| 66 | hard_reset(); |
| 67 | } |
Li-Ta Lo | e526669 | 2004-03-23 21:28:05 +0000 | [diff] [blame] | 68 | |
Eric Biederman | 7003ba4 | 2004-10-16 06:20:29 +0000 | [diff] [blame] | 69 | /* FIXME: Is there a better way to handle this? */ |
| 70 | init_timer(); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 71 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 72 | /* pick how to scan the bus. This is first so we can get at memory size. */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 73 | printk_info("Finding PCI configuration type.\n"); |
| 74 | pci_set_method(); |
| 75 | post_code(0x5f); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 76 | dev_enumerate(); |
| 77 | post_code(0x66); |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 78 | /* Now do the real bus. |
| 79 | * We round the total ram up a lot for thing like the SISFB, which |
| 80 | * shares high memory with the CPU. |
| 81 | */ |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 82 | dev_configure(); |
| 83 | post_code(0x88); |
| 84 | |
| 85 | dev_enable(); |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 86 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 87 | dev_initialize(); |
| 88 | post_code(0x89); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 89 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 90 | /* Now that we have collected all of our information |
| 91 | * write our configuration tables. |
| 92 | */ |
| 93 | lb_mem = write_tables(); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 94 | |
Greg Watson | 9cfecd1 | 2004-03-17 17:10:32 +0000 | [diff] [blame] | 95 | #if CONFIG_FS_STREAM == 1 |
| 96 | filo(lb_mem); |
| 97 | #else |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 98 | elfboot(lb_mem); |
Greg Watson | 9cfecd1 | 2004-03-17 17:10:32 +0000 | [diff] [blame] | 99 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 100 | } |
| 101 | |