Angel Pons | a2ee761 | 2020-04-04 18:51:15 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 3 | |
| 4 | #include <cbmem.h> |
| 5 | #include <soc/addressmap.h> |
| 6 | |
Arthur Heymans | 340e4b8 | 2019-10-23 17:25:58 +0200 | [diff] [blame] | 7 | void *cbmem_top_chipset(void) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 8 | { |
| 9 | static uintptr_t addr; |
| 10 | |
| 11 | if (addr == 0) { |
| 12 | uintptr_t begin_mib; |
| 13 | uintptr_t end_mib; |
| 14 | |
| 15 | memory_in_range_below_4gb(&begin_mib, &end_mib); |
| 16 | /* Make sure we consume everything up to 4GIB. */ |
| 17 | if (end_mib == 4096) |
| 18 | addr = ~(uint32_t)0; |
| 19 | else |
| 20 | addr = end_mib << 20; |
| 21 | } |
| 22 | |
| 23 | return (void *)addr; |
| 24 | } |