c9c0de1c66313fdbec4fb5c198041c06eb68830a
[coreboot.git] / src / mainboard / gigabyte / m57sli / ap_romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 AMD
5  * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21
22 #define ASSEMBLY 1
23 #define __PRE_RAM__
24
25 #define K8_REV_F_SUPPORT_F0_F1_WORKAROUND 0
26
27 #include <stdint.h>
28 #include <device/pci_def.h>
29 #include <device/pci_ids.h>
30 #include <arch/io.h>
31 #include <device/pnp_def.h>
32 #include <arch/romcc_io.h>
33 #include <cpu/x86/lapic.h>
34 #include <pc80/mc146818rtc.h>
35
36 #include "lib/uart8250.c"
37 #include "arch/x86/lib/printk_init.c"
38 #include "console/vtxprintf.c"
39 #include "console/console.c"
40
41 #include <cpu/amd/model_fxx_rev.h>
42 #include "northbridge/amd/amdk8/raminit.h"
43 #include "cpu/amd/model_fxx/apic_timer.c"
44
45 #include "lib/delay.c"
46
47 //#include "cpu/x86/lapic/boot_cpu.c"
48 #include "northbridge/amd/amdk8/reset_test.c"
49
50 #include "northbridge/amd/amdk8/debug.c"
51
52 #include "southbridge/nvidia/mcp55/mcp55_early_ctrl.c"
53
54 #include "northbridge/amd/amdk8/amdk8_f.h"
55
56 #include "cpu/x86/mtrr.h"
57 #include "cpu/amd/mtrr.h"
58 #include "cpu/x86/tsc.h"
59
60 #include "northbridge/amd/amdk8/amdk8_f_pci.c"
61 #include "northbridge/amd/amdk8/raminit_f_dqs.c"
62
63 #include "cpu/amd/dualcore/dualcore.c"
64
65 void hardwaremain(int ret_addr)
66 {
67         struct sys_info *sysinfo = (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - CONFIG_DCACHE_RAM_GLOBAL_VAR_SIZE); // in CACHE
68         struct sys_info *sysinfox = ((CONFIG_RAMTOP) - CONFIG_DCACHE_RAM_GLOBAL_VAR_SIZE); // in RAM
69
70         struct node_core_id id;
71
72         id = get_node_core_id_x();
73
74         //FIXME: for USBDEBUG you need to make sure dbg_info get assigned in AP
75         print_debug("CODE IN CACHE ON NODE:"); print_debug_hex8(id.nodeid); print_debug("\n");
76
77         train_ram(id.nodeid, sysinfo, sysinfox);
78
79         /*
80                 go back, but can not use stack any more, because we only keep ret_addr and can not restore esp, and ebp
81         */
82
83         __asm__ volatile (
84                 "movl  %0, %%edi\n\t"
85                 "jmp     *%%edi\n\t"
86                 :: "a"(ret_addr)
87         );
88
89
90
91 }
92
93 #include <arch/registers.h>
94
95 void x86_exception(struct eregs *info)
96 {
97         do {
98                 hlt();
99         } while(1);
100 }
101
102