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