Commit | Line | Data |
---|---|---|
d73e60b7 RK |
1 | /* |
2 | * linux/arch/arm/mm/copypage-xsc3.S | |
3 | * | |
4 | * Copyright (C) 2004 Intel Corp. | |
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 | * Adapted for 3rd gen XScale core, no more mini-dcache | |
11 | * Author: Matt Gilbert (matthew.m.gilbert@intel.com) | |
12 | */ | |
13 | #include <linux/init.h> | |
063b0a42 | 14 | #include <linux/highmem.h> |
d73e60b7 RK |
15 | |
16 | /* | |
17 | * General note: | |
18 | * We don't really want write-allocate cache behaviour for these functions | |
19 | * since that will just eat through 8K of the cache. | |
20 | */ | |
21 | ||
22 | /* | |
063b0a42 | 23 | * XSC3 optimised copy_user_highpage |
d73e60b7 RK |
24 | * r0 = destination |
25 | * r1 = source | |
d73e60b7 RK |
26 | * |
27 | * The source page may have some clean entries in the cache already, but we | |
28 | * can safely ignore them - break_cow() will flush them out of the cache | |
29 | * if we eventually end up using our copied page. | |
30 | * | |
31 | */ | |
063b0a42 RK |
32 | static void __attribute__((naked)) |
33 | xsc3_mc_copy_user_page(void *kto, const void *kfrom) | |
d73e60b7 RK |
34 | { |
35 | asm("\ | |
36 | stmfd sp!, {r4, r5, lr} \n\ | |
37 | mov lr, %0 \n\ | |
38 | \n\ | |
39 | pld [r1, #0] \n\ | |
40 | pld [r1, #32] \n\ | |
41 | 1: pld [r1, #64] \n\ | |
42 | pld [r1, #96] \n\ | |
43 | \n\ | |
44 | 2: ldrd r2, [r1], #8 \n\ | |
45 | mov ip, r0 \n\ | |
46 | ldrd r4, [r1], #8 \n\ | |
47 | mcr p15, 0, ip, c7, c6, 1 @ invalidate\n\ | |
48 | strd r2, [r0], #8 \n\ | |
49 | ldrd r2, [r1], #8 \n\ | |
50 | strd r4, [r0], #8 \n\ | |
51 | ldrd r4, [r1], #8 \n\ | |
52 | strd r2, [r0], #8 \n\ | |
53 | strd r4, [r0], #8 \n\ | |
54 | ldrd r2, [r1], #8 \n\ | |
55 | mov ip, r0 \n\ | |
56 | ldrd r4, [r1], #8 \n\ | |
57 | mcr p15, 0, ip, c7, c6, 1 @ invalidate\n\ | |
58 | strd r2, [r0], #8 \n\ | |
59 | ldrd r2, [r1], #8 \n\ | |
60 | subs lr, lr, #1 \n\ | |
61 | strd r4, [r0], #8 \n\ | |
62 | ldrd r4, [r1], #8 \n\ | |
63 | strd r2, [r0], #8 \n\ | |
64 | strd r4, [r0], #8 \n\ | |
65 | bgt 1b \n\ | |
66 | beq 2b \n\ | |
67 | \n\ | |
68 | ldmfd sp!, {r4, r5, pc}" | |
69 | : | |
70 | : "I" (PAGE_SIZE / 64 - 1)); | |
71 | } | |
72 | ||
063b0a42 RK |
73 | void xsc3_mc_copy_user_highpage(struct page *to, struct page *from, |
74 | unsigned long vaddr) | |
75 | { | |
76 | void *kto, *kfrom; | |
77 | ||
78 | kto = kmap_atomic(to, KM_USER0); | |
79 | kfrom = kmap_atomic(from, KM_USER1); | |
80 | xsc3_mc_copy_user_page(kto, kfrom); | |
81 | kunmap_atomic(kfrom, KM_USER1); | |
82 | kunmap_atomic(kto, KM_USER0); | |
83 | } | |
84 | ||
d73e60b7 RK |
85 | /* |
86 | * XScale optimised clear_user_page | |
87 | * r0 = destination | |
88 | * r1 = virtual user address of ultimate destination page | |
89 | */ | |
90 | void __attribute__((naked)) | |
91 | xsc3_mc_clear_user_page(void *kaddr, unsigned long vaddr) | |
92 | { | |
93 | asm("\ | |
94 | mov r1, %0 \n\ | |
95 | mov r2, #0 \n\ | |
96 | mov r3, #0 \n\ | |
97 | 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate line\n\ | |
98 | strd r2, [r0], #8 \n\ | |
99 | strd r2, [r0], #8 \n\ | |
100 | strd r2, [r0], #8 \n\ | |
101 | strd r2, [r0], #8 \n\ | |
102 | subs r1, r1, #1 \n\ | |
103 | bne 1b \n\ | |
104 | mov pc, lr" | |
105 | : | |
106 | : "I" (PAGE_SIZE / 32)); | |
107 | } | |
108 | ||
109 | struct cpu_user_fns xsc3_mc_user_fns __initdata = { | |
110 | .cpu_clear_user_page = xsc3_mc_clear_user_page, | |
063b0a42 | 111 | .cpu_copy_user_highpage = xsc3_mc_copy_user_highpage, |
d73e60b7 | 112 | }; |