2 * arch/sh/mm/pg-sh7705.c
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2004 Alex Song
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/init.h>
12 #include <linux/mman.h>
14 #include <linux/threads.h>
15 #include <asm/addrspace.h>
17 #include <asm/pgtable.h>
18 #include <asm/processor.h>
19 #include <asm/cache.h>
21 #include <asm/uaccess.h>
22 #include <asm/pgalloc.h>
23 #include <asm/mmu_context.h>
24 #include <asm/cacheflush.h>
26 static inline void __flush_purge_virtual_region(void *p1
, void *virt
, int size
)
29 unsigned long begin
, end
;
30 unsigned long p1_begin
;
33 begin
= L1_CACHE_ALIGN((unsigned long)virt
);
34 end
= L1_CACHE_ALIGN((unsigned long)virt
+ size
);
36 p1_begin
= (unsigned long)p1
& ~(L1_CACHE_BYTES
- 1);
38 /* do this the slow way as we may not have TLB entries
40 for (v
= begin
; v
< end
; v
+= L1_CACHE_BYTES
) {
42 unsigned long ways
, addr
;
46 ways
= current_cpu_data
.dcache
.ways
;
47 addr
= CACHE_OC_ADDRESS_ARRAY
;
52 addr
|= (v
& current_cpu_data
.dcache
.entry_mask
);
54 data
= ctrl_inl(addr
);
55 if ((data
& CACHE_PHYSADDR_MASK
) ==
56 (p
& CACHE_PHYSADDR_MASK
)) {
57 data
&= ~(SH_CACHE_UPDATED
|SH_CACHE_VALID
);
58 ctrl_outl(data
, addr
);
61 addr
+= current_cpu_data
.dcache
.way_incr
;
64 p1_begin
+= L1_CACHE_BYTES
;
71 * @address: U0 address to be mapped
73 void clear_user_page(void *to
, unsigned long address
, struct page
*pg
)
75 struct page
*page
= virt_to_page(to
);
77 if (((address
^ (unsigned long)to
) & CACHE_ALIAS
) == 0) {
79 __flush_wback_region(to
, PAGE_SIZE
);
81 __flush_purge_virtual_region(to
,
82 (void *)(address
& 0xfffff000),
85 __flush_wback_region(to
, PAGE_SIZE
);
93 * @address: U0 address to be mapped
95 void copy_user_page(void *to
, void *from
, unsigned long address
,
98 struct page
*page
= virt_to_page(to
);
100 if (((address
^ (unsigned long)to
) & CACHE_ALIAS
) == 0) {
102 __flush_wback_region(to
, PAGE_SIZE
);
104 __flush_purge_virtual_region(to
,
105 (void *)(address
& 0xfffff000),
108 __flush_wback_region(to
, PAGE_SIZE
);