xref: /openbmc/u-boot/arch/x86/cpu/qemu/e820.c (revision 78a88f79)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
4  */
5 
6 #include <common.h>
7 #include <asm/e820.h>
8 
9 DECLARE_GLOBAL_DATA_PTR;
10 
11 unsigned int install_e820_map(unsigned int max_entries,
12 			      struct e820_entry *entries)
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 }
46