xref: /openbmc/linux/arch/csky/abiv1/inc/abi/page.h (revision b9df3997)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3 
4 #include <asm/shmparam.h>
5 
6 extern void flush_dcache_page(struct page *page);
7 
8 static inline unsigned long pages_do_alias(unsigned long addr1,
9 					   unsigned long addr2)
10 {
11 	return (addr1 ^ addr2) & (SHMLBA-1);
12 }
13 
14 static inline void clear_user_page(void *addr, unsigned long vaddr,
15 				   struct page *page)
16 {
17 	clear_page(addr);
18 	if (pages_do_alias((unsigned long) addr, vaddr & PAGE_MASK))
19 		flush_dcache_page(page);
20 }
21 
22 static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
23 				  struct page *page)
24 {
25 	copy_page(to, from);
26 	if (pages_do_alias((unsigned long) to, vaddr & PAGE_MASK))
27 		flush_dcache_page(page);
28 }
29