e820.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <environment.h>
  7. #include <asm/e820.h>
  8. DECLARE_GLOBAL_DATA_PTR;
  9. unsigned int install_e820_map(unsigned int max_entries,
  10. struct e820_entry *entries)
  11. {
  12. entries[0].addr = 0;
  13. entries[0].size = ISA_START_ADDRESS;
  14. entries[0].type = E820_RAM;
  15. entries[1].addr = ISA_START_ADDRESS;
  16. entries[1].size = ISA_END_ADDRESS - ISA_START_ADDRESS;
  17. entries[1].type = E820_RESERVED;
  18. /*
  19. * since we use memalign(malloc) to allocate high memory for
  20. * storing ACPI tables, we need to reserve them in e820 tables,
  21. * otherwise kernel will reclaim them and data will be corrupted
  22. */
  23. entries[2].addr = ISA_END_ADDRESS;
  24. entries[2].size = gd->relocaddr - TOTAL_MALLOC_LEN - ISA_END_ADDRESS;
  25. entries[2].type = E820_RAM;
  26. /* for simplicity, reserve entire malloc space */
  27. entries[3].addr = gd->relocaddr - TOTAL_MALLOC_LEN;
  28. entries[3].size = TOTAL_MALLOC_LEN;
  29. entries[3].type = E820_RESERVED;
  30. entries[4].addr = gd->relocaddr;
  31. entries[4].size = gd->ram_size - gd->relocaddr;
  32. entries[4].type = E820_RESERVED;
  33. entries[5].addr = CONFIG_PCIE_ECAM_BASE;
  34. entries[5].size = CONFIG_PCIE_ECAM_SIZE;
  35. entries[5].type = E820_RESERVED;
  36. return 6;
  37. }