1 #ifndef _VIDEO_ATAFB_UTILS_H
2 #define _VIDEO_ATAFB_UTILS_H
48 static inline void *fb_memclear_small(
void *
s,
size_t count)
54 " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n"
55 "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n"
56 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n"
57 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n"
59 :
"=a" (
s),
"=d" (count)
60 :
"d" (0),
"0" ((
char *)s +
count),
"1" (count));
64 " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n"
65 "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n"
68 :
"=a" (
s),
"=d" (count)
69 :
"d" (0),
"0" (s),
"1" (
count)
77 static inline void *fb_memclear(
void *s,
size_t count)
84 " lsr.l #1,%1 ; jcc 1f ; clr.b (%0)+\n"
85 "1: lsr.l #1,%1 ; jcc 1f ; clr.w (%0)+\n"
86 "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+\n"
87 "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+ ; clr.l (%0)+\n"
89 :
"=a" (
s),
"=d" (count)
90 :
"0" (
s),
"1" (count));
95 " lsr.l #1,%2 ; jcc 1f ; clr.b (%0)+ ; subq.w #1,%1\n"
96 " lsr.l #1,%2 ; jcs 2f\n"
97 " clr.w (%0)+ ; subq.w #2,%1 ; jra 2f\n"
98 "1: lsr.l #1,%2 ; jcc 2f\n"
99 " clr.w (%0)+ ; subq.w #2,%1\n"
100 "2: move.w %1,%2; lsr.l #2,%1 ; jeq 6f\n"
101 " lsr.l #1,%1 ; jcc 3f ; clr.l (%0)+\n"
102 "3: lsr.l #1,%1 ; jcc 4f ; clr.l (%0)+ ; clr.l (%0)+\n"
103 "4: subq.l #1,%1 ; jcs 6f\n"
104 "5: clr.l (%0)+; clr.l (%0)+ ; clr.l (%0)+ ; clr.l (%0)+\n"
105 " dbra %1,5b ; clr.w %1; subq.l #1,%1; jcc 5b\n"
106 "6: move.w %2,%1; btst #1,%1 ; jeq 7f ; clr.w (%0)+\n"
107 "7: btst #0,%1 ; jeq 8f ; clr.b (%0)+\n"
109 :
"=a" (
s),
"=d" (count),
"=d" (
tmp)
110 :
"0" (s),
"1" (
count));
117 static inline void *fb_memset255(
void *s,
size_t count)
123 " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n"
124 "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n"
125 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n"
126 "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n"
128 :
"=a" (
s),
"=d" (count)
129 :
"d" (-1),
"0" ((
char *)s+
count),
"1" (count));
131 " subq.l #1,%1 ; jcs 3f\n"
132 " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n"
133 "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n"
136 :
"=a" (
s),
"=d" (count)
137 :
"d" (-1),
"0" (s),
"1" (
count)
144 static inline void *fb_memmove(
void *
d,
const void *s,
size_t count)
149 " lsr.l #1,%2 ; jcc 1f ; move.b (%1)+,(%0)+\n"
150 "1: lsr.l #1,%2 ; jcc 1f ; move.w (%1)+,(%0)+\n"
151 "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+\n"
152 "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n"
154 :
"=a" (
d),
"=a" (s),
"=d" (
count)
155 :
"0" (d),
"1" (
s),
"2" (count));
160 " lsr.l #1,%3 ; jcc 1f ; move.b (%1)+,(%0)+ ; subqw #1,%2\n"
161 " lsr.l #1,%3 ; jcs 2f\n"
162 " move.w (%1)+,(%0)+ ; subqw #2,%2 ; jra 2f\n"
163 "1: lsr.l #1,%3 ; jcc 2f\n"
164 " move.w (%1)+,(%0)+ ; subqw #2,%2\n"
165 "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n"
166 " lsr.l #1,%2 ; jcc 3f ; move.l (%1)+,(%0)+\n"
167 "3: lsr.l #1,%2 ; jcc 4f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n"
168 "4: subq.l #1,%2 ; jcs 6f\n"
169 "5: move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n"
170 " move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n"
171 " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n"
172 "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w (%1)+,(%0)+\n"
173 "7: btst #0,%2 ; jeq 8f ; move.b (%1)+,(%0)+\n"
175 :
"=a" (
d),
"=a" (s),
"=d" (
count),
"=d" (tmp)
176 :
"0" (
d),
"1" (s),
"2" (
count));
181 " lsr.l #1,%2 ; jcc 1f ; move.b -(%1),-(%0)\n"
182 "1: lsr.l #1,%2 ; jcc 1f ; move.w -(%1),-(%0)\n"
183 "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0)\n"
184 "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n"
186 :
"=a" (
d),
"=a" (s),
"=d" (
count)
187 :
"0" ((
char *) d +
count),
"1" ((
char *) s +
count),
"2" (count));
193 " lsr.l #1,%3 ; jcc 1f ; move.b -(%1),-(%0) ; subqw #1,%2\n"
194 " lsr.l #1,%3 ; jcs 2f\n"
195 " move.w -(%1),-(%0) ; subqw #2,%2 ; jra 2f\n"
196 "1: lsr.l #1,%3 ; jcc 2f\n"
197 " move.w -(%1),-(%0) ; subqw #2,%2\n"
198 "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n"
199 " lsr.l #1,%2 ; jcc 3f ; move.l -(%1),-(%0)\n"
200 "3: lsr.l #1,%2 ; jcc 4f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n"
201 "4: subq.l #1,%2 ; jcs 6f\n"
202 "5: move.l -(%1),-(%0); move.l -(%1),-(%0)\n"
203 " move.l -(%1),-(%0); move.l -(%1),-(%0)\n"
204 " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n"
205 "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w -(%1),-(%0)\n"
206 "7: btst #0,%2 ; jeq 8f ; move.b -(%1),-(%0)\n"
208 :
"=a" (
d),
"=a" (s),
"=d" (
count),
"=d" (tmp)
209 :
"0" ((
char *) d + count),
"1" ((
char *) s + count),
"2" (
count));
219 static inline void fast_memmove(
char *
dst,
const char *
src,
size_t size)
225 "1: movem.l (%0)+,%%d0/%%d1/%%a0/%%a1\n"
226 " movem.l %%d0/%%d1/%%a0/%%a1,%1@\n"
227 " addq.l #8,%1; addq.l #8,%1\n"
229 " clr.w %2; subq.l #1,%2\n"
231 :
"=a" (
src),
"=a" (dst),
"=d" (
size)
232 :
"0" (src),
"1" (
dst),
"2" (size / 16 - 1)
233 :
"d0",
"d1",
"a0",
"a1",
"memory");
236 "1: subq.l #8,%0; subq.l #8,%0\n"
237 " movem.l %0@,%%d0/%%d1/%%a0/%%a1\n"
238 " movem.l %%d0/%%d1/%%a0/%%a1,-(%1)\n"
240 " clr.w %2; subq.l #1,%2\n"
242 :
"=a" (
src),
"=a" (dst),
"=d" (
size)
243 :
"0" (src + size),
"1" (dst +
size),
"2" (size / 16 - 1)
244 :
"d0",
"d1",
"a0",
"a1",
"memory");
253 static const u32 four2long[] = {
254 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
255 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
256 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
257 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff,
260 static inline void expand8_col2mask(
u8 c,
u32 m[])
262 m[0] = four2long[c & 15];
264 m[1] = four2long[c >> 4];
268 static inline void expand8_2col2mask(
u8 fg,
u8 bg,
u32 fgm[],
u32 bgm[])
270 fgm[0] = four2long[fg & 15] ^ (bgm[0] = four2long[bg & 15]);
272 fgm[1] = four2long[fg >> 4] ^ (bgm[1] = four2long[bg >> 4]);
279 static inline void fill8_col(
u8 *dst,
u32 m[])
283 dst[2] = (tmp >>= 8);
285 dst[4] = (tmp >>= 8);
291 dst[10] = (tmp >>= 8);
292 dst[12] = (tmp >>= 8);
304 expand8_2col2mask(fg, bg, fgm, bgm);
310 tmp = (mask & fgm[0]) ^ bgm[0];
312 dst[2] = (tmp >>= 8);
314 dst[4] = (tmp >>= 8);
318 tmp = (mask & fgm[1]) ^ bgm[1];
320 dst[10] = (tmp >>= 8);
321 dst[12] = (tmp >>= 8);
326 static const u32 two2word[] = {
327 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
330 static inline void expand16_col2mask(
u8 c,
u32 m[])
332 m[0] = two2word[c & 3];
334 m[1] = two2word[(c >> 2) & 3];
337 m[2] = two2word[(c >> 4) & 3];
338 m[3] = two2word[c >> 6];
342 static inline void expand16_2col2mask(
u8 fg,
u8 bg,
u32 fgm[],
u32 bgm[])
344 bgm[0] = two2word[bg & 3];
345 fgm[0] = two2word[fg & 3] ^ bgm[0];
347 bgm[1] = two2word[(bg >> 2) & 3];
348 fgm[1] = two2word[(fg >> 2) & 3] ^ bgm[1];
351 bgm[2] = two2word[(bg >> 4) & 3];
352 fgm[2] = two2word[(fg >> 4) & 3] ^ bgm[2];
353 bgm[3] = two2word[bg >> 6];
354 fgm[3] = two2word[fg >> 6] ^ bgm[3];
381 v = (*s++ &
mask) | (*d & ~mask);
384 v = (*s++ &
mask) | (*d & ~mask);
388 v = (*s++ &
mask) | (*d & ~mask);
390 v = (*s++ &
mask) | (*d & ~mask);