mm/early_ioremap.c
Source file repositories/reference/linux-study-clean/mm/early_ioremap.c
File Facts
- System
- Linux kernel
- Corpus path
mm/early_ioremap.c- Extension
.c- Size
- 7072 bytes
- Lines
- 312
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
Dependency Surface
linux/kernel.hlinux/init.hlinux/io.hlinux/module.hlinux/slab.hlinux/mm.hlinux/vmalloc.hasm/fixmap.hasm/early_ioremap.hinternal.h
Detected Declarations
function early_ioremap_debug_setupfunction early_memremap_pgprot_adjustfunction early_ioremap_resetfunction paging_initfunction __late_clear_fixmapfunction early_ioremap_setupfunction check_early_ioremap_leakfunction __early_ioremapfunction early_iounmapfunction early_ioremapfunction early_memremapfunction early_memremap_rofunction early_memremap_protfunction copy_from_early_memfunction early_ioremapfunction early_memremapfunction early_memremap_rofunction early_iounmap
Annotated Snippet
if (unlikely(early_ioremap_debug)) { \
pr_warn(fmt, ##args); \
dump_stack(); \
} \
} while (0)
static int after_paging_init __initdata;
pgprot_t __init __weak early_memremap_pgprot_adjust(resource_size_t phys_addr,
unsigned long size,
pgprot_t prot)
{
return prot;
}
void __init early_ioremap_reset(void)
{
after_paging_init = 1;
}
/*
* Generally, ioremap() is available after paging_init() has been called.
* Architectures wanting to allow early_ioremap after paging_init() can
* define __late_set_fixmap and __late_clear_fixmap to do the right thing.
*/
#ifndef __late_set_fixmap
static inline void __init __late_set_fixmap(enum fixed_addresses idx,
phys_addr_t phys, pgprot_t prot)
{
BUG();
}
#endif
#ifndef __late_clear_fixmap
static inline void __init __late_clear_fixmap(enum fixed_addresses idx)
{
BUG();
}
#endif
static void __iomem *prev_map[FIX_BTMAPS_SLOTS] __initdata;
static unsigned long prev_size[FIX_BTMAPS_SLOTS] __initdata;
static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata;
void __init early_ioremap_setup(void)
{
int i;
for (i = 0; i < FIX_BTMAPS_SLOTS; i++) {
WARN_ON_ONCE(prev_map[i]);
slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
}
}
static int __init check_early_ioremap_leak(void)
{
int count = 0;
int i;
for (i = 0; i < FIX_BTMAPS_SLOTS; i++)
if (prev_map[i])
count++;
if (WARN(count, KERN_WARNING
"Debug warning: early ioremap leak of %d areas detected.\n"
"please boot with early_ioremap_debug and report the dmesg.\n",
count))
return 1;
return 0;
}
late_initcall(check_early_ioremap_leak);
static void __init __iomem *
__early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
{
unsigned long offset;
resource_size_t last_addr;
unsigned int nrpages;
enum fixed_addresses idx;
int i, slot;
WARN_ON(system_state >= SYSTEM_RUNNING);
slot = -1;
for (i = 0; i < FIX_BTMAPS_SLOTS; i++) {
if (!prev_map[i]) {
slot = i;
break;
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/io.h`, `linux/module.h`, `linux/slab.h`, `linux/mm.h`, `linux/vmalloc.h`, `asm/fixmap.h`.
- Detected declarations: `function early_ioremap_debug_setup`, `function early_memremap_pgprot_adjust`, `function early_ioremap_reset`, `function paging_init`, `function __late_clear_fixmap`, `function early_ioremap_setup`, `function check_early_ioremap_leak`, `function __early_ioremap`, `function early_iounmap`, `function early_ioremap`.
- Atlas domain: Core OS / Memory Management.
- Implementation status: source implementation candidate.
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.