arch/nios2/mm/ioremap.c
Source file repositories/reference/linux-study-clean/arch/nios2/mm/ioremap.c
File Facts
- System
- Linux kernel
- Corpus path
arch/nios2/mm/ioremap.c- Extension
.c- Size
- 4573 bytes
- Lines
- 189
- Domain
- Architecture Layer
- Bucket
- arch/nios2
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/sched.hlinux/mm.hlinux/slab.hlinux/vmalloc.hlinux/io.hasm/cacheflush.hasm/tlbflush.h
Detected Declarations
function Copyrightfunction remap_area_pmdfunction remap_area_pagesfunction iounmapexport ioremapexport iounmap
Annotated Snippet
if (!pte_none(*pte)) {
pr_err("remap_area_pte: page already exists\n");
BUG();
}
set_pte(pte, pfn_pte(pfn, pgprot));
address += PAGE_SIZE;
pfn++;
pte++;
} while (address && (address < end));
}
static inline int remap_area_pmd(pmd_t *pmd, unsigned long address,
unsigned long size, unsigned long phys_addr,
unsigned long flags)
{
unsigned long end;
address &= ~PGDIR_MASK;
end = address + size;
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
phys_addr -= address;
if (address >= end)
BUG();
do {
pte_t *pte = pte_alloc_kernel(pmd, address);
if (!pte)
return -ENOMEM;
remap_area_pte(pte, address, end - address, address + phys_addr,
flags);
address = (address + PMD_SIZE) & PMD_MASK;
pmd++;
} while (address && (address < end));
return 0;
}
static int remap_area_pages(unsigned long address, unsigned long phys_addr,
unsigned long size, unsigned long flags)
{
int error;
pgd_t *dir;
unsigned long end = address + size;
phys_addr -= address;
dir = pgd_offset(&init_mm, address);
flush_cache_all();
if (address >= end)
BUG();
do {
p4d_t *p4d;
pud_t *pud;
pmd_t *pmd;
error = -ENOMEM;
p4d = p4d_alloc(&init_mm, dir, address);
if (!p4d)
break;
pud = pud_alloc(&init_mm, p4d, address);
if (!pud)
break;
pmd = pmd_alloc(&init_mm, pud, address);
if (!pmd)
break;
if (remap_area_pmd(pmd, address, end - address,
phys_addr + address, flags))
break;
error = 0;
address = (address + PGDIR_SIZE) & PGDIR_MASK;
dir++;
} while (address && (address < end));
flush_tlb_all();
return error;
}
#define IS_MAPPABLE_UNCACHEABLE(addr) (addr < 0x20000000UL)
/*
* Map some physical address range into the kernel address space.
*/
void __iomem *ioremap(unsigned long phys_addr, unsigned long size)
{
struct vm_struct *area;
unsigned long offset;
unsigned long last_addr;
void *addr;
/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
Annotation
- Immediate include surface: `linux/export.h`, `linux/sched.h`, `linux/mm.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/io.h`, `asm/cacheflush.h`, `asm/tlbflush.h`.
- Detected declarations: `function Copyright`, `function remap_area_pmd`, `function remap_area_pages`, `function iounmap`, `export ioremap`, `export iounmap`.
- Atlas domain: Architecture Layer / arch/nios2.
- Implementation status: integration 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.