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) | cad91fd | 2005-08-05 18:55:52 +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 | |
arch import user (historical) | cad91fd | 2005-08-05 18:55:52 +0000 | [diff] [blame^] | 20 | nodeid=lapicid(); |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 21 | /* Is this a cpu only reset? */ |
arch import user (historical) | b9a0e03 | 2005-07-06 18:17:28 +0000 | [diff] [blame] | 22 | if (cpu_init_detected(nodeid)) { |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 23 | 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 Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 39 | /* Nothing special needs to be done to find bus 0 */ |
| 40 | /* Allow the HT devices to be found */ |
Stefan Reinauer | 1943d50 | 2004-03-19 12:15:19 +0000 | [diff] [blame] | 41 | enumerate_ht_chain(); |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 42 | |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 43 | /* Setup the 8111 */ |
| 44 | amd8111_enable_rom(); |
| 45 | |
Stefan Reinauer | e4436bd | 2003-10-24 13:53:33 +0000 | [diff] [blame] | 46 | /* Is this a deliberate reset by the bios */ |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 47 | if (bios_reset_detected() && last_boot_normal()) { |
| 48 | goto normal_image; |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 49 | } |
| 50 | /* This is the primary cpu how should I boot? */ |
| 51 | else if (do_normal_boot()) { |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 52 | goto normal_image; |
Stefan Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 53 | } |
Stefan Reinauer | a49f416 | 2004-10-21 17:06:49 +0000 | [diff] [blame] | 54 | 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 Reinauer | b980e39 | 2003-08-28 17:23:15 +0000 | [diff] [blame] | 71 | } |