main.c
40.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
/*
* File: main.c
*
*
* This application is a test-bed of single frame tests for RDP
* test vector generation. The idea is that each frame possibly uses a
* different dataset (see static.c) to render a particular test.
*
* Under argc, argv control, you can choose to run a single frame test, or
* (by default) run all the "frames" of vector generation at once. When
* sending multiple "frames" down, we always wait for vertical retrace before
* drawing the next frame (frames are always drawn in the first cfb, so that we
* know how to extract the image data when running simulations/test vectors).
*
* At the user's option, they may specify that RDRAM (e.g. the frame buffer)
* has been preinitialized, thus eliminating the need for a screen/zbuffer
* clear. Use the -m flag when this is the case.
*
* A similar strategy was used in RDP verification, so we are leveraging
* heavily from the old rdpverif program.
*
* The "-c <number>" flag performs checksum screen compares:
*
* -c 0 dumps the checksums
*
* -c 1 compares the generated checksums with a previously acquired set
* compiled into this program. If the checsums don't match, we PRINTF
* and/or print the results to the screen.
*
*
* Use gload's -a flag to pass arguments through to this app.
*
* NOTE:
*
* This test-bed is composed of some shared code, and test-specific
* code. To add or modify a test case, you should only touch the
* test-specific code. Modifying shared code might break other tests, should
* we ever create other directories of test vector generators based upon this
* program.
*
* FILES THAT MAY BE SHARED WITH OTHER TESTS: (don't modify)
*
* main.c
* init.c
* dynamic.c
* zbuffer.c
* spec
*
* FILES THAT ARE TEST-SPECIFIC: (may modify)
*
* <module_name>_static.c (holds static display list data for tests)
* <module_name>.h (exports info to main.c, etc.)
* <module_name.c (holds test frame procedures, etc.)
* <any related include files> (textures, etc.)
* Makefile (make test rules)
*
* A separate set of files should be modified when producing display lists for
* per module testing (e.g. cs.h, cs.c, cs_static.c). A template display list
* test has been provided; some real gfx dl's are provided as samples in the ms
* test series.
*
* TO ADD A TEST CASE:
*
* decide which module your test will focus on, then tweak:
*
* <module_name>.h - extern the static display list, so that it is
* visible from <module_name>_static.c
*
* <module_name>_static.c - add the static display list for the test.
*
* <module_name>.c - add the procedure to be called to
* perform the test case. (also put it
* in the testCaseProc table appropriate for
* this module)
*
* - put the static display list pointer
* in the testList table (appropriately named
* for your module under test) as a Gfx pointer
* in the GfxTest_t struct; also provide a name
* for your test so that the rdpascii2rdp tool
* can provide a filename for the resulting
* binary .rdp file.
*
* ... plus add any new textures, include files, etc.
*
* All locations are marked with comments that say "ADD TEST CASE"
* and give some hints what you need to do there.
*
* ADVANCED USAGE:
* You could re-use test case procedures or data, as long as you
* coordinate with all the tests that share it. It is a bad idea
* to share data or procedures with a test that someone else may
* go in and modify.
*
* If your test case needs a command line argument, that isn't handled
* too cleanly. You would have to add it to main.c, and export the
* global variables, etc. (messy)
*
* This test suite favors single-frame tests. Animation support is clumsy.
*
* Fri Sep 22 11:39:18 PDT 1995
*/
#include <ultra64.h>
#include <ramrom.h>
#include <assert.h>
#include "controller.h"
#include "rdpvector.h"
#include "ms.h"
#include "checksum.h"
/*
* Symbol genererated by "makerom" to indicate the end of the code segment
* in virtual (and physical) memory
*/
extern char _textureSegmentEnd[];
/* these are fixed sizes: */
#define SP_UCODE_SIZE 4096
#define SP_UCODE_DATA_SIZE 2048
/*
* Symbols generated by "makerom" to tell us where the static segment is
* in ROM.
*/
extern char _staticSegmentRomStart[], _staticSegmentRomEnd[];
extern char _textureSegmentRomStart[], _textureSegmentRomEnd[];
extern char _textureSegmentStart[];
/*
* Stacks for the threads as well as message queues for synchronization
*/
u64 bootStack[STACKSIZE/sizeof(u64)];
static int uselines = 0;
static int useblack = 0;
static int skipZclear = 0;
static void idle(void *);
static void mainproc(void *);
static OSThread idleThread;
static u64 idleThreadStack[STACKSIZE/sizeof(u64)];
static OSThread mainThread;
static u64 mainThreadStack[STACKSIZE/sizeof(u64)];
static OSThread rmonThread;
static u64 rmonStack[RMON_STACKSIZE/sizeof(u64)];
static char dummy[1024*1024] = {0}; /* idiotic array to pad out image size for makemask */
/* this number (the depth of the message queue) needs to be equal
* to the maximum number of possible overlapping PI requests.
* For this app, 1 or 2 is probably plenty, other apps might
* require a lot more.
*/
#define NUM_PI_MSGS 8
static OSMesg PiMessages[NUM_PI_MSGS];
static OSMesgQueue PiMessageQ;
OSMesgQueue dmaMessageQ, rspMessageQ, rdpMessageQ, retraceMessageQ;
OSMesg dmaMessageBuf, rspMessageBuf, rdpMessageBuf, retraceMessageBuf;
OSMesg dummyMessage;
OSIoMesg dmaIOMessageBuf;
/*
* Dynamic segment in code space. Needs OS_K0_TO_PHYSICAL()...
*/
Dynamic dynamic;
/*
* necessary for RSP tasks:
*/
u64 dram_stack[SP_DRAM_STACK_SIZE64];
u64 dram_yield[OS_YIELD_DATA_SIZE];
u64 rdp_output_len;
u64 rdp_output[4096*16];
/*
* must be in BSS, not on the stack for this to work:
*/
OSTask tlist =
{
M_GFXTASK, /* task type */
OS_TASK_DP_WAIT, /* task flags */
NULL, /* boot ucode pointer (fill in later) */
0, /* boot ucode size (fill in later) */
NULL, /* task ucode pointer (fill in later) */
SP_UCODE_SIZE, /* task ucode size */
NULL, /* task ucode data pointer (fill in later) */
SP_UCODE_DATA_SIZE, /* task ucode data size */
&(dram_stack[0]), /* task dram stack pointer */
SP_DRAM_STACK_SIZE8, /* task dram stack size */
&(rdp_output[0]), /* task output buffer ptr (not always used) */
&rdp_output_len, /* task output buffer size ptr */
NULL, /* task data pointer (fill in later) */
0, /* task data size (fill in later) */
NULL, /* task yield buffer ptr (not used here) */
0 /* task yield buffer size (not used here) */
};
static char *staticSegment;
static char *textureSegment;
Gfx *glistp; /* global for test case procs */
/*
* global variables for arguments, to control test cases
*/
static int frame_count = -1;
static int module_num = -1;
int rdp_DRAM_io = 0;
static int checksumRequest = -1;
static int rdp_regressionFlag = 0;
static int rdp_mspanFlushFlag = 0;
static int debugflag = 0;
static int dumpImage = 0;
static int dumpImage2 = 0;
static int draw_buffer = 0;
static void *cfb_ptrs[2];
static int cfb_size = G_IM_SIZ_16b;
static u64 ramrombuf[RAMROM_MSG_SIZE/8];
int controlFrame = 0;
int lastFrameNum = -2;
/*
* When TRUE, toplevel.c routines will issue a full sync after
* the frame's DL has been rendered. When dumping DL's, we
* will want to inhibit the full sync's for every frame of a
* particular module until the last frame, so that we can
* accumulate all the frame's test vectors together in one
* monster DL.
*/
int generateFullSync = 0;
typedef union {
u32 word[2];
u64 force_alignment;
} scratch_t;
scratch_t scratch_buff[1024], *scrp;
#define PI_BASE ((u32)(0xb0700000))
static u32 *piAddr = (u32 *)(PI_BASE);
u32 dummy_val;
/*
* Declare an array of ModuleTest_t structs, so that we can cycle through all
* the tests designed for each of the rdp's major functional blocks.
*/
ModuleTest_t moduleTestSet[MODULE_COUNT];
u32 argbuf[16];
/*
* The boot() function MUST be the first function in this module, otherwise
* the original boot thread (loaded at 2MB in rdram) will be unable to invoke
* this secondary boot procedure, which loads the program low in rdram.
*/
boot(void *arg)
{
int i, *pr;
char *ap;
u32 *argp;
osInitialize();
for (pr = (int *)0xb0700000; (u32)pr < 0xb0702000; pr++)
__osPiRawWriteIo((u32)pr, 0x55555555);
argp = (u32 *)RAMROM_APP_WRITE_ADDR;
for (i=0; i<sizeof(argbuf)/4; i++, argp++) {
__osPiRawReadIo((u32)argp, &argbuf[i]); /* Assume no DMA */
}
osCreateThread(&idleThread, 1, idle, arg, idleThreadStack+STACKSIZE/sizeof(u64), 10);
osStartThread(&idleThread);
/* never reached */
}
/*
* private routine used to parse args.
*/
static int
myatoi(char *str)
{
int log10[5], logn = 0, val = 0, i, pow10 = 1;
if (str == NULL || *str == '\0')
return(-1);
while (*str != '\0') {
if (!(*str == '0' ||
*str == '1' ||
*str == '2' ||
*str == '3' ||
*str == '4' ||
*str == '5' ||
*str == '6' ||
*str == '7' ||
*str == '8' ||
*str == '9')) {
logn = 0;
break;
}
log10[logn++] = *str - '0';
str++;
}
if (logn == 0)
return(-1);
for (i=logn-1; i>= 0; i--) {
val += log10[i] * pow10;
pow10 *= 10;
}
return (val);
}
/*
* private routine used to parse args.
*/
static void
parse_args(char *argstring)
{
int argc = 1, i;
char *arglist[32], **argv = arglist; /* max 32 args */
char *c, *ptr;
if (argstring == NULL || argstring[0] == '\0')
return;
/* re-organize argstring to be like main(argv,argc) */
ptr = argstring;
while (*ptr != '\0') {
while (*ptr != '\0' && (*ptr == ' ')) {
*ptr = '\0';
ptr++;
}
if (*ptr != '\0')
arglist[argc++] = ptr;
while (*ptr != '\0' && (*ptr != ' ')) {
ptr++;
}
}
/* ADD TEST CASE:
* might want to pick off special arguments here.
*/
/* process the arguments: */
while ((argc > 1) && (argv[1][0] == '-')) {
switch(argv[1][1]) {
/*
* -c controls checksum behavior; legitimate values are "0" to
* dump checksums, "1" to compare generated checksums with
* old values compiled in to this program.
*/
case 'c':
checksumRequest = myatoi(argv[2]);
if ( (checksumRequest < 0) || (checksumRequest > 1) ) {
checksumRequest = -1;
}
argc--;
argv++;
break;
case 'd':
rdp_DRAM_io = 1; /* route RSP output for RDP back to DRAM */
break;
case 'f':
frame_count = myatoi(argv[2]); /* start frame */
if (frame_count < 0) {
frame_count = -1;
}
controlFrame = frame_count;
argc--;
argv++;
break;
case 'g':
debugflag = 1;
break;
case 'i':
dumpImage = 1;
break;
case 'I':
dumpImage2 = 1;
break;
case 'F':
rdp_mspanFlushFlag = 1; /* flush mspan cache by enabling 1PRIM */
break;
case 'r':
rdp_regressionFlag = 1; /* when set, shrink viewport for brevity */
break;
case 'l':
uselines = 1;
break;
/*
* -m specifies that we run a single module's set of tests.
*/
case 'm':
module_num = myatoi(argv[2]);
if (module_num < 0) {
module_num = -1;
}
argc--;
argv++;
break;
case 'b':
useblack = 1;
break;
case 'z':
skipZclear = 1;
break;
default:
/*
PRINTF("option [%s] not recognized.\n", argv[1]);
*/
break;
}
argc--;
argv++;
}
}
static void
idle(void *arg)
{
/* Initialize video */
osCreateViManager(OS_PRIORITY_VIMGR);
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
/*
* Parse option arguments before we start the main thread, so that if we
* set the debugflag, we won't start the main thread (debugger will have to
* do that for us). Unfortunately this means we can't PRINTF any
* errors in argument parsing...
*/
parse_args((char *)argbuf);
/*
* Start PI Mgr for access to cartridge
*/
osCreatePiManager((OSPri)OS_PRIORITY_PIMGR, &PiMessageQ, PiMessages,
NUM_PI_MSGS);
/*
* Start RMON for debugging & data xfer (make sure to start
* PI Mgr first)
*/
osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
rmonStack+RMON_STACKSIZE/sizeof(u64), OS_PRIORITY_RMON);
osStartThread(&rmonThread);
/*
* Create main thread
*/
osCreateThread(&mainThread, 3, mainproc, arg,
mainThreadStack+STACKSIZE/sizeof(u64), 10);
if (debugflag != 1) {
osStartThread(&mainThread);
}
/*
* Become the idle thread
*/
osSetThreadPri( 0, 0 );
for(;;);
}
/*
* Dumps texture memory out as raw data. We expect texture data to always be
* 64 bit aligned, and dump a little extra if the size says there's less.
*/
static void
dump_texture_memory(u64 *textureSegment, u64 size)
{
char String[128];
sprintf(String,
"TEXTURE DUMP 0x%x\n", osVirtualToPhysical(textureSegment));
guParseString(String, 128);
if (size % sizeof(u64)) {
size += sizeof(u64);
size &= ~(sizeof(u64));
}
guParseRdpDL(textureSegment, size, GU_PARSERDP_DUMPONLY);
}
/*
* Build up an RDP task to clear the frame buffer, in whatever video mode the
* current test requires.
*/
void
clear_framebuffers(int cfb_pixSize)
{
OSTask *tlistp;
Dynamic *dynamicp;
/*
* set up pointers to build the display list.
*/
tlistp = &tlist;
dynamicp = &dynamic;
glistp = &(dynamicp->glist[0]);
/*
* Tell RCP where each segment is
*/
gSPSegment(glistp++, 0, 0x0); /* K0 (physical) address segment */
gSPSegment(glistp++, STATIC_SEGMENT,
osVirtualToPhysical(staticSegment));
gSPSegment(glistp++, TEXTURE_SEGMENT,
osVirtualToPhysical(textureSegment));
/*
* XXX Probably not necessary to do this each time, but too hard to figure
* out what's needed and what's not, so we do it every time & wonder...
*/
gSPDisplayList(glistp++, rdpinit_dl);
gSPDisplayList(glistp++, rspinit_dl);
if (cfb_pixSize == G_IM_SIZ_16b) {
if (skipZclear == 0) {
gSPDisplayList(glistp++, clear_16fb_z);
}
gSPDisplayList(glistp++, clear_16fb);
} else {
if (skipZclear == 0) {
gSPDisplayList(glistp++, clear_32fb_z);
}
gSPDisplayList(glistp++, clear_32fb);
}
gDPFullSync(glistp++);
gSPEndDisplayList(glistp++);
assert((glistp - dynamicp->glist) < MAX_GRAPHICS_SIZE);
/*
* Build a graphics task to execute the frame buffer clears, fire it off,
* then wait for RDP completion.
*/
tlistp->t.type = M_GFXTASK;
tlistp->t.flags = OS_TASK_DP_WAIT;
tlistp->t.ucode_boot = (u64 *) rspbootTextStart;
tlistp->t.ucode_boot_size = ((int)rspbootTextEnd -
(int)rspbootTextStart);
/*
* RSP output over XBUS to RDP.
*/
tlistp->t.ucode = (u64 *) gspFast3DTextStart;
tlistp->t.ucode_data = (u64 *) gspFast3DDataStart;
tlistp->t.ucode_size = SP_UCODE_SIZE;
tlistp->t.ucode_data_size = SP_UCODE_DATA_SIZE;
tlistp->t.dram_stack = (u64 *) &(dram_stack[0]);
tlistp->t.dram_stack_size = SP_DRAM_STACK_SIZE8;
tlistp->t.output_buff = (u64 *) 0x0;
tlistp->t.output_buff_size = (u64 *) 0x0;
/* initial display list: */
tlistp->t.data_ptr = (u64 *) dynamicp->glist;
tlistp->t.data_size = ((int)(glistp - dynamicp->glist) *
sizeof (Gfx));
tlistp->t.yield_data_ptr = (u64 *) NULL;
tlistp->t.yield_data_size = 0xDA0;
/*
* Can just flush 16KB and forget about each individual pieces
* of data to flush.
*/
osWritebackDCacheAll();
/* unwrap this macro for debugging:
*
* osSpTaskStart(tlistp);
*
*/
osSpTaskLoad(tlistp);
osSpTaskStartGo(tlistp);
/*
* ignore SP completion, wait for DP completion.
*/
(void)osRecvMesg(&rdpMessageQ, &dummyMessage, OS_MESG_BLOCK);
/*
* Now wait for a vertical retrace to go by.
*
* Make sure there isn't an old retrace in queue
* (assumes queue has a depth of 1) by checking to see if the MQ is full.
*/
if (MQ_IS_FULL(&retraceMessageQ))
(void)osRecvMesg(&retraceMessageQ, &dummyMessage, OS_MESG_BLOCK);
/*
* Now really wait for vertical retrace to finish.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage, OS_MESG_BLOCK);
}
#define DUMP_REQUEST 0xdeadbeef
#define DUMP_REPLY 0xbaaddeed
void
dumpRGB( int pixSize, int width, int height, unsigned long *fb)
{
unsigned long *longPixels;
unsigned long pixelValue;
int row, column;
int channel;
char str[32];
char String[128];
/*
* checksum calculates 32 bits, so if 16 bit fb, than 2 pixels at a time.
* if 8 bit fb, than 4 pixels at a time
*/
PRINTF("START IMAGE\n");
if ( pixSize == G_IM_SIZ_8b ) {
PRINTF("Dimensions %d %d 8\n",width,height);
width >>= 2;
} else
if ( pixSize == G_IM_SIZ_16b ) {
PRINTF("Dimensions %d %d 16\n",width,height);
width >>= 1;
} else {
PRINTF("Dimensions %d %d 32\n",width,height);
}
longPixels = (unsigned long *) (fb);
for (column = 0; column < height; column++){
for (row = 0; row < width; row += 8) {
PRINTF("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ",
longPixels[0],longPixels[1],longPixels[2],longPixels[3],
longPixels[4],longPixels[5],longPixels[6],longPixels[7]);
longPixels += 8;
}
PRINTF("\n");
}
PRINTF("END IMAGE\n");
}
static void
computeChecksum(int pixSize, int moduleNum, int frameNum)
{
unsigned short *shortPixels;
unsigned long *longPixels, *longPixels1;
unsigned long long checksumValue;
int row, column, i, checksumIndex;
unsigned int hostBuffer[2];
static stored_cfb = 0;
/*
* Only spin cycles to compute/compare the checksum upon user request.
*/
if ( (checksumRequest == 0) || (checksumRequest == 1) ) {
#define HUSH 1
#ifdef HUSH
PRINTF("moduleNum = %d, frameNum = %d, pixSize = %d\n",
moduleNum, frameNum, pixSize);
#endif
if ( pixSize == G_IM_SIZ_16b ) {
shortPixels = (unsigned short *) (cfb_16_a);
checksumValue = 0;
for (row = 0; row < SCREEN_WD; row++) {
for (column = 0; column < SCREEN_HT; column++) {
checksumValue += *shortPixels++;
}
}
} else if ( pixSize == G_IM_SIZ_32b ) {
longPixels = (unsigned long *) (cfb_16_a);
checksumValue = 0;
for (row = 0; row < SCREEN_WD; row++) {
for (column = 0; column < SCREEN_HT; column++) {
checksumValue += *longPixels++;
}
}
} else {
/*
* 1024 x 1024 framebuffer renders in 32 bits.
*/
longPixels = (unsigned long *) (cfb_16_a);
checksumValue = 0;
for (row = 0; row < 1024; row++) {
for (column = 0; column < 1024; column++) {
checksumValue += *longPixels++;
}
}
}
PRINTF("checksumValue = 0x%llx\n", checksumValue);
if (checksumRequest == 1) {
/*
* Figure out which checksum value to use.
*/
for (i = 0, checksumIndex = 0; i < moduleNum; i++) {
checksumIndex += moduleTestSet[i].testListCount;
}
checksumIndex += frameNum;
#ifdef HUSH
if (checksumValues[checksumIndex] != checksumValue) {
PRINTF("ERROR: (%d): exp 0x%llx, computed 0x%llx\n",
checksumIndex, checksumValues[checksumIndex], checksumValue);
} else {
PRINTF("PASS checksum test.\n");
}
#endif
}
/*
* Wait for a vertical retrace to go by. SP sometimes hangs if we
* don't do this after computing a checksum (hack, I know, sigh).
*
* Make sure there isn't an old retrace in queue
* (assumes queue has a depth of 1) by checking to see if the
* MQ is full.
*/
if (MQ_IS_FULL(&retraceMessageQ))
/*
* Eat the old retrace message prior to the real wait below.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage,
OS_MESG_BLOCK);
/*
* Now really wait for vertical retrace to finish.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage,
OS_MESG_BLOCK);
}
/* Alternate route for dumping frame buffer since below code looks like
debugging crap left over by someone */
if (dumpImage) {
dumpRGB(pixSize, 320, 240, cfb_ptrs[draw_buffer]);
PRINTF("End frame dump \n");
/* Now fill up output buffers so we get a flush of real data */
for (i = 0; i < 1024; i++) PRINTF("================\n");
dumpImage = 0; /* Don't dump any more frame */
}
/*
* Hack to store framebuffer, so that we can read & compare, & see what's
* different, since the checksums are differing inexplicably.
*/
if ( (moduleNum == 5) && (frameNum == 3) ) {
longPixels = (unsigned long *) (cfb_16_a);
longPixels1 = (unsigned long *) (0x8034b000);
if (stored_cfb == 0) {
for (row = 0; row < SCREEN_WD; row++) {
for (column = 0; column < SCREEN_HT; column++) {
*longPixels1++ = *longPixels++;
}
}
stored_cfb = 1;
/*
* If we are dumping an image, negotiate with the host side
* process now & dump the image using the debug port.
*/
if (dumpImage2) {
osReadHost(hostBuffer, 4);
if (hostBuffer[0] != DUMP_REQUEST) {
PRINTF("host request 0x%x received\n", hostBuffer[0]);
return;
}
hostBuffer[0] = DUMP_REPLY;
hostBuffer[1] = (SCREEN_WD * SCREEN_HT * sizeof(unsigned int));
osWriteHost(hostBuffer, 8);
osWriteHost(cfb_16_a,
(SCREEN_WD * SCREEN_HT * sizeof(unsigned int)));
osExit();
}
} else {
#ifdef NOTDEF
for (row = 0; row < SCREEN_WD; row++) {
for (column = 0; column < SCREEN_HT; column++) {
if (*longPixels1 != *longPixels) {
PRINTF("ERROR (%d, %d): exp 0x%x, rd 0x%x, xor 0x%x\n",
row, column, *longPixels1, *longPixels, (*longPixels1 ^ *longPixels));
}
++longPixels;
++longPixels1;
}
}
#endif
}
}
}
static void
mainproc(void *arg)
{
OSTask *tlistp;
Dynamic *dynamicp;
int controllerSlot;
int testListCount;
int frameNum, endFrame;
int moduleNum, startModule, endModule;
int keep_going = 1;
int pixSize;
cfb_ptrs[0] = cfb_16_a;
cfb_ptrs[1] = cfb_16_b;
/*
* Setup the message queues
*/
osCreateMesgQueue(&dmaMessageQ, &dmaMessageBuf, 1);
osCreateMesgQueue(&rspMessageQ, &rspMessageBuf, 1);
osSetEventMesg(OS_EVENT_SP, &rspMessageQ, dummyMessage);
osCreateMesgQueue(&rdpMessageQ, &rdpMessageBuf, 1);
osSetEventMesg(OS_EVENT_DP, &rdpMessageQ, dummyMessage);
osCreateMesgQueue(&retraceMessageQ, &retraceMessageBuf, 1);
osViSetEvent(&retraceMessageQ, dummyMessage, 1);
/*
* Load the texture segment wherever it ended up (it will be right after
* the codeSegment as per our spec file directives to makerom).
*
* We'll dump out it's address when dumping texture data, for inclusion
* in all .rdram files to be generated by this program and rdpascii2rdram.
*/
textureSegment = (char *)_textureSegmentStart;
osInvalDCache( textureSegment,
(_textureSegmentRomEnd - _textureSegmentRomStart) );
osPiStartDma(&dmaIOMessageBuf, OS_MESG_PRI_NORMAL, OS_READ,
(u32)_textureSegmentRomStart, textureSegment,
_textureSegmentRomEnd - _textureSegmentRomStart, &dmaMessageQ);
/*
* Wait for DMA to finish
*/
(void)osRecvMesg(&dmaMessageQ, &dummyMessage, OS_MESG_BLOCK);
/*
* Stick the static segment right after the texture segment.
*/
staticSegment = _textureSegmentEnd;
osInvalDCache( staticSegment,
(_staticSegmentRomEnd - _staticSegmentRomStart) );
osPiStartDma(&dmaIOMessageBuf, OS_MESG_PRI_NORMAL, OS_READ,
(u32)_staticSegmentRomStart, staticSegment,
_staticSegmentRomEnd - _staticSegmentRomStart, &dmaMessageQ);
/*
* Wait for DMA to finish
*/
(void)osRecvMesg(&dmaMessageQ, &dummyMessage, OS_MESG_BLOCK);
/*
* Initialize controller
*/
controllerSlot = initControllers();
/*
* Tell the VI to display the first frame buffer.
*/
osViSwapBuffer(cfb_16_a);
/*
* Dump the contents of texture memory, so that rdpascii2rdram can load
* each .rdram file with the contents of texture memory, as well the
* pre-initialized frame buffer.
*/
if (rdp_DRAM_io) {
dump_texture_memory( (u64 *)textureSegment,
(u64)(_textureSegmentRomEnd - _textureSegmentRomStart) );
}
/*
* Count number of tests to run for each module under test, and stuff
* an array of pointers to the individual module test entry points, so
* that we can invoke them from the main game loop below.
*/
/*
* CS_MODULE
*/
testListCount = 0;
moduleTestSet[CS_MODULE].gfxTests = testList_cs;
while ( (testList_cs[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_cs[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[CS_MODULE].testListCount = testListCount;
/*
* EW_MODULE
*/
testListCount = 0;
moduleTestSet[EW_MODULE].gfxTests = testList_ew;
while ( (testList_ew[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_ew[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[EW_MODULE].testListCount = testListCount;
/*
* ST_MODULE
*/
testListCount = 0;
moduleTestSet[ST_MODULE].gfxTests = testList_st;
while ( (testList_st[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_st[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[ST_MODULE].testListCount = testListCount;
/*
* TM_MODULE
*/
testListCount = 0;
moduleTestSet[TM_MODULE].gfxTests = testList_tm;
while ( (testList_tm[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_tm[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[TM_MODULE].testListCount = testListCount;
/*
* TC_MODULE
*/
testListCount = 0;
moduleTestSet[TC_MODULE].gfxTests = testList_tc;
while ( (testList_tc[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_tc[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[TC_MODULE].testListCount = testListCount;
/*
* TF_MODULE
*/
testListCount = 0;
moduleTestSet[TF_MODULE].gfxTests = testList_tf;
while ( (testList_tf[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_tf[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[TF_MODULE].testListCount = testListCount;
/*
* CC_MODULE
*/
testListCount = 0;
moduleTestSet[CC_MODULE].gfxTests = testList_cc;
while ( (testList_cc[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_cc[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[CC_MODULE].testListCount = testListCount;
/*
* BL_MODULE
*/
testListCount = 0;
moduleTestSet[BL_MODULE].gfxTests = testList_bl;
while ( (testList_bl[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_bl[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[BL_MODULE].testListCount = testListCount;
/*
* MS_MODULE
*/
testListCount = 0;
moduleTestSet[MS_MODULE].gfxTests = testList_ms;
while ( (testList_ms[testListCount].gfx_dl != (Gfx *) NULL) &&
(testList_ms[testListCount].toplevel_dl != (CaseProc_t) NULL) ) {
testListCount++;
}
moduleTestSet[MS_MODULE].testListCount = testListCount;
/*
* Main game loop. Send one (if specified) or all frames worth of DL to
* be processed into test vectors, one after the other. Optionally
* restrict ourselves to a single module as well; you can also run a single
* frame from multiple module's, but that's a weird combination of -m and
* -f that isn't terribly interesting (but not worth ruling out).
*
* When dumping DL information, the commands will be sequentially numbered
* such that we can generate separate .rdp files for each display list,
* and thus generate separate tests to run as test vectors (providing
* better fault isolation).
*
* Externally, we can write a tool to collapse redundant RDP initialization
* from a sequence of DL's, so that if a second DL does not require as much
* initialization as the first, we'll skip the unecessary set of mode
* twiddling DL operations.
*/
if (module_num < 0 || module_num > MODULE_COUNT) {
startModule = 0;
endModule = MODULE_COUNT;
} else {
startModule = module_num;
endModule = module_num + 1;
}
for (moduleNum = startModule; moduleNum < endModule; moduleNum++) {
if (controlFrame > moduleTestSet[moduleNum].testListCount) {
controlFrame = 0;
}
if ( frame_count >= moduleTestSet[moduleNum].testListCount ) {
PRINTF("bogus -f <frame_count> %d ignored (testListCount for module %d is %d)\n",
frame_count, moduleNum, moduleTestSet[moduleNum].testListCount);
PRINTF("NOTE: -f <frame_count> numbers frames from 0 .. (n-1)\n");
frame_count = -1;
}
if (frame_count < 0) {
frame_count = -1;
frameNum = -1;
endFrame = moduleTestSet[moduleNum].testListCount;
}
else {
frameNum = frame_count;
}
/*
* Reset this variable (which keeps us from drawing the same frame over
* and over again) each time we step to a new module.
*/
lastFrameNum = -2;
/*
* IF
* we are rendering the last frame for this module,
* THEN
* generate a fullsync in toplevel.c
* ELSE
* inhibit fullsync
*/
generateFullSync = 0;
while (keep_going) {
/*
* Read controller
*/
if (frame_count > -1) {
readController(controllerSlot);
/*
* If the user has requested a particular frame AND we are
* dumping to dram, generate the full sync because we are
* going to exit after the rendering of this single frame.
*/
if (rdp_DRAM_io) {
generateFullSync = 1;
}
}
else {
frameNum++;
if (frameNum == endFrame) break;
if (frameNum == (endFrame - 1) ) {
generateFullSync = 1;
}
}
/*
PRINTF("moduleNum %d, frameNum %d, lastFrameNum %d\n",
moduleNum, frameNum, lastFrameNum);
*/
if (frameNum != lastFrameNum) {
/*
* Always clear the frame buffer, but do it as a separate task
* so that the RDP instructions don't make it into the RDP DL
* we dump out as input for the test vector generator.
*/
pixSize = moduleTestSet[moduleNum].gfxTests[frameNum].cfb_pixSize;
clear_framebuffers(pixSize);
/*
* Set up the video mode for either 16 bit or 32 bit pixels.
*/
if ( pixSize == G_IM_SIZ_16b ) {
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
} else {
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN2]);
}
/*
* Provide a name for each display list segment we are to dump, so
* that rdpasciitordram can provide meaningful filenames. Only the
* first frame's name is used for each module. If a module needs
* to render in 16 bit and 32 bit, there will have to be two
* sequences of frames (and two .rdram files), since the rdram
* file can only support 16 or 32 bit rendering (not both).
*
* Finally, a third type of rdram file could be a 1024x1024 cfb,
* which we use for edge walker testing.
*/
{
char String[128];
if ( ( (rdp_DRAM_io) && (frameNum == 0) ) ||
( (rdp_DRAM_io) && (frame_count > -1) ) ) {
if ( pixSize == G_IM_SIZ_16b ) {
sprintf(String, "TEST %s %d bit framebuffer\n",
moduleTestSet[moduleNum].gfxTests[frameNum].testname, 16);
} else if ( pixSize == G_IM_SIZ_32b ) {
sprintf(String, "TEST %s %d bit framebuffer\n",
moduleTestSet[moduleNum].gfxTests[frameNum].testname, 32);
} else if ( pixSize == 1024 ) {
sprintf(String, "TEST %s 1024 x 1024 32 bit framebuffer\n",
moduleTestSet[moduleNum].gfxTests[frameNum].testname);
} else {
sprintf(String, "bogus pixel size %d for test %s\n", pixSize,
moduleTestSet[moduleNum].gfxTests[frameNum].testname);
}
guParseString(String, 128);
}
}
/*
* set up pointers to build the display list.
*/
tlistp = &tlist;
dynamicp = &dynamic;
glistp = &(dynamicp->glist[0]);
/*
* Tell RCP where each segment is
*/
gSPSegment(glistp++, 0, 0x0); /* K0 (physical) address segment */
gSPSegment(glistp++, STATIC_SEGMENT,
osVirtualToPhysical(staticSegment));
/*
gSPSegment(glistp++, TEXTURE_SEGMENT,
osVirtualToPhysical(textureSegment));
*/
if (rdp_mspanFlushFlag) {
/*
* Force the pipeline to empty after the rendering of each
* display list item, to avoid incurring span buffer cache
* coherency problems with DRAM r-m-w cycles.
*/
gDPPipelineMode(glistp++, G_PM_1PRIMITIVE);
}
gSPDisplayList(glistp++, rdpinit_dl);
gSPDisplayList(glistp++, rspinit_dl);
/*
* If the rdp_regressionFlag is set, apply a 1/4 shrink to the
* viewport so that the tests will render more quickly (because they
* won't be as fill limited). Do this after we invoke the display
* list pointed to by setup_rspstate.
*/
if (rdp_regressionFlag) {
gSPDisplayList(glistp++, regression_viewport);
}
/*
* Determine 16/32 bit rendering, then issue the appropriate
* gsDPSetColorImage() calls. Width of Z buffer is determined
* by width of color frame buffer.
*/
gDPSetDepthImage( glistp++, APP_ZBUFFER );
gDPPipeSync(glistp++);
if ( pixSize == G_IM_SIZ_16b ) {
gDPSetColorImage( glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b,
SCREEN_WD, OS_K0_TO_PHYSICAL(cfb_16_a) );
} else if ( pixSize == G_IM_SIZ_32b ) {
gDPSetColorImage( glistp++, G_IM_FMT_RGBA, G_IM_SIZ_32b,
SCREEN_WD, OS_K0_TO_PHYSICAL(cfb_16_a) );
} else {
/*
* 1024 x 1024 framebuffer; we'll render in 32 bits.
*/
gDPSetColorImage( glistp++, G_IM_FMT_RGBA, G_IM_SIZ_32b,
1024, OS_K0_TO_PHYSICAL(cfb_16_a) );
}
gDPPipeSync(glistp++);
/* end of standard display list part. */
/*
* Build graphics task:
*/
tlistp->t.type = M_GFXTASK;
tlistp->t.flags = OS_TASK_DP_WAIT;
tlistp->t.ucode_boot = (u64 *) rspbootTextStart;
tlistp->t.ucode_boot_size = ((int)rspbootTextEnd -
(int)rspbootTextStart);
/*
* choose which ucode to run:
*/
if (rdp_DRAM_io) {
/* re-direct output to DRAM: */
if (uselines) {
tlistp->t.ucode = (u64 *) gspLine3D_dramTextStart;
tlistp->t.ucode_data = (u64 *) gspLine3D_dramDataStart;
} else {
tlistp->t.ucode = (u64 *) gspFast3D_dramTextStart;
tlistp->t.ucode_data = (u64 *) gspFast3D_dramDataStart;
}
} else {
/* RSP output over XBUS to RDP: */
if (uselines) {
tlistp->t.ucode = (u64 *) gspLine3DTextStart;
tlistp->t.ucode_data = (u64 *) gspLine3DDataStart;
} else {
tlistp->t.ucode = (u64 *) gspFast3DTextStart;
tlistp->t.ucode_data = (u64 *) gspFast3DDataStart;
}
}
tlistp->t.ucode_size = SP_UCODE_SIZE;
tlistp->t.ucode_data_size = SP_UCODE_DATA_SIZE;
tlistp->t.dram_stack = (u64 *) &(dram_stack[0]);
tlistp->t.dram_stack_size = SP_DRAM_STACK_SIZE8;
if (rdp_DRAM_io) {
tlistp->t.output_buff = (u64 *) &(rdp_output[0]);
tlistp->t.output_buff_size = (u64 *) &rdp_output_len;
} else {
tlistp->t.output_buff = (u64 *) 0x0;
tlistp->t.output_buff_size = (u64 *) 0x0;
}
/* initial display list: */
tlistp->t.data_ptr = (u64 *) dynamicp->glist;
tlistp->t.data_size = ((int)(glistp - dynamicp->glist) *
sizeof (Gfx));
tlistp->t.yield_data_ptr = (u64 *) NULL;
tlistp->t.yield_data_size = 0xDA0;
/*
* Render the display list stored in the dynamic segment.
*
* The top level DL driver routines in toplevel.c will decide
* whether to issue a FullSync or not depending on the value of
* generateFullSync.
*
* NOTE: this is done after setting up the task header so that
* the testcase procedure can modify the task list if neccessary
*/
(*(moduleTestSet[moduleNum].gfxTests[frameNum].toplevel_dl))
(dynamicp, (moduleTestSet[moduleNum].gfxTests[frameNum].gfx_dl));
/*
* Force top-level display list to have an END.
*/
gSPEndDisplayList(glistp++);
assert((glistp - dynamicp->glist) < MAX_GRAPHICS_SIZE);
/*
* Can just flush 16KB and forget about each individual pieces
* of data to flush.
*/
osWritebackDCacheAll();
/* unwrap this macro for debugging:
*
* osSpTaskStart(tlistp);
*
*/
osSpTaskLoad(tlistp);
osSpTaskStartGo(tlistp);
if (rdp_DRAM_io) {
/* wait for SP completion */
(void)osRecvMesg(&rspMessageQ, &dummyMessage, OS_MESG_BLOCK);
/*
* Wait for a vertical retrace to go by (Total hack, but necessary, as
* rdp_output_len is not updated properly unless we wait for a vertical,
* even though the SP interrupt has arrived). Maybe we need to flush
* a data cache?
*
* Make sure there isn't an old retrace in queue
* (assumes queue has a depth of 1) by checking to see if the
* MQ is full.
*/
if (MQ_IS_FULL(&retraceMessageQ))
/*
* Eat the old retrace message prior to the real wait below.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage,
OS_MESG_BLOCK);
/*
* Now really wait for vertical retrace to finish.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage,
OS_MESG_BLOCK);
/*
PRINTF("SP done: rdp_output_len = 0x%llx\n", rdp_output_len);
*/
guParseRdpDL(&(rdp_output[0]),rdp_output_len,
GU_PARSERDP_DUMPONLY);
dummy_val = osDpSetNextBuffer((void *)( &(rdp_output[0]) ),
(u32) rdp_output_len);
}
/*
* wait for DP completion, but only if this DL had a fullsync.
*/
if (generateFullSync == 1) {
(void)osRecvMesg(&rdpMessageQ, &dummyMessage,
OS_MESG_BLOCK);
}
/*
* Wait for a vertical retrace to go by.
*
* Make sure there isn't an old retrace in queue
* (assumes queue has a depth of 1) by checking to see if the
* MQ is full.
*/
if (MQ_IS_FULL(&retraceMessageQ))
/*
* Eat the old retrace message prior to the real wait below.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage,
OS_MESG_BLOCK);
/*
* Now really wait for vertical retrace to finish.
*/
(void)osRecvMesg(&retraceMessageQ, &dummyMessage,
OS_MESG_BLOCK);
}
lastFrameNum = frameNum;
#if 0
#define SEE_X 30
#define SEE_Y 40
{
u32 *fbp;
u16 *zbp;
int c;
fbp=(u32 *)cfb_16_a;
zbp=zbuffer;
fbp += (320*SEE_Y) + SEE_X;
zbp += (320*SEE_Y) + SEE_X;
for (c=0; c<270; c++){
PRINTF("%08x : %08x (%04x)-> %04x , %01x",(int)fbp,*fbp,*zbp,*zbp>>2,*zbp&0x3);
if (!(c%8)) PRINTF(" === %x",c/8);
PRINTF("\n");
fbp++;
zbp++;
}
}
while(1) PRINTF ("-\n");
#endif /* 0 */
computeChecksum(pixSize, moduleNum, frameNum);
if (frame_count > -1) {
if (rdp_DRAM_io) {
/*
* User has requested a DRAM dump of a particular frame.
* Clear the "keep_going" variable so that we will call
* osExit(), which will force gload to exit & flush all
* pending character I/O.
*/
keep_going = 0;
} else {
frameNum = controlFrame;
if ((frameNum < 0) || (frameNum >
moduleTestSet[moduleNum].testListCount - 1)) {
frameNum = 0;
controlFrame = 0;
}
}
}
}
}
/*
* This will cause gload to terminate, possibly ending our ascii dump of
* the rdp display list.
*/
if (rdp_DRAM_io) {
char String[128];
sprintf(String, "END DUMP\n");
guParseString(String, 128);
}
osExit();
}