Aaron Durbin | df3a109 | 2013-03-13 12:41:44 -0500 | [diff] [blame] | 1 | /* |
| 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 Durbin | 2c4aab3 | 2015-03-06 23:26:06 -0600 | [diff] [blame] | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Aaron Durbin | df3a109 | 2013-03-13 12:41:44 -0500 | [diff] [blame] | 12 | * 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 |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | #include <console/console.h> |
| 20 | #include <cbmem.h> |
Aaron Durbin | 0dff57d | 2015-03-05 21:18:33 -0600 | [diff] [blame^] | 21 | #include <bootstate.h> |
| 22 | #include <rules.h> |
| 23 | #if IS_ENABLED(CONFIG_ARCH_X86) && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) |
| 24 | #include <arch/acpi.h> |
| 25 | #endif |
Aaron Durbin | df3a109 | 2013-03-13 12:41:44 -0500 | [diff] [blame] | 26 | |
Kyösti Mälkki | 0a11a61 | 2014-12-31 19:29:02 +0200 | [diff] [blame] | 27 | /* FIXME: Remove after CBMEM_INIT_HOOKS. */ |
| 28 | #include <console/cbmem_console.h> |
Kyösti Mälkki | 4d10750 | 2014-12-19 10:17:46 +0200 | [diff] [blame] | 29 | #include <timestamp.h> |
Kyösti Mälkki | 0a11a61 | 2014-12-31 19:29:02 +0200 | [diff] [blame] | 30 | |
Kyösti Mälkki | 823edda | 2014-12-18 18:30:29 +0200 | [diff] [blame] | 31 | |
| 32 | /* FIXME: Replace with CBMEM_INIT_HOOKS API. */ |
| 33 | #if !IS_ENABLED(CONFIG_ARCH_X86) |
| 34 | void cbmem_run_init_hooks(void) |
| 35 | { |
Kyösti Mälkki | 0a11a61 | 2014-12-31 19:29:02 +0200 | [diff] [blame] | 36 | /* Relocate CBMEM console. */ |
| 37 | cbmemc_reinit(); |
Kyösti Mälkki | 4d10750 | 2014-12-19 10:17:46 +0200 | [diff] [blame] | 38 | |
| 39 | /* Relocate timestamps stash. */ |
| 40 | timestamp_reinit(); |
Kyösti Mälkki | 823edda | 2014-12-18 18:30:29 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void __attribute__((weak)) cbmem_fail_resume(void) |
| 44 | { |
| 45 | } |
| 46 | #endif |
Aaron Durbin | 0dff57d | 2015-03-05 21:18:33 -0600 | [diff] [blame^] | 47 | |
| 48 | #if ENV_RAMSTAGE && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) |
| 49 | static void init_cbmem_post_device(void *unused) |
| 50 | { |
| 51 | if (acpi_is_wakeup()) |
| 52 | cbmem_initialize(); |
| 53 | else |
| 54 | cbmem_initialize_empty(); |
| 55 | } |
| 56 | |
| 57 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, |
| 58 | init_cbmem_post_device, NULL); |
| 59 | #endif |