blob: 0a690fde685800aef771ecbccddc66db16d238ff [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Rinibcb3c8d2016-05-06 10:40:22 -04002/*
3 * (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
Tom Rinibcb3c8d2016-05-06 10:40:22 -04004 */
5
6#include <common.h>
Tom Rinibcb3c8d2016-05-06 10:40:22 -04007#include <asm/e820.h>
Tom Rinibcb3c8d2016-05-06 10:40:22 -04008
Bin Mengd6da81d2017-01-18 03:32:51 -08009DECLARE_GLOBAL_DATA_PTR;
10
Bin Meng3838d712018-04-11 22:02:10 -070011unsigned int install_e820_map(unsigned int max_entries,
Bin Meng4b8fc742018-04-11 22:02:11 -070012 struct e820_entry *entries)
Tom Rinibcb3c8d2016-05-06 10:40:22 -040013{
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}