162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
262306a36Sopenharmony_ci#ifndef _UAPI_ASM_X86_E820_H
362306a36Sopenharmony_ci#define _UAPI_ASM_X86_E820_H
462306a36Sopenharmony_ci#define E820MAP	0x2d0		/* our map */
562306a36Sopenharmony_ci#define E820MAX	128		/* number of entries in E820MAP */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/*
862306a36Sopenharmony_ci * Legacy E820 BIOS limits us to 128 (E820MAX) nodes due to the
962306a36Sopenharmony_ci * constrained space in the zeropage.  If we have more nodes than
1062306a36Sopenharmony_ci * that, and if we've booted off EFI firmware, then the EFI tables
1162306a36Sopenharmony_ci * passed us from the EFI firmware can list more nodes.  Size our
1262306a36Sopenharmony_ci * internal memory map tables to have room for these additional
1362306a36Sopenharmony_ci * nodes, based on up to three entries per node for which the
1462306a36Sopenharmony_ci * kernel was built: MAX_NUMNODES == (1 << CONFIG_NODES_SHIFT),
1562306a36Sopenharmony_ci * plus E820MAX, allowing space for the possible duplicate E820
1662306a36Sopenharmony_ci * entries that might need room in the same arrays, prior to the
1762306a36Sopenharmony_ci * call to sanitize_e820_map() to remove duplicates.  The allowance
1862306a36Sopenharmony_ci * of three memory map entries per node is "enough" entries for
1962306a36Sopenharmony_ci * the initial hardware platform motivating this mechanism to make
2062306a36Sopenharmony_ci * use of additional EFI map entries.  Future platforms may want
2162306a36Sopenharmony_ci * to allow more than three entries per node or otherwise refine
2262306a36Sopenharmony_ci * this size.
2362306a36Sopenharmony_ci */
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#ifndef __KERNEL__
2662306a36Sopenharmony_ci#define E820_X_MAX E820MAX
2762306a36Sopenharmony_ci#endif
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#define E820NR	0x1e8		/* # entries in E820MAP */
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define E820_RAM	1
3262306a36Sopenharmony_ci#define E820_RESERVED	2
3362306a36Sopenharmony_ci#define E820_ACPI	3
3462306a36Sopenharmony_ci#define E820_NVS	4
3562306a36Sopenharmony_ci#define E820_UNUSABLE	5
3662306a36Sopenharmony_ci#define E820_PMEM	7
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/*
3962306a36Sopenharmony_ci * This is a non-standardized way to represent ADR or NVDIMM regions that
4062306a36Sopenharmony_ci * persist over a reboot.  The kernel will ignore their special capabilities
4162306a36Sopenharmony_ci * unless the CONFIG_X86_PMEM_LEGACY option is set.
4262306a36Sopenharmony_ci *
4362306a36Sopenharmony_ci * ( Note that older platforms also used 6 for the same type of memory,
4462306a36Sopenharmony_ci *   but newer versions switched to 12 as 6 was assigned differently.  Some
4562306a36Sopenharmony_ci *   time they will learn... )
4662306a36Sopenharmony_ci */
4762306a36Sopenharmony_ci#define E820_PRAM	12
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/*
5062306a36Sopenharmony_ci * reserved RAM used by kernel itself
5162306a36Sopenharmony_ci * if CONFIG_INTEL_TXT is enabled, memory of this type will be
5262306a36Sopenharmony_ci * included in the S3 integrity calculation and so should not include
5362306a36Sopenharmony_ci * any memory that BIOS might alter over the S3 transition
5462306a36Sopenharmony_ci */
5562306a36Sopenharmony_ci#define E820_RESERVED_KERN        128
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#ifndef __ASSEMBLY__
5862306a36Sopenharmony_ci#include <linux/types.h>
5962306a36Sopenharmony_cistruct e820entry {
6062306a36Sopenharmony_ci	__u64 addr;	/* start of memory segment */
6162306a36Sopenharmony_ci	__u64 size;	/* size of memory segment */
6262306a36Sopenharmony_ci	__u32 type;	/* type of memory segment */
6362306a36Sopenharmony_ci} __attribute__((packed));
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_cistruct e820map {
6662306a36Sopenharmony_ci	__u32 nr_map;
6762306a36Sopenharmony_ci	struct e820entry map[E820_X_MAX];
6862306a36Sopenharmony_ci};
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define ISA_START_ADDRESS	0xa0000
7162306a36Sopenharmony_ci#define ISA_END_ADDRESS		0x100000
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define BIOS_BEGIN		0x000a0000
7462306a36Sopenharmony_ci#define BIOS_END		0x00100000
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#define BIOS_ROM_BASE		0xffe00000
7762306a36Sopenharmony_ci#define BIOS_ROM_END		0xffffffff
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#endif /* _UAPI_ASM_X86_E820_H */
83