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