/[pcsx2_0.9.7]/trunk/pcsx2/ps2/eeHwTraceLog.inl
ViewVC logotype

Contents of /trunk/pcsx2/ps2/eeHwTraceLog.inl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File size: 7319 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 #define eeAddrInRange(name, addr) \
19 (addr >= EEMemoryMap::name##_Start && addr < EEMemoryMap::name##_End)
20
21 static __ri bool _eelog_enabled( u32 addr )
22 {
23 // Selective enable/disable ability for specific register maps
24 if (eeAddrInRange(RCNT0, addr)) return false;
25 if (eeAddrInRange(RCNT1, addr)) return true;
26 if (eeAddrInRange(RCNT2, addr)) return true;
27 if (eeAddrInRange(RCNT3, addr)) return true;
28
29 if (eeAddrInRange(SBUS, addr)) return false;
30
31 // INTC!
32 if (addr == INTC_STAT || addr == INTC_MASK) return false;
33
34 return true;
35 }
36
37 template< typename T>
38 static __ri const char* _eelog_GetHwName( u32 addr, T val )
39 {
40 #define EasyCase(label) case label: return #label
41
42 switch( addr )
43 {
44 // Counters!
45 EasyCase(RCNT0_COUNT);
46 EasyCase(RCNT0_MODE);
47 EasyCase(RCNT0_TARGET);
48 EasyCase(RCNT0_HOLD);
49
50 EasyCase(RCNT1_COUNT);
51 EasyCase(RCNT1_MODE);
52 EasyCase(RCNT1_TARGET);
53 EasyCase(RCNT1_HOLD);
54
55 EasyCase(RCNT2_COUNT);
56 EasyCase(RCNT2_MODE);
57 EasyCase(RCNT2_TARGET);
58
59 EasyCase(RCNT3_COUNT);
60 EasyCase(RCNT3_MODE);
61 EasyCase(RCNT3_TARGET);
62
63 // IPU!
64 EasyCase(IPU_CMD);
65 EasyCase(IPU_CTRL);
66 EasyCase(IPU_BP);
67 EasyCase(IPU_TOP);
68
69 // GIF!
70 EasyCase(GIF_CTRL);
71 EasyCase(GIF_MODE);
72 EasyCase(GIF_STAT);
73 EasyCase(GIF_TAG0);
74 EasyCase(GIF_TAG1);
75 EasyCase(GIF_TAG2);
76 EasyCase(GIF_TAG3);
77 EasyCase(GIF_CNT);
78 EasyCase(GIF_P3CNT);
79 EasyCase(GIF_P3TAG);
80
81 // VIF!
82 EasyCase(VIF0_STAT);
83 EasyCase(VIF0_FBRST);
84 EasyCase(VIF0_ERR);
85 EasyCase(VIF0_MARK);
86 EasyCase(VIF0_CYCLE);
87 EasyCase(VIF0_MODE);
88 EasyCase(VIF0_NUM);
89 EasyCase(VIF0_MASK);
90 EasyCase(VIF0_CODE);
91 EasyCase(VIF0_ITOPS);
92 EasyCase(VIF0_ITOP);
93 EasyCase(VIF0_TOP);
94 EasyCase(VIF0_ROW0);
95 EasyCase(VIF0_ROW1);
96 EasyCase(VIF0_ROW2);
97 EasyCase(VIF0_ROW3);
98 EasyCase(VIF0_COL0);
99 EasyCase(VIF0_COL1);
100 EasyCase(VIF0_COL2);
101 EasyCase(VIF0_COL3);
102
103 EasyCase(VIF1_STAT);
104 EasyCase(VIF1_FBRST);
105 EasyCase(VIF1_ERR);
106 EasyCase(VIF1_MARK);
107 EasyCase(VIF1_CYCLE);
108 EasyCase(VIF1_MODE);
109 EasyCase(VIF1_NUM);
110 EasyCase(VIF1_MASK);
111 EasyCase(VIF1_CODE);
112 EasyCase(VIF1_ITOPS);
113 EasyCase(VIF1_BASE);
114 EasyCase(VIF1_OFST);
115 EasyCase(VIF1_TOPS);
116 EasyCase(VIF1_ITOP);
117 EasyCase(VIF1_TOP);
118 EasyCase(VIF1_ROW0);
119 EasyCase(VIF1_ROW1);
120 EasyCase(VIF1_ROW2);
121 EasyCase(VIF1_ROW3);
122 EasyCase(VIF1_COL0);
123 EasyCase(VIF1_COL1);
124 EasyCase(VIF1_COL2);
125 EasyCase(VIF1_COL3);
126
127 // VIF DMA!
128 EasyCase(VIF0_CHCR);
129 EasyCase(VIF0_MADR);
130 EasyCase(VIF0_QWC);
131 EasyCase(VIF0_TADR);
132 EasyCase(VIF0_ASR0);
133 EasyCase(VIF0_ASR1);
134
135 EasyCase(VIF1_CHCR);
136 EasyCase(VIF1_MADR);
137 EasyCase(VIF1_QWC);
138 EasyCase(VIF1_TADR);
139 EasyCase(VIF1_ASR0);
140 EasyCase(VIF1_ASR1);
141
142 // GIF DMA!
143 EasyCase(GIF_CHCR);
144 EasyCase(GIF_MADR);
145 EasyCase(GIF_QWC);
146 EasyCase(GIF_TADR);
147 EasyCase(GIF_ASR0);
148 EasyCase(GIF_ASR1);
149
150 // IPU DMA!
151 EasyCase(fromIPU_CHCR);
152 EasyCase(fromIPU_MADR);
153 EasyCase(fromIPU_QWC);
154 EasyCase(fromIPU_TADR);
155
156 EasyCase(toIPU_CHCR);
157 EasyCase(toIPU_MADR);
158 EasyCase(toIPU_QWC);
159 EasyCase(toIPU_TADR);
160
161 // SIF DMA!
162 EasyCase(SIF0_CHCR);
163 EasyCase(SIF0_MADR);
164 EasyCase(SIF0_QWC);
165
166 EasyCase(SIF1_CHCR);
167 EasyCase(SIF1_MADR);
168 EasyCase(SIF1_QWC);
169 EasyCase(SIF1_TADR);
170
171 EasyCase(SIF2_CHCR);
172 EasyCase(SIF2_MADR);
173 EasyCase(SIF2_QWC);
174
175 // Scratchpad DMA! (SPRdma)
176
177 EasyCase(fromSPR_CHCR);
178 EasyCase(fromSPR_MADR);
179 EasyCase(fromSPR_QWC);
180 EasyCase(fromSPR_SADR);
181
182 EasyCase(toSPR_CHCR);
183 EasyCase(toSPR_MADR);
184 EasyCase(toSPR_QWC);
185 EasyCase(toSPR_TADR);
186 EasyCase(toSPR_SADR);
187
188 // DMAC!
189 EasyCase(DMAC_CTRL);
190 EasyCase(DMAC_STAT);
191 EasyCase(DMAC_PCR);
192 EasyCase(DMAC_SQWC);
193 EasyCase(DMAC_RBSR);
194 EasyCase(DMAC_RBOR);
195 EasyCase(DMAC_STADR);
196 EasyCase(DMAC_ENABLER);
197 EasyCase(DMAC_ENABLEW);
198
199 // INTC!
200 EasyCase(INTC_STAT);
201 EasyCase(INTC_MASK);
202
203 // SIO
204 EasyCase(SIO_LCR);
205 EasyCase(SIO_LSR);
206 EasyCase(SIO_IER);
207 EasyCase(SIO_ISR);
208 EasyCase(SIO_FCR);
209 EasyCase(SIO_BGR);
210 EasyCase(SIO_TXFIFO);
211 EasyCase(SIO_RXFIFO);
212
213 // SBUS (terribly mysterious!)
214 EasyCase(SBUS_F200);
215 EasyCase(SBUS_F210);
216 EasyCase(SBUS_F220);
217 EasyCase(SBUS_F230);
218 EasyCase(SBUS_F240);
219 EasyCase(SBUS_F250);
220 EasyCase(SBUS_F260);
221
222 // MCH (vaguely mysterious!)
223 EasyCase(MCH_RICM);
224 EasyCase(MCH_DRD);
225 }
226
227 #define EasyZone(zone) \
228 if ((addr >= EEMemoryMap::zone##_Start) && (addr < EEMemoryMap::zone##_End)) return #zone
229
230 #define EasyZoneR(zone) \
231 EasyZone(zone) "_reserved"
232
233 // Nothing discovered/handled : Check for "zoned" registers -- registers mirrored
234 // across large sections of memory (FIFOs mainly).
235
236 EasyZone(VIF0_FIFO); EasyZone(VIF1_FIFO); EasyZone(GIF_FIFO);
237
238 if( (addr >= EEMemoryMap::IPU_FIFO_Start) && (addr < EEMemoryMap::IPU_FIFO_End) )
239 {
240 return (addr & 0x10) ? "IPUin_FIFO" : "IPUout_FIFO";
241 }
242
243 // Check for "reserved" regions -- registers that most likely discard writes and
244 // return 0 when read. To assist in having useful logs, we determine the general
245 // "zone" of the register address and return the zone name in the unknown string.
246
247 EasyZoneR(RCNT0); EasyZoneR(RCNT1);
248 EasyZoneR(RCNT2); EasyZoneR(RCNT3);
249
250 EasyZoneR(IPU); EasyZoneR(GIF);
251 EasyZoneR(VIF0); EasyZoneR(VIF1);
252 EasyZoneR(VIF0dma); EasyZoneR(VIF1dma);
253 EasyZoneR(GIFdma); EasyZoneR(fromIPU); EasyZoneR(toIPU);
254 EasyZoneR(SIF0dma); EasyZoneR(SIF1dma); EasyZoneR(SIF2dma);
255 EasyZoneR(fromSPR); EasyZoneR(toSPR);
256
257 EasyZoneR(DMAC); EasyZoneR(INTC);
258 EasyZoneR(SIO); EasyZoneR(SBUS);
259 EasyZoneR(MCH); EasyZoneR(DMACext);
260
261 // If we get this far it's an *unknown* register; plain and simple.
262
263 return NULL; //"Unknown";
264 }
265
266 template< typename T>
267 static __ri void eeHwTraceLog( u32 addr, T val, bool mode )
268 {
269 if (!IsDevBuild) return;
270 if (!EmuConfig.Trace.Enabled || !EmuConfig.Trace.EE.m_EnableAll || !EmuConfig.Trace.EE.m_EnableRegisters) return;
271 if (!_eelog_enabled(addr)) return;
272
273 FastFormatAscii valStr;
274 FastFormatAscii labelStr;
275 labelStr.Write("Hw%s%u", mode ? "Read" : "Write", sizeof (T) * 8);
276
277 switch( sizeof(T) )
278 {
279 case 1: valStr.Write("0x%02x", val); break;
280 case 2: valStr.Write("0x%04x", val); break;
281 case 4: valStr.Write("0x%08x", val); break;
282
283 case 8: valStr.Write("0x%08x.%08x", ((u32*)&val)[1], ((u32*)&val)[0]); break;
284 case 16: ((u128&)val).WriteTo(valStr);
285 }
286
287 static const char* temp = "%-12s @ 0x%08X/%-16s %s %s";
288
289 if( const char* regname = _eelog_GetHwName<T>( addr, val ) )
290 HW_LOG( temp, labelStr.c_str(), addr, regname, mode ? "->" : "<-", valStr.c_str() );
291 else
292 UnknownHW_LOG( temp, labelStr.c_str(), addr, "Unknown", mode ? "->" : "<-", valStr.c_str() );
293 }

  ViewVC Help
Powered by ViewVC 1.1.22