Path: blob/master/arch/microblaze/mm/mmu_context.c
10817 views
/*1* This file contains the routines for handling the MMU.2*3* Copyright (C) 2007 Xilinx, Inc. All rights reserved.4*5* Derived from arch/ppc/mm/4xx_mmu.c:6* -- paulus7*8* Derived from arch/ppc/mm/init.c:9* Copyright (C) 1995-1996 Gary Thomas ([email protected])10*11* Modifications by Paul Mackerras (PowerMac) ([email protected])12* and Cort Dougan (PReP) ([email protected])13* Copyright (C) 1996 Paul Mackerras14* Amiga/APUS changes by Jesper Skov ([email protected]).15*16* Derived from "arch/i386/mm/init.c"17* Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds18*19* This program is free software; you can redistribute it and/or20* modify it under the terms of the GNU General Public License21* as published by the Free Software Foundation; either version22* 2 of the License, or (at your option) any later version.23*24*/2526#include <linux/mm.h>27#include <linux/init.h>2829#include <asm/tlbflush.h>30#include <asm/mmu_context.h>3132mm_context_t next_mmu_context;33unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];34atomic_t nr_free_contexts;35struct mm_struct *context_mm[LAST_CONTEXT+1];3637/*38* Initialize the context management stuff.39*/40void __init mmu_context_init(void)41{42/*43* The use of context zero is reserved for the kernel.44* This code assumes FIRST_CONTEXT < 32.45*/46context_map[0] = (1 << FIRST_CONTEXT) - 1;47next_mmu_context = FIRST_CONTEXT;48atomic_set(&nr_free_contexts, LAST_CONTEXT - FIRST_CONTEXT + 1);49}5051/*52* Steal a context from a task that has one at the moment.53*54* This isn't an LRU system, it just frees up each context in55* turn (sort-of pseudo-random replacement :). This would be the56* place to implement an LRU scheme if anyone were motivated to do it.57*/58void steal_context(void)59{60struct mm_struct *mm;6162/* free up context `next_mmu_context' */63/* if we shouldn't free context 0, don't... */64if (next_mmu_context < FIRST_CONTEXT)65next_mmu_context = FIRST_CONTEXT;66mm = context_mm[next_mmu_context];67flush_tlb_mm(mm);68destroy_context(mm);69}707172