Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* cache-page.c: whole-page cache wrangling functions for MMU linux |
| 2 | * |
| 3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 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. |
| 10 | */ |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/mm.h> |
| 13 | #include <linux/highmem.h> |
David Howells | 4023440 | 2006-01-08 01:01:19 -0800 | [diff] [blame] | 14 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/pgalloc.h> |
| 16 | |
| 17 | /*****************************************************************************/ |
| 18 | /* |
| 19 | * DCF takes a virtual address and the page may not currently have one |
| 20 | * - temporarily hijack a kmap_atomic() slot and attach the page to it |
| 21 | */ |
| 22 | void flush_dcache_page(struct page *page) |
| 23 | { |
| 24 | unsigned long dampr2; |
| 25 | void *vaddr; |
| 26 | |
| 27 | dampr2 = __get_DAMPR(2); |
| 28 | |
Cong Wang | 144cf86 | 2012-06-27 13:02:49 +0800 | [diff] [blame] | 29 | vaddr = kmap_atomic_primary(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE); |
| 32 | |
Cong Wang | 144cf86 | 2012-06-27 13:02:49 +0800 | [diff] [blame] | 33 | kunmap_atomic_primary(vaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | if (dampr2) { |
| 36 | __set_DAMPR(2, dampr2); |
| 37 | __set_IAMPR(2, dampr2); |
| 38 | } |
| 39 | |
| 40 | } /* end flush_dcache_page() */ |
| 41 | |
David Howells | 4023440 | 2006-01-08 01:01:19 -0800 | [diff] [blame] | 42 | EXPORT_SYMBOL(flush_dcache_page); |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | /*****************************************************************************/ |
| 45 | /* |
| 46 | * ICI takes a virtual address and the page may not currently have one |
| 47 | * - so we temporarily attach the page to a bit of virtual space so that is can be flushed |
| 48 | */ |
| 49 | void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, |
| 50 | unsigned long start, unsigned long len) |
| 51 | { |
| 52 | unsigned long dampr2; |
| 53 | void *vaddr; |
| 54 | |
| 55 | dampr2 = __get_DAMPR(2); |
| 56 | |
Cong Wang | 144cf86 | 2012-06-27 13:02:49 +0800 | [diff] [blame] | 57 | vaddr = kmap_atomic_primary(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | start = (start & ~PAGE_MASK) | (unsigned long) vaddr; |
| 60 | frv_cache_wback_inv(start, start + len); |
| 61 | |
Cong Wang | 144cf86 | 2012-06-27 13:02:49 +0800 | [diff] [blame] | 62 | kunmap_atomic_primary(vaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | if (dampr2) { |
| 65 | __set_DAMPR(2, dampr2); |
| 66 | __set_IAMPR(2, dampr2); |
| 67 | } |
| 68 | |
| 69 | } /* end flush_icache_user_range() */ |
David Howells | 4023440 | 2006-01-08 01:01:19 -0800 | [diff] [blame] | 70 | |
| 71 | EXPORT_SYMBOL(flush_icache_user_range); |