MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / arch / arm / mm / copypage-fa.S
blob2791c93b1de6d38f8641ffe619d943fc1ac6249d
1 /*
2  *  linux/arch/arm/lib/copypage-fa.S
3  *
4  *  Copyright (C) 2005 Faraday 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  *  ASM optimised string functions
11  * 05/18/2005 : Luke Lee created, modified from copypage-v4wb.S
12  */
13 #include <linux/linkage.h>
14 #include <linux/init.h>
15 #include <asm/constants.h>
17         .text
19  * ARMv4 optimised copy_user_page for Faraday processors
20  *
21  * We flush the destination cache lines just before we write the data into the
22  * corresponding address.  Since the Dcache is read-allocate, this removes the
23  * Dcache aliasing issue.  The writes will be forwarded to the write buffer,
24  * and merged as appropriate.
25  *
26  * Note: We rely on all ARMv4 processors implementing the "invalidate D line"
27  * instruction.  If your processor does not supply this, you have to write your
28  * own copy_user_page that does the right thing.
29  *
30  * copy_user_page(to,from,vaddr)
31  */
32         .align  4
33 ENTRY(fa_copy_user_page)
34 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
35         /* Write through */
36         stmfd   sp!, {r4, lr}                   @ 2
37         mov     r2, #PAGE_SZ/32                 @ 1
38         
39         ldmia   r1!, {r3, r4, ip, lr}           @ 4
40 1:      stmia   r0!, {r3, r4, ip, lr}           @ 4
41         ldmia   r1!, {r3, r4, ip, lr}           @ 4+1
42         subs    r2, r2, #1                      @ 1
43         stmia   r0!, {r3, r4, ip, lr}           @ 4
44         ldmneia r1!, {r3, r4, ip, lr}           @ 4
45         bne     1b                              @ 1
46         
47         mcr     p15, 0, r2, c7, c7, 0           @ flush ID cache
48         ldmfd   sp!, {r4, pc}                   @ 3
49 #else
50         /* Write back */
51         stmfd   sp!, {r4, lr}                   @ 2
52         mov     r2, #PAGE_SZ/32                 @ 1
53         
54 1:      ldmia   r1!, {r3, r4, ip, lr}           @ 4
55         mcr     p15, 0, r0, c7, c6, 1           @ 1   invalidate D line
56         stmia   r0!, {r3, r4, ip, lr}           @ 4
57         ldmia   r1!, {r3, r4, ip, lr}           @ 4
58         mcr     p15, 0, r0, c7, c6, 1           @ 1   invalidate D line
59         stmia   r0!, {r3, r4, ip, lr}           @ 4
60         subs    r2, r2, #1                      @ 1
61         bne     1b
62         mcr     p15, 0, r2, c7, c10, 4          @ 1   drain WB
63         ldmfd   sp!, {r4, pc}                   @ 3
64 #endif  
67  * ARMv4 optimised clear_user_page
68  *
69  * Same story as above.
70  */
71         .align  4       
72 ENTRY(fa_clear_user_page)
73         str     lr, [sp, #-4]!
74         mov     r1, #PAGE_SZ/32                 @ 1
75         mov     r2, #0                          @ 1
76         mov     r3, #0                          @ 1
77         mov     ip, #0                          @ 1
78         mov     lr, #0                          @ 1     
79 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
80         /* Write through */
81 1:      stmia   r0!, {r2, r3, ip, lr}           @ 4
82         stmia   r0!, {r2, r3, ip, lr}           @ 4
83         subs    r1, r1, #1                      @ 1
84         bne     1b                              @ 1
85         
86         mcr     p15, 0, r1, c7, c7, 0           @ flush ID cache
87         ldr     pc, [sp], #4    
88 #else
89         /* Write back */
90 1:      mcr     p15, 0, r0, c7, c6, 1           @ 1   invalidate D line
91         stmia   r0!, {r2, r3, ip, lr}           @ 4
92         mcr     p15, 0, r0, c7, c6, 1           @ 1   invalidate D line
93         stmia   r0!, {r2, r3, ip, lr}           @ 4
94         subs    r1, r1, #1                      @ 1
95         bne     1b                              @ 1
96         mcr     p15, 0, r1, c7, c10, 4          @ 1   drain WB
97         ldr     pc, [sp], #4
98 #endif  
100         __INITDATA
102         .type   fa_user_fns, #object
103 ENTRY(fa_user_fns)
104         .long   fa_clear_user_page
105         .long   fa_copy_user_page
106         .size   fa_user_fns, . - fa_user_fns