arch/x86/kernel/e820.c

Source file repositories/reference/linux-study-clean/arch/x86/kernel/e820.c

File Facts

System
Linux kernel
Corpus path
arch/x86/kernel/e820.c
Extension
.c
Size
39539 bytes
Lines
1381
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

core_initcall(e820__register_nvs_regions);
#endif

/*
 * Allocate the requested number of bytes with the requested alignment
 * and return (the physical address) to the caller. Also register this
 * range in the 'kexec' E820 table as a reserved range.
 *
 * This allows kexec to fake a new mptable, as if it came from the real
 * system.
 */
__init u64 e820__memblock_alloc_reserved(u64 size, u64 align)
{
	u64 addr;

	addr = memblock_phys_alloc(size, align);
	if (addr) {
		e820__range_update_table(e820_table_kexec, addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED);
		pr_info("update e820_table_kexec for e820__memblock_alloc_reserved()\n");
		e820__update_table_kexec();
	}

	return addr;
}

#ifdef CONFIG_X86_32
# ifdef CONFIG_X86_PAE
#  define MAX_ARCH_PFN		(1ULL<<(36-PAGE_SHIFT))
# else
#  define MAX_ARCH_PFN		(1ULL<<(32-PAGE_SHIFT))
# endif
#else /* CONFIG_X86_32 */
# define MAX_ARCH_PFN MAXMEM>>PAGE_SHIFT
#endif

/*
 * Find the highest page frame number we have available
 */
__init static unsigned long e820__end_ram_pfn(unsigned long limit_pfn)
{
	u32 idx;
	unsigned long last_pfn = 0;
	unsigned long max_arch_pfn = MAX_ARCH_PFN;

	for (idx = 0; idx < e820_table->nr_entries; idx++) {
		struct e820_entry *entry = &e820_table->entries[idx];
		unsigned long start_pfn;
		unsigned long end_pfn;

		if (entry->type != E820_TYPE_RAM &&
		    entry->type != E820_TYPE_ACPI)
			continue;

		start_pfn = entry->addr >> PAGE_SHIFT;
		end_pfn = (entry->addr + entry->size) >> PAGE_SHIFT;

		if (start_pfn >= limit_pfn)
			continue;
		if (end_pfn > limit_pfn) {
			last_pfn = limit_pfn;
			break;
		}
		if (end_pfn > last_pfn)
			last_pfn = end_pfn;
	}

	if (last_pfn > max_arch_pfn)
		last_pfn = max_arch_pfn;

	pr_info("last_pfn = %#lx max_arch_pfn = %#lx\n",
		last_pfn, max_arch_pfn);
	return last_pfn;
}

__init unsigned long e820__end_of_ram_pfn(void)
{
	return e820__end_ram_pfn(MAX_ARCH_PFN);
}

__init unsigned long e820__end_of_low_ram_pfn(void)
{
	return e820__end_ram_pfn(1UL << (32 - PAGE_SHIFT));
}

__initdata static int userdef;

/* The "mem=nopentium" boot option disables 4MB page tables on 32-bit kernels: */
__init static int parse_memopt(char *p)
{
	u64 mem_size;

Annotation

Implementation Notes