Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Tom Rini | bcb3c8d | 2016-05-06 10:40:22 -0400 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com> |
Tom Rini | bcb3c8d | 2016-05-06 10:40:22 -0400 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Tom Rini | bcb3c8d | 2016-05-06 10:40:22 -0400 | [diff] [blame] | 7 | #include <asm/e820.h> |
Tom Rini | bcb3c8d | 2016-05-06 10:40:22 -0400 | [diff] [blame] | 8 | |
Bin Meng | d6da81d | 2017-01-18 03:32:51 -0800 | [diff] [blame] | 9 | DECLARE_GLOBAL_DATA_PTR; |
| 10 | |
Bin Meng | 3838d71 | 2018-04-11 22:02:10 -0700 | [diff] [blame] | 11 | unsigned int install_e820_map(unsigned int max_entries, |
Bin Meng | 4b8fc74 | 2018-04-11 22:02:11 -0700 | [diff] [blame] | 12 | struct e820_entry *entries) |
Tom Rini | bcb3c8d | 2016-05-06 10:40:22 -0400 | [diff] [blame] | 13 | { |
| 14 | entries[0].addr = 0; |
| 15 | entries[0].size = ISA_START_ADDRESS; |
| 16 | entries[0].type = E820_RAM; |
| 17 | |
| 18 | entries[1].addr = ISA_START_ADDRESS; |
| 19 | entries[1].size = ISA_END_ADDRESS - ISA_START_ADDRESS; |
| 20 | entries[1].type = E820_RESERVED; |
| 21 | |
| 22 | /* |
| 23 | * since we use memalign(malloc) to allocate high memory for |
| 24 | * storing ACPI tables, we need to reserve them in e820 tables, |
| 25 | * otherwise kernel will reclaim them and data will be corrupted |
| 26 | */ |
| 27 | entries[2].addr = ISA_END_ADDRESS; |
| 28 | entries[2].size = gd->relocaddr - TOTAL_MALLOC_LEN - ISA_END_ADDRESS; |
| 29 | entries[2].type = E820_RAM; |
| 30 | |
| 31 | /* for simplicity, reserve entire malloc space */ |
| 32 | entries[3].addr = gd->relocaddr - TOTAL_MALLOC_LEN; |
| 33 | entries[3].size = TOTAL_MALLOC_LEN; |
| 34 | entries[3].type = E820_RESERVED; |
| 35 | |
| 36 | entries[4].addr = gd->relocaddr; |
| 37 | entries[4].size = gd->ram_size - gd->relocaddr; |
| 38 | entries[4].type = E820_RESERVED; |
| 39 | |
| 40 | entries[5].addr = CONFIG_PCIE_ECAM_BASE; |
| 41 | entries[5].size = CONFIG_PCIE_ECAM_SIZE; |
| 42 | entries[5].type = E820_RESERVED; |
| 43 | |
| 44 | return 6; |
| 45 | } |