blob: 5d5e7e9bba2f41a462a05bb416c9cba5b7dad163 [file] [log] [blame]
Stefan Reinauerb980e392003-08-28 17:23:15 +00001#define ASSEMBLY 1
2#include <stdint.h>
3#include <device/pci_def.h>
4#include <device/pci_ids.h>
5#include <arch/io.h>
Stefan Reinauera49f4162004-10-21 17:06:49 +00006#include <arch/romcc_io.h>
7#include <cpu/x86/lapic.h>
Stefan Reinauerb980e392003-08-28 17:23:15 +00008#include "pc80/mc146818rtc_early.c"
9#include "southbridge/amd/amd8111/amd8111_enable_rom.c"
10#include "northbridge/amd/amdk8/early_ht.c"
Stefan Reinauera49f4162004-10-21 17:06:49 +000011#include "cpu/x86/lapic/boot_cpu.c"
Stefan Reinauerb980e392003-08-28 17:23:15 +000012#include "northbridge/amd/amdk8/reset_test.c"
13
Stefan Reinauera49f4162004-10-21 17:06:49 +000014static unsigned long main(unsigned long bist)
Stefan Reinauerb980e392003-08-28 17:23:15 +000015{
arch import user (historical)cad91fd2005-08-05 18:55:52 +000016 unsigned nodeid;
Stefan Reinauera49f4162004-10-21 17:06:49 +000017 /* Make cerain my local apic is useable */
18 enable_lapic();
19
arch import user (historical)cad91fd2005-08-05 18:55:52 +000020 nodeid=lapicid();
Stefan Reinauera49f4162004-10-21 17:06:49 +000021 /* Is this a cpu only reset? */
arch import user (historical)b9a0e032005-07-06 18:17:28 +000022 if (cpu_init_detected(nodeid)) {
Stefan Reinauera49f4162004-10-21 17:06:49 +000023 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
Stefan Reinauerb980e392003-08-28 17:23:15 +000039 /* Nothing special needs to be done to find bus 0 */
40 /* Allow the HT devices to be found */
Stefan Reinauer1943d502004-03-19 12:15:19 +000041 enumerate_ht_chain();
Stefan Reinauera49f4162004-10-21 17:06:49 +000042
Stefan Reinauerb980e392003-08-28 17:23:15 +000043 /* Setup the 8111 */
44 amd8111_enable_rom();
45
Stefan Reinauere4436bd2003-10-24 13:53:33 +000046 /* Is this a deliberate reset by the bios */
Stefan Reinauera49f4162004-10-21 17:06:49 +000047 if (bios_reset_detected() && last_boot_normal()) {
48 goto normal_image;
Stefan Reinauerb980e392003-08-28 17:23:15 +000049 }
50 /* This is the primary cpu how should I boot? */
51 else if (do_normal_boot()) {
Stefan Reinauera49f4162004-10-21 17:06:49 +000052 goto normal_image;
Stefan Reinauerb980e392003-08-28 17:23:15 +000053 }
Stefan Reinauera49f4162004-10-21 17:06:49 +000054 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;
Stefan Reinauerb980e392003-08-28 17:23:15 +000071}