rename Iwill to iwill to keep naming scheme consistent
[coreboot.git] / src / mainboard / iwill / DK8X / failover.c
1 #define ASSEMBLY 1
2 #include <stdint.h>
3 #include <device/pci_def.h>
4 #include <device/pci_ids.h>
5 #include <arch/io.h>
6 #include <arch/romcc_io.h>
7 #include <cpu/x86/lapic.h>
8 #include "pc80/mc146818rtc_early.c"
9 #include "southbridge/amd/amd8111/amd8111_enable_rom.c"
10 #include "northbridge/amd/amdk8/early_ht.c"
11 #include "cpu/x86/lapic/boot_cpu.c"
12 #include "cpu/x86/mtrr/earlymtrr.c"
13 #include "northbridge/amd/amdk8/reset_test.c"
14
15 static unsigned long main(unsigned long bist)
16 {
17         unsigned nodeid;
18
19         /* Make cerain my local apic is useable */
20         enable_lapic();
21
22         /* Is this a cpu only reset? */
23         if (early_mtrr_init_detected()) {
24                 if (last_boot_normal()) {
25                         goto normal_image;
26                 } else {
27                         goto fallback_image;
28                 }
29         }
30         /* Is this a secondary cpu? */
31         if (!boot_cpu()) {
32                 if (last_boot_normal()) {
33                         goto normal_image;
34                 } else {
35                         goto fallback_image;
36                 }
37         }
38         
39
40         /* Nothing special needs to be done to find bus 0 */
41         /* Allow the HT devices to be found */
42         enumerate_ht_chain();
43         
44         /* Setup the 8111 */
45         amd8111_enable_rom();
46
47         /* Is this a deliberate reset by the bios */
48         if (bios_reset_detected() && last_boot_normal()) {
49                 goto normal_image;
50         }
51         /* This is the primary cpu how should I boot? */
52         else if (do_normal_boot()) {
53                 goto normal_image;
54         }
55         else {
56                 goto fallback_image;
57         }
58  normal_image:
59         asm volatile ("jmp __normal_image" 
60                 : /* outputs */ 
61                 : "a" (bist) /* inputs */
62                 : /* clobbers */
63                 );
64  fallback_image:
65         return bist;
66 }