CBMEM CONSOLE: Add code using the new console driver.
[coreboot.git] / src / boot / hardwaremain.c
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 coreboot
26  */
27
28 #include <console/console.h>
29 #include <version.h>
30 #include <device/device.h>
31 #include <device/pci.h>
32 #include <delay.h>
33 #include <stdlib.h>
34 #include <reset.h>
35 #include <boot/tables.h>
36 #include <boot/elf.h>
37 #include <cbfs.h>
38 #if CONFIG_HAVE_ACPI_RESUME
39 #include <arch/acpi.h>
40 #endif
41 #if CONFIG_WRITE_HIGH_TABLES
42 #include <cbmem.h>
43 #endif
44
45 /**
46  * @brief Main function of the RAM part of coreboot.
47  *
48  * Coreboot is divided into Pre-RAM part and RAM part.
49  *
50  * Device Enumeration:
51  *      In the dev_enumerate() phase,
52  */
53
54 void hardwaremain(int boot_complete);
55
56 void hardwaremain(int boot_complete)
57 {
58         struct lb_memory *lb_mem;
59
60         post_code(POST_ENTRY_RAMSTAGE);
61
62         /* console_init() MUST PRECEDE ALL printk()! */
63         console_init();
64
65         post_code(POST_CONSOLE_READY);
66
67         printk(BIOS_NOTICE, "coreboot-%s%s %s %s...\n",
68                       coreboot_version, coreboot_extra_version, coreboot_build,
69                       (boot_complete)?"rebooting":"booting");
70
71         post_code(POST_CONSOLE_BOOT_MSG);
72
73         /* If we have already booted attempt a hard reboot */
74         if (boot_complete) {
75                 hard_reset();
76         }
77
78         /* FIXME: Is there a better way to handle this? */
79         init_timer();
80
81         /* Find the devices we don't have hard coded knowledge about. */
82         dev_enumerate();
83         post_code(POST_DEVICE_ENUMERATION_COMPLETE);
84         /* Now compute and assign the bus resources. */
85         dev_configure();
86         post_code(POST_DEVICE_CONFIGURATION_COMPLETE);
87         /* Now actually enable devices on the bus */
88         dev_enable();
89         /* And of course initialize devices on the bus */
90         dev_initialize();
91         post_code(POST_DEVICES_ENABLED);
92
93 #if CONFIG_WRITE_HIGH_TABLES == 1
94         cbmem_initialize();
95 #if CONFIG_CONSOLE_CBMEM
96         cbmemc_reinit();
97 #endif
98 #endif
99 #if CONFIG_HAVE_ACPI_RESUME == 1
100         suspend_resume();
101         post_code(0x8a);
102 #endif
103
104         /* Now that we have collected all of our information
105          * write our configuration tables.
106          */
107         lb_mem = write_tables();
108         cbfs_load_payload(lb_mem, CONFIG_CBFS_PREFIX "/payload");
109         printk(BIOS_ERR, "Boot failed.\n");
110 }
111