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