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