PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
iop_regs.h
Go to the documentation of this file.
1
6#ifndef __IOP_REGS_H__
7#define __IOP_REGS_H__
8
9#include <tamtypes.h>
10
11#define A_IOP_SIF0_HANDLER ((vu32 *)(0x000003C0))
12#define A_IOP_SIF1_HANDLER ((vu32 *)(0x000003D0))
13#define A_IOP_SIF2_HANDLER ((vu32 *)(0x000003E0))
14
15#define M_reg8(___base, ___reg_num) ((vu8 *)(___base + (___reg_num)))
16
18#define R_CDVD_N_CMD M_reg8(A_CDVD_REG_BASE, 0x04)
19
34#define R_CDVD_N_CMD_STATUS M_reg8(A_CDVD_REG_BASE, 0x05)
35#define R_CDVD_N_CMD_PARAM_FIFO M_reg8(A_CDVD_REG_BASE, 0x05)
36
37#define R_CDVD_LAST_ERROR M_reg8(A_CDVD_REG_BASE, 0x06)
38
39// 0x01 is written to this register to cause a "break" to occur, along with an interrupt.
40#define R_CDVD_REG07 M_reg8(A_CDVD_REG_BASE, 0x07)
41
42/* TRAY_STAT is read to get the status of the drive tray.
43 * Tray status:
44 * bit explaination
45 * --- ------------
46 * 0 Tray Open(1 if tray is open, 0 if closed)
47 * 1-7 Unknown
48 */
49#define R_CDVD_TRAY_STATUS M_reg8(A_CDVD_REG_BASE, 0x0A)
50
52#define CDVD_TRAY_STAT_OPEN (1 << 0)
53
54#define R_CDVD_DISK_TYPE M_reg8(A_CDVD_REG_BASE, 0x0F)
55
60#define R_CDVD_S_CMD M_reg8(A_CDVD_REG_BASE, 0x16)
61
62/* CDVD Register 0x17 is written to add a parameter to the S-command param FIFO
63 * and read to determine command status.
64 * Command status:
65 * bit explaination
66 * --- ------------
67 * 0 Unknown
68 * 1 Unknown
69 * 2 Unknown
70 * 3 Unknown
71 * 4 Unknown
72 * 5 Unknown
73 * 6 result FIFO empty(0 = result in FIFO, 1 = result FIFO is empty)
74 * 7 busy(1 if currently processing a command)
75 */
76#define R_CDVD_S_STATUS M_reg8(A_CDVD_REG_BASE, 0x17)
77#define R_CDVD_S_PARAM_FIFO M_reg8(A_CDVD_REG_BASE, 0x17)
78
79#define CDVD_S_STAT_RFIFO_EMPTY (1 << 6)
80#define CDVD_S_STAT_BUSY (1 << 7)
81
83#define R_CDVD_S_RES_FIFO M_reg8(A_CDVD_REG_BASE, 0x18)
84
85#define R_CDVD_KEY_DATA0 M_reg8(A_CDVD_REG_BASE, 0x20)
86#define R_CDVD_KEY_DATA1 M_reg8(A_CDVD_REG_BASE, 0x21)
87#define R_CDVD_KEY_DATA2 M_reg8(A_CDVD_REG_BASE, 0x22)
88#define R_CDVD_KEY_DATA3 M_reg8(A_CDVD_REG_BASE, 0x23)
89#define R_CDVD_KEY_DATA4 M_reg8(A_CDVD_REG_BASE, 0x24)
90
91#define R_CDVD_KEY_DATA5 M_reg8(A_CDVD_REG_BASE, 0x28)
92#define R_CDVD_KEY_DATA6 M_reg8(A_CDVD_REG_BASE, 0x29)
93#define R_CDVD_KEY_DATA7 M_reg8(A_CDVD_REG_BASE, 0x2A)
94#define R_CDVD_KEY_DATA8 M_reg8(A_CDVD_REG_BASE, 0x2B)
95#define R_CDVD_KEY_DATA9 M_reg8(A_CDVD_REG_BASE, 0x2C)
96
97#define R_CDVD_KEY_DATAA M_reg8(A_CDVD_REG_BASE, 0x30)
98#define R_CDVD_KEY_DATAB M_reg8(A_CDVD_REG_BASE, 0x31)
99#define R_CDVD_KEY_DATAC M_reg8(A_CDVD_REG_BASE, 0x32)
100#define R_CDVD_KEY_DATAD M_reg8(A_CDVD_REG_BASE, 0x33)
101#define R_CDVD_KEY_DATAE M_reg8(A_CDVD_REG_BASE, 0x34)
102
107#define R_CDVD_KEY_FLAGS M_reg8(A_CDVD_REG_BASE, 0x38)
108
112#define R_CDVD_KEY_XOR M_reg8(A_CDVD_REG_BASE, 0x39)
113
124#define R_CDVD_DEC_CTRL M_reg8(A_CDVD_REG_BASE, 0x3A)
125
126// bits for CDVD_DEC_CTRL(bits 4-7 are "rotate left number")
127#define CDVD_DEC_XOR_EN (1 << 0)
128#define CDVD_DEC_ROTL_EN (1 << 1)
129#define CDVD_DEC_UNK_EN (1 << 2)
130#define CDVD_DEC_SWAP_EN (1 << 3)
131
132
133#define A_IOP_IRQ_CTRL 0xBF801450
134#define A_IOP_REG_1454 0xBF801454
135
137#define A_PS1_1F801018 0x1F801018
138
140#define A_PS1_1F801020 0x1F801020
141
142
143#define A_PS1_SIO0_DATA 0x1F801040
144#define A_PS1_SIO0_STAT 0x1F801044
145#define A_PS1_SIO0_MODE 0x1F801048
146#define A_PS1_SIO0_CTRL 0x1F80104A
147#define A_PS1_SIO0_BAUD 0x1F80104E
148
149#define A_PS1_SIO1_DATA 0x1F801050
150#define A_PS1_SIO1_STAT 0x1F801054
151#define A_PS1_SIO1_MODE 0x1F801058
152#define A_PS1_SIO1_CTRL 0x1F80105A
153#define A_PS1_SIO1_BAUD 0x1F80105E
154
155#define A_PS1_RAM_SIZE 0x1F801060
156
157#define A_IOP_I_STAT 0xBF801070
158#define A_IOP_I_MASK 0xBF801074
159
160#define A_IOP_IREG_1078 0xBF801078
161#define A_IOP_IREG_107C 0xBF80107C
162
163#define A_IOP_D0_MADR 0xBF801080
164#define A_IOP_D0_BCR 0xBF801084
165#define A_IOP_D0_CHCR 0xBF801088
166
167#define A_IOP_D1_MADR 0xBF801090
168#define A_IOP_D1_BCR 0xBF801094
169#define A_IOP_D1_CHCR 0xBF801098
170
171#define A_IOP_D2_MADR 0xBF8010A0
172#define A_IOP_D2_BCR 0xBF8010A4
173#define A_IOP_D2_CHCR 0xBF8010A8
174
175#define A_IOP_D3_MADR 0xBF8010B0
176#define A_IOP_D3_BCR 0xBF8010B4
177#define A_IOP_D3_CHCR 0xBF8010B8
178
179#define A_IOP_D4_MADR 0xBF8010C0
180#define A_IOP_D4_BCR 0xBF8010C4
181#define A_IOP_D4_CHCR 0xBF8010C8
182#define A_IOP_D4_TADR 0xBF8010CC
183
184#define A_IOP_D5_MADR 0xBF8010D0
185#define A_IOP_D5_BCR 0xBF8010D4
186#define A_IOP_D5_CHCR 0xBF8010D8
187
188#define A_IOP_D6_MADR 0xBF8010E0
189#define A_IOP_D6_BCR 0xBF8010E4
190#define A_IOP_D6_CHCR 0xBF8010E8
191
192#define A_IOP_SIF_1450 0xBF801450
193#define A_IOP_SIF_1454 0xBF801454
194
195#define A_IOP_BF80146E 0xBF80146E
196#define A_IOP_BF801470 0xBF801470
197#define A_IOP_BF801472 0xBF801472
198
199#define A_IOP_D7_MADR 0xBF801500
200#define A_IOP_D7_BCR 0xBF801504
201#define A_IOP_D7_CHCR 0xBF801508
202
203#define A_IOP_D8_MADR 0xBF801510
204#define A_IOP_D8_BCR 0xBF801514
205#define A_IOP_D8_CHCR 0xBF801518
206
207#define A_IOP_D9_MADR 0xBF801520
208#define A_IOP_D9_BCR 0xBF801524
209#define A_IOP_D9_CHCR 0xBF801528
210#define A_IOP_D9_TADR 0xBF80152C
211
212#define A_IOP_D10_MADR 0xBF801530
213#define A_IOP_D10_BCR 0xBF801534
214#define A_IOP_D10_CHCR 0xBF801538
215
216#define A_IOP_D11_MADR 0xBF801540
217#define A_IOP_D11_BCR 0xBF801544
218#define A_IOP_D11_CHCR 0xBF801548
219
220#define A_IOP_D12_MADR 0xBF801550
221#define A_IOP_D12_BCR 0xBF801554
222#define A_IOP_D12_CHCR 0xBF801558
223
224#define A_IOP_DMAC_1560 0xBF801560
225#define A_IOP_DMAC_1564 0xBF801564
226#define A_IOP_DMAC_1568 0xBF801568
227
228#define A_IOP_DPCR 0xBF8010F0
229#define A_IOP_DPCR2 0xBF801570
230#define A_IOP_DPCR3 0xBF8015F0
231
232#define A_IOP_DICR 0xBF8010F4
233#define A_IOP_DICR2 0xBF801574
234#define A_IOP_DICR3 0xBF80157C
235
236#define A_IOP_DMAC_1578 0xBF801578
237
238#define A_PS1_CD_REG0 0x1F801800
239#define A_PS1_CD_REG1 0x1F801801
240#define A_PS1_CD_REG2 0x1F801802
241#define A_PS1_CD_REG3 0x1F801803
242
243#define A_IOP_GPU_DATA 0x1F801810
244#define A_IOP_GPU_CTRL 0x1F801814
245
246// $1f801c00-$1f801dff
247#define A_IOP_SPU1_BASE 0x1F801C00
248
249#define A_IOP_UNK_2070 0xBF802070
250
251#define A_IOP_BF803200 0xBF803200
252#define A_IOP_BF803204 0xBF803204
253#define A_IOP_BF803218 0xBF803218
254#define A_IOP_BF808400 0xBF808400
255#define A_IOP_BF808414 0xBF808414
256#define A_IOP_BF80844C 0xBF80844C
257#define A_IOP_BF808420 0xBF808420
258#define A_IOP_BF808428 0xBF808428
259#define A_IOP_BF808430 0xBF808430
260#define A_IOP_BF80847C 0xBF80847C
261
262#define A_IOP_SBUS_REG_BASE 0xBD000000
263
264// Register pointer definitions
265
266// IOP/EE IRQ control?
267#define R_IOP_IRQ_CTRL ((vu32 *)(A_IOP_IRQ_CTRL))
268
269// ??? related to IOP/EE communication?
270#define R_IOP_REG_1454 ((vu32 *)(A_IOP_REG_1454))
271
272// PS1 SIO0(pad/card slots) All 16-bit?
273#define R_PS1_SIO0_DATA ((vu16 *)(A_PS1_SIO0_DATA))
274#define R_PS1_SIO0_STAT ((vu16 *)(A_PS1_SIO0_STAT))
275#define R_PS1_SIO0_MODE ((vu16 *)(A_PS1_SIO0_MODE))
276#define R_PS1_SIO0_CTRL ((vu16 *)(A_PS1_SIO0_CTRL))
277#define R_PS1_SIO0_BAUD ((vu16 *)(A_PS1_SIO0_BAUD))
278
279// PS1 SIO1(serial port) All 16-bit?
280// note: these are just duplicated from SIO0 infos!
281#define R_PS1_SIO1_DATA ((vu16 *)(A_PS1_SIO1_DATA))
282#define R_PS1_SIO1_STAT ((vu16 *)(A_PS1_SIO1_STAT))
283#define R_PS1_SIO1_MODE ((vu16 *)(A_PS1_SIO1_MODE))
284#define R_PS1_SIO1_CTRL ((vu16 *)(A_PS1_SIO1_CTRL))
285#define R_PS1_SIO1_BAUD ((vu16 *)(A_PS1_SIO1_BAUD))
286
287// ??
288#define R_PS1_RAM_SIZE ((vu32 *)(A_PS1_RAM_SIZE))
289
290#define R_IOP_I_STAT ((vu32 *)(A_IOP_I_STAT))
291#define R_IOP_I_MASK ((vu32 *)(A_IOP_I_MASK))
292
293// unknown functions, likely interrupt/dma related.
294#define R_IOP_IREG_1078 ((vu32 *)(A_IOP_IREG_1078))
295#define R_IOP_IREG_107C ((vu32 *)(A_IOP_IREG_107C))
296
297// IOP DMAC Registers
298#define R_IOP_D0_MADR ((vu32 *)(A_IOP_D0_MADR))
299#define R_IOP_D0_BCR ((vu32 *)(A_IOP_D0_BCR))
300#define R_IOP_D0_CHCR ((vu32 *)(A_IOP_D0_CHCR))
301
302#define R_IOP_D1_MADR ((vu32 *)(A_IOP_D1_MADR))
303#define R_IOP_D1_BCR ((vu32 *)(A_IOP_D1_BCR))
304#define R_IOP_D1_CHCR ((vu32 *)(A_IOP_D1_CHCR))
305
306#define R_IOP_D2_MADR ((vu32 *)(A_IOP_D2_MADR))
307#define R_IOP_D2_BCR ((vu32 *)(A_IOP_D2_BCR))
308#define R_IOP_D2_BCR_BS ((vu16 *)(A_IOP_D2_BCR + 0x00))
309#define R_IOP_D2_BCR_BC ((vu16 *)(A_IOP_D2_BCR + 0x02))
310#define R_IOP_D2_CHCR ((vu32 *)(A_IOP_D2_CHCR))
311
312#define R_IOP_D3_MADR ((vu32 *)(A_IOP_D3_MADR))
313#define R_IOP_D3_BCR ((vu32 *)(A_IOP_D3_BCR))
314#define R_IOP_D3_CHCR ((vu32 *)(A_IOP_D3_CHCR))
315
316#define R_IOP_D4_MADR ((vu32 *)(A_IOP_D4_MADR))
317#define R_IOP_D4_BCR ((vu32 *)(A_IOP_D4_BCR))
318#define R_IOP_D4_CHCR ((vu32 *)(A_IOP_D4_CHCR))
319#define R_IOP_D4_TADR ((vu32 *)(A_IOP_D4_TADR))
320
321#define R_IOP_D5_MADR ((vu32 *)(A_IOP_D5_MADR))
322#define R_IOP_D5_BCR ((vu32 *)(A_IOP_D5_BCR))
323#define R_IOP_D5_CHCR ((vu32 *)(A_IOP_D5_CHCR))
324
325#define R_IOP_D6_MADR ((vu32 *)(A_IOP_D6_MADR))
326#define R_IOP_D6_BCR ((vu32 *)(A_IOP_D6_BCR))
327#define R_IOP_D6_CHCR ((vu32 *)(A_IOP_D6_CHCR))
328
329#define R_IOP_D7_MADR ((vu32 *)(A_IOP_D7_MADR))
330#define R_IOP_D7_BCR ((vu32 *)(A_IOP_D7_BCR))
331#define R_IOP_D7_CHCR ((vu32 *)(A_IOP_D7_CHCR))
332
333#define R_IOP_D8_MADR ((vu32 *)(A_IOP_D8_MADR))
334#define R_IOP_D8_BCR ((vu32 *)(A_IOP_D8_BCR))
335#define R_IOP_D8_CHCR ((vu32 *)(A_IOP_D8_CHCR))
336
337#define R_IOP_D9_MADR ((vu32 *)(A_IOP_D9_MADR))
338#define R_IOP_D9_BCR ((vu32 *)(A_IOP_D9_BCR))
339#define R_IOP_D9_CHCR ((vu32 *)(A_IOP_D9_CHCR))
340#define R_IOP_D9_TADR ((vu32 *)(A_IOP_D9_TADR))
341
342#define R_IOP_D10_MADR ((vu32 *)(A_IOP_D10_MADR))
343#define R_IOP_D10_BCR ((vu32 *)(A_IOP_D10_BCR))
344#define R_IOP_D10_CHCR ((vu32 *)(A_IOP_D10_CHCR))
345
346#define R_IOP_D11_MADR ((vu32 *)(A_IOP_D11_MADR))
347#define R_IOP_D11_BCR ((vu32 *)(A_IOP_D11_BCR))
348#define R_IOP_D11_CHCR ((vu32 *)(A_IOP_D11_CHCR))
349
350#define R_IOP_D12_MADR ((vu32 *)(A_IOP_D12_MADR))
351#define R_IOP_D12_BCR ((vu32 *)(A_IOP_D12_BCR))
352#define R_IOP_D12_CHCR ((vu32 *)(A_IOP_D12_CHCR))
353
354// These are some type of extended DMA control/address
355// Reg 1560 is for SIF0(CH9), 1564 is for SIF1(CH10) and 1568 is for "SPU"(CH4) though "SPU" seems odd, perhaps SIF2??
356#define R_IOP_DMAC_1560 ((vu32 *)(A_IOP_DMAC_1560))
357#define R_IOP_DMAC_1564 ((vu32 *)(A_IOP_DMAC_1564))
358#define R_IOP_DMAC_1568 ((vu32 *)(A_IOP_DMAC_1568))
359
360#define R_IOP_DPCR ((vu32 *)(A_IOP_DPCR))
361#define R_IOP_DPCR2 ((vu32 *)(A_IOP_DPCR2))
362#define R_IOP_DPCR3 ((vu32 *)(A_IOP_DPCR3))
363
364#define R_IOP_DICR ((vu32 *)(A_IOP_DICR))
365#define R_IOP_DICR2 ((vu32 *)(A_IOP_DICR2))
366#define R_IOP_DICR3 ((vu32 *)(A_IOP_DICR3))
367
369#define R_IOP_DMAC_1578 ((vu32 *)(A_IOP_DMAC_1578))
370
371// SIF/SBUS
372
373#define R_IOP_SIF_1450 ((vu32 *)(A_IOP_SIF_1450))
374#define R_IOP_SIF_1454 ((vu32 *)(A_IOP_SIF_1454))
375
376
377
378#define R_PS1_CD_REG0 ((vu8 *)(A_PS1_CD_REG0))
379#define R_PS1_CD_REG1 ((vu8 *)(A_PS1_CD_REG1))
380#define R_PS1_CD_REG2 ((vu8 *)(A_PS1_CD_REG2))
381#define R_PS1_CD_REG3 ((vu8 *)(A_PS1_CD_REG3))
382
383#define R_IOP_GPU_DATA ((vu32 *)(A_IOP_GPU_DATA))
384#define R_IOP_GPU_CTRL ((vu32 *)(A_IOP_GPU_CTRL))
385
386#define R_IOP_UNK_2070 ((vu32 *)(A_IOP_UNK_2070))
387
389#define R_IOP_SBUS_REG_BASE ((vu32 *)(A_IOP_SBUS_REG_BASE))
390
391// Accessed by EECONF.IRX:
392
393// accessed as 8-bit
394#define R_IOP_BF80146E ((vu8 *)(A_IOP_BF80146E))
395
396// accessed as 16-bit
397#define R_IOP_BF801470 ((vu16 *)(A_IOP_BF801470))
398#define R_IOP_BF801472 ((vu16 *)(A_IOP_BF801472))
399
400// accessed as 8-bit
401#define R_IOP_BF803200 ((vu8 *)(A_IOP_BF803200))
402#define R_IOP_BF803204 ((vu8 *)(A_IOP_BF803204))
403#define R_IOP_BF803218 ((vu8 *)(A_IOP_BF803218))
404
405// 32-bit??
406#define R_IOP_BF808400 ((vu32 *)(A_IOP_BF808400))
407#define R_IOP_BF808414 ((vu32 *)(A_IOP_BF808414))
408#define R_IOP_BF80844C ((vu32 *)(A_IOP_BF80844C))
409#define R_IOP_BF808420 ((vu32 *)(A_IOP_BF808420))
410#define R_IOP_BF808428 ((vu32 *)(A_IOP_BF808428))
411#define R_IOP_BF808430 ((vu32 *)(A_IOP_BF808430))
412#define R_IOP_BF80847C ((vu32 *)(A_IOP_BF80847C))
413
415#define IOP_CHCR_30 (1 << 30)
416
418#define IOP_CHCR_TR (1 << 24)
419
421#define IOP_CHCR_LI (1 << 10)
422
424#define IOP_CHCR_CO (1 << 9)
425
426// Unknown
427#define IOP_CHCR_08 (1 << 8)
428
430#define IOP_CHCR_DR (1 << 0)
431
432#define IOP_TO_MEM 0
433#define IOP_FROM_MEM 1
434
435#define IOP_I_STAT_VB (1 << 0)
436#define IOP_I_STAT_SBUS (1 << 1)
437
438//Borrowed from XPARAM patch applier by krat0s
439//Bit 31 of GM_IF is for the IOP type.
440#define GM_IF ((vu32 *)0x1F801450)
441#define GM_IOP_TYPE (0x80000000)
442
443#define IOP_CPU_TYPE (*GM_IF & GM_IOP_TYPE)
444#define IOP_TYPE_MIPSR3000 0
445#define IOP_TYPE_POWERPC 1
446
447#endif /* __IOP_REGS_H__ */