arch/m68k/include/asm/mmu_context.h
Source file repositories/reference/linux-study-clean/arch/m68k/include/asm/mmu_context.h
File Facts
- System
- Linux kernel
- Corpus path
arch/m68k/include/asm/mmu_context.h- Extension
.h- Size
- 7273 bytes
- Lines
- 323
- 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.
- 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
asm-generic/mm_hooks.hlinux/mm_types.hasm/atomic.hasm/bitops.hasm/mcfmmu.hasm/mmu.hasm/sun3mmu.hlinux/sched.hasm/setup.hasm/page.hasm/cacheflush.hasm-generic/mmu_context.hasm-generic/nommu_context.h
Detected Declarations
function get_mmu_contextfunction destroy_contextfunction set_contextfunction switch_mmfunction activate_mmfunction load_ksp_mmufunction init_new_contextfunction get_mmu_contextfunction destroy_contextfunction activate_contextfunction switch_mmfunction activate_mmfunction init_new_contextfunction switch_mm_0230function switch_mm_0460function switch_mmfunction activate_mm
Annotated Snippet
#ifndef __M68K_MMU_CONTEXT_H
#define __M68K_MMU_CONTEXT_H
#include <asm-generic/mm_hooks.h>
#include <linux/mm_types.h>
#ifdef CONFIG_MMU
#if defined(CONFIG_COLDFIRE)
#include <asm/atomic.h>
#include <asm/bitops.h>
#include <asm/mcfmmu.h>
#include <asm/mmu.h>
#define NO_CONTEXT 256
#define LAST_CONTEXT 255
#define FIRST_CONTEXT 1
extern unsigned long context_map[];
extern mm_context_t next_mmu_context;
extern atomic_t nr_free_contexts;
extern struct mm_struct *context_mm[LAST_CONTEXT+1];
extern void steal_context(void);
static inline void get_mmu_context(struct mm_struct *mm)
{
mm_context_t ctx;
if (mm->context != NO_CONTEXT)
return;
while (arch_atomic_dec_and_test_lt(&nr_free_contexts)) {
atomic_inc(&nr_free_contexts);
steal_context();
}
ctx = next_mmu_context;
while (test_and_set_bit(ctx, context_map)) {
ctx = find_next_zero_bit(context_map, LAST_CONTEXT+1, ctx);
if (ctx > LAST_CONTEXT)
ctx = 0;
}
next_mmu_context = (ctx + 1) & LAST_CONTEXT;
mm->context = ctx;
context_mm[ctx] = mm;
}
/*
* Set up the context for a new address space.
*/
#define init_new_context(tsk, mm) (((mm)->context = NO_CONTEXT), 0)
/*
* We're finished using the context for an address space.
*/
#define destroy_context destroy_context
static inline void destroy_context(struct mm_struct *mm)
{
if (mm->context != NO_CONTEXT) {
clear_bit(mm->context, context_map);
mm->context = NO_CONTEXT;
atomic_inc(&nr_free_contexts);
}
}
static inline void set_context(mm_context_t context, pgd_t *pgd)
{
__asm__ __volatile__ ("movec %0,%%asid" : : "d" (context));
}
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
struct task_struct *tsk)
{
get_mmu_context(tsk->mm);
set_context(tsk->mm->context, next->pgd);
}
/*
* After we have set current->mm to a new value, this activates
* the context for the new mm so we see the new mappings.
*/
#define activate_mm activate_mm
static inline void activate_mm(struct mm_struct *active_mm,
struct mm_struct *mm)
{
get_mmu_context(mm);
set_context(mm->context, mm->pgd);
}
#define prepare_arch_switch(next) load_ksp_mmu(next)
Annotation
- Immediate include surface: `asm-generic/mm_hooks.h`, `linux/mm_types.h`, `asm/atomic.h`, `asm/bitops.h`, `asm/mcfmmu.h`, `asm/mmu.h`, `asm/sun3mmu.h`, `linux/sched.h`.
- Detected declarations: `function get_mmu_context`, `function destroy_context`, `function set_context`, `function switch_mm`, `function activate_mm`, `function load_ksp_mmu`, `function init_new_context`, `function get_mmu_context`, `function destroy_context`, `function activate_context`.
- Atlas domain: Architecture Layer / arch/m68k.
- Implementation status: source implementation candidate.
- 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.