dump_gbi.c
6.46 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
/**************************************************************************
* *
* Copyright (C) 1994, 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. *
* *
*************************************************************************/
/*
* Interpret Task with GBI display list and dump it for debugging.
*/
/**************************************************
*
* guDumpGbiDL no longer supported
* applications should use guParseGbiDL with the
* GU_PARSEGBI_DUMPONLY flag set.
*
**************************************************/
#if 0
#include "ultra64.h"
#include "bstring.h"
#undef PRINTF
#define PRINTF osSyncPrintf
#define DL_STACKSIZE 11
static u32 *Gp[DL_STACKSIZE];
#define TX_MAX 100
static u32 textures[TX_MAX];
static u32 numtextures;
static u32 segment_base[16];
static u32 dotextures = TRUE;
static int dl_depth = 0;
/*
* dump a DMA-type display list command.
*/
static void
dump_dma(u32 *bufp)
{
u32 addr,
*data;
u8 seg_id;
u16 len;
char op,
b0;
op = ((*bufp & 0xff000000) >> 24);
/*
* DMA op addressing is all the same:
*/
seg_id = (u8) ((bufp[1] & 0x0f000000) >> 24);
addr = segment_base[seg_id] + (bufp[1] & 0x00ffffff);
addr = (u32) osPhysicalToVirtual(addr);
len = (u16) (bufp[0] & 0x0000ffff);
PRINTF(">%08x\n-%08x\n", bufp[0], bufp[1]);
if (op == (char) G_DL) {
b0 = (char) ((bufp[0] & 0x00ff0000) >> 16);
++dl_depth;
if (dl_depth > (DL_STACKSIZE - 1)) {
PRINTF("***** Error, max levels of display lists exceeded\n");
return;
}
Gp[dl_depth] = (u32 *) addr;
PRINTF("@ %08x\n",(int)Gp[dl_depth]&0x7fffffff);
} else {
PRINTF("& %08x\n", (int)addr&0x7fffffff);
data = (u32 *) addr;
while(len>0) {
PRINTF("+%08x\n", *data);
data++;
len -= 4;
}
PRINTF("@ %08x\n",(int)(Gp[dl_depth] + (sizeof(Gfx) >> 2))&0x7fffffff);
}
}
/*
* dump a IMM-type display list command.
*/
static void
dump_imm(u32 *bufp)
{
char op,
b0;
op = ((*bufp & 0xff000000) >> 24);
PRINTF(">%08x\n-%08x\n", bufp[0], bufp[1]);
if (op == (char) G_ENDDL) {
dl_depth--;
if (dl_depth >= 0) {
PRINTF("@ %08x\n",(int)(Gp[dl_depth] + (sizeof(Gfx) >> 2))&0x7fffffff);
}
}
if (op == (char) G_MOVEWORD) {
if (((bufp[0] ) & 0xff) == G_MW_SEGMENT) {
b0 = (char) ((bufp[0] & 0xff00)>>10);
segment_base[b0] = bufp[1] & 0x00ffffff;
}
}
}
/*
* dump a RDP-type display list command.
*/
static void
dump_rdp(u32 *bufp)
{
u8 seg_id;
u32 addr;
int i0,
i1;
char op;
op = ((*bufp & 0xff000000) >> 24);
PRINTF(">%08x\n-%08x\n", bufp[0], bufp[1]);
if (op == (char) G_SETTIMG && dotextures) {
if (numtextures>=TX_MAX) {
PRINTF("GBI DUMP ERROR: too many textures (max=%d)\n",TX_MAX);
return;
}
seg_id = (u8) ((bufp[1] & 0x0f000000) >> 24);
addr = segment_base[seg_id] + (bufp[1] & 0x00ffffff);
addr = (u32) osPhysicalToVirtual(addr);
i1=1;
for (i0=0;i0<numtextures;i0++)
if (textures[i0] == addr) i1=0;
if (i1) textures[numtextures++]=addr;
}
}
/*
* Takes a pointer in DRAM, and a length in bytes. Dumps
* the display list, until a G_ENDDL command is found.
*/
static void
guDumpGbi(u32 *gfxp)
{
u8 op;
u32 readBuf[4];
Gp[dl_depth] = gfxp;
numtextures=0;
PRINTF("@ %08x\n",(int)Gp[dl_depth]&0x7fffffff);
while ((dl_depth >= 0) && (dl_depth < (DL_STACKSIZE - 1))) {
op = (u8) ((*Gp[dl_depth] & 0xff000000) >> 24);
bcopy((char *) Gp[dl_depth], (char *) &(readBuf[0]), sizeof(Gfx));
switch (op & 0xc0) {
case (u8) 0x00:
dump_dma(readBuf);
break;
case (u8) 0x80:
dump_imm(readBuf);
break;
case (u8) 0xc0:
dump_rdp(readBuf);
break;
default:
PRINTF("ERROR : display list is lost, op = %02x\n", op);
break;
}
if (op != (u8) G_DL) {
Gp[dl_depth] += (sizeof(Gfx) >> 2);
}
}
if (dotextures) {
u32 i,j;
for (i=0; i<numtextures; i++) {
PRINTF("%% %08x\n",textures[i]&0x7fffffff);
for (j=textures[i]; j<textures[i]+0x400; j+=4) {
PRINTF("*%08x\n",(int) *((u32 *) j));
}
}
}
}
#define UCODE_SIZE_MAX (4096*3)
void
guDumpGbiDL(OSTask *tp,u8 flags)
{
int i;
if (flags & GU_PARSEGBI_NOTEXTURES) dotextures=0;
PRINTF("\nGBI_DUMP_START:\n");
PRINTF("$ %08x\n",(int) tp & 0x7fffffff);
for (i=(int)tp; i<(int)tp+sizeof(OSTask); i+=4) {
PRINTF("<%08x\n",(int) *((u32 *) i));
}
PRINTF("? %08x\n",(int) tp->t.ucode_boot & 0x7fffffff);
for (i=(int)tp->t.ucode_boot; i<(int)tp->t.ucode_boot+tp->t.ucode_boot_size; i+=4) {
PRINTF("|%08x\n",(int) *((u32 *) i));
}
PRINTF("? %08x\n",(int) tp->t.ucode& 0x7fffffff);
for (i=(int)tp->t.ucode; i<(int)tp->t.ucode+UCODE_SIZE_MAX; i+=4) {
PRINTF("|%08x\n",(int) *((u32 *) i));
}
PRINTF("? %08x\n",(int) tp->t.ucode_data & 0x7fffffff);
for (i=(int)tp->t.ucode_data; i<(int)tp->t.ucode_data+tp->t.ucode_data_size; i+=4) {
PRINTF("|%08x\n",(int) *((u32 *) i));
}
guDumpGbi((u32 *) tp->t.data_ptr);
PRINTF("^\nGBI_DUMP_END:\n");
if (flags & GU_PARSEGBI_HANGAFTER) {
int i;
for (i=0; i<1000;i++)
PRINTF("=============================================================\n");
while(1);
}
/*
* Dumps stuff
* each line is either an address for data to follow or data itself
* 1st char on line indicates what it is:
*
* $ task header address
* @ display list address
* & dma data address
* % texture address
* ? code/code data address
*
* < task header data
* > 1st half of display list command
* - 2nd half of display list command
* + dma data
* * texture data
* | code/code data
*
*/
}
#endif