blob: 496bafa986ab802690e0e17f1172eff7788a4694 [file] [log] [blame]
Aaron Durbindf3a1092013-03-13 12:41:44 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google, Inc.
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,
Aaron Durbin2c4aab32015-03-06 23:26:06 -060011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Aaron Durbindf3a1092013-03-13 12:41:44 -050012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Aaron Durbindf3a1092013-03-13 12:41:44 -050018 */
19#include <console/console.h>
20#include <cbmem.h>
Aaron Durbin0dff57d2015-03-05 21:18:33 -060021#include <bootstate.h>
22#include <rules.h>
Kyösti Mälkki4fbac462015-01-07 04:48:43 +020023#include <symbols.h>
Aaron Durbin0dff57d2015-03-05 21:18:33 -060024#if IS_ENABLED(CONFIG_ARCH_X86) && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
25#include <arch/acpi.h>
26#endif
Aaron Durbindf3a1092013-03-13 12:41:44 -050027
Kyösti Mälkki823edda2014-12-18 18:30:29 +020028void cbmem_run_init_hooks(void)
29{
Kyösti Mälkki4fbac462015-01-07 04:48:43 +020030 cbmem_init_hook_t *init_hook_ptr = (cbmem_init_hook_t*) &_cbmem_init_hooks;
31 cbmem_init_hook_t *einit_hook_ptr = (cbmem_init_hook_t*) &_ecbmem_init_hooks;
Kyösti Mälkki4d107502014-12-19 10:17:46 +020032
Kyösti Mälkki4fbac462015-01-07 04:48:43 +020033 if (_cbmem_init_hooks_size == 0)
34 return;
35
36 while (init_hook_ptr != einit_hook_ptr) {
37 (*init_hook_ptr)();
38 init_hook_ptr++;
39 }
Kyösti Mälkki823edda2014-12-18 18:30:29 +020040}
41
42void __attribute__((weak)) cbmem_fail_resume(void)
43{
44}
Aaron Durbin0dff57d2015-03-05 21:18:33 -060045
46#if ENV_RAMSTAGE && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
47static void init_cbmem_post_device(void *unused)
48{
49 if (acpi_is_wakeup())
50 cbmem_initialize();
51 else
52 cbmem_initialize_empty();
53}
54
55BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY,
56 init_cbmem_post_device, NULL);
57#endif