1 /* 2 * Copyright (C) 2018-2022 Intel Corporation. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef E820_H 8 #define E820_H 9 #include <types.h> 10 11 /* E820 memory types */ 12 #define E820_TYPE_RAM 1U /* EFI 1, 2, 3, 4, 5, 6, 7 */ 13 #define E820_TYPE_RESERVED 2U 14 /* EFI 0, 11, 12, 13 (everything not used elsewhere) */ 15 #define E820_TYPE_ACPI_RECLAIM 3U /* EFI 9 */ 16 #define E820_TYPE_ACPI_NVS 4U /* EFI 10 */ 17 #define E820_TYPE_UNUSABLE 5U /* EFI 8 */ 18 19 #define E820_MAX_ENTRIES 64U 20 21 #define MEM_SIZE_MAX (~0UL) 22 23 /** Defines a single entry in an E820 memory map. */ 24 struct e820_entry { 25 /** The base address of the memory range. */ 26 uint64_t baseaddr; 27 /** The length of the memory range. */ 28 uint64_t length; 29 /** The type of memory region. */ 30 uint32_t type; 31 } __packed; 32 33 struct mem_range { 34 uint64_t mem_bottom; 35 uint64_t mem_top; 36 uint64_t total_mem_size; 37 }; 38 39 /* HV read multiboot header to get e820 entries info and calc total RAM info */ 40 void init_e820(void); 41 42 uint64_t e820_alloc_memory(uint64_t size_arg, uint64_t max_addr); 43 uint64_t get_e820_ram_size(void); 44 /* get total number of the e820 entries */ 45 uint32_t get_e820_entries_count(void); 46 47 /* get the e802 entiries */ 48 const struct e820_entry *get_e820_entry(void); 49 50 #endif 51