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.
15 #include <console/console.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)
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
);
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();
55 if (ENV_RAMSTAGE
&& cbmem_top_backup
!= NULL
)
56 return cbmem_top_backup
;
58 top_backup
= restore_cbmem_top();
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. */