huangcm
2025-08-30 0269911b91ed7e03c24005924cc6423abf245fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* cache-page.c: whole-page cache wrangling functions for MMU linux
 *
 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/module.h>
#include <asm/pgalloc.h>
 
/*****************************************************************************/
/*
 * DCF takes a virtual address and the page may not currently have one
 * - temporarily hijack a kmap_atomic() slot and attach the page to it
 */
void flush_dcache_page(struct page *page)
{
   unsigned long dampr2;
   void *vaddr;
 
   dampr2 = __get_DAMPR(2);
 
   vaddr = kmap_atomic_primary(page);
 
   frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);
 
   kunmap_atomic_primary(vaddr);
 
   if (dampr2) {
       __set_DAMPR(2, dampr2);
       __set_IAMPR(2, dampr2);
   }
 
} /* end flush_dcache_page() */
 
EXPORT_SYMBOL(flush_dcache_page);
 
/*****************************************************************************/
/*
 * ICI takes a virtual address and the page may not currently have one
 * - so we temporarily attach the page to a bit of virtual space so that is can be flushed
 */
void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
                unsigned long start, unsigned long len)
{
   unsigned long dampr2;
   void *vaddr;
 
   dampr2 = __get_DAMPR(2);
 
   vaddr = kmap_atomic_primary(page);
 
   start = (start & ~PAGE_MASK) | (unsigned long) vaddr;
   frv_cache_wback_inv(start, start + len);
 
   kunmap_atomic_primary(vaddr);
 
   if (dampr2) {
       __set_DAMPR(2, dampr2);
       __set_IAMPR(2, dampr2);
   }
 
} /* end flush_icache_user_range() */
 
EXPORT_SYMBOL(flush_icache_user_range);