arch/m68k/kernel/sys_m68k.c
Source file repositories/reference/linux-study-clean/arch/m68k/kernel/sys_m68k.c
File Facts
- System
- Linux kernel
- Corpus path
arch/m68k/kernel/sys_m68k.c- Extension
.c- Size
- 13610 bytes
- Lines
- 585
- Domain
- Architecture Layer
- Bucket
- arch/m68k
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/capability.hlinux/errno.hlinux/sched.hlinux/mm.hlinux/fs.hlinux/smp.hlinux/sem.hlinux/msg.hlinux/shm.hlinux/stat.hlinux/syscalls.hlinux/mman.hlinux/file.hlinux/ipc.hasm/setup.hlinux/uaccess.hasm/cachectl.hasm/traps.hasm/page.hasm/syscalls.hasm/unistd.hasm/cacheflush.hasm/tlb.h../mm/fault.h
Detected Declarations
function sys_mmap2function cache_flush_040function cache_flush_060function sys_cacheflushfunction D1function sys_cacheflushfunction D1function sys_getpagesizefunction sys_get_thread_areafunction sys_set_thread_areafunction sys_atomic_barrier
Annotated Snippet
if ((paddr = virt_to_phys_040(addr))) {
paddr += addr & ~(PAGE_MASK | 15);
len = (len + (addr & 15) + 15) >> 4;
} else {
unsigned long tmp = PAGE_SIZE - (addr & ~PAGE_MASK);
if (len <= tmp)
return 0;
addr += tmp;
len -= tmp;
tmp = PAGE_SIZE;
for (;;)
{
if ((paddr = virt_to_phys_040(addr)))
break;
if (len <= tmp)
return 0;
addr += tmp;
len -= tmp;
}
len = (len + 15) >> 4;
}
i = (PAGE_SIZE - (paddr & ~PAGE_MASK)) >> 4;
while (len--)
{
switch (cache)
{
case FLUSH_CACHE_DATA:
__asm__ __volatile__ ("nop\n\t"
".chip 68040\n\t"
"cpushl %%dc,(%0)\n\t"
".chip 68k"
: : "a" (paddr));
break;
case FLUSH_CACHE_INSN:
__asm__ __volatile__ ("nop\n\t"
".chip 68040\n\t"
"cpushl %%ic,(%0)\n\t"
".chip 68k"
: : "a" (paddr));
break;
default:
case FLUSH_CACHE_BOTH:
__asm__ __volatile__ ("nop\n\t"
".chip 68040\n\t"
"cpushl %%bc,(%0)\n\t"
".chip 68k"
: : "a" (paddr));
break;
}
if (!--i && len)
{
/*
* No need to page align here since it is done by
* virt_to_phys_040().
*/
addr += PAGE_SIZE;
i = PAGE_SIZE / 16;
/* Recompute physical address when crossing a page
boundary. */
for (;;)
{
if ((paddr = virt_to_phys_040(addr)))
break;
if (len <= i)
return 0;
len -= i;
addr += PAGE_SIZE;
}
}
else
paddr += 16;
}
break;
default:
case FLUSH_SCOPE_PAGE:
len += (addr & ~PAGE_MASK) + (PAGE_SIZE - 1);
for (len >>= PAGE_SHIFT; len--; addr += PAGE_SIZE)
{
if (!(paddr = virt_to_phys_040(addr)))
continue;
switch (cache)
{
case FLUSH_CACHE_DATA:
__asm__ __volatile__ ("nop\n\t"
".chip 68040\n\t"
"cpushp %%dc,(%0)\n\t"
".chip 68k"
: : "a" (paddr));
Annotation
- Immediate include surface: `linux/capability.h`, `linux/errno.h`, `linux/sched.h`, `linux/mm.h`, `linux/fs.h`, `linux/smp.h`, `linux/sem.h`, `linux/msg.h`.
- Detected declarations: `function sys_mmap2`, `function cache_flush_040`, `function cache_flush_060`, `function sys_cacheflush`, `function D1`, `function sys_cacheflush`, `function D1`, `function sys_getpagesize`, `function sys_get_thread_area`, `function sys_set_thread_area`.
- Atlas domain: Architecture Layer / arch/m68k.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.