/* cache-page.c: whole-page cache wrangling functions for MMU linux1*2* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* as published by the Free Software Foundation; either version8* 2 of the License, or (at your option) any later version.9*/10#include <linux/sched.h>11#include <linux/mm.h>12#include <linux/highmem.h>13#include <linux/module.h>14#include <asm/pgalloc.h>1516/*****************************************************************************/17/*18* DCF takes a virtual address and the page may not currently have one19* - temporarily hijack a kmap_atomic() slot and attach the page to it20*/21void flush_dcache_page(struct page *page)22{23unsigned long dampr2;24void *vaddr;2526dampr2 = __get_DAMPR(2);2728vaddr = kmap_atomic_primary(page, __KM_CACHE);2930frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);3132kunmap_atomic_primary(vaddr, __KM_CACHE);3334if (dampr2) {35__set_DAMPR(2, dampr2);36__set_IAMPR(2, dampr2);37}3839} /* end flush_dcache_page() */4041EXPORT_SYMBOL(flush_dcache_page);4243/*****************************************************************************/44/*45* ICI takes a virtual address and the page may not currently have one46* - so we temporarily attach the page to a bit of virtual space so that is can be flushed47*/48void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,49unsigned long start, unsigned long len)50{51unsigned long dampr2;52void *vaddr;5354dampr2 = __get_DAMPR(2);5556vaddr = kmap_atomic_primary(page, __KM_CACHE);5758start = (start & ~PAGE_MASK) | (unsigned long) vaddr;59frv_cache_wback_inv(start, start + len);6061kunmap_atomic_primary(vaddr, __KM_CACHE);6263if (dampr2) {64__set_DAMPR(2, dampr2);65__set_IAMPR(2, dampr2);66}6768} /* end flush_icache_user_range() */6970EXPORT_SYMBOL(flush_icache_user_range);717273