blob: ac163de7dc015f5c02c305d450f18151fdecc795 [file] [log] [blame]
Russell Kingd73e60b2008-10-31 13:08:02 +00001/*
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 *
Russell King063b0a42008-10-31 15:08:35 +000010 * This handles copy_user_highpage and clear_user_page on Feroceon
Russell Kingd73e60b2008-10-31 13:08:02 +000011 * more optimally than the generic implementations.
12 */
13#include <linux/init.h>
Russell King063b0a42008-10-31 15:08:35 +000014#include <linux/highmem.h>
Russell Kingd73e60b2008-10-31 13:08:02 +000015
Uwe Kleine-König446c92b2009-03-12 18:03:16 +010016static void __naked
Russell King063b0a42008-10-31 15:08:35 +000017feroceon_copy_user_page(void *kto, const void *kfrom)
Russell Kingd73e60b2008-10-31 13:08:02 +000018{
19 asm("\
20 stmfd sp!, {r4-r9, lr} \n\
Khem Raj9a40ac862010-06-04 04:05:15 +010021 mov ip, %2 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +0000221: mov lr, r1 \n\
23 ldmia r1!, {r2 - r9} \n\
24 pld [lr, #32] \n\
25 pld [lr, #64] \n\
26 pld [lr, #96] \n\
27 pld [lr, #128] \n\
28 pld [lr, #160] \n\
29 pld [lr, #192] \n\
30 pld [lr, #224] \n\
31 stmia r0, {r2 - r9} \n\
32 ldmia r1!, {r2 - r9} \n\
33 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
34 add r0, r0, #32 \n\
35 stmia r0, {r2 - r9} \n\
36 ldmia r1!, {r2 - r9} \n\
37 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
38 add r0, r0, #32 \n\
39 stmia r0, {r2 - r9} \n\
40 ldmia r1!, {r2 - r9} \n\
41 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
42 add r0, r0, #32 \n\
43 stmia r0, {r2 - r9} \n\
44 ldmia r1!, {r2 - r9} \n\
45 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
46 add r0, r0, #32 \n\
47 stmia r0, {r2 - r9} \n\
48 ldmia r1!, {r2 - r9} \n\
49 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
50 add r0, r0, #32 \n\
51 stmia r0, {r2 - r9} \n\
52 ldmia r1!, {r2 - r9} \n\
53 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
54 add r0, r0, #32 \n\
55 stmia r0, {r2 - r9} \n\
56 ldmia r1!, {r2 - r9} \n\
57 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
58 add r0, r0, #32 \n\
59 stmia r0, {r2 - r9} \n\
60 subs ip, ip, #(32 * 8) \n\
61 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line\n\
62 add r0, r0, #32 \n\
63 bne 1b \n\
64 mcr p15, 0, ip, c7, c10, 4 @ drain WB\n\
65 ldmfd sp!, {r4-r9, pc}"
66 :
Khem Raj9a40ac862010-06-04 04:05:15 +010067 : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE));
Russell Kingd73e60b2008-10-31 13:08:02 +000068}
69
Russell King063b0a42008-10-31 15:08:35 +000070void feroceon_copy_user_highpage(struct page *to, struct page *from,
Russell Kingf00a75c2009-10-05 15:17:45 +010071 unsigned long vaddr, struct vm_area_struct *vma)
Russell King063b0a42008-10-31 15:08:35 +000072{
73 void *kto, *kfrom;
74
75 kto = kmap_atomic(to, KM_USER0);
76 kfrom = kmap_atomic(from, KM_USER1);
Russell King27258982009-10-05 15:34:22 +010077 flush_cache_page(vma, vaddr, page_to_pfn(from));
Russell King063b0a42008-10-31 15:08:35 +000078 feroceon_copy_user_page(kto, kfrom);
79 kunmap_atomic(kfrom, KM_USER1);
80 kunmap_atomic(kto, KM_USER0);
81}
82
Russell King303c6442008-10-31 16:32:19 +000083void feroceon_clear_user_highpage(struct page *page, unsigned long vaddr)
Russell Kingd73e60b2008-10-31 13:08:02 +000084{
Nicolas Pitre43ae2862008-11-04 02:42:27 -050085 void *ptr, *kaddr = kmap_atomic(page, KM_USER0);
86 asm volatile ("\
87 mov r1, %2 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000088 mov r2, #0 \n\
89 mov r3, #0 \n\
90 mov r4, #0 \n\
91 mov r5, #0 \n\
92 mov r6, #0 \n\
93 mov r7, #0 \n\
94 mov ip, #0 \n\
95 mov lr, #0 \n\
Russell King303c6442008-10-31 16:32:19 +0000961: stmia %0, {r2-r7, ip, lr} \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000097 subs r1, r1, #1 \n\
Russell King303c6442008-10-31 16:32:19 +000098 mcr p15, 0, %0, c7, c14, 1 @ clean and invalidate D line\n\
Nicolas Pitre43ae2862008-11-04 02:42:27 -050099 add %0, %0, #32 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +0000100 bne 1b \n\
Russell King303c6442008-10-31 16:32:19 +0000101 mcr p15, 0, r1, c7, c10, 4 @ drain WB"
Nicolas Pitre43ae2862008-11-04 02:42:27 -0500102 : "=r" (ptr)
103 : "0" (kaddr), "I" (PAGE_SIZE / 32)
Russell King303c6442008-10-31 16:32:19 +0000104 : "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ip", "lr");
105 kunmap_atomic(kaddr, KM_USER0);
Russell Kingd73e60b2008-10-31 13:08:02 +0000106}
107
108struct cpu_user_fns feroceon_user_fns __initdata = {
Russell King303c6442008-10-31 16:32:19 +0000109 .cpu_clear_user_highpage = feroceon_clear_user_highpage,
Russell King063b0a42008-10-31 15:08:35 +0000110 .cpu_copy_user_highpage = feroceon_copy_user_highpage,
Russell Kingd73e60b2008-10-31 13:08:02 +0000111};
112