blob: e682486547146ae905ec291189ba2477ea07360a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Rinidd6f3ab2016-05-06 10:40:22 -04002/*
3 * (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
Tom Rinidd6f3ab2016-05-06 10:40:22 -04004 */
5
6#include <common.h>
Simon Glassf3998fd2019-08-02 09:44:25 -06007#include <env_internal.h>
Tom Rinidd6f3ab2016-05-06 10:40:22 -04008#include <asm/e820.h>
Tom Rinidd6f3ab2016-05-06 10:40:22 -04009
Bin Meng45ffa122017-01-18 03:32:51 -080010DECLARE_GLOBAL_DATA_PTR;
11
Bin Meng87af71c2018-04-11 22:02:10 -070012unsigned int install_e820_map(unsigned int max_entries,
Bin Meng45519922018-04-11 22:02:11 -070013 struct e820_entry *entries)
Tom Rinidd6f3ab2016-05-06 10:40:22 -040014{
15 entries[0].addr = 0;
16 entries[0].size = ISA_START_ADDRESS;
17 entries[0].type = E820_RAM;
18
19 entries[1].addr = ISA_START_ADDRESS;
20 entries[1].size = ISA_END_ADDRESS - ISA_START_ADDRESS;
21 entries[1].type = E820_RESERVED;
22
23 /*
24 * since we use memalign(malloc) to allocate high memory for
25 * storing ACPI tables, we need to reserve them in e820 tables,
26 * otherwise kernel will reclaim them and data will be corrupted
27 */
28 entries[2].addr = ISA_END_ADDRESS;
29 entries[2].size = gd->relocaddr - TOTAL_MALLOC_LEN - ISA_END_ADDRESS;
30 entries[2].type = E820_RAM;
31
32 /* for simplicity, reserve entire malloc space */
33 entries[3].addr = gd->relocaddr - TOTAL_MALLOC_LEN;
34 entries[3].size = TOTAL_MALLOC_LEN;
35 entries[3].type = E820_RESERVED;
36
37 entries[4].addr = gd->relocaddr;
38 entries[4].size = gd->ram_size - gd->relocaddr;
39 entries[4].type = E820_RESERVED;
40
41 entries[5].addr = CONFIG_PCIE_ECAM_BASE;
42 entries[5].size = CONFIG_PCIE_ECAM_SIZE;
43 entries[5].type = E820_RESERVED;
44
45 return 6;
46}