added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / mn10300 / mm / mmu-context.c
blob31c9d27a75ae8cab8a0e3daa650ddb8e8659febc
1 /* MN10300 MMU context allocation and management
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <asm/mmu_context.h>
14 #include <asm/tlbflush.h>
17 * list of the MMU contexts last allocated on each CPU
19 unsigned long mmu_context_cache[NR_CPUS] = {
20 [0 ... NR_CPUS - 1] = MMU_CONTEXT_FIRST_VERSION * 2 - 1,
24 * flush the specified TLB entry
26 void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
28 unsigned long pteu, cnx, flags;
30 addr &= PAGE_MASK;
32 /* make sure the context doesn't migrate and defend against
33 * interference from vmalloc'd regions */
34 local_irq_save(flags);
36 cnx = mm_context(vma->vm_mm);
38 if (cnx != MMU_NO_CONTEXT) {
39 pteu = addr | (cnx & 0x000000ffUL);
40 IPTEU = pteu;
41 DPTEU = pteu;
42 if (IPTEL & xPTEL_V)
43 IPTEL = 0;
44 if (DPTEL & xPTEL_V)
45 DPTEL = 0;
48 local_irq_restore(flags);
52 * preemptively set a TLB entry
54 void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
56 unsigned long pteu, ptel, cnx, flags;
58 addr &= PAGE_MASK;
59 ptel = pte_val(pte) & ~(xPTEL_UNUSED1 | xPTEL_UNUSED2);
61 /* make sure the context doesn't migrate and defend against
62 * interference from vmalloc'd regions */
63 local_irq_save(flags);
65 cnx = mm_context(vma->vm_mm);
67 if (cnx != MMU_NO_CONTEXT) {
68 pteu = addr | (cnx & 0x000000ffUL);
69 if (!(pte_val(pte) & _PAGE_NX)) {
70 IPTEU = pteu;
71 if (IPTEL & xPTEL_V)
72 IPTEL = ptel;
74 DPTEU = pteu;
75 if (DPTEL & xPTEL_V)
76 DPTEL = ptel;
79 local_irq_restore(flags);