Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 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> |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 6 | #include <arch/romcc_io.h> |
| 7 | #include <cpu/x86/lapic.h> |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 8 | #include "pc80/mc146818rtc_early.c" |
| 9 | #include "southbridge/amd/amd8111/amd8111_enable_rom.c" |
| 10 | #include "northbridge/amd/amdk8/early_ht.c" |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 11 | #include "cpu/x86/lapic/boot_cpu.c" |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 12 | #include "northbridge/amd/amdk8/reset_test.c" |
| 13 | |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 14 | static unsigned long main(unsigned long bist) |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 15 | { |
arch import user (historical) | b9a0e03 | 2005-07-06 18:17:28 +0000 | [diff] [blame] | 16 | unsigned nodeid; |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 17 | /* Make cerain my local apic is useable */ |
| 18 | enable_lapic(); |
| 19 | |
| 20 | /* Is this a cpu only reset? */ |
arch import user (historical) | b9a0e03 | 2005-07-06 18:17:28 +0000 | [diff] [blame] | 21 | if (cpu_init_detected(nodeid)) { |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 22 | 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 Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 38 | /* Nothing special needs to be done to find bus 0 */ |
| 39 | /* Allow the HT devices to be found */ |
Stefan Reinauer | 1943d50 | 2004-03-19 12:15:19 +0000 | [diff] [blame] | 40 | enumerate_ht_chain(); |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 41 | |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 42 | /* Setup the 8111 */ |
| 43 | amd8111_enable_rom(); |
| 44 | |
Stefan Reinauer | e4436bd | 2003-10-24 13:53:33 +0000 | [diff] [blame] | 45 | /* Is this a deliberate reset by the bios */ |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 46 | if (bios_reset_detected() && last_boot_normal()) { |
| 47 | goto normal_image; |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 48 | } |
| 49 | /* This is the primary cpu how should I boot? */ |
| 50 | else if (do_normal_boot()) { |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 51 | goto normal_image; |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 52 | } |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 53 | 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 Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 70 | } |