blob: 6b959fc7384a0631bac11d5128a6f482392de409 [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)b9a0e032005-07-06 18:17:28 +000016 unsigned nodeid;
Stefan Reinauera49f4162004-10-21 17:06:49 +000017 /* Make cerain my local apic is useable */
18 enable_lapic();
19
20 /* Is this a cpu only reset? */
arch import user (historical)b9a0e032005-07-06 18:17:28 +000021 if (cpu_init_detected(nodeid)) {
Stefan Reinauera49f4162004-10-21 17:06:49 +000022 if (last_boot_normal()) {
23 goto normal_image;
24 } else {
25 goto cpu_reset;
26 }
27 }
28 /* Is this a secondary cpu? */
29 if (!boot_cpu()) {
30 if (last_boot_normal()) {
31 goto normal_image;
32 } else {
33 goto fallback_image;
34 }
35 }
36
37
Stefan Reinauerb980e392003-08-28 17:23:15 +000038 /* Nothing special needs to be done to find bus 0 */
39 /* Allow the HT devices to be found */
Stefan Reinauer1943d502004-03-19 12:15:19 +000040 enumerate_ht_chain();
Stefan Reinauera49f4162004-10-21 17:06:49 +000041
Stefan Reinauerb980e392003-08-28 17:23:15 +000042 /* Setup the 8111 */
43 amd8111_enable_rom();
44
Stefan Reinauere4436bd2003-10-24 13:53:33 +000045 /* Is this a deliberate reset by the bios */
Stefan Reinauera49f4162004-10-21 17:06:49 +000046 if (bios_reset_detected() && last_boot_normal()) {
47 goto normal_image;
Stefan Reinauerb980e392003-08-28 17:23:15 +000048 }
49 /* This is the primary cpu how should I boot? */
50 else if (do_normal_boot()) {
Stefan Reinauera49f4162004-10-21 17:06:49 +000051 goto normal_image;
Stefan Reinauerb980e392003-08-28 17:23:15 +000052 }
Stefan Reinauera49f4162004-10-21 17:06:49 +000053 else {
54 goto fallback_image;
55 }
56 normal_image:
57 asm volatile ("jmp __normal_image"
58 : /* outputs */
59 : "a" (bist) /* inputs */
60 : /* clobbers */
61 );
62 cpu_reset:
63 asm volatile ("jmp __cpu_reset"
64 : /* outputs */
65 : "a"(bist) /* inputs */
66 : /* clobbers */
67 );
68 fallback_image:
69 return bist;
Stefan Reinauerb980e392003-08-28 17:23:15 +000070}