arch/m68k/sun3/mmu_emu.c
Source file repositories/reference/linux-study-clean/arch/m68k/sun3/mmu_emu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/m68k/sun3/mmu_emu.c- Extension
.c- Size
- 11915 bytes
- Lines
- 428
- 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/init.hlinux/mman.hlinux/mm.hlinux/kernel.hlinux/ptrace.hlinux/delay.hlinux/memblock.hlinux/bitops.hlinux/module.hlinux/sched/mm.hlinux/string_choices.hasm/setup.hasm/traps.hlinux/uaccess.hasm/page.hasm/sun3mmu.hasm/oplib.hasm/mmu_context.hasm/dvma.hsun3.h
Detected Declarations
function print_ptefunction print_pte_vaddrfunction mmu_emu_initfunction clear_contextfunction get_free_contextfunction mmu_emu_map_pmegfunction mmu_emu_handle_faultexport m68k_vmalloc_end
Annotated Snippet
if(!pmeg_alloc[i]) {
#ifdef DEBUG_MMU_EMU
pr_info("freed:");
print_pte_vaddr (seg);
#endif
sun3_put_segmap(seg, SUN3_INVALID_PMEG);
}
}
j = 0;
for (num=0, seg=0x0F800000; seg<0x10000000; seg+=16*PAGE_SIZE) {
if (sun3_get_segmap (seg) != SUN3_INVALID_PMEG) {
#ifdef DEBUG_PROM_MAPS
for(i = 0; i < 16; i++) {
pr_info("mapped:");
print_pte_vaddr (seg + (i*PAGE_SIZE));
break;
}
#endif
// the lowest mapping here is the end of our
// vmalloc region
if (!m68k_vmalloc_end)
m68k_vmalloc_end = seg;
// mark the segmap alloc'd, and reserve any
// of the first 0xbff pages the hardware is
// already using... does any sun3 support > 24mb?
pmeg_alloc[sun3_get_segmap(seg)] = 2;
}
}
dvma_init();
/* blank everything below the kernel, and we've got the base
mapping to start all the contexts off with... */
for(seg = 0; seg < PAGE_OFFSET; seg += SUN3_PMEG_SIZE)
sun3_put_segmap(seg, SUN3_INVALID_PMEG);
set_fc(3);
for(seg = 0; seg < 0x10000000; seg += SUN3_PMEG_SIZE) {
i = sun3_get_segmap(seg);
for(j = 1; j < CONTEXTS_NUM; j++)
(*(romvec->pv_setctxt))(j, (void *)seg, i);
}
set_fc(USER_DATA);
}
/* erase the mappings for a dead context. Uses the pg_dir for hints
as the pmeg tables proved somewhat unreliable, and unmapping all of
TASK_SIZE was much slower and no more stable. */
/* todo: find a better way to keep track of the pmegs used by a
context for when they're cleared */
void clear_context(unsigned long context)
{
unsigned char oldctx;
unsigned long i;
if (context) {
if (!ctx_alloc[context])
panic("%s: context not allocated\n", __func__);
ctx_alloc[context]->context = SUN3_INVALID_CONTEXT;
ctx_alloc[context] = (struct mm_struct *)0;
ctx_avail++;
}
oldctx = sun3_get_context();
sun3_put_context(context);
for (i = 0; i < SUN3_INVALID_PMEG; i++) {
if ((pmeg_ctx[i] == context) && (pmeg_alloc[i] == 1)) {
sun3_put_segmap(pmeg_vaddr[i], SUN3_INVALID_PMEG);
pmeg_ctx[i] = 0;
pmeg_alloc[i] = 0;
pmeg_vaddr[i] = 0;
}
}
sun3_put_context(oldctx);
}
/* gets an empty context. if full, kills the next context listed to
die first */
/* This context invalidation scheme is, well, totally arbitrary, I'm
sure it could be much more intelligent... but it gets the job done
for now without much overhead in making it's decision. */
/* todo: come up with optimized scheme for flushing contexts */
unsigned long get_free_context(struct mm_struct *mm)
Annotation
- Immediate include surface: `linux/init.h`, `linux/mman.h`, `linux/mm.h`, `linux/kernel.h`, `linux/ptrace.h`, `linux/delay.h`, `linux/memblock.h`, `linux/bitops.h`.
- Detected declarations: `function print_pte`, `function print_pte_vaddr`, `function mmu_emu_init`, `function clear_context`, `function get_free_context`, `function mmu_emu_map_pmeg`, `function mmu_emu_handle_fault`, `export m68k_vmalloc_end`.
- 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.