Kyösti Mälkki | e7e847c | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 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. |
| 7 | * |
| 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. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA |
| 16 | */ |
| 17 | |
| 18 | #include <console/console.h> |
| 19 | #include <cbmem.h> |
| 20 | |
| 21 | #if !CONFIG_DYNAMIC_CBMEM |
Kyösti Mälkki | c04afd6 | 2013-09-04 13:31:39 +0300 | [diff] [blame] | 22 | void get_cbmem_table(uint64_t *base, uint64_t *size) |
| 23 | { |
| 24 | uint64_t top_of_ram = get_top_of_ram(); |
| 25 | |
| 26 | if (top_of_ram >= HIGH_MEMORY_SIZE) { |
| 27 | *base = top_of_ram - HIGH_MEMORY_SIZE; |
| 28 | *size = HIGH_MEMORY_SIZE; |
| 29 | } else { |
| 30 | *base = 0; |
| 31 | *size = 0; |
| 32 | } |
| 33 | } |
Kyösti Mälkki | c04afd6 | 2013-09-04 13:31:39 +0300 | [diff] [blame] | 34 | |
Kyösti Mälkki | 082c19e | 2013-10-12 00:22:57 +0300 | [diff] [blame^] | 35 | #if !defined(__PRE_RAM__) |
Kyösti Mälkki | bc90e15 | 2013-09-04 13:26:11 +0300 | [diff] [blame] | 36 | void __attribute__((weak)) backup_top_of_ram(uint64_t ramtop) |
| 37 | { |
| 38 | /* Do nothing. Chipset may have implementation to save ramtop in NVRAM. */ |
| 39 | } |
| 40 | |
Kyösti Mälkki | e7e847c | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 41 | /* This is for compatibility with old boards only. Any new chipset and board |
| 42 | * must implement get_top_of_ram() for both romstage and ramstage to support |
Kyösti Mälkki | cbf5bdf | 2013-09-10 00:07:21 +0300 | [diff] [blame] | 43 | * early features like COLLECT_TIMESTAMPS and CBMEM_CONSOLE. |
Kyösti Mälkki | e7e847c | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 44 | */ |
Kyösti Mälkki | 2b790f6 | 2013-09-03 05:25:57 +0300 | [diff] [blame] | 45 | void set_top_of_ram(uint64_t ramtop) |
Kyösti Mälkki | e7e847c | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 46 | { |
Kyösti Mälkki | bc90e15 | 2013-09-04 13:26:11 +0300 | [diff] [blame] | 47 | backup_top_of_ram(ramtop); |
Kyösti Mälkki | 1ae305e | 2013-09-04 13:05:01 +0300 | [diff] [blame] | 48 | cbmem_late_set_table(ramtop - HIGH_MEMORY_SIZE, HIGH_MEMORY_SIZE); |
Kyösti Mälkki | e7e847c | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 49 | } |
Kyösti Mälkki | 082c19e | 2013-10-12 00:22:57 +0300 | [diff] [blame^] | 50 | |
| 51 | unsigned long __attribute__((weak)) get_top_of_ram(void) |
| 52 | { |
| 53 | printk(BIOS_WARNING, "WARNING: you need to define get_top_of_ram() for your chipset\n"); |
| 54 | return 0; |
| 55 | } |
| 56 | #endif /* !__PRE_RAM__ */ |
| 57 | |
Kyösti Mälkki | e7e847c | 2013-06-27 08:20:09 +0300 | [diff] [blame] | 58 | #endif |