Add constants for fast path resume copying
[coreboot.git] / src / mainboard / amd / torpedo / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 Advanced Micro Devices, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #include <stdint.h>
21 #include <string.h>
22 #include <device/pci_def.h>
23 #include <device/pci_ids.h>
24 #include <arch/io.h>
25 #include <arch/stages.h>
26 #include <device/pnp_def.h>
27 #include <arch/romcc_io.h>
28 #include <cpu/x86/lapic.h>
29 #include <console/console.h>
30 #include <console/loglevel.h>
31 #include "agesawrapper.h"
32 #include "cpu/x86/bist.h"
33 #include "superio/smsc/kbc1100/kbc1100_early_init.c"
34 #include "cpu/x86/lapic/boot_cpu.c"
35 #include "pc80/i8254.c"
36 #include "pc80/i8259.c"
37 #include "SbEarly.h"
38 #include "SbPlatform.h"
39 #include <arch/cpu.h>
40 #include "platform_cfg.h"
41
42 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx);
43
44 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
45 {
46         u32 val;
47
48         post_code(0x35);
49         printk(BIOS_DEBUG, "agesawrapper_amdinitmmio ");
50         val = agesawrapper_amdinitmmio();
51         if (val)
52                 printk(BIOS_DEBUG, "error level: %x \n", val);
53         else
54                 printk(BIOS_DEBUG, "passed.\n");
55
56         if (!cpu_init_detectedx && boot_cpu()) {
57                 post_code(0x30);
58                 gpioEarlyInit();
59                 sb_poweron_init();
60
61                 post_code(0x31);
62
63                 kbc1100_early_init(CONFIG_SIO_PORT);
64
65                 post_code(0x32);
66                 uart_init();
67                 post_code(0x33);
68                 console_init();
69         }
70
71         /* Halt if there was a built in self test failure */
72         post_code(0x34);
73         report_bist_failure(bist);
74
75         // Load MPB
76         val = cpuid_eax(1);
77         printk(BIOS_DEBUG, "BSP Family_Model: %08x \n", val);
78         printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx \n", cpu_init_detectedx);
79
80         post_code(0x36);
81         printk(BIOS_DEBUG, "agesawrapper_amdinitreset ");
82         val = agesawrapper_amdinitreset();
83         if (val)
84                 printk(BIOS_DEBUG, "error level: %x \n", val);
85         else
86                 printk(BIOS_DEBUG, "passed.\n");
87
88         post_code(0x37);
89         printk(BIOS_DEBUG, "agesawrapper_amdinitearly ");
90         val = agesawrapper_amdinitearly();
91         if (val)
92                 printk(BIOS_DEBUG, "error level: %x \n", val);
93         else
94                 printk(BIOS_DEBUG, "passed.\n");
95
96         post_code(0x38);
97         printk(BIOS_DEBUG, "agesawrapper_amdinitpost ");
98         val = agesawrapper_amdinitpost();
99         if (val)
100                 printk(BIOS_DEBUG, "error level: %x \n", val);
101         else
102                 printk(BIOS_DEBUG, "passed.\n");
103
104         post_code(0x39);
105         printk(BIOS_DEBUG, "sb_before_pci_init ");
106         sb_before_pci_init();
107         printk(BIOS_DEBUG, "passed.\n");
108
109         post_code(0x40);
110         printk(BIOS_DEBUG, "agesawrapper_amdinitenv ");
111         val = agesawrapper_amdinitenv();
112         if (val)
113                 printk(BIOS_DEBUG, "error level: %x \n", val);
114         else
115                 printk(BIOS_DEBUG, "passed.\n");
116
117         /* Initialize i8259 pic */
118         post_code(0x41);
119         printk(BIOS_DEBUG, "setup_i8259\n");
120         setup_i8259();
121
122         /* Initialize i8254 timers */
123         post_code(0x42);
124         printk(BIOS_DEBUG, "setup_i8254\n");
125         setup_i8254();
126
127
128         post_code(0x43);
129         copy_and_run(0);
130         printk(BIOS_ERR, "Error: copy_and_run returned!\n");
131
132         post_code(0x44);        // Should never see this post code.
133 }