• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  linux/arch/arm/mm/copypage-feroceon.S
3  *
4  *  Copyright (C) 2008 Marvell Semiconductors
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This handles copy_user_highpage and clear_user_page on Feroceon
11  * more optimally than the generic implementations.
12  */
13 #include <linux/init.h>
14 #include <linux/highmem.h>
15 
feroceon_copy_user_page(void * kto,const void * kfrom)16 static void feroceon_copy_user_page(void *kto, const void *kfrom)
17 {
18 	int tmp;
19 
20 	asm volatile ("\
21 1:	ldmia	%1!, {r2 - r7, ip, lr}		\n\
22 	pld	[%1, #0]			\n\
23 	pld	[%1, #32]			\n\
24 	pld	[%1, #64]			\n\
25 	pld	[%1, #96]			\n\
26 	pld	[%1, #128]			\n\
27 	pld	[%1, #160]			\n\
28 	pld	[%1, #192]			\n\
29 	stmia	%0, {r2 - r7, ip, lr}		\n\
30 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
31 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
32 	add	%0, %0, #32			\n\
33 	stmia	%0, {r2 - r7, ip, lr}		\n\
34 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
35 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
36 	add	%0, %0, #32			\n\
37 	stmia	%0, {r2 - r7, ip, lr}		\n\
38 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
39 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
40 	add	%0, %0, #32			\n\
41 	stmia	%0, {r2 - r7, ip, lr}		\n\
42 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
43 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
44 	add	%0, %0, #32			\n\
45 	stmia	%0, {r2 - r7, ip, lr}		\n\
46 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
47 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
48 	add	%0, %0, #32			\n\
49 	stmia	%0, {r2 - r7, ip, lr}		\n\
50 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
51 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
52 	add	%0, %0, #32			\n\
53 	stmia	%0, {r2 - r7, ip, lr}		\n\
54 	ldmia	%1!, {r2 - r7, ip, lr}		\n\
55 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
56 	add	%0, %0, #32			\n\
57 	stmia	%0, {r2 - r7, ip, lr}		\n\
58 	subs	%2, %2, #(32 * 8)		\n\
59 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
60 	add	%0, %0, #32			\n\
61 	bne	1b				\n\
62 	mcr	p15, 0, %2, c7, c10, 4		@ drain WB"
63 	: "+&r" (kto), "+&r" (kfrom), "=&r" (tmp)
64 	: "2" (PAGE_SIZE)
65 	: "r2", "r3", "r4", "r5", "r6", "r7", "ip", "lr");
66 }
67 
feroceon_copy_user_highpage(struct page * to,struct page * from,unsigned long vaddr,struct vm_area_struct * vma)68 void feroceon_copy_user_highpage(struct page *to, struct page *from,
69 	unsigned long vaddr, struct vm_area_struct *vma)
70 {
71 	void *kto, *kfrom;
72 
73 	kto = kmap_atomic(to);
74 	kfrom = kmap_atomic(from);
75 	flush_cache_page(vma, vaddr, page_to_pfn(from));
76 	feroceon_copy_user_page(kto, kfrom);
77 	kunmap_atomic(kfrom);
78 	kunmap_atomic(kto);
79 }
80 
feroceon_clear_user_highpage(struct page * page,unsigned long vaddr)81 void feroceon_clear_user_highpage(struct page *page, unsigned long vaddr)
82 {
83 	void *ptr, *kaddr = kmap_atomic(page);
84 	asm volatile ("\
85 	mov	r1, %2				\n\
86 	mov	r2, #0				\n\
87 	mov	r3, #0				\n\
88 	mov	r4, #0				\n\
89 	mov	r5, #0				\n\
90 	mov	r6, #0				\n\
91 	mov	r7, #0				\n\
92 	mov	ip, #0				\n\
93 	mov	lr, #0				\n\
94 1:	stmia	%0, {r2-r7, ip, lr}		\n\
95 	subs	r1, r1, #1			\n\
96 	mcr	p15, 0, %0, c7, c14, 1		@ clean and invalidate D line\n\
97 	add	%0, %0, #32			\n\
98 	bne	1b				\n\
99 	mcr	p15, 0, r1, c7, c10, 4		@ drain WB"
100 	: "=r" (ptr)
101 	: "0" (kaddr), "I" (PAGE_SIZE / 32)
102 	: "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ip", "lr");
103 	kunmap_atomic(kaddr);
104 }
105 
106 struct cpu_user_fns feroceon_user_fns __initdata = {
107 	.cpu_clear_user_highpage = feroceon_clear_user_highpage,
108 	.cpu_copy_user_highpage	= feroceon_copy_user_highpage,
109 };
110 
111