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