Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <cbmem.h> |
| 16 | #include <soc/addressmap.h> |
| 17 | |
Arthur Heymans | 340e4b8 | 2019-10-23 17:25:58 +0200 | [diff] [blame] | 18 | void *cbmem_top_chipset(void) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 19 | { |
| 20 | static uintptr_t addr; |
| 21 | |
| 22 | if (addr == 0) { |
| 23 | uintptr_t begin_mib; |
| 24 | uintptr_t end_mib; |
| 25 | |
| 26 | memory_in_range_below_4gb(&begin_mib, &end_mib); |
| 27 | /* Make sure we consume everything up to 4GIB. */ |
| 28 | if (end_mib == 4096) |
| 29 | addr = ~(uint32_t)0; |
| 30 | else |
| 31 | addr = end_mib << 20; |
| 32 | } |
| 33 | |
| 34 | return (void *)addr; |
| 35 | } |