soc/amd/stoneyridge: Add CPU files
[coreboot.git] / src / arch / x86 / cbmem.c
blob57ed83b5ca2f2b82da09c53985a9d41c43e42c5b
1 /*
2 * This file is part of the coreboot project.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <stdlib.h>
15 #include <console/console.h>
16 #include <cbmem.h>
17 #include <arch/acpi.h>
19 #if IS_ENABLED(CONFIG_LATE_CBMEM_INIT)
21 void __attribute__((weak)) backup_top_of_low_cacheable(uintptr_t ramtop)
23 /* Do nothing. Chipset may have implementation to save ramtop in NVRAM.
27 uintptr_t __attribute__((weak)) restore_top_of_low_cacheable(void)
29 return 0;
32 #endif /* LATE_CBMEM_INIT */
34 #if IS_ENABLED(CONFIG_CBMEM_TOP_BACKUP)
36 static void *cbmem_top_backup;
38 void set_late_cbmem_top(uintptr_t ramtop)
40 backup_top_of_low_cacheable(ramtop);
41 if (ENV_RAMSTAGE)
42 cbmem_top_backup = (void *)ramtop;
45 /* Top of CBMEM is at highest usable DRAM address below 4GiB. */
46 uintptr_t __attribute__((weak)) restore_cbmem_top(void)
48 return restore_top_of_low_cacheable();
51 void *cbmem_top(void)
53 uintptr_t top_backup;
55 if (ENV_RAMSTAGE && cbmem_top_backup != NULL)
56 return cbmem_top_backup;
58 top_backup = restore_cbmem_top();
60 if (ENV_RAMSTAGE)
61 cbmem_top_backup = (void *)top_backup;
63 return (void *)top_backup;
66 #endif /* CBMEM_TOP_BACKUP */
68 /* Something went wrong, our high memory area got wiped */
69 void cbmem_fail_resume(void)
71 #if !defined(__PRE_RAM__) && IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)
72 /* ACPI resume needs to be cleared in the fail-to-recover case, but that
73 * condition is only handled during ramstage. */
74 acpi_fail_wakeup();
75 #endif