blob: 50126261d7e2670f269f5c1a03c8835e2f0a1327 [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/*
25 * C Bootstrap code for the LinuxBIOS
26 */
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
Eric Biederman8ca8d762003-04-22 19:02:15 +000040void hardwaremain(int boot_complete)
41{
Eric Biedermanb78c1972004-10-14 20:54:17 +000042 /* 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 Biederman8ca8d762003-04-22 19:02:15 +000050 struct lb_memory *lb_mem;
Eric Biederman8ca8d762003-04-22 19:02:15 +000051
52 post_code(0x80);
Li-Ta Lo6a8745ae2004-05-13 20:39:07 +000053
Eric Biederman8ca8d762003-04-22 19:02:15 +000054 /* displayinit MUST PRECEDE ALL PRINTK! */
55 console_init();
56
57 post_code(0x39);
58 printk_notice("LinuxBIOS-%s%s %s %s...\n",
Eric Biedermanb78c1972004-10-14 20:54:17 +000059 linuxbios_version, linuxbios_extra_version, linuxbios_build,
60 (boot_complete)?"rebooting":"booting");
Eric Biederman8ca8d762003-04-22 19:02:15 +000061
62 post_code(0x40);
63
Eric Biederman8ca8d762003-04-22 19:02:15 +000064 /* If we have already booted attempt a hard reboot */
65 if (boot_complete) {
66 hard_reset();
67 }
Li-Ta Loe5266692004-03-23 21:28:05 +000068
Eric Biederman7003ba42004-10-16 06:20:29 +000069 /* FIXME: Is there a better way to handle this? */
70 init_timer();
Eric Biederman8ca8d762003-04-22 19:02:15 +000071
Eric Biederman018d8dd2004-11-04 11:04:33 +000072 /* Find the devices we don't have hard coded knowledge about. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000073 dev_enumerate();
74 post_code(0x66);
Eric Biederman018d8dd2004-11-04 11:04:33 +000075 /* Now compute and assign the bus resources. */
Eric Biederman8ca8d762003-04-22 19:02:15 +000076 dev_configure();
77 post_code(0x88);
Eric Biederman018d8dd2004-11-04 11:04:33 +000078 /* Now actually enable devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000079 dev_enable();
Eric Biederman018d8dd2004-11-04 11:04:33 +000080 /* And of course initialize devices on the bus */
Eric Biederman8ca8d762003-04-22 19:02:15 +000081 dev_initialize();
82 post_code(0x89);
Eric Biederman8ca8d762003-04-22 19:02:15 +000083
Eric Biedermanb78c1972004-10-14 20:54:17 +000084 /* Now that we have collected all of our information
85 * write our configuration tables.
86 */
87 lb_mem = write_tables();
Eric Biederman8ca8d762003-04-22 19:02:15 +000088
Greg Watson9cfecd12004-03-17 17:10:32 +000089#if CONFIG_FS_STREAM == 1
90 filo(lb_mem);
91#else
Eric Biederman8ca8d762003-04-22 19:02:15 +000092 elfboot(lb_mem);
Greg Watson9cfecd12004-03-17 17:10:32 +000093#endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000094}
95