blob: 51ed502e5777aee2d9219b27f5ac092f74ee2af1 [file] [log] [blame]
Russell Kingd73e60b2008-10-31 13:08:02 +00001/*
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>
14
15#include <asm/page.h>
16
17/*
18 * General note:
19 * We don't really want write-allocate cache behaviour for these functions
20 * since that will just eat through 8K of the cache.
21 */
22
23/*
24 * XSC3 optimised copy_user_page
25 * r0 = destination
26 * r1 = source
27 * r2 = virtual user address of ultimate destination page
28 *
29 * The source page may have some clean entries in the cache already, but we
30 * can safely ignore them - break_cow() will flush them out of the cache
31 * if we eventually end up using our copied page.
32 *
33 */
34void __attribute__((naked))
35xsc3_mc_copy_user_page(void *kto, const void *kfrom, unsigned long vaddr)
36{
37 asm("\
38 stmfd sp!, {r4, r5, lr} \n\
39 mov lr, %0 \n\
40 \n\
41 pld [r1, #0] \n\
42 pld [r1, #32] \n\
431: pld [r1, #64] \n\
44 pld [r1, #96] \n\
45 \n\
462: ldrd r2, [r1], #8 \n\
47 mov ip, r0 \n\
48 ldrd r4, [r1], #8 \n\
49 mcr p15, 0, ip, c7, c6, 1 @ invalidate\n\
50 strd r2, [r0], #8 \n\
51 ldrd r2, [r1], #8 \n\
52 strd r4, [r0], #8 \n\
53 ldrd r4, [r1], #8 \n\
54 strd r2, [r0], #8 \n\
55 strd r4, [r0], #8 \n\
56 ldrd r2, [r1], #8 \n\
57 mov ip, r0 \n\
58 ldrd r4, [r1], #8 \n\
59 mcr p15, 0, ip, c7, c6, 1 @ invalidate\n\
60 strd r2, [r0], #8 \n\
61 ldrd r2, [r1], #8 \n\
62 subs lr, lr, #1 \n\
63 strd r4, [r0], #8 \n\
64 ldrd r4, [r1], #8 \n\
65 strd r2, [r0], #8 \n\
66 strd r4, [r0], #8 \n\
67 bgt 1b \n\
68 beq 2b \n\
69 \n\
70 ldmfd sp!, {r4, r5, pc}"
71 :
72 : "I" (PAGE_SIZE / 64 - 1));
73}
74
75/*
76 * XScale optimised clear_user_page
77 * r0 = destination
78 * r1 = virtual user address of ultimate destination page
79 */
80void __attribute__((naked))
81xsc3_mc_clear_user_page(void *kaddr, unsigned long vaddr)
82{
83 asm("\
84 mov r1, %0 \n\
85 mov r2, #0 \n\
86 mov r3, #0 \n\
871: mcr p15, 0, r0, c7, c6, 1 @ invalidate line\n\
88 strd r2, [r0], #8 \n\
89 strd r2, [r0], #8 \n\
90 strd r2, [r0], #8 \n\
91 strd r2, [r0], #8 \n\
92 subs r1, r1, #1 \n\
93 bne 1b \n\
94 mov pc, lr"
95 :
96 : "I" (PAGE_SIZE / 32));
97}
98
99struct cpu_user_fns xsc3_mc_user_fns __initdata = {
100 .cpu_clear_user_page = xsc3_mc_clear_user_page,
101 .cpu_copy_user_page = xsc3_mc_copy_user_page,
102};