| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 
|---|
| 2 | #ifndef _ASM_E820_TYPES_H | 
|---|
| 3 | #define _ASM_E820_TYPES_H | 
|---|
| 4 |  | 
|---|
| 5 | #include <uapi/asm/bootparam.h> | 
|---|
| 6 |  | 
|---|
| 7 | /* | 
|---|
| 8 | * These are the E820 types known to the kernel: | 
|---|
| 9 | */ | 
|---|
| 10 | enum e820_type { | 
|---|
| 11 | E820_TYPE_RAM		= 1, | 
|---|
| 12 | E820_TYPE_RESERVED	= 2, | 
|---|
| 13 | E820_TYPE_ACPI		= 3, | 
|---|
| 14 | E820_TYPE_NVS		= 4, | 
|---|
| 15 | E820_TYPE_UNUSABLE	= 5, | 
|---|
| 16 | E820_TYPE_PMEM		= 7, | 
|---|
| 17 |  | 
|---|
| 18 | /* | 
|---|
| 19 | * This is a non-standardized way to represent ADR or | 
|---|
| 20 | * NVDIMM regions that persist over a reboot. | 
|---|
| 21 | * | 
|---|
| 22 | * The kernel will ignore their special capabilities | 
|---|
| 23 | * unless the CONFIG_X86_PMEM_LEGACY=y option is set. | 
|---|
| 24 | * | 
|---|
| 25 | * ( Note that older platforms also used 6 for the same | 
|---|
| 26 | *   type of memory, but newer versions switched to 12 as | 
|---|
| 27 | *   6 was assigned differently. Some time they will learn... ) | 
|---|
| 28 | */ | 
|---|
| 29 | E820_TYPE_PRAM		= 12, | 
|---|
| 30 |  | 
|---|
| 31 | /* | 
|---|
| 32 | * Special-purpose memory is indicated to the system via the | 
|---|
| 33 | * EFI_MEMORY_SP attribute. Define an e820 translation of this | 
|---|
| 34 | * memory type for the purpose of reserving this range and | 
|---|
| 35 | * marking it with the IORES_DESC_SOFT_RESERVED designation. | 
|---|
| 36 | */ | 
|---|
| 37 | E820_TYPE_SOFT_RESERVED	= 0xefffffff, | 
|---|
| 38 | }; | 
|---|
| 39 |  | 
|---|
| 40 | /* | 
|---|
| 41 | * A single E820 map entry, describing a memory range of [addr...addr+size-1], | 
|---|
| 42 | * of 'type' memory type: | 
|---|
| 43 | * | 
|---|
| 44 | * (We pack it because there can be thousands of them on large systems.) | 
|---|
| 45 | */ | 
|---|
| 46 | struct e820_entry { | 
|---|
| 47 | u64			addr; | 
|---|
| 48 | u64			size; | 
|---|
| 49 | enum e820_type		type; | 
|---|
| 50 | } __attribute__((packed)); | 
|---|
| 51 |  | 
|---|
| 52 | /* | 
|---|
| 53 | * The legacy E820 BIOS limits us to 128 (E820_MAX_ENTRIES_ZEROPAGE) nodes | 
|---|
| 54 | * due to the constrained space in the zeropage. | 
|---|
| 55 | * | 
|---|
| 56 | * On large systems we can easily have thousands of nodes with RAM, | 
|---|
| 57 | * which cannot be fit into so few entries - so we have a mechanism | 
|---|
| 58 | * to extend the e820 table size at build-time, via the E820_MAX_ENTRIES | 
|---|
| 59 | * define below. | 
|---|
| 60 | * | 
|---|
| 61 | * ( Those extra entries are enumerated via the EFI memory map, not | 
|---|
| 62 | *   via the legacy zeropage mechanism. ) | 
|---|
| 63 | * | 
|---|
| 64 | * Size our internal memory map tables to have room for these additional | 
|---|
| 65 | * entries, based on a heuristic calculation: up to three entries per | 
|---|
| 66 | * NUMA node, plus E820_MAX_ENTRIES_ZEROPAGE for some extra space. | 
|---|
| 67 | * | 
|---|
| 68 | * This allows for bootstrap/firmware quirks such as possible duplicate | 
|---|
| 69 | * E820 entries that might need room in the same arrays, prior to the | 
|---|
| 70 | * call to e820__update_table() to remove duplicates.  The allowance | 
|---|
| 71 | * of three memory map entries per node is "enough" entries for | 
|---|
| 72 | * the initial hardware platform motivating this mechanism to make | 
|---|
| 73 | * use of additional EFI map entries.  Future platforms may want | 
|---|
| 74 | * to allow more than three entries per node or otherwise refine | 
|---|
| 75 | * this size. | 
|---|
| 76 | */ | 
|---|
| 77 |  | 
|---|
| 78 | #include <linux/numa.h> | 
|---|
| 79 |  | 
|---|
| 80 | #define E820_MAX_ENTRIES	(E820_MAX_ENTRIES_ZEROPAGE + 3*MAX_NUMNODES) | 
|---|
| 81 |  | 
|---|
| 82 | /* | 
|---|
| 83 | * The whole array of E820 entries: | 
|---|
| 84 | */ | 
|---|
| 85 | struct e820_table { | 
|---|
| 86 | __u32 nr_entries; | 
|---|
| 87 | struct e820_entry entries[E820_MAX_ENTRIES]; | 
|---|
| 88 | }; | 
|---|
| 89 |  | 
|---|
| 90 | /* | 
|---|
| 91 | * Various well-known legacy memory ranges in physical memory: | 
|---|
| 92 | */ | 
|---|
| 93 | #define ISA_START_ADDRESS	0x000a0000 | 
|---|
| 94 | #define ISA_END_ADDRESS		0x00100000 | 
|---|
| 95 |  | 
|---|
| 96 | #define BIOS_BEGIN		0x000a0000 | 
|---|
| 97 | #define BIOS_END		0x00100000 | 
|---|
| 98 |  | 
|---|
| 99 | #define HIGH_MEMORY		0x00100000 | 
|---|
| 100 |  | 
|---|
| 101 | #define BIOS_ROM_BASE		0xffe00000 | 
|---|
| 102 | #define BIOS_ROM_END		0xffffffff | 
|---|
| 103 |  | 
|---|
| 104 | #endif /* _ASM_E820_TYPES_H */ | 
|---|
| 105 |  | 
|---|