blob: 11a62ad302bb53d2ea01d60ee450cb516c96f4d7 [file] [log] [blame]
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2017 Kyösti Mälkki
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
16#include <arch/acpi.h>
17#include <arch/cpu.h>
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020018#include <cbmem.h>
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020019#include <cpu/amd/car.h>
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020020#include <cpu/amd/agesa/s3_resume.h>
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020021#include <cpu/x86/bist.h>
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020022#include <cpu/x86/mtrr.h>
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020023#include <console/console.h>
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020024#include <halt.h>
25#include <program_loading.h>
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020026#include <smp/node.h>
27#include <string.h>
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020028#include <northbridge/amd/agesa/agesa_helper.h>
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020029#include <northbridge/amd/agesa/state_machine.h>
30
31static void fill_sysinfo(struct sysinfo *cb)
32{
33 memset(cb, 0, sizeof(*cb));
34 cb->s3resume = acpi_is_wakeup_s3();
35}
36
37void * asmlinkage romstage_main(unsigned long bist)
38{
39 struct sysinfo romstage_state;
40 struct sysinfo *cb = &romstage_state;
41 u8 initial_apic_id = (u8) (cpuid_ebx(1) >> 24);
42
43 fill_sysinfo(cb);
44
45 if ((initial_apic_id == 0) && boot_cpu()) {
46
47 platform_once(cb);
48
49 console_init();
50 }
51
52 printk(BIOS_DEBUG, "APIC %02d: CPU Family_Model = %08x\n",
53 initial_apic_id, cpuid_eax(1));
54
55 /* Halt if there was a built in self test failure */
56 report_bist_failure(bist);
57
58 agesa_main(cb);
59
Kyösti Mälkkiba22e152016-11-23 06:47:15 +020060 uintptr_t stack_top = CACHE_TMP_RAMTOP;
61 if (cb->s3resume) {
62 if (cbmem_recovery(1)) {
63 printk(BIOS_EMERG, "Unable to recover CBMEM\n");
64 halt();
65 }
66 stack_top = romstage_ram_stack_base(HIGH_ROMSTAGE_STACK_SIZE,
67 ROMSTAGE_STACK_CBMEM);
68 stack_top += HIGH_ROMSTAGE_STACK_SIZE;
69 }
70
71 printk(BIOS_DEBUG, "Move CAR stack.\n");
72 return (void*)stack_top;
73}
74
75void asmlinkage romstage_after_car(void)
76{
77 struct sysinfo romstage_state;
78 struct sysinfo *cb = &romstage_state;
79
80 printk(BIOS_DEBUG, "CAR disabled.\n");
81
82 fill_sysinfo(cb);
83 agesa_postcar(cb);
84
85 if (cb->s3resume)
86 set_resume_cache();
87
88 run_ramstage();
Kyösti Mälkkidf7ff312016-11-25 12:02:00 +020089}