1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/m68k/mm/cache.c
5 * Instruction cache handling
7 * Copyright (C) 1995 Hamish Macdonald
10 #include <linux/module.h>
11 #include <asm/cacheflush.h>
12 #include <asm/traps.h>
15 static unsigned long virt_to_phys_slow(unsigned long vaddr
)
20 /* The PLPAR instruction causes an access error if the translation
21 * is not possible. To catch this we use the same exception mechanism
22 * as for user space accesses in <asm/uaccess.h>. */
23 asm volatile (".chip 68060\n"
27 ".section .fixup,\"ax\"\n"
32 ".section __ex_table,\"a\"\n"
39 } else if (CPU_IS_040
) {
42 asm volatile (".chip 68040\n\t"
44 "movec %%mmusr, %0\n\t"
49 if (mmusr
& MMU_R_040
)
50 return (mmusr
& PAGE_MASK
) | (vaddr
& ~PAGE_MASK
);
52 WARN_ON_ONCE(!CPU_IS_040_OR_060
);
57 /* Push n pages at kernel virtual address and clear the icache */
58 /* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
59 void flush_icache_user_range(unsigned long address
, unsigned long endaddr
)
61 if (CPU_IS_COLDFIRE
) {
62 unsigned long start
, end
;
63 start
= address
& ICACHE_SET_MASK
;
64 end
= endaddr
& ICACHE_SET_MASK
;
66 flush_cf_icache(0, end
);
67 end
= ICACHE_MAX_ADDR
;
69 flush_cf_icache(start
, end
);
70 } else if (CPU_IS_040_OR_060
) {
74 asm volatile ("nop\n\t"
76 "cpushp %%bc,(%0)\n\t"
78 : : "a" (virt_to_phys_slow(address
)));
80 } while (address
< endaddr
);
83 asm volatile ("movec %%cacr,%0\n\t"
91 void flush_icache_range(unsigned long address
, unsigned long endaddr
)
94 flush_icache_user_range(address
, endaddr
);
97 EXPORT_SYMBOL(flush_icache_range
);
99 void flush_icache_user_page(struct vm_area_struct
*vma
, struct page
*page
,
100 unsigned long addr
, int len
)
102 if (CPU_IS_COLDFIRE
) {
103 unsigned long start
, end
;
104 start
= addr
& ICACHE_SET_MASK
;
105 end
= (addr
+ len
) & ICACHE_SET_MASK
;
107 flush_cf_icache(0, end
);
108 end
= ICACHE_MAX_ADDR
;
110 flush_cf_icache(start
, end
);
112 } else if (CPU_IS_040_OR_060
) {
113 asm volatile ("nop\n\t"
115 "cpushp %%bc,(%0)\n\t"
117 : : "a" (page_to_phys(page
)));
120 asm volatile ("movec %%cacr,%0\n\t"