The wake_vec must be HAVE_ACPI_RESUME guarded because PPC uses -Werror on this file.
[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
29 #include <console/console.h>
30 #include <version.h>
31 #include <boot/tables.h>
32 #include <device/device.h>
33 #include <device/pci.h>
34 #include <delay.h>
35 #include <stdlib.h>
36 #include <part/hard_reset.h>
37 #include <part/init_timer.h>
38 #include <boot/elf.h>
39 #include <romfs.h>
40 #include <arch/acpi.h>
41
42 /**
43  * @brief Main function of the DRAM part of coreboot.
44  *
45  * Coreboot is divided into Pre-DRAM part and DRAM part. 
46  *
47  * 
48  * Device Enumeration:
49  *      In the dev_enumerate() phase, 
50  */
51
52 void hardwaremain(int boot_complete)
53 {
54         struct lb_memory *lb_mem;
55 #if HAVE_ACPI_RESUME == 1
56         void *wake_vec;
57 #endif
58
59         post_code(0x80);
60
61         /* displayinit MUST PRECEDE ALL PRINTK! */
62         console_init();
63         
64         post_code(0x39);
65
66         printk_notice("coreboot-%s%s %s %s...\n", 
67                       coreboot_version, coreboot_extra_version, coreboot_build,
68                       (boot_complete)?"rebooting":"booting");
69
70         post_code(0x40);
71
72         /* If we have already booted attempt a hard reboot */
73         if (boot_complete) {
74                 hard_reset();
75         }
76
77         /* FIXME: Is there a better way to handle this? */
78         init_timer(); 
79
80         /* Find the devices we don't have hard coded knowledge about. */
81         dev_enumerate();
82         post_code(0x66);
83         /* Now compute and assign the bus resources. */
84         dev_configure();
85         post_code(0x88);
86         /* Now actually enable devices on the bus */
87         dev_enable();
88         /* And of course initialize devices on the bus */
89         dev_initialize();
90         post_code(0x89);
91
92 #if HAVE_ACPI_RESUME == 1
93
94 #if MEM_TRAIN_SEQ != 0
95         #error "So far it works on AMD and MEM_TRAIN_SEQ == 0"
96 #endif
97
98 #if _RAMBASE < 0x1F00000
99         #error "For ACPI RESUME you need to have _RAMBASE at least 31MB"
100         #error "Chipset support (S3_NVRAM_EARLY and ACPI_IS_WAKEUP_EARLY functions and memory ctrl)"
101         #error "And coreboot memory reserved in mainboard.c"
102 #endif
103         /* if we happen to be resuming find wakeup vector and jump to OS */
104         wake_vec = acpi_find_wakeup_vector();
105         if (wake_vec)
106                 acpi_jump_to_wakeup(wake_vec);
107 #endif
108
109         /* Now that we have collected all of our information
110          * write our configuration tables.
111          */
112         lb_mem = write_tables();
113 #if CONFIG_ROMFS == 1
114 # if USE_FALLBACK_IMAGE == 1
115         void (*pl)(void) = romfs_load_payload(lb_mem, "fallback/payload");
116 # else
117         void (*pl)(void) = romfs_load_payload(lb_mem, "normal/payload");
118 # endif
119 #endif
120
121 #if CONFIG_FS_PAYLOAD == 1
122 #warning "CONFIG_FS_PAYLOAD is deprecated."
123         filo(lb_mem);
124 #else
125 #warning "elfboot will soon be deprecated."
126         elfboot(lb_mem);
127 #endif
128         printk_err("Boot failed.\n");
129 }
130