soc: Remove copyright notices
[coreboot.git] / src / soc / amd / picasso / finalize.c
blob91cc5c26b611f3a7cdb610447844e537400792cf
1 /*
2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <arch/acpi.h>
16 #include <cpu/x86/mp.h>
17 #include <cpu/x86/msr.h>
18 #include <cpu/amd/msr.h>
19 #include <bootstate.h>
20 #include <timer.h>
21 #include <console/console.h>
22 #include <amdblocks/acpi.h>
24 static void per_core_finalize(void *unused)
26 msr_t hwcr, mask;
28 /* Finalize SMM settings */
29 hwcr = rdmsr(HWCR_MSR);
30 if (hwcr.lo & SMM_LOCK) /* Skip if already locked, avoid GPF */
31 return;
33 if (CONFIG(HAVE_SMI_HANDLER)) {
34 mask = rdmsr(SMM_MASK_MSR);
35 mask.lo |= SMM_TSEG_VALID;
36 wrmsr(SMM_MASK_MSR, mask);
39 hwcr.lo |= SMM_LOCK;
40 wrmsr(HWCR_MSR, hwcr);
43 static void finalize_cores(void)
45 int r;
46 printk(BIOS_SPEW, "Lock SMM configuration\n");
48 r = mp_run_on_all_cpus(per_core_finalize, NULL);
49 if (r)
50 printk(BIOS_WARNING, "Failed to finalize all cores\n");
53 static void soc_finalize(void *unused)
55 finalize_cores();
57 if (!acpi_is_wakeup_s3()) {
58 if (CONFIG(HAVE_SMI_HANDLER))
59 acpi_disable_sci();
60 else
61 acpi_enable_sci();
64 post_code(POST_OS_BOOT);
67 BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
68 BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);