arch/m68k/mm/kmap.c
Source file repositories/reference/linux-study-clean/arch/m68k/mm/kmap.c
File Facts
- System
- Linux kernel
- Corpus path
arch/m68k/mm/kmap.c- Extension
.c- Size
- 8713 bytes
- Lines
- 401
- Domain
- Architecture Layer
- Bucket
- arch/m68k
- 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/module.hlinux/mm.hlinux/kernel.hlinux/string.hlinux/types.hlinux/slab.hlinux/vmalloc.hasm/setup.hasm/page.hasm/io.hasm/tlbflush.h
Detected Declarations
function Copyrightfunction free_io_areafunction __free_io_areafunction free_io_areafunction ioremapfunction kernel_set_cachemodeexport __ioremapexport iounmapexport kernel_set_cachemode
Annotated Snippet
if (pud_bad(*pud_dir)) {
printk("iounmap: bad pud(%08lx)\n", pud_val(*pud_dir));
pud_clear(pud_dir);
return;
}
pmd_dir = pmd_offset(pud_dir, virtaddr);
#if CONFIG_PGTABLE_LEVELS == 3
if (CPU_IS_020_OR_030) {
int pmd_type = pmd_val(*pmd_dir) & _DESCTYPE_MASK;
if (pmd_type == _PAGE_PRESENT) {
pmd_clear(pmd_dir);
virtaddr += PMD_SIZE;
size -= PMD_SIZE;
} else if (pmd_type == 0)
continue;
}
#endif
if (pmd_bad(*pmd_dir)) {
printk("iounmap: bad pmd (%08lx)\n", pmd_val(*pmd_dir));
pmd_clear(pmd_dir);
return;
}
pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
pte_val(*pte_dir) = 0;
virtaddr += PAGE_SIZE;
size -= PAGE_SIZE;
}
flush_tlb_all();
}
static struct vm_struct *get_io_area(unsigned long size)
{
unsigned long addr;
struct vm_struct **p, *tmp, *area;
area = kmalloc_obj(*area);
if (!area)
return NULL;
addr = KMAP_START;
for (p = &iolist; (tmp = *p) ; p = &tmp->next) {
if (size + addr < (unsigned long)tmp->addr)
break;
if (addr > KMAP_END-size) {
kfree(area);
return NULL;
}
addr = tmp->size + (unsigned long)tmp->addr;
}
area->addr = (void *)addr;
area->size = size + IO_SIZE;
area->next = *p;
*p = area;
return area;
}
static inline void free_io_area(void *addr)
{
struct vm_struct **p, *tmp;
if (!addr)
return;
addr = (void *)((unsigned long)addr & -IO_SIZE);
for (p = &iolist ; (tmp = *p) ; p = &tmp->next) {
if (tmp->addr == addr) {
*p = tmp->next;
/* remove gap added in get_io_area() */
__free_io_area(tmp->addr, tmp->size - IO_SIZE);
kfree(tmp);
return;
}
}
}
#endif
/*
* Map some physical address range into the kernel address space.
*/
/* Rewritten by Andreas Schwab to remove all races. */
void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
{
struct vm_struct *area;
unsigned long virtaddr, retaddr;
Annotation
- Immediate include surface: `linux/module.h`, `linux/mm.h`, `linux/kernel.h`, `linux/string.h`, `linux/types.h`, `linux/slab.h`, `linux/vmalloc.h`, `asm/setup.h`.
- Detected declarations: `function Copyright`, `function free_io_area`, `function __free_io_area`, `function free_io_area`, `function ioremap`, `function kernel_set_cachemode`, `export __ioremap`, `export iounmap`, `export kernel_set_cachemode`.
- Atlas domain: Architecture Layer / arch/m68k.
- 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.