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. |
Aaron Durbin | df3a109 | 2013-03-13 12:41:44 -0500 | [diff] [blame] | 14 | */ |
| 15 | #include <console/console.h> |
| 16 | #include <cbmem.h> |
Aaron Durbin | 0dff57d | 2015-03-05 21:18:33 -0600 | [diff] [blame] | 17 | #include <bootstate.h> |
| 18 | #include <rules.h> |
Kyösti Mälkki | 4fbac46 | 2015-01-07 04:48:43 +0200 | [diff] [blame] | 19 | #include <symbols.h> |
Aaron Durbin | 0dff57d | 2015-03-05 21:18:33 -0600 | [diff] [blame] | 20 | #if IS_ENABLED(CONFIG_ARCH_X86) && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) |
| 21 | #include <arch/acpi.h> |
| 22 | #endif |
Aaron Durbin | df3a109 | 2013-03-13 12:41:44 -0500 | [diff] [blame] | 23 | |
Aaron Durbin | 41607a4 | 2015-06-09 13:54:10 -0500 | [diff] [blame] | 24 | void cbmem_run_init_hooks(int is_recovery) |
Kyösti Mälkki | 823edda | 2014-12-18 18:30:29 +0200 | [diff] [blame] | 25 | { |
Lee Leahy | b2d834a | 2017-03-08 16:52:22 -0800 | [diff] [blame] | 26 | cbmem_init_hook_t *init_hook_ptr = (cbmem_init_hook_t *) &_cbmem_init_hooks; |
| 27 | cbmem_init_hook_t *einit_hook_ptr = (cbmem_init_hook_t *) &_ecbmem_init_hooks; |
Kyösti Mälkki | 4d10750 | 2014-12-19 10:17:46 +0200 | [diff] [blame] | 28 | |
Kyösti Mälkki | 4fbac46 | 2015-01-07 04:48:43 +0200 | [diff] [blame] | 29 | if (_cbmem_init_hooks_size == 0) |
| 30 | return; |
| 31 | |
| 32 | while (init_hook_ptr != einit_hook_ptr) { |
Aaron Durbin | 41607a4 | 2015-06-09 13:54:10 -0500 | [diff] [blame] | 33 | (*init_hook_ptr)(is_recovery); |
Kyösti Mälkki | 4fbac46 | 2015-01-07 04:48:43 +0200 | [diff] [blame] | 34 | init_hook_ptr++; |
| 35 | } |
Kyösti Mälkki | 823edda | 2014-12-18 18:30:29 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void __attribute__((weak)) cbmem_fail_resume(void) |
| 39 | { |
| 40 | } |
Aaron Durbin | 0dff57d | 2015-03-05 21:18:33 -0600 | [diff] [blame] | 41 | |
| 42 | #if ENV_RAMSTAGE && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) |
| 43 | static void init_cbmem_post_device(void *unused) |
| 44 | { |
| 45 | if (acpi_is_wakeup()) |
| 46 | cbmem_initialize(); |
| 47 | else |
| 48 | cbmem_initialize_empty(); |
| 49 | } |
| 50 | |
| 51 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, |
| 52 | init_cbmem_post_device, NULL); |
| 53 | #endif |