blob: 3539123fe5174b29fb95c1b64fcc3e46a3e688a3 [file] [log] [blame]
Paul Mundt510c72ad2006-11-27 12:06:26 +09001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * __clear_user_page, __clear_user, clear_page implementation of SuperH
3 *
4 * Copyright (C) 2001 Kaz Kojima
5 * Copyright (C) 2001, 2002 Niibe Yutaka
Paul Mundt510c72ad2006-11-27 12:06:26 +09006 * Copyright (C) 2006 Paul Mundt
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <linux/linkage.h>
Paul Mundt510c72ad2006-11-27 12:06:26 +09009#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11/*
Paul Mundt0dcb9572007-11-23 13:55:02 +090012 * clear_page
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * @to: P1 address
14 *
Paul Mundt0dcb9572007-11-23 13:55:02 +090015 * void clear_page(void *to)
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17
18/*
19 * r0 --- scratch
20 * r4 --- to
Paul Mundt510c72ad2006-11-27 12:06:26 +090021 * r5 --- to + PAGE_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 */
Paul Mundt0dcb9572007-11-23 13:55:02 +090023ENTRY(clear_page)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 mov r4,r5
Paul Mundt510c72ad2006-11-27 12:06:26 +090025 mov.l .Llimit,r0
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 add r0,r5
27 mov #0,r0
28 !
291:
30#if defined(CONFIG_CPU_SH3)
31 mov.l r0,@r4
32#elif defined(CONFIG_CPU_SH4)
33 movca.l r0,@r4
34 mov r4,r1
35#endif
36 add #32,r4
37 mov.l r0,@-r4
38 mov.l r0,@-r4
39 mov.l r0,@-r4
40 mov.l r0,@-r4
41 mov.l r0,@-r4
42 mov.l r0,@-r4
43 mov.l r0,@-r4
44#if defined(CONFIG_CPU_SH4)
45 ocbwb @r1
46#endif
47 cmp/eq r5,r4
48 bf/s 1b
49 add #28,r4
50 !
51 rts
52 nop
Paul Mundt325df7f2007-11-30 16:34:26 +090053
54 .balign 4
Paul Mundt510c72ad2006-11-27 12:06:26 +090055.Llimit: .long (PAGE_SIZE-28)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57ENTRY(__clear_user)
58 !
59 mov #0, r0
60 mov #0xe0, r1 ! 0xffffffe0
61 !
62 ! r4..(r4+31)&~32 -------- not aligned [ Area 0 ]
63 ! (r4+31)&~32..(r4+r5)&~32 -------- aligned [ Area 1 ]
64 ! (r4+r5)&~32..r4+r5 -------- not aligned [ Area 2 ]
65 !
66 ! Clear area 0
67 mov r4, r2
68 !
69 tst r1, r5 ! length < 32
70 bt .Larea2 ! skip to remainder
71 !
72 add #31, r2
73 and r1, r2
74 cmp/eq r4, r2
75 bt .Larea1
76 mov r2, r3
77 sub r4, r3
78 mov r3, r7
79 mov r4, r2
80 !
81.L0: dt r3
820: mov.b r0, @r2
83 bf/s .L0
84 add #1, r2
85 !
86 sub r7, r5
87 mov r2, r4
88.Larea1:
89 mov r4, r3
90 add r5, r3
91 and r1, r3
92 cmp/hi r2, r3
93 bf .Larea2
94 !
95 ! Clear area 1
96#if defined(CONFIG_CPU_SH4)
971: movca.l r0, @r2
98#else
991: mov.l r0, @r2
100#endif
101 add #4, r2
1022: mov.l r0, @r2
103 add #4, r2
1043: mov.l r0, @r2
105 add #4, r2
1064: mov.l r0, @r2
107 add #4, r2
1085: mov.l r0, @r2
109 add #4, r2
1106: mov.l r0, @r2
111 add #4, r2
1127: mov.l r0, @r2
113 add #4, r2
1148: mov.l r0, @r2
115 add #4, r2
116 cmp/hi r2, r3
117 bt/s 1b
118 nop
119 !
120 ! Clear area 2
121.Larea2:
122 mov r4, r3
123 add r5, r3
124 cmp/hs r3, r2
125 bt/s .Ldone
126 sub r2, r3
127.L2: dt r3
1289: mov.b r0, @r2
129 bf/s .L2
130 add #1, r2
131 !
132.Ldone: rts
133 mov #0, r0 ! return 0 as normal return
134
135 ! return the number of bytes remained
136.Lbad_clear_user:
137 mov r4, r0
138 add r5, r0
139 rts
140 sub r2, r0
141
142.section __ex_table,"a"
143 .align 2
144 .long 0b, .Lbad_clear_user
145 .long 1b, .Lbad_clear_user
146 .long 2b, .Lbad_clear_user
147 .long 3b, .Lbad_clear_user
148 .long 4b, .Lbad_clear_user
149 .long 5b, .Lbad_clear_user
150 .long 6b, .Lbad_clear_user
151 .long 7b, .Lbad_clear_user
152 .long 8b, .Lbad_clear_user
153 .long 9b, .Lbad_clear_user
154.previous