Revision: linuxbios@linuxbios.org--devel/freebios--devel--2.0--patch-58
[coreboot.git] / src / mainboard / Iwill / DK8S2 / 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 "northbridge/amd/amdk8/reset_test.c"
13
14 static unsigned long main(unsigned long bist)
15 {
16         unsigned nodeid;
17
18         /* Make cerain my local apic is useable */
19         enable_lapic();
20
21         /* Is this a cpu only reset? */
22         if (cpu_init_detected(nodeid)) {
23                 if (last_boot_normal()) {
24                         goto normal_image;
25                 } else {
26                         goto cpu_reset;
27                 }
28         }
29         /* Is this a secondary cpu? */
30         if (!boot_cpu()) {
31                 if (last_boot_normal()) {
32                         goto normal_image;
33                 } else {
34                         goto fallback_image;
35                 }
36         }
37         
38
39         /* Nothing special needs to be done to find bus 0 */
40         /* Allow the HT devices to be found */
41         enumerate_ht_chain();
42         
43         /* Setup the 8111 */
44         amd8111_enable_rom();
45
46         /* Is this a deliberate reset by the bios */
47         if (bios_reset_detected() && last_boot_normal()) {
48                 goto normal_image;
49         }
50         /* This is the primary cpu how should I boot? */
51         else if (do_normal_boot()) {
52                 goto normal_image;
53         }
54         else {
55                 goto fallback_image;
56         }
57  normal_image:
58         asm volatile ("jmp __normal_image" 
59                 : /* outputs */ 
60                 : "a" (bist) /* inputs */
61                 : /* clobbers */
62                 );
63  cpu_reset:
64         asm volatile ("jmp __cpu_reset"
65                 : /* outputs */ 
66                 : "a"(bist) /* inputs */
67                 : /* clobbers */
68                 );
69  fallback_image:
70         return bist;
71 }