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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/memblock.hlinux/suspend.hlinux/acpi.hlinux/firmware-map.hlinux/sort.hlinux/kvm_types.hasm/e820/api.hasm/setup.h
Detected Declarations
struct change_memberfunction _e820__mapped_anyfunction e820__mapped_raw_anyfunction e820__mapped_anyfunction e820__mapped_allfunction e820__get_entry_typefunction __e820__range_addfunction e820__range_addfunction e820_print_typefunction e820__print_tablefunction cpcomparefunction e820_type_mergeablefunction e820__update_tablefunction append_e820_tablefunction __e820__range_updatefunction e820__range_updatefunction e820__range_update_tablefunction e820__range_removefunction e820__update_table_printfunction e820__update_table_kexecfunction MAX_GAP_ENDfunction e820__setup_pci_gapfunction afunction remainingfunction hibernationfunction e820__register_nvs_regionsfunction e820__end_ram_pfnfunction e820__end_of_ram_pfnfunction e820__end_of_low_ram_pfnfunction parse_memoptfunction parse_memmap_onefunction parse_memmap_optfunction parse_early_paramfunction e820_type_to_stringfunction e820_type_to_iomem_typefunction e820_type_to_iores_descfunction e820_device_regionfunction e820__reserve_resourcesfunction pcibios_resource_surveyfunction ram_alignmentfunction e820__reserve_resources_latefunction firmwarefunction e820__memory_setup_defaultfunction e820__memblock_setupmodule init e820__register_nvs_regionsexport pci_mem_startexport e820__mapped_any
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
- Immediate include surface: `linux/memblock.h`, `linux/suspend.h`, `linux/acpi.h`, `linux/firmware-map.h`, `linux/sort.h`, `linux/kvm_types.h`, `asm/e820/api.h`, `asm/setup.h`.
- Detected declarations: `struct change_member`, `function _e820__mapped_any`, `function e820__mapped_raw_any`, `function e820__mapped_any`, `function e820__mapped_all`, `function e820__get_entry_type`, `function __e820__range_add`, `function e820__range_add`, `function e820_print_type`, `function e820__print_table`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.