Linux-2.6.12-rc2
[linux-2.6/kvm.git] / arch / frv / mm / cache-page.c
blob683b5e344318b7ec6bf39d4b0ee3e1c07265a269
1 /* cache-page.c: whole-page cache wrangling functions for MMU linux
3 * Copyright (C) 2004 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <linux/highmem.h>
14 #include <asm/pgalloc.h>
16 /*****************************************************************************/
18 * DCF takes a virtual address and the page may not currently have one
19 * - temporarily hijack a kmap_atomic() slot and attach the page to it
21 void flush_dcache_page(struct page *page)
23 unsigned long dampr2;
24 void *vaddr;
26 dampr2 = __get_DAMPR(2);
28 vaddr = kmap_atomic(page, __KM_CACHE);
30 frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);
32 kunmap_atomic(vaddr, __KM_CACHE);
34 if (dampr2) {
35 __set_DAMPR(2, dampr2);
36 __set_IAMPR(2, dampr2);
39 } /* end flush_dcache_page() */
41 /*****************************************************************************/
43 * ICI takes a virtual address and the page may not currently have one
44 * - so we temporarily attach the page to a bit of virtual space so that is can be flushed
46 void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
47 unsigned long start, unsigned long len)
49 unsigned long dampr2;
50 void *vaddr;
52 dampr2 = __get_DAMPR(2);
54 vaddr = kmap_atomic(page, __KM_CACHE);
56 start = (start & ~PAGE_MASK) | (unsigned long) vaddr;
57 frv_cache_wback_inv(start, start + len);
59 kunmap_atomic(vaddr, __KM_CACHE);
61 if (dampr2) {
62 __set_DAMPR(2, dampr2);
63 __set_IAMPR(2, dampr2);
66 } /* end flush_icache_user_range() */