arch/x86 cbmem: Drop tests for LATE_CBMEM_INIT
[coreboot.git] / src / arch / x86 / cbmem.c
blob73967e17f848dd767087ca6a3d73884900c93130
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 <cbmem.h>
16 #include <arch/acpi.h>
18 #if IS_ENABLED(CONFIG_CBMEM_TOP_BACKUP)
20 void *cbmem_top(void)
22 static void *cbmem_top_backup;
23 void *top_backup;
25 if (ENV_RAMSTAGE && cbmem_top_backup != NULL)
26 return cbmem_top_backup;
28 /* Top of CBMEM is at highest usable DRAM address below 4GiB. */
29 top_backup = (void *)restore_top_of_low_cacheable();
31 if (ENV_RAMSTAGE)
32 cbmem_top_backup = top_backup;
34 return top_backup;
37 #endif /* CBMEM_TOP_BACKUP */
39 /* Something went wrong, our high memory area got wiped */
40 void cbmem_fail_resume(void)
42 #if !defined(__PRE_RAM__) && IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)
43 /* ACPI resume needs to be cleared in the fail-to-recover case, but that
44 * condition is only handled during ramstage. */
45 acpi_fail_wakeup();
46 #endif