]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/bcopytest.c
xnu-1228.15.4.tar.gz
[apple/xnu.git] / osfmk / ppc / bcopytest.c
1 #include <debug.h>
2 #include <mach_kgdb.h>
3 #include <mach_vm_debug.h>
4 #include <db_machine_commands.h>
5
6 #include <kern/thread.h>
7 #include <mach/vm_attributes.h>
8 #include <mach/vm_param.h>
9 #include <vm/vm_kern.h>
10 #include <vm/vm_map.h>
11 #include <vm/vm_page.h>
12 #include <kern/spl.h>
13
14 #include <kern/misc_protos.h>
15 #include <ppc/exception.h>
16 #include <ppc/misc_protos.h>
17 #include <ppc/proc_reg.h>
18
19 #include <vm/pmap.h>
20 #include <ppc/pmap.h>
21 #include <ppc/mem.h>
22
23 #include <ppc/new_screen.h>
24 #include <ppc/Firmware.h>
25 #include <ppc/mappings.h>
26 #include <ddb/db_output.h>
27
28 #include <console/video_console.h> /* (TEST/DEBUG) */
29
30 #define patper 253
31
32
33 int main(void);
34 void clrarea(unsigned int *source, unsigned int *sink);
35 int tstcopy(void *src, void *snk, unsigned int lgn);
36 void clrarea2(unsigned int *source, unsigned int *sink);
37 int tstcopy2(void *src, void *snk, unsigned int lgn);
38 int tstcopy3(void *src, void *snk, unsigned int lgn);
39 int tstcopy4(void *src, void *snk, unsigned int lgn);
40 int tstcopy5(void *src, void *snk, unsigned int lgn);
41 int dumbcopy(void *src, void *snk, unsigned int lgn);
42
43
44 unsigned int gtick(void);
45
46
47 void bcopytest(void);
48 void bcopytest(void) {
49
50 void *srcptr, *snkptr, *asrc, *asnk;
51 int bsrc, bsnk, size, i, ret, n;
52 volatile int dbg = 0;
53 unsigned int *sink, *source;
54
55 kern_return_t retr;
56
57 db_printf("bcopy test\n");
58
59 retr = kmem_alloc_wired(kernel_map, (vm_offset_t *)&sink, (1024*1024)+4096); /* Get sink area */
60 if(retr != KERN_SUCCESS) { /* Did we find any memory at all? */
61 panic("bcopytest: Whoops... no memory for sink\n");
62 }
63
64 retr = kmem_alloc_wired(kernel_map, (vm_offset_t *)&source, (1024*1024)+4096); /* Get source area */
65 if(retr != KERN_SUCCESS) { /* Did we find any memory at all? */
66 panic("bcopytest: Whoops... no memory for source\n");
67 }
68
69 db_printf("Source at %08X; Sink at %08X\n", source, sink);
70
71 srcptr = (void *)&source[0];
72 snkptr = (void *)&sink[0];
73
74 #if 1
75 db_printf("Testing non-overlap case; source bndry = 0 to 7F; sink bndry = 0 - 7F; lgn = 1 to 256\n");
76 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step the source by 1 */
77 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step the sink by 1 */
78 for(size = 1; size <= 256; size++) { /* Step the size by 1 */
79
80 clrarea(source, sink); /* Reset source and clear sink */
81 if(size == 255) {
82 dbg = 99;
83 }
84 if(tstcopy((void *)((unsigned int)srcptr + bsrc), (void *)((unsigned int)snkptr + bsnk), size)) {
85 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
86 db_printf("failed\n");
87 }
88 }
89 }
90 }
91 db_printf("Non-overlap test complete\n");
92 #endif
93
94
95 #if 1
96 db_printf("Testing overlap\n");
97 for(bsrc = 1; bsrc < 128; bsrc++) { /* Step the source by 1 */
98 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step the sink by 1 */
99 for(size = 1; size <= 256; size++) { /* Step the size by 1 */
100
101 clrarea2(source, sink); /* Reset source and clear sink */
102 if(bsrc < bsnk) {
103 dbg = 88;
104 }
105 else {
106 dbg = 99;
107 }
108 if(tstcopy2((void *)((unsigned int)srcptr + bsrc), (void *)((unsigned int)srcptr + bsnk), size)) {
109 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
110 db_printf("failed\n");
111 }
112 }
113 }
114 }
115 db_printf("Overlap test complete\n");
116 #endif
117
118 #if 1
119 db_printf("Starting exhaustive tests\n");
120 for(i = 0; i < 262144 * 4; i++) { /* Set all 1MB of source and dest to known pattern */
121 ((unsigned char *)srcptr)[i] = i % patper; /* Make a non-power-of-two length pattern */
122 ((unsigned char *)snkptr)[i] = i % patper; /* Make a non-power-of-two length pattern */
123 }
124
125 db_printf("No overlap; source < sink, length = 0 to 1023\nSource =");
126
127 #if 1
128 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
129 db_printf(" %3d", bsrc); /* Show where we're at */
130 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
131 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
132 asrc = (void *)((unsigned int)srcptr + bsrc); /* Start byte address */
133 asnk = (void *)((unsigned int)srcptr + bsnk + 2048); /* End byte address */
134 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
135 if(ret) {
136 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
137 db_printf("failed\n");
138 }
139 }
140 }
141 }
142 #endif
143
144 db_printf("\n");
145 db_printf("No overlap; source > sink, length = 0 to 1023\nSource =");
146
147 #if 1
148 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
149 db_printf(" %3d", bsrc); /* Show where we're at */
150 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
151 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
152 asrc = (void *)((unsigned int)srcptr + bsrc + 2048); /* Start byte address */
153 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
154 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
155 if(ret) {
156 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
157 db_printf("failed\n");
158 }
159 }
160 }
161 }
162 #endif
163
164 db_printf("\n");
165 db_printf("Overlap; source = sink + N (N = 0 to 127), length = 0 to 1023\nN =");
166
167 #if 1
168 for(n = 0; n < 128; n++) { /* Step n by 1 */
169 db_printf(" %3d", n); /* Show where we're at */
170 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
171 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
172 asrc = (void *)((unsigned int)srcptr + bsnk + n); /* Start byte address */
173 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
174 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
175 if(ret) {
176 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
177 db_printf("failed\n");
178 }
179 }
180 }
181 }
182 #endif
183
184 db_printf("\n");
185 db_printf("Overlap; source + N = sink (N = 0 to 127), length = 0 to 1023\nSource =");
186
187 #if 1
188 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
189 db_printf(" %3d", bsrc); /* Show where we're at */
190 for(n = 0; n < 128; n++) { /* Step N by 1 */
191 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
192 asrc = (void *)((unsigned int)srcptr + bsnk); /* Start byte address */
193 asnk = (void *)((unsigned int)srcptr + bsnk + n); /* End byte address */
194 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
195 if(ret) {
196 db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
197 db_printf("failed\n");
198 }
199 }
200 }
201 }
202 #endif
203
204
205 db_printf("\n");
206 db_printf("Overlap; source = sink + N + 128 (N = 0 to 127), length = 0 to 1023\nN =");
207
208 #if 1
209 for(n = 0; n < 128; n++) { /* Step n by 1 */
210 db_printf(" %3d", n); /* Show where we're at */
211 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
212 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
213 asrc = (void *)((unsigned int)srcptr + bsnk + n + 128); /* Start byte address */
214 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
215 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
216 if(ret) {
217 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
218 db_printf("failed\n");
219 }
220 }
221 }
222 }
223 #endif
224
225 db_printf("\n");
226 db_printf("Overlap; source + N + 128 = sink (N = 0 to 127), length = 0 to 1023\nSource =");
227
228 #if 1
229 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
230 db_printf(" %3d", bsrc); /* Show where we're at */
231 for(n = 0; n < 128; n++) { /* Step N by 1 */
232 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
233 asrc = (void *)((unsigned int)srcptr + bsnk); /* Start byte address */
234 asnk = (void *)((unsigned int)srcptr + bsnk + n + 128); /* End byte address */
235 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
236 if(ret) {
237 db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
238 db_printf("failed\n");
239 }
240 }
241 }
242 }
243 #endif
244
245 db_printf("\n");
246 db_printf("Overlap; source = sink + N + 256 (N = 0 to 127), length = 0 to 1023\nSource =");
247
248 #if 1
249 for(n = 0; n < 128; n++) { /* Step n by 1 */
250 db_printf(" %3d", n); /* Show where we're at */
251 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
252 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
253 asrc = (void *)((unsigned int)srcptr + bsnk + n + 256); /* Start byte address */
254 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
255 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
256 if(ret) {
257 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
258 db_printf("failed\n");
259 }
260 }
261 }
262 }
263 #endif
264
265 db_printf("\n");
266 db_printf("Overlap; source + N + 256 = sink (N = 0 to 127), length = 0 to 1023\nSource =");
267 #if 1
268 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
269 db_printf(" %3d", bsrc); /* Show where we're at */
270 for(n = 0; n < 128; n++) { /* Step N by 1 */
271 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
272 asrc = (void *)((unsigned int)srcptr + bsnk); /* Start byte address */
273 asnk = (void *)((unsigned int)srcptr + bsnk + n + 256); /* End byte address */
274 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
275 if(ret) {
276 db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
277 db_printf("failed\n");
278 }
279 }
280 }
281 }
282 #endif
283
284
285
286
287
288
289 #endif
290
291 #if 0
292 iterations = 1000;
293 tottime = 0;
294 totbytes = 0;
295
296 db_printf("Random test starting; iterations = %d\n", iterations);
297 for(i = 0; i < 262144 * 4; i++) { /* Clear all 2MB of source (and dest for this test) */
298 ((unsigned char *)srcptr)[i] = i & 255;
299 }
300
301 for(i = 0; i < iterations; i++) { /* Test until we are done */
302 makerand = rand() << 16 | (rand() & 0x0000FFFF);
303 bsrc = makerand & 0x0007FFFF; /* Generate source */
304 makerand = rand() << 16 | (rand() & 0x0000FFFF);
305 bsnk = makerand & 0x0007FFFF; /* Generate sink */
306 makerand = rand() << 16 | (rand() & 0x0000FFFF);
307 size = makerand & 0x0007FFFF; /* Generate length */
308 #if 1
309 db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
310 ((unsigned int)srcptr + bsnk), size);
311 #endif
312
313 asrc = (void *)((unsigned int)srcptr + bsrc);
314 asnk = (void *)((unsigned int)srcptr + bsnk);
315 timein = gtick();
316 ret = tstcopy3(asrc, asnk, size);
317 timeout = gtick();
318 if(ret) {
319 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
320 db_printf("failed\n");
321
322 }
323 ticks = timeout - timein; /* Get time in ticks for copy */
324 tottime += ticks;
325 totbytes += size;
326
327 rate = (double) totbytes / (double)tottime; /* Get bytes per tick */
328 // rate = rate * (double)11250000.0; /* Bytes per second */
329 // rate = rate * (double)16500000.0; /* Bytes per second */
330 rate = rate * (double)tbfreq; /* Bytes per second */
331 rate = rate / (double)1000000.0; /* Get number of MBs */
332
333 db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
334
335 }
336 #endif
337
338
339
340 #if 0
341 iterations = 100;
342 tottime = 0;
343 totbytes = 0;
344
345 db_printf("Random test starting; iterations = %d\n", iterations);
346 for(i = 0; i < 262144 * 4; i++) { /* Clear all 2MB of source (and dest for this test) */
347 ((unsigned char *)srcptr)[i] = i & 255;
348 }
349
350 for(i = 0; i < iterations; i++) { /* Test until we are done */
351 makerand = rand() << 16 | (rand() & 0x0000FFFF);
352 bsrc = makerand & 0x0007FFFF; /* Generate source */
353 makerand = rand() << 16 | (rand() & 0x0000FFFF);
354 bsnk = makerand & 0x0007FFFF; /* Generate sink */
355 makerand = rand() << 16 | (rand() & 0x0000FFFF);
356 size = makerand & 0x0007FFFF; /* Generate length */
357 #if 1
358 db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
359 ((unsigned int)srcptr + bsnk), size);
360 #endif
361
362 asrc = (void *)((unsigned int)srcptr + bsrc);
363 asnk = (void *)((unsigned int)srcptr + bsnk);
364 timein = gtick();
365 ret = tstcopy4(asrc, asnk, size);
366 timeout = gtick();
367 if(ret) {
368 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
369 db_printf("failed\n");
370
371 }
372 ticks = timeout - timein; /* Get time in ticks for copy */
373 tottime += ticks;
374 totbytes += size;
375
376 rate = (double) totbytes / (double)tottime; /* Get bytes per tick */
377 // rate = rate * (double)11250000.0; /* Bytes per second */
378 // rate = rate * (double)16500000.0; /* Bytes per second */
379 rate = rate * (double)tbfreq; /* Bytes per second */
380 rate = rate / (double)1000000.0; /* Get number of MBs */
381
382 db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
383
384 }
385 #endif
386
387 #if 0
388 iterations = 100;
389 tottime = 0;
390 totbytes = 0;
391
392 db_printf("Random test starting; iterations = %d\n", iterations);
393 for(i = 0; i < 262144 * 4; i++) { /* Clear all 2MB of source (and dest for this test) */
394 ((unsigned char *)srcptr)[i] = i & 255;
395 }
396
397 for(i = 0; i < iterations; i++) { /* Test until we are done */
398 makerand = rand() << 16 | (rand() & 0x0000FFFF);
399 bsrc = makerand & 0x0007FFFF; /* Generate source */
400 makerand = rand() << 16 | (rand() & 0x0000FFFF);
401 bsnk = makerand & 0x0007FFFF; /* Generate sink */
402 makerand = rand() << 16 | (rand() & 0x0000FFFF);
403 size = makerand & 0x0007FFFF; /* Generate length */
404 #if 1
405 db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
406 ((unsigned int)srcptr + bsnk), size);
407 #endif
408
409 asrc = (void *)((unsigned int)srcptr + bsrc);
410 asnk = (void *)((unsigned int)srcptr + bsnk);
411 timein = gtick();
412 ret = dumbcopy(asrc, asnk, size);
413 timeout = gtick();
414 if(ret) {
415 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
416 db_printf("failed\n");
417
418 }
419 ticks = timeout - timein; /* Get time in ticks for copy */
420 tottime += ticks;
421 totbytes += size;
422
423 rate = (double) totbytes / (double)tottime; /* Get bytes per tick */
424 rate = rate * (double)tbfreq; /* Bytes per second */
425 rate = rate / (double)1000000.0; /* Get number of MBs */
426
427 db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
428
429 }
430 #endif
431
432 kmem_free(kernel_map, (vm_offset_t) sink, (1024*1024)+4096); /* Release this mapping block */
433 kmem_free(kernel_map, (vm_offset_t) source, (1024*1024)+4096); /* Release this mapping block */
434
435 if(dbg == 22) db_printf("Gabbagoogoo\n");
436 return;
437 }
438
439 void clrarea(unsigned int *source, unsigned int *sink) {
440
441 unsigned int i;
442
443 for(i=0; i < 1024; i++) { /* Init source & sink */
444 source[i] = 0x55555555; /* Known pattern */
445 sink[i] = 0xAAAAAAAA; /* Known pattern */
446 }
447 return;
448 }
449
450 void
451 clrarea2(unsigned int *source, __unused unsigned int *sink)
452 {
453 unsigned int i;
454 unsigned char *ss;
455
456 ss = (unsigned char *)&source[0];
457
458 for(i=0; i < 1024 * 4; i++) { /* Init source/sink */
459 ss[i] = i & 0xFF; /* Known pattern */
460 }
461 return;
462 }
463
464 int tstcopy(void *src, void *snk, unsigned int lgn) {
465
466 unsigned int i, crap;
467
468 bcopy(src, snk, lgn);
469
470 for(i = 0; i < lgn; i++) {
471 if(((unsigned char *)snk)[i] != 0x55) {
472 crap = (unsigned int)&((unsigned char *)snk)[i];
473 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i,crap, ((unsigned char *)snk)[i]);
474 return 1;
475 }
476 }
477 if(((unsigned char *)snk)[lgn] != 0xAA) { /* Is it right? */
478 crap = (unsigned int)&((unsigned char *)snk)[i];
479 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
480 return 1;
481 }
482 return 0;
483
484 }
485
486 int tstcopy2(void *src, void *snk, unsigned int lgn) {
487
488 unsigned int i, crap;
489 unsigned char ic, ec;
490
491 ic = ((unsigned char *)src)[0];
492 ec = ((unsigned char *)snk)[lgn];
493
494 bcopy(src, snk, lgn);
495
496 for(i = 0; i < lgn; i++) {
497 if(((unsigned char *)snk)[i] != ic) {
498 crap = (unsigned int)&((unsigned char *)snk)[i];
499 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i,crap, ((unsigned char *)snk)[i]);
500 return 1;
501 }
502 ic = (ic + 1) & 0xFF;
503 }
504
505 if(((unsigned char *)snk)[lgn] != ec) { /* Is it right? */
506 crap = (unsigned int)&((unsigned char *)snk)[i];
507 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
508 return 1;
509 }
510 return 0;
511
512 }
513
514 int tstcopy3(void *src, void *snk, unsigned int lgn) {
515
516 unsigned int i, crap;
517 unsigned char ic, ec, oic;
518
519 oic = ((unsigned char *)snk)[0];
520 ic = ((unsigned char *)src)[0];
521 ec = ((unsigned char *)snk)[lgn];
522
523 bcopy(src, snk, lgn);
524
525 for(i = 0; i < lgn; i++) {
526 if(((unsigned char *)snk)[i] != ic) {
527 crap = (unsigned int)&((unsigned char *)snk)[i];
528 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i ,crap, ((unsigned char *)snk)[i]);
529 return 1;
530 }
531 ic = (ic + 1) & 0xFF;
532 }
533
534 if(((unsigned char *)snk)[lgn] != ec) { /* Is it right? */
535 crap = (unsigned int)&((unsigned char *)snk)[i];
536 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
537 return 1;
538 }
539
540 for(i=0; i < lgn; i++) { /* Restore pattern */
541 ((unsigned char *)snk)[i] = oic;
542 oic = (oic + 1) & 0xFF;
543 }
544
545 return 0;
546
547 }
548
549 int tstcopy4(void *src, void *snk, unsigned int lgn) {
550
551 bcopy(src, snk, lgn);
552 return 0;
553
554 }
555
556 int tstcopy5(void *src, void *snk, unsigned int lgn) {
557
558 unsigned int i = 0, crap;
559 unsigned char ic, ec, oic, pc;
560
561 oic = ((unsigned char *)snk)[0]; /* Original first sink character */
562 ic = ((unsigned char *)src)[0]; /* Original first source character */
563 ec = ((unsigned char *)snk)[lgn]; /* Original character just after last sink character */
564 pc = ((unsigned char *)snk)[-1]; /* Original character just before sink */
565
566 bcopy(src, snk, lgn);
567
568 if(((unsigned char *)snk)[lgn] != ec) { /* Did we copy too far forward? */
569 crap = (unsigned int)&((unsigned char *)snk)[i];
570 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
571 return 1;
572 }
573
574 if(((unsigned char *)snk)[-1] != pc) { /* Did we copy too far backward? */
575 crap = (unsigned int)&((unsigned char *)snk)[i];
576 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
577 return 1;
578 }
579
580 for(i = 0; i < lgn; i++) { /* Check sink byte sequence */
581 if(((unsigned char *)snk)[i] != ic) {
582 crap = (unsigned int)&((unsigned char *)snk)[i];
583 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i ,crap, ((unsigned char *)snk)[i]);
584 return 1;
585 }
586 ic = (ic + 1) % patper;
587 }
588
589 for(i=0; i < lgn; i++) { /* Restore pattern */
590 ((unsigned char *)snk)[i] = oic;
591 oic = (oic + 1) % patper;
592 }
593
594 return 0;
595
596 }
597
598 int dumbcopy(void *src, void *snk, unsigned int lgn) {
599 unsigned int i;
600 char *p = (char *)snk;
601 char *q = (char *)src;
602
603 for(i = 0; i < lgn; i++) {
604 *p++ = *q++;
605 }
606 return 0;
607
608 }
609
610
611
612
613
614
615
616
617
618
619
620
621