]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/um/kernel/skas/tlb.c
uml: remove user_util.h
[karo-tx-linux.git] / arch / um / kernel / skas / tlb.c
1 /* 
2  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3  * Copyright 2003 PathScale, Inc.
4  * Licensed under the GPL
5  */
6
7 #include "linux/stddef.h"
8 #include "linux/sched.h"
9 #include "linux/mm.h"
10 #include "asm/page.h"
11 #include "asm/pgtable.h"
12 #include "asm/mmu.h"
13 #include "mem_user.h"
14 #include "mem.h"
15 #include "skas.h"
16 #include "os.h"
17 #include "tlb.h"
18
19 static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
20                   int finished, void **flush)
21 {
22         struct host_vm_op *op;
23         int i, ret = 0;
24
25         for(i = 0; i <= last && !ret; i++){
26                 op = &ops[i];
27                 switch(op->type){
28                 case MMAP:
29                         ret = map(&mmu->skas.id, op->u.mmap.addr,
30                                   op->u.mmap.len, op->u.mmap.r, op->u.mmap.w,
31                                   op->u.mmap.x, op->u.mmap.fd,
32                                   op->u.mmap.offset, finished, flush);
33                         break;
34                 case MUNMAP:
35                         ret = unmap(&mmu->skas.id,
36                                     (void *) op->u.munmap.addr,
37                                     op->u.munmap.len, finished, flush);
38                         break;
39                 case MPROTECT:
40                         ret = protect(&mmu->skas.id, op->u.mprotect.addr,
41                                       op->u.mprotect.len, op->u.mprotect.r,
42                                       op->u.mprotect.w, op->u.mprotect.x,
43                                       finished, flush);
44                         break;
45                 default:
46                         printk("Unknown op type %d in do_ops\n", op->type);
47                         break;
48                 }
49         }
50
51         return ret;
52 }
53
54 extern int proc_mm;
55
56 static void fix_range(struct mm_struct *mm, unsigned long start_addr,
57                       unsigned long end_addr, int force)
58 {
59         if(!proc_mm && (end_addr > CONFIG_STUB_START))
60                 end_addr = CONFIG_STUB_START;
61
62         fix_range_common(mm, start_addr, end_addr, force, do_ops);
63 }
64
65 void __flush_tlb_one_skas(unsigned long addr)
66 {
67         flush_tlb_kernel_range_common(addr, addr + PAGE_SIZE);
68 }
69
70 void flush_tlb_range_skas(struct vm_area_struct *vma, unsigned long start, 
71                      unsigned long end)
72 {
73         if(vma->vm_mm == NULL)
74                 flush_tlb_kernel_range_common(start, end);
75         else fix_range(vma->vm_mm, start, end, 0);
76 }
77
78 void flush_tlb_mm_skas(struct mm_struct *mm)
79 {
80         unsigned long end;
81
82         /* Don't bother flushing if this address space is about to be
83          * destroyed.
84          */
85         if(atomic_read(&mm->mm_users) == 0)
86                 return;
87
88         end = proc_mm ? task_size : CONFIG_STUB_START;
89         fix_range(mm, 0, end, 0);
90 }
91
92 void force_flush_all_skas(void)
93 {
94         unsigned long end = proc_mm ? task_size : CONFIG_STUB_START;
95         fix_range(current->mm, 0, end, 1);
96 }