Contents |
PS2 Overview |
Emotion Engine (EE) - Main CPU. DMAC - Intelligent DMA controller. Used for accessing most peripherals on the EE. EE Timers - Four 16-bit timers. Graphics Interface (GIF) - Transmits graphical data to the GS. Vector Interface (VIF) - Decompresses vector data, uploads microprograms to the VUs, and sends graphical data to the GIF. Vector Units (VUs) - Custom DSPs used to process vertex data, physics calculations, and other related tasks. Image Processing Unit (IPU) - MPEG1/MPEG2 video decoder. Scratchpad - 16 KB of fast memory. Graphics Synthesizer (GS) - Fixed-function GPU. Designed to draw polygons very, very fast. PCRTC - Renders GS output to a television screen. Can be programmed to work on a variety of TVs, including NTSC and PAL. Input/Output Processor (IOP) - Duplicate of the PSX's CPU. Used for slower input/output tasks and for PSX backwards compatibility. IOP DMA - Same channels as on the PSX, along with additional channels exclusive to PS2 mode. IOP Timers - Same timers as on the PSX, with three additional 32-bit counters. CDVD Drive - Reads disc media. Also responsible for MagicGate decryption. SIO2 - Serial ports used to read controllers and memory cards. SPU2 - Sound processor. Similar to the PSX SPU with added features. DEV9 - Expansion port. Used mainly for the PS2 HDD and Network Adapter. USB FireWire Subsystem Interface (SIF) - Allows the EE and IOP to communicate with each other. |
Memory Map |
KUSEG: 00000000h-7FFFFFFFh User segment KSEG0: 80000000h-9FFFFFFFh Kernel segment 0 KSEG1: A0000000h-BFFFFFFFh Kernel segment 1 KSSEG: C0000000h-DFFFFFFFh Supervisor segment KSEG3: E0000000h-FFFFFFFFh Kernel segment 3 Virtual Physical 00000000h 00000000h 32 MB Main RAM (first 1 MB reserved for kernel) 20000000h 00000000h 32 MB Main RAM, uncached 30100000h 00100000h 31 MB Main RAM, uncached and accelerated 10000000h 10000000h 64 KB I/O registers 11000000h 11000000h 4 KB VU0 code memory 11004000h 11004000h 4 KB VU0 data memory 11008000h 11008000h 16 KB VU1 code memory 1100C000h 1100C000h 16 KB VU1 data memory 12000000h 12000000h 8 KB GS privileged registers 1C000000h 1C000000h 2 MB IOP RAM 1FC00000h 1FC00000h 4 MB BIOS, uncached (rom0) 9FC00000h 1FC00000h 4 MB BIOS, cached (rom09) BFC00000h 1FC00000h 4 MB BIOS, uncached (rom0b) 70000000h --------- 16 KB Scratchpad RAM (only accessible via virtual addressing) |
KUSEG: 00000000h-7FFFFFFFh User segment KSEG0: 80000000h-9FFFFFFFh Kernel segment 0 KSEG1: A0000000h-BFFFFFFFh Kernel segment 1 Physical 00000000h 2 MB Main RAM (same as on PSX) 1D000000h SIF registers 1F800000h 64 KB Various I/O registers 1F900000h 1 KB SPU2 registers 1FC00000h 4 MB BIOS (rom0) - Same as EE BIOS FFFE0000h (KSEG2) Cache control |
4 MB GS VRAM (used for framebuffer, textures, zbuffer, etc) 2 MB SPU2 work RAM - quadrupled from PSX's SPU 8 MB Memory card |
I/O Maps |
100000xxh Timer 0 100008xxh Timer 1 100010xxh Timer 2 100018xxh Timer 3 |
10002000h 8h IPU Command 10002010h 4h IPU Control 10002020h 4h IPU bit pointer control 10002030h 8h Top of bitstream 10007000h 10h Out FIFO (read) 10007010h 10h In FIFO (write) |
10003000h 4h GIF_CTRL - Control register 10003010h 4h GIF_MODE - Mode setting 10003020h 4h GIF_STAT - Status 10003040h 4h GIF_TAG0 - Bits 0-31 of tag before 10003050h 4h GIF_TAG1 - Bits 32-63 of tag before 10003060h 4h GIF_TAG2 - Bits 64-95 of tag before 10003070h 4h GIF_TAG3 - Bits 96-127 of tag before 10003080h 4h GIF_CNT - Transfer status counter 10003090h 4h GIF_P3CNT - PATH3 transfer status counter 100030A0h 4h GIF_P3TAG - Bits 0-31 of PATH3 tag when interrupted 10006000h 10h GIF FIFO |
100080xxh VIF0 - channel 0 100090xxh VIF1 - channel 1 1000A0xxh GIF - channel 2 1000B0xxh IPU_FROM - channel 3 1000B4xxh IPU_TO - channel 4 1000C0xxh SIF0 - channel 5 1000C4xxh SIF1 - channel 6 1000C8xxh SIF2 - channel 7 1000D0xxh SPR_FROM - channel 8 1000D4xxh SPR_TO - channel 9 1000E000h 4h D_CTRL - DMAC control 1000E010h 4h D_STAT - DMAC interrupt status 1000E020h 4h D_PCR - DMAC priority control 1000E030h 4h D_SQWC - DMAC skip quadword 1000E040h 4h D_RBSR - DMAC ringbuffer size 1000E050h 4h D_RBOR - DMAC ringbuffer offset 1000E060h 4h D_STADR - DMAC stall address 1000F520h 4h D_ENABLER - DMAC disabled status 1000F590h 4h D_ENABLEW - DMAC disable |
1000F000h 4h INTC_STAT - Interrupt status 1000F010h 4h INTC_MASK - Interrupt mask |
1000F200h 4h MSCOM - EE->IOP communication 1000F210h 4h SMCOM - IOP->EE communication 1000F220h 4h MSFLAG - EE->IOP flags 1000F230h 4h SMFLAG - IOP->EE flags 1000F240h 4h Control register |
12000000h 8h PMODE - various PCRTC controls 12000010h 8h SMODE1 12000020h 8h SMODE2 12000030h 8h SRFSH 12000040h 8h SYNCH1 12000050h 8h SYNCH2 12000060h 8h SYNCV 12000070h 8h DISPFB1 - display buffer for output circuit 1 12000080h 8h DISPLAY1 - output circuit 1 control 12000090h 8h DISPFB2 - display buffer for output circuit 2 120000A0h 8h DISPLAY2 - output circuit 2 control 120000B0h 8h EXTBUF 120000C0h 8h EXTDATA 120000D0h 8h EXTWRITE 120000E0h 8h BGCOLOR - background color 12001000h 8h GS_CSR - control register 12001010h 8h GS_IMR - GS interrupt control 12001040h 8h BUSDIR - transfer direction 12001080h 8h SIGLBLID - signal |
1000F180h 1h KPUTCHAR - Console output 1000F430h 4h MCH_DRD - RDRAM initialization 1000F440h 4h MCH_RICM |
1D000000h 4h MSCOM - EE->IOP communication 1D000010h 4h SMCOM - IOP->EE communication 1D000020h 4h MSFLAG - EE->IOP flags 1D000030h 4h SMFLAG - IOP->EE flags 1D000040h 4h Control register |
1F402004h 1h Current N command 1F402005h 1h N command status (R) 1F402005h 1h N command params (W) 1F402006h 1h Error 1F402007h 1h Send BREAK command 1F402008h 1h CDVD I_STAT - interrupt register 1F40200Ah 1h Drive status 1F40200Fh 1h Disk type 1F402016h 1h Current S command 1F402017h 1h S command status 1F402018h 1h S command params |
1F801070h 4h I_STAT - Interrupt status 1F801074h 4h I_MASK - Interrupt mask 1F801078h 1h I_CTRL - Global interrupt disable |
1F80108xh MDECin - channel 0 1F80109xh MDECout - channel 1 1F8010Axh SIF2 (GPU) - channel 2 1F8010Bxh CDVD - channel 3 1F8010Cxh SPU2 Core0 - channel 4 1F8010Dxh PIO - channel 5 1F8010Exh OTC - channel 6 1F80150xh SPU2 Core1 - channel 7 1F80151xh DEV9 - channel 8 1F80152xh SIF0 - channel 9 1F80153xh SIF1 - channel 10 1F80154xh SIO2in - channel 11 1F80155xh SIO2out - channel 12 1F8010F0h 4h DPCR - DMA priority control 1F8010F4h 4h DICR - DMA interrupt control 1F801570h 4h DPCR2 - DMA priority control 2 1F801574h 4h DICR2 - DMA priority control 2 1F801578h 4h DMACEN - DMA global enable 1F80157Ch 4h DMACINTEN - DMA global interrupt control |
1F80110xh Timer 0 1F80111xh Timer 1 1F80112xh Timer 2 1F80148xh Timer 3 1F80149xh Timer 4 1F8014Axh Timer 5 |
1F808200h 40h SEND3 buffer 1F808240h 20h SEND1/2 buffers 1F808260h 1h In FIFO 1F808264h 1h Out FIFO 1F808268h 4h SIO2 control 1F80826Ch 4h RECV1 1F808270h 4h RECV2 1F808274h 4h RECV3 |
1F900000h 180h Core0 Voice 0-23 registers 1F900190h 4h Key ON 0/1 1F900194h 4h Key OFF 0/1 1F90019Ah 2h Core attributes 1F90019Ch 4h Interrupt address H/L 1F9001A8h 4h DMA transfer address H/L 1F9001ACh 2h Internal transfer FIFO 1F9001B0h 2h AutoDMA status 1F9001C0h 120h Core0 Voice 0-23 start/loop/next addresses 1F900340h 4h ENDX 0/1 1F900344h 2h Status register ... above addresses repeat for Core1 starting at 1F900400h ... 1F900760h 2h Master Volume Left 1F900762h 2h Master Volume Right 1F900764h 2h Effect Volume Left 1F900766h 2h Effect Volume Right 1F900768h 2h Core1 External Input Volume Left 1F90076Ah 2h Core1 External Input Volume Right |
Emotion Engine (EE) |
EE Architecture |
Mix of MIPS III and MIPS IV with dozens of custom instructions Speed: 294.912 MHz Superscalar, able to issue two instructions per cycle in ideal conditions Support for custom integer SIMD instructions known as MMI (MultiMedia Instructions) 16 KB instruction cache 8 KB data cache 16 KB scratchpad. Fast memory directly accessible by program and DMAC COP0 system coprocessor. Responsible for handling memory management, exceptions, caches, and performance counters COP1 FPU. Fast single-precision unit COP2 VU0. SIMD floating-point processor that can either run as a separate CPU or be used by the EE core for COP2 instructions |
EE Registers |
Name Convention zero Hardwired to 0, writes are ignored at Temporary register used for pseudo-instructions v0-v1 Return register, holds values returned by functions a0-a3 Argument registers, holds first four parameters passed to a function t0-t7 Temporary registers. t0-t3 may also be used as additional argument registers s0-s7 Saved registers. Functions must save and restore these before using them t8-t9 Temporary registers k0-k1 Reserved for use by kernels gp Global pointer sp Stack pointer fp Frame pointer ra Return address. Used by JAL and (usually) JALR to store the address to return to after a function |
Name Purpose pc Program counter, address of currently-executing instruction (32-bit) hi/lo Stores multiplication and division results (64-bit) hi1/lo1 Used by MULT1/DIV1 type instructions, same as above (64-bit) sa Shift amount used by QFSRV instruction |
EE Instruction Decoding |
31---------26---------------------------------------------------0 | opcode | | ------6---------------------------------------------------------- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | *1 | *2 | J | JAL | BEQ | BNE | BLEZ | BGTZ | 001 | ADDI | ADDIU | SLTI | SLTIU | ANDI | ORI | XORI | LUI | 010 | *3 | *4 | *5 | --- | BEQL | BNEL | BLEZL | BGTZL | 011 | DADDI |DADDIU | LDL | LDR | *6 | --- | LQ | SQ | 100 | LB | LH | LWL | LW | LBU | LHU | LWR | LWU | 101 | SB | SH | SWL | SW | SDL | SDR | SWR | CACHE | 110 | --- | LWC1 | --- | PREF | --- | --- | LQC2 | LD | 111 | --- | SWC1 | --- | --- | --- | --- | SQC2 | SD | hi |-------|-------|-------|-------|-------|-------|-------|-------| *1 = SPECIAL, see SPECIAL list *2 = REGIMM, see REGIMM list *3 = COP0 *4 = COP1 *5 = COP2 *6 = MMI table |
31---------26------------------------------------------5--------0 | = SPECIAL | | function| ------6----------------------------------------------------6----- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | SLL | --- | SRL | SRA | SLLV | --- | SRLV | SRAV | 001 | JR | JALR | MOVZ | MOVN |SYSCALL| BREAK | --- | SYNC | 010 | MFHI | MTHI | MFLO | MTLO | DSLLV | --- | DSRLV | DSRAV | 011 | MULT | MULTU | DIV | DIVU | ---- | --- | ---- | ----- | 100 | ADD | ADDU | SUB | SUBU | AND | OR | XOR | NOR | 101 | MFSA | MTSA | SLT | SLTU | DADD | DADDU | DSUB | DSUBU | 110 | TGE | TGEU | TLT | TLTU | TEQ | --- | TNE | --- | 111 | DSLL | --- | DSRL | DSRA |DSLL32 | --- |DSRL32 |DSRA32 | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31---------26----------20-------16------------------------------0 | = REGIMM | | rt | | ------6---------------------5------------------------------------ |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | BLTZ | BGEZ | BLTZL | BGEZL | --- | --- | --- | --- | 01 | TGEI | TGEIU | TLTI | TLTIU | TEQI | --- | TNEI | --- | 10 | BLTZAL| BGEZAL|BLTZALL|BGEZALL| --- | --- | --- | --- | 11 | MTSAB | MTSAH | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31---------26------------------------------------------5--------0 | = MMI | | function| ------6----------------------------------------------------6----- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | MADD | MADDU | --- | --- | PLZCW | --- | --- | --- | 001 | *1 | *2 | --- | --- | --- | --- | --- | --- | 010 | MFHI1 | MTHI1 | MFLO1 | MTLO1 | --- | --- | --- | --- | 011 | MULT1 | MULTU1| DIV1 | DIVU1 | --- | --- | --- | --- | 100 | MADD1 | MADDU1| --- | --- | --- | --- | --- | --- | 101 | *3 | *4 | --- | --- | --- | --- | --- | --- | 110 | PMFHL | PMTHL | --- | --- | PSLLH | --- | PSRLH | PSRAH | 111 | --- | --- | --- | --- | PSLLW | --- | PSRLW | PSRAW | hi |-------|-------|-------|-------|-------|-------|-------|-------| *1 = MMI0 list *2 = MMI2 list *3 = MMI1 list *4 = MMI3 list |
31---------26------------------------------10--------6-5--------0 | | |function | MMI0 | ------6----------------------------------------------------6----- |---00--|---01--|---10--|---11--| lo 000 |PADDW | PSUBW | PCGTW | PMAXW | 001 |PADDH | PSUBH | PCGTH | PMAXH | 010 |PADDB | PSUBB | PCGTB | --- | 011 | --- | --- | --- | --- | 100 |PADDSW |PSUBSW |PEXTLW | PPACW | 101 |PADDSH |PSUBSH |PEXTLH | PPACH | 110 |PADDSB |PSUBSB |PEXTLB | PPACB | 111 | --- | --- | PEXT5 | PPAC5 | hi |-------|-------|-------|-------| |
31---------26------------------------------------------5--------0 | | |function | MMI1 | ------6----------------------------------------------------6----- |---00--|---01--|---10--|---11--| lo 000 | --- | PABSW | PCEQW | PMINW | 001 |PADSBH | PABSH | PCEQH | PMINH | 010 | --- | --- | PCEQB | --- | 011 | --- | --- | --- | --- | 100 |PADDUW |PSUBUW |PEXTUW | --- | 101 |PADDUH |PSUBUH |PEXTUH | --- | 110 |PADDUB |PSUBUB |PEXTUB | QFSRV | 111 | --- | --- | --- | --- | hi |-------|-------|-------|-------| |
31---------26------------------------------------------5--------0 | | |function | MMI2 | ------6----------------------------------------------------6----- |---00--|---01--|---10--|---11--| lo 000 |PMADDW | --- |PSLLVW |PSRLVW | 001 |PMSUBW | --- | --- | --- | 010 |PMFHI |PMFLO |PINTH | --- | 011 |PMULTW |PDIVW |PCPYLD | --- | 100 |PMADDH |PHMADH | PAND | PXOR | 101 |PMSUBH |PHMSBH | --- | --- | 110 | --- | --- | PEXEH | PREVH | 111 |PMULTH |PDIVBW | PEXEW |PROT3W | hi |-------|-------|-------|-------| |
31---------26------------------------------------------5--------0 | | |function | MMI3 | ------6----------------------------------------------------6----- |---00--|---01--|---10--|---11--| lo 000 |PMADDUW| --- | --- |PSRAVW | 001 | --- | --- | --- | --- | 010 |PMTHI | PMTLO |PINTEH | --- | 011 |PMULTUW| PDIVUW|PCPYUD | --- | 100 | --- | --- | POR | PNOR | 101 | --- | --- | --- | --- | 110 | --- | --- | PEXCH | PCPYH | 111 | --- | --- | PEXCW | --- | hi |-------|-------|-------|-------| |
31--------26-25------21 ----------------------------------------0 | = COP0 | fmt | | ------6----------5----------------------------------------------- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | MFC0 | --- | --- | --- | MTC0 | --- | --- | --- | 01 | *1 | --- | --- | --- | --- | --- | --- | --- | 10 | *2 | --- | --- | --- | --- | --- | --- | --- | 11 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| *1=BC See BC0 list *2 = TLB instr, see TLB list |
31--------26-25------21-20------16------------------------------0 | = COP0 | BC0 | fmt | | ------6----------5----------5------------------------------------ |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | BC0F | BC0T | BC0FL | BC0TL | --- | --- | --- | --- | 01 | --- | --- | --- | --- | --- | --- | --- | --- | 10 | --- | --- | --- | --- | --- | --- | --- | --- | 11 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31--------26-25------21--------------------------------5--------0 | = COP0 | TLB | | fmt | ------6----------5----------------------------------------------- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | --- | TLBR | TLBWI | --- | --- | --- | TLBWR | --- | 001 | TLBP | --- | --- | --- | --- | --- | --- | --- | 010 | --- | --- | --- | --- | --- | --- | --- | --- | 011 | ERET | --- | --- | --- | --- | --- | --- | --- | 100 | --- | --- | --- | --- | --- | --- | --- | --- | 101 | --- | --- | --- | --- | --- | --- | --- | --- | 110 | --- | --- | --- | --- | --- | --- | --- | --- | 111 | EI | DI | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31--------26-25------21 ----------------------------------------0 | = COP1 | fmt | | ------6----------5----------------------------------------------- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | MFC1 | --- | CFC1 | --- | MTC1 | --- | CTC1 | --- | 01 | *1 | --- | --- | --- | --- | --- | --- | --- | 10 | *2 | --- | --- | --- | *3 | --- | --- | --- | 11 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| *1 = BC instructions, see BC1 list *2 = S instr, see FPU list *3 = W instr, see FPU list |
31--------26-25------21-20------16------------------------------0 | = COP1 | BC1 | fmt | | ------6----------5----------5------------------------------------ |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | BC1F | BC1T | BC1FL | BC1TL | --- | --- | --- | --- | 01 | --- | --- | --- | --- | --- | --- | --- | --- | 10 | --- | --- | --- | --- | --- | --- | --- | --- | 11 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31--------26-25------21 -------------------------------5--------0 | = COP1 | = S | | function| ------6----------5-----------------------------------------6----- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | ADD.S | SUB.S | MUL.S | DIV.S | SQRT.S| ABS.S | MOV.S | NEG.S | 001 | --- | --- | --- | --- | --- | --- | --- | --- | 010 | --- | --- | --- | --- | --- | --- |RSQRT.S| --- | 011 | ADDA.S| SUBA.S| MULA.S| --- | MADD.S| MSUB.S|MADDA.S|MSUBA.S| 100 | --- | --- | --- | --- | CVT.W | --- | --- | --- | 101 | MAX.S | MIN.S | --- | --- | --- | --- | --- | --- | 110 | C.F | --- | C.EQ | --- | C.LT | --- | C.LE | --- | 111 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31--------26-25------21 -------------------------------5--------0 | = COP1 | = W | | function| ------6----------5-----------------------------------------6----- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | --- | --- | --- | --- | --- | --- | --- | --- | 001 | --- | --- | --- | --- | --- | --- | --- | --- | 010 | --- | --- | --- | --- | --- | --- | --- | --- | 011 | --- | --- | --- | --- | --- | --- | --- | --- | 100 | CVT.S | --- | --- | --- | --- | --- | --- | --- | 101 | --- | --- | --- | --- | --- | --- | --- | --- | 110 | --- | --- | --- | --- | --- | --- | --- | --- | 111 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31--------26-25------21 ----------------------------------------0 | = COP2 | fmt | | ------6----------5----------------------------------------------- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | --- | QMFC2 | CFC2 | --- | --- | QMTC2 | CTC2 | --- | 01 | *1 | --- | --- | --- | --- | --- | --- | --- | 10 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | 11 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | hi |-------|-------|-------|-------|-------|-------|-------|-------| *1 = BC instructions, see BC2 list *2 =see special1 table |
31--------26-25------21-20------16------------------------------0 | = COP0 | BC2 | fmt | | ------6----------5----------5------------------------------------ |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 00 | BC2F | BC2T | BC2FL | BC2TL | --- | --- | --- | --- | 01 | --- | --- | --- | --- | --- | --- | --- | --- | 10 | --- | --- | --- | --- | --- | --- | --- | --- | 11 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
31---------26-25-----21-20-----------------------------5--------0 | =COP2 | Special1 | |function| ------6----------5------------------------------------------6---- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 |VADDx |VADDy |VADDz |VADDw |VSUBx |VSUBy |VSUBz |VSUBw | 001 |VMADDx |VMADDy |VMADDz |VMADDw |VMSUBx |VMSUBy |VMSUBz |VMSUBw | 010 |VMAXx |VMAXy |VMAXz |VMAXw |VMINIx |VMINIy |VMINIz |VMINIw | 011 |VMULx |VMULy |VMULz |VMULw |VMULq |VMAXi |VMULi |VMINIi | 100 |VADDq |VMADDq |VADDi |VMADDi |VSUBq |VMSUBq |VSUbi |VMSUBi | 101 |VADD |VMADD |VMUL |VMAX |VSUB |VMSUB |VOPMSUB|VMINI | 110 |VIADD |VISUB |VIADDI | --- |VIAND |VIOR | --- | --- | 111 |VCALLMS|CALLMSR| --- | --- | *1 | *1 | *1 | *1 | hi |-------|-------|-------|-------|-------|-------|-------|-------| *1=see special2 table |
31---------26-25-----21-20------------------11-10------6-5-2-1--0 | =COP2 | Special2 | | fhi |1111|flo| ------6----------5----------------------------------------------- Note: opcode is flo | (fhi * 4). |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 0000 |VADDAx |VADDAy |VADDAz |VADDAw |VSUBAx |VSUBAy |VSUBAz |VSUBAw | 0001 |VMADDAx|VMADDAy|VMADDAz|VMADDAw|VMSUBAx|VMSUBAy|VMSUBAz|VMSUBAw| 0010 |VITOF0 |VITOF4 |VITOF12|VITOF15|VFTOI0 |VFTOI4 |VFTOI12|VFTOI15| 0011 |VMULAx |VMULAy |VMULAz |VMULAw |VMULAq |VABS |VMULAi |VCLIPw | 0100 |VADDAq |VMADDAq|VADDAi |VMADDAi|VSUBAq |VMSUBAq|VSUBAi |VMSUBAi| 0101 |VADDA |VMADDA |VMULA | --- |VSUBA |VMSUBA |VOPMULA|VNOP | 0110 |VMOVE |VMR32 | --- | --- |VLQI |VSQI |VLQD |VSQD | 0111 |VDIV |VSQRT |VRSQRT |VWAITQ |VMTIR |VMFIR |VILWR |VISWR | 1000 |VRNEXT |VRGET |VRINIT |VRXOR | --- | --- | --- | --- | 1001 | --- | --- | --- | --- | --- | --- | --- | --- | 1010 | --- | --- | --- | --- | --- | --- | --- | --- | 1011 | --- | --- | --- | --- | --- | --- | --- | --- | 1100 | --- | --- | --- | --- | --- | --- | --- | --- | 1101 | --- | --- | --- | --- | --- | --- | --- | --- | 1110 | --- | --- | --- | --- | --- | --- | --- | --- | 1111 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| |
EE RDRAM initialization |
case 0x1000f430: { return 0; } case 0x1000f440: { uint8_t SOP = (MCH_RICM >> 6) & 0xF; uint8_t SA = (MCH_RICM >> 16) & 0xFFF; if (!SOP) { switch (SA) { case 0x21: if (rdram_sdevid < 2) { rdram_sdevid++; return 0x1F; } return 0; case 0x23: return 0x0D0D; case 0x24: return 0x0090; case 0x40: return MCH_RICM & 0x1F; } } return 0; } |
case 0x1000f430: { uint8_t SA = (data >> 16) & 0xFFF; uint8_t SBC = (data >> 6) & 0xF; if (SA == 0x21 && SBC == 0x1 && ((MCH_DRD >> 7) & 1) == 0) rdram_sdevid = 0; MCH_RICM = data & ~0x80000000; break; } case 0x1000f440: { MCH_DRD = data; break; } |
EE COP0 Registers |
Num Name $0 Index $1 Random $2 EntryLo0 $3 EntryLo1 $4 Context $5 PageMask $6 Wired $8 BadVAddr $9 Count $10 EntryHi $11 Compare $12 Status $13 Cause $14 EPC $15 PRid $16 Config $23 BadPAddr $24 Debug $25 Perf $28 TagLo $29 TagHi $30 ErrorEPC |
EE COP0 Exception Handling |
Name Normal Bootstrap Level ------------------------------------------------ | Reset/NMI | BFC00000h | BFC00000h | 2 | ------------------------------------------------ | TLB Refill | 80000000h | BFC00200h | 1 | ------------------------------------------------ | Perf. Counter | 80000080h | BFC00280h | 2 | ------------------------------------------------ | Debug | 80000100h | BFC00300h | 2 | ------------------------------------------------ | All others | 80000180h | BFC00380h | 1 | ------------------------------------------------ | Interrupt | 80000200h | BFC00400h | 1 | ------------------------------------------------ |
void handle_exception_level1(u32 vector, u8 cause) { Cause.ExcCode = cause; if (in_branch_delay) { EPC = PC - 4; Cause.BD = true; } else { EPC = PC; Cause.BD = false; } Status.EXL = true; PC = vector; } void handle_exception_level2(u32 vector, u8 cause) { Cause.ExcCode = cause; if (in_branch_delay) { ErrorEPC = PC - 4; Cause.BD2 = true; } else { ErrorEPC = PC; Cause.BD2 = false; } Status.ERL = true; PC = vector; } |
0 IE - Interrupt enable 1 EXL - Exception level (set when a level 1 exception occurs) 2 ERL - Error level (set when a level 2 exception occurs) 3-4 KSU - Privilege level 0=Kernel 1=Supervisor 2=User 10 INT0 enable (INTC) 11 INT1 enable (DMAC) 12 Bus error mask - when set, bus errors are disabled 15 INT5 enable (COP0 timer) 16 EIE - Master interrupt enable 17 EDI - If not set, EI/DI only works in kernel mode 18 CH - Status of most recent Cache Hit instruction 0=miss 1=hit 22 BEV - If set, level 1 exceptions go to "bootstrap" vectors in BFC00xxx 23 DEV - If set, level 2 exceptions go to "bootstrap" vectors in BFC00xxx 28-31 Usability of coprocessors 0-3 If not set, using a coprocessor raises an exception |
Status.IE && Status.EIE && !Status.EXL && !Status.ERL |
2-6 Exception code 00h=Interrupt 01h=TLB Modified 02h=TLB Refill (instruction fetch or load) 03h=TLB Refill (store) 04h=Address Error (instruction fetch or load) 05h=Address Error (store) 06h=Bus Error (instruction) 07h=Bus Error (data) 08h=Syscall 09h=Breakpoint 0Ah=Reserved Instruction 0Bh=Coprocessor Unusable 0Ch=Overflow 0Dh=Trap 10 INTC interrupt pending 11 DMAC interrupt pending 15 COP0 timer interrupt pending 16-18 Error code 00h=Reset 01h=NMI 02h=Performance counter 03h=Debug 28-29 Coprocessor that triggered a CU exception 30 BD2 - Set when a level 2 exception occurs in a delay slot 31 BD - Set when a level 1 exception occurs in a delay slot |
0-31 Address to return to after an exception |
0-31 Physical address that caused an exception |
EE COP0 Memory Management |
Name Range Description ------------------------------------------------------------------- | kuseg | 00000000h-7FFFFFFFh | User, TLB-mapped | ------------------------------------------------------------------- | kseg0 | 80000000h-9FFFFFFFh | Kernel, directly-mapped, cached | ------------------------------------------------------------------- | kseg1 | A0000000h-BFFFFFFFh | Kernel, directly-mapped, uncached | ------------------------------------------------------------------- | ksseg | C0000000h-DFFFFFFFh | Supervisor, TLB-mapped | ------------------------------------------------------------------- | kseg3 | E0000000h-FFFFFFFFh | Kernel, TLB-mapped | ------------------------------------------------------------------- |
1 V0 - Even page valid. When not set, the memory referenced in this entry is not mapped. 2 D0 - Even page dirty. When not set, writes cause an exception. 3-5 C0 - Even page cache mode. 2=Uncached 3=Cached 7=Uncached accelerated 6-25 PFN0 - Even page frame number. 33 V1 - Odd page valid. 34 D1 - Odd page dirty. 35 C1 - Odd page cache mode. 38-57 PFN1 - Odd page frame number. 63 S - Scratchpad. When set, the virtual mapping goes to scratchpad instead of main memory. 64-71 ASID - Address Space ID. 76 G - Global. When set, ASID is ignored. 77-95 VPN2 - Virtual page number / 2. Even pages have a VPN of (VPN2 * 2) and odd pages have a VPN of (VPN2 * 2) + 1 109-120 MASK - Size of an even/odd page. |
0-5 TLB entry to access with TLBR/TLBWI |
0-5 TLB entry to access with TLBWR |
0 G - Global. 1 V - Page valid. When not set, the memory referenced in this entry is not mapped. 2 D - Page dirty. When not set, writes cause an exception. 3-5 C - Page cache mode. 2=Uncached 3=Cached 7=Uncached accelerated 6-25 PFN - Page frame number. 31 S - Scratchpad. Only applicable for EntryLo0. |
13-24 Page size 000h=4 KB 003h=16 KB 00Fh=64 KB 03Fh=256 KB 0FFh=1 MB 3FFh=4 MB FFFh=16 MB |
0-5 Lower bound of Random |
0-7 ASID 13-31 VPN2 |
EE COP0 Caches |
icache ------------------------------------------- |V|R| PFN | ------------------------------------------- dcache ------------------------------------------- |D|V|R|L| PFN | ------------------------------------------- V=Valid. If set, the way contains valid data. R=LRF bit. Used for the LRF cache replacement algorithm. D=Dirty. Set on writes. If set when the way is reloaded, the data is first stored to main memory before loading new data. L=Locked. Prevents the way from ever being reloaded. Only allowed for a single way in a line. |
icache 31---------------------------------14-13-------------6-5---------0 | PFN | index | offset | ------------------------------------------------------------------ dcache 31------------------------------------13-12----------6-5---------0 | PFN | index | offset | ------------------------------------------------------------------ Note how the dcache index is 6-bit, whereas the icache index is 7-bit. |
EE COP0 Timer |
0-31 Timer count value |
0-31 Timer compare value |
EE COP1 Registers |
Name Convention f0-f3 Return values f4-f11 Temporary registers f12-f19 Argument registers f20-f31 Saved registers |
Name Purpose fcr0 Reports implementation and revision of FPU fcr31 Control register, stores status flags |
EE COP1 Floating Point Format |
31-30---------23-22---------------------------------------------0 |si| exponent | mantissa | ----------------------------------------------------------------- |
num = (si ? -1 : 1) * 2 ^ (exponent - 127) * (1.mantissa) |
EE Timers |
0-15 Current counter |
0-1 Clock 0=Bus clock (~147 MHz) 1=Bus clock / 16 2=Bus clock / 256 3=HBLANK 2 Gate enable 3 Gate type 0=HBLANK 1=VBLANK 4-5 Gate mode 0=Count while gate not active 1=Reset counter when gate goes from low to high 2=Reset counter when gate goes from high to low 3=Reset counter for high<->low gate transitions 6 Clear counter when it reaches compare value 7 Timer enable 8 Compare interrupt enable - trigger interrupt when COUNT==COMP 9 Overflow interrupt enable - trigger interrupt when COUNT goes from FFFFh to 0000h 10 Compare interrupt flag W: Clears flag 11 Overflow interrupt flag W: Clears flag |
0-15 Compare value |
0-15 Counter value when an SBUS interrupt occurs |
PAL: 312 scanlines per frame (VBOFF: 286 | VBON: 26) NTSC: 262 scanlines per frame (VBOFF: 240 | VBON: 22) |
PAL: 9436 BUSCLK cycles per scanline NTSC: 9370 BUSCLK cycles per scanline |
Graphics Interface (GIF) |
GIF I/O |
0 Reset GIF 1-2 Unused 3 Temporary stop (1=stop transfers, 0=restart transfers) 4-31 Unused |
0 Mask PATH3 (1=Mask) 1 Unused 2 Intermittent mode |
0 PATH3 masked by GIF_MODE 1 PATH3 masked by VIF1 MASKP3 register 2 Intermittent mode activated 3 Temporary stop 4 Unused 5 PATH3 interrupted (by intermittent mode?) 6 PATH3 queued 7 PATH2 queued 8 PATH1 queued 9 Output path (1=transfer ongoing) 10-11 Active path 0=Idle 1=PATH1 2=PATH2 3=PATH3 12 Transfer direction (0=EE->GS, 1=GS->EE) 13-23 Unused 24-28 Data in GIF FIFO (in quadwords, max 16) 29-31 Unused |
0-31 Bits 0-31 of most recently read GIFtag |
0-31 Bits 32-63 of most recently read GIFtag |
0-31 Bits 64-95 of most recently read GIFtag |
0-31 Bits 96-127 of most recently read GIFtag |
0-14 Backwards loop counter from NLOOP Decrements to zero 15 Unused 16-19 Register descriptor in progress 0=highest 1=lowest 2=2nd lowest ... 15=15th lowest 20-29 VU data address being transferred 30-31 Unused |
0-14 Backwards loop counter from PATH3 NLOOP when PATH3 is interrupted 15-31 Unused |
0-31 Bits 0-31 of PATH3 GIFtag when PATH3 is interrupted |
GIFtags |
0-14 NLOOP - Data per register to transfer 15 EOP - End of packet 16-45 Unused 46 Enable PRIM field 47-57 Data to be sent to GS PRIM register if GIFtag.46 == 1 58-59 Data format 0=PACKED 1=REGLIST 2=IMAGE 3=IMAGE 60-63 NREGS - Number of registers 0=16 registers 64-127 Register field, 4 bits each |
GIF Data Formats |
0-10 Data to write to GS PRIM 11-127 Unused |
Writes to RGBAQ register (Q is unchanged) 0-7 R 8-31 Unused 32-39 G 40-63 Unused 64-71 B 72-95 Unused 96-103 A 104-127 Unused |
Writes to ST register and Q component of RGBAQ. 0-31 S 32-63 T 64-95 Q 96-127 Unused |
0-13 U 14-31 Unused 32-45 V 46-127 Unused |
0-15 X 16-31 Unused 32-47 Y 48-67 Unused 68-91 Z 92-99 Unused 100-107 F 108-110 Unused 111 Disable drawing (1=write to XYZ3F, 0=write to XYZ2F) 112-127 Unused |
0-15 X 16-31 Unused 32-47 Y 48-63 Unused 64-95 Z 96-110 Unused 111 Disable drawing (1=write to XYZ3F, 0=write to XYZ2F) 112-127 Unused |
0-99 Unused 100-107 F 108-127 Unused |
0-63 Data 64-71 Register address 72-127 Unused |
Data not output to GS. |
GIF PATH3 Masking |
DMA Controller (DMAC) |
DMAC I/O |
100080xxh VIF0 100090xxh VIF1 (can act as PATH2 for GIF) 1000A0xxh GIF (PATH3) 1000B0xxh IPU_FROM 1000B4xxh IPU_TO 1000C0xxh SIF0 (from IOP) 1000C4xxh SIF1 (to IOP) 1000C8xxh SIF2 (bidirectional, used for PSX mode and debugging) 1000D0xxh SPR_FROM 1000D4xxh SPR_TO |
0 DIR - Direction (0=to memory, 1=from memory) Only effective for VIF1 and SIF2 1 Unused 2-3 MOD - Mode (0=normal, 1=chain, 2=interleave) 4-5 ASP - Address stack pointer 6 TTE - Transfer DMAtag (only in source chain mode) 7 TIE - Enable IRQ bit in DMAtag 8 STR - Start/busy 9-15 Unused 16-31 TAG - Bits 16-31 of most recently read DMAtag |
0-30 Address (lower 4 bits must be zero) 31 Memory selection (0=RAM, 1=scratchpad) |
0-15 Quadwords 16-31 Unused |
0-30 Tag address (lower 4 bits must be zero) 31 Memory selection (0=RAM, 1=scratchpad) |
0-13 Address (lower 4 bits must be zero) 14-31 Unused |
0 DMA enable 1 Cycle stealing on 2-3 MFIFO drain channel 0=None 1=Reserved 2=VIF1 3=GIF 4-5 Stall control channel 0=None 1=SIF0 2=SPR_FROM 3=IPU_FROM 6-7 Stall control drain channel 0=None 1=VIF1 2=GIF 3=SIF1 8-10 Release cycle period 0=8 1=16 2=32 3=64 4=128 5=256 |
0-9 Channel interrupt status (1=IRQ, write 1 to clear) 10-12 Unused 13 DMA stall interrupt status 14 MFIFO empty interrupt status 15 BUSERR interrupt status 16-25 Channel interrupt mask (1=enabled, write 1 to reverse) 26-28 Unused 29 Stall interrupt mask 30 MFIFO empty mask |
0-9 COP0 condition control 10-15 Unused 16-25 Channel priority (0=Channel disabled, only if D_PCR.31 is true) 26-30 Unused 31 Priority enable |
0-7 Quadwords to skip 8-15 Unused 16-23 Quadwords to transfer 24-31 Unused |
4-30 Size of MFIFO buffer in quadwords, minus 1 |
0-30 Starting address of MFIFO buffer. Lower 4 bits are 0 |
16 DMAC disabled All other bits appear to be garbage, but writable SCPH-39001 (and other BIOSes?) seems to expect D_ENABLER to be set to 1201h upon boot |
DMAC Chain Mode |
0-15 QWC to transfer 16-25 Unused 26-27 Priority control 0=No effect 1=Reserved 2=Priority control disabled (D_PCR.31 = 0) 3=Priority control enabled (D_PCR.31 = 1) 28-30 Tag ID 31 IRQ 32-62 ADDR field (lower 4 bits must be zero) 63 Memory selection for ADDR (0=RAM, 1=scratchpad) 64-127 Data to transfer (only if Dn_CHCR.TTE==1) |
0 refe MADR=DMAtag.ADDR TADR+=16 tag_end=true 1 cnt MADR=TADR+16 (next to DMAtag) TADR=MADR (next to transfer data) 2 next MADR=TADR+16 TADR=DMAtag.ADDR 3 ref MADR=DMAtag.ADDR TADR+=16 4 refs MADR=DMAtag.ADDR TADR+=16 5 call MADR=TADR+16 if (CHCR.ASP == 0) ASR0=MADR+(QWC*16) else if (CHCR.ASP == 1) ASR1=MADR+(QWC*16) TADR=DMAtag.ADDR CHCR.ASP++ 6 ret MADR=TADR+16 if (CHCR.ASP == 2) TADR=ASR1 CHCR.ASP-- else if (CHCR.ASP == 1) TADR=ASR0 CHCR.ASP-- else tag_end=true 7 end MADR=TADR+16 tag_end=true |
0 cnt MADR=DMAtag.ADDR 1 cnts MADR=DMAtag.ADDR 7 end MADR=DMAtag.ADDR tag_end=true |
DMAC MFIFO |
DMAC Interrupts |
Graphics Synthesizer (GS) |
GS Register List |
00h PRIM 01h RGBAQ 02h ST 03h UV 04h XYZF2 05h XYZ2 06h/07h TEX0_1/2 08h/09h CLAMP_1/2 0Ah FOG 0Ch XYZF3 0Dh XYZ3 14h/15h TEX1_1/2 16h/17h TEX2_1/2 18h/19h XYOFFSET_1/2 1Ah PRMODECONT 1Bh PRMODE 1Ch TEXCLUT 22h SCANMSK 34h/35h MIPTBP1_1/2 36h/37h MIPTBP2_1/2 3Bh TEXA 3Dh FOGCOL 3Fh TEXFLUSH 40h/41h SCISSOR_1/2 42h/43h ALPHA_1/2 44h DIMX 45h DTHE 46h COLCLAMP 47h/48h TEST_1/2 49h PABE 4Ah/4Bh FBA_1/2 4Ch/4Dh FRAME_1/2 4Eh/4Fh ZBUF_1/2 50h BITBLTBUF 51h TRXPOS 52h TRXREG 53h TRXDIR 54h HWREG 60h SIGNAL 61h FINISH 62h LABEL |
12000000h PMODE 12000020h SMODE2 12000070h DISPFB1 12000080h DISPLAY1 12000090h DISPFB2 120000A0h DISPLAY2 120000B0h EXTBUF 120000C0h EXTDATA 120000D0h EXTWRITE 120000E0h BGCOLOR 12001000h CSR 12001010h IMR 12001040h BUSDIR 12001080h SIGLBLID |
GS Primitives |
0-2 Primitive type 0=Point 1=Line 2=LineStrip 3=Triangle 4=TriangleStrip 5=TriangleFan 6=Sprite 7=Reserved 3 Gourand shading 4 Texture mapping 5 Fog 6 Alpha blending 7 Antialiasing 8 Use UV for texture coordinates (0=Use STQ) 9 Use Context 2's registers for drawing (0=Use Context 1) 10 Fix fragment value (related to antialiasing?) |
GS Vertex Attributes |
0-7 Red 8-15 Green 16-23 Blue 24-31 Alpha 32-63 Q |
0-15 X 16-31 Y 32-55 Z 56-63 Fog coefficient (placed in FOG register) |
0-15 X 16-31 Y 32-63 Z |
0-15 X 32-47 Y |
GS Frame and Z Buffers |
0-8 Base pointer in words/2048 16-21 Buffer width in pixels/64 24-29 Format 00h=PSMCT32 01h=PSMCT24 02h=PSMCT16 0Ah=PSMCT16S 30h=PSMZ32 31h=PSMZ24 32h=PSMZ16 3Ah=PSMZ16S 32-63 Framebuffer mask |
0-8 Base pointer in words/2048 24-27 Format 00h=PSMZ32 01h=PSMZ24 02h=PSMZ16 0Ah=PSMZ16S 32 Buffer mask (1=do not update zbuffer) |
GS Transfers |
0-13 Source base pointer in words/64 16-21 Source buffer width in pixels/64 24-29 Source format 00h=PSMCT32 01h=PSMCT24 02h=PSMCT16 0Ah=PSMCT16S 13h=PSMCT8 14h=PSMCT4 1Bh=PSMCT8H 24h=PSMCT4HL 2Ch=PSMCT4HH 30h=PSMZ32 31h=PSMZ24 32h=PSMZ16 3Ah=PSMZ16S 32-45 Destination base pointer in words/64 48-53 Destination buffer width in pixels/64 56-61 Destination format (same as source format) |
0-10 X for source rectangle 16-26 Y for source rectangle 32-42 X for destination rectangle 48-58 Y for destination rectangle 59-60 Transmission order for VRAM->VRAM transfers 0=Upper-left->lower-right 1=Lower-left->upper-right 2=Upper-right->lower-left 3=Lower-right->upper-left |
0-11 Width in pixels of transmission area 32-43 Height in pixels of transmission area |
0-1 Transmission direction 0=GIF->VRAM 1=VRAM->GIF 2=VRAM->VRAM 3=Deactivated |
0-63 Data to be transferred for GIF->VRAM |
GS Textures |
0-13 Base pointer in words/64 14-19 Buffer width in pixels/64 20-25 Texture format 00h=PSMCT32 01h=PSMCT24 02h=PSMCT16 0Ah=PSMCT16S 13h=PSMCT8 14h=PSMCT4 1Bh=PSMCT8H 24h=PSMCT4HL 2Ch=PSMCT4HH 30h=PSMZ32 31h=PSMZ24 32h=PSMZ16 3Ah=PSMZ16S 26-29 Texture width (width = min(2^value, 1024)) 30-33 Texture height (height = min(2^value, 1024)) 34 Alpha control (0=texture is RGB, 1=texture is RGBA) 35-36 Color function 0=Modulate 1=Decal 2=Highlight 3=Highlight2 37-50 CLUT base pointer in words/64 51-54 CLUT format 00h=PSMCT32 02h=PSMCT16 0Ah=PSMCT16S 55 CLUT uses CSM2 (0=CSM1) 56-60 CLUT entry offset/16 (In CSM2, this value must be 0) 61-63 CLUT cache control 0=Do not reload cache 1=Reload cache 2=Reload cache and copy CLUT base pointer to CBP0 3=Reload cache and copy CLUT base pointer to CBP1 4=IF CLUT base pointer != CBP0, reload cache and copy pointer to CBP0 5=IF CLUT base pointer != CBP1, reload cache and copy pointer to CBP1 |
0 LOD (level of detail) calculation method 0=LOD=(log2(1/abs(Q))< |
20-25 Texture format (same as TEX0) 37-50 CLUT base pointer in words/64 51-54 CLUT format 55 CLUT uses CSM2 (0=CSM1) 56-60 CLUT entry offset/16 61-63 CLUT cache control (same as TEX0) |
0-31 S (lower 8 bits are rounded down to zero) 32-63 T (lower 8 bits are rounded down to zero) |
0-13 U 16-29 V |
RGB RGBA Modulate Rv = (Rv * Rt) >> 7 <- Same Gv = (Gv * Gt) >> 7 <- Same Bv = (Bv * Bt) >> 7 <- Same Av = Av Av = (Av * At) >> 7 Decal Rv = Rt <- Same Gv = Gt <- Same Bv = Bt <- Same Av = Av Av = At Highlight Rv = ((Rv * Rt) >> 7) + Av <- Same Gv = ((Gv * Gt) >> 7) + Av <- Same Bv = ((Bv * Bt) >> 7) + Av <- Same Av = Av Av = At + Av Highlight2 Same as Highlight Same as Highlight, but Av = At |
GS Fog |
0-7 R 8-15 G 16-23 B |
0-7 Fog effect |
GS Alpha Blending |
0-1 Spec A 2-3 Spec B 4-5 Spec C 6-7 Spec D 8-15 Alpha FIX |
A B C D 0 Source RGB Source RGB Source alpha Source RGB 1 Framebuffer RGB Framebuffer RGB Framebuffer alpha Framebuffer RGB 2 0 0 FIX 0 3 Reserved Reserved Reserved Reserved |
0 8-bit signed clamp (0=8-bit AND) |
GS Tests and Pixel Control |
0-10 X0 16-26 X1 32-42 Y0 48-58 Y1 |
0 Alpha test enabled 1-3 Alpha test method 0=NEVER (all pixels fail) 1=ALWAYS (all pixels pass) 2=LESS (pixel alpha < AREF passes) 3=LEQUAL (pixel alpha <= AREF passes) 4=EQUAL (pixel alpha == AREF passes) 5=GEQUAL (pixel alpha >= AREF passes) 6=GREATER (pixel alpha > AREF passes) 7=NEQUAL (pixel alpha != AREF passes) 4-11 AREF 12-13 Alpha test failure processing 0=Neither framebuffer nor zbuffer are updated. 1=Only framebuffer is updated. 2=Only zbuffer is updated. 3=Only RGB in framebuffer is updated. 14 Destination alpha test enabled 15 Destination alpha test method 0=destination alpha bit == 0 passes 1=destination alpha bit == 1 passes 16 Depth test enabled (0 is prohibited?) 17-18 Depth test method 0=NEVER (all pixels fail) 1=ALWAYS (all pixels pass) 2=GEQUAL (pixel Z >= zbuffer Z passes) 3=GREATER (pixel Z > zbuffer Z passes) |
GS Special Effects and Optimizations |
Vector Interface (VIF) |
VIF I/O Registers |
0-1 VPS - VIF command status 0=Idle 1=Waiting for data following command 2=Decoding command 3=Decompressing/transferring data 2 VEW - VU is executing microprogram 3 VGW - Stalled waiting for GIF (VIF1 only) 6 MRK - MARK detected 7 DBF - Double buffer flag (VIF1 only) 0=TOPS = BASE 1=TOPS = BASE + OFST 8 VSS - Stalled after STOP was sent to FBRST 9 VFS - Stalled after force break was sent to FBRST 10 VIS - Stalled on interrupt ibt 11 INT - Interrupt bit detected 12 ER0 - DMAtag mismatch error (don't know what this means) 13 ER1 - Invalid VIF command was sent 23 FDR - FIFO direction (VIF1 only) 0=Memory -> VIF FIFO 1=VIF FIFO -> Memory 24-28 FQC - Amount of quadwords in FIFO Max 8 for VIF0, 16 for VIF1 |
0 RST - Reset VIF including contents of FIFO when written to 1 FBK - Force break the VIF, causing an immediate stall 2 STP - STOP the VIF, stalling it after it finishes the current command 3 STC - Stall cancel. Clears VSS, VFS, VIS, INT, ER0, and ER1 in VIFn_STAT |
0 MII - Disable interrupt bit stalls and interrupts if set 1 ME0 - Disable DMAtag mismatch error and stall if set 2 ME1 - Disable invalid command error and stall if set |
0-15 Most recently set MARK value |
0-7 CL - Cycle length 8-15 WL - Write cycle length |
0-1 Addition mode used for UNPACK |
0-7 Amount of untransferred data in MPG/UNPACK |
0-31 Write mask matrix |
0-15 IMMEDIATE value processed most recently 16-23 NUM value processed most recently 24-31 CMD value processed most recently |
0-9 ITOPS value |
0-9 BASE value |
0-9 OFST value |
0-9 TOPS value |
0-9 ITOP value |
0-9 TOP value |
VIF Commands |
31 24 23 16 15 0 ------------------------------------------------- | CMD | NUM | IMMEDIATE | ------------------------------------------------- |
VIF UNPACK |
Input 128---------96----------64----------32----------0 | S3 | S2 | S1 | cmd | ------------------------------------------------- Output w z y x 128---------96----------64----------32----------0 | S1 | S1 | S1 | S1 | ------------------------------------------------- | S2 | S2 | S2 | S2 | ------------------------------------------------- | S3 | S3 | S3 | S3 | ------------------------------------------------- |
Input 96-----80----64----48----32----------0 | pad | S3 | S2 | S1 | cmd | -------------------------------------- Output w z y x 128---------96----------64----------32----------0 | ext | S1 | ext | S1 | ext | S1 | ext | S1 | ------------------------------------------------- | ext | S2 | ext | S2 | ext | S2 | ext | S2 | ------------------------------------------------- | ext | S3 | ext | S3 | ext | S3 | ext | S3 | ------------------------------------------------- |
Input 96----------64----------32----------0 | V2 | V1 | cmd | ------------------------------------- Output w z y x 128---------96----------64----------32----------0 |Indetermin.|Indetermin.| V2 | V1 | ------------------------------------------------- |
Input 64----48----32----------0 | V2 | V1 | cmd | ------------------------- Output w z y x 128---------96----------64----------32----------0 |Indetermin.||Indetermin.| ext | V2 | ext | V1 | ------------------------------------------------- |
Input 128---------96----------64----------32----------0 | V3 | V2 | V1 | cmd | ------------------------------------------------- Output w z y x 128---------96----------64----------32----------0 |Indetermin.| V3 | V2 | V1 | ------------------------------------------------- |
Input 80----64----48----32----------0 | V3 | V2 | V1 | cmd | ------------------------------- Output w z y x 128---------96----------64----------32----------0 |Indetermin.| ext | V3 | ext | V2 | ext | V1 | ------------------------------------------------- |
Input 128---------96----------64----------32----------0 | V3 | V2 | V1 | cmd | ------------------------------------------------- | V4 | ------------ Output w z y x 128---------96----------64----------32----------0 | V4 | V3 | V2 | V1 | ------------------------------------------------- |
Input 96-----80----64----48----32----------0 | V4 | V3 | V2 | V1 | cmd | -------------------------------------- Output w z y x 128---------96----------64----------32----------0 | ext | V4 | ext | V3 | ext | V2 | ext | V1 | ------------------------------------------------- |
Vector Unit (VU) |
VU Architecture |
Custom SIMD floating-point processors designed by Sony Speed: 294.912 MHz (same as EE) Executes two instructions per cycle through upper and lower pipelines - each pipeline is specialized and can only execute certain instructions 4/16 KB of instruction ("micro") memory for VU0 and VU1 respectively 4/16 KB of data memory for VU0 and VU1 respectively 32 128-bit vector registers, 16 16-bit integer registers, and an assortment of special registers FDIV unit: Used for division and square root operations Elementary Function Unit (EFU): Exclusive to VU1. Used for complex calculations such as square of sums, sine, and e^x MAC/CLIP flags: Processor flags used to compare the results of floating-point arithmetic XGKICK: Exclusive to VU1. Transfers data directly to the GIF through PATH1 Similar decoding and quirks to standard MIPS, such as branch delay slots |
VU Registers |
15 0 ------------------------------------------------- |Ox|Oy|Oz|Ow|Ux|Uy|Uz|Uw|Sx|Sy|Sz|Sw|Zx|Zy|Zz|Zw| ------------------------------------------------- |
5 0 ------------------- |-z|+z|-y|+y|-x|+x| ------------------- |
11 0 ------------------------------------- |DS|IS|OS|US|SS|ZS|D |I |O |U |S |Z | ------------------------------------- |
VU Instruction Format and Decoding |
3 3 2 2 2 2 2 1-0-9-8-7-6-5-----------------------------------0 |I|E|M|D|T| instr | ------------------------------------------------- |
VU Pipelining |
------------- |M|T|X|Y|Z|S| |M|T|X|Y|Z| |M|T|X|Y| |M|T|X| ------------- |
------------- |M|T|X|Y|Z|S| |M|T|X|Y|Z| |M|T|X|Y| |M|T|X| ------------- |
DIV/SQRT ------------------------- |M|T|D1|D2|D3|D4|D5|D6|F| ------------------------- RSQRT ------------------------- |M|T|D1| ........ |D12|F| ------------------------- |
------------------------- |M|T|N1|N2| ...... |Nn|P| ------------------------- |
EATAN/EATANxy/EATANxz 54 EEXP 44 ELENG 18 ERCPR 12 ERLENG 24 ERSADD 18 ERSQRT 18 ESADD 11 ESIN 29 ESQRT 12 ESUM 12 |
Image Processing Unit (IPU) |
IPU I/O Registers |
Write 0-27 Option - dependent on command 28-31 Code - the actual command Read 0-31 Result of FDEC/VDEC command 63 Busy |
0-3 IFC - Size of data in input FIFO in quadwords 4-7 OFC - Size of data in output FIFO in quadwords 8-13 CBP - Coded block pattern, written to by BDEC/IDEC 14 ECD - Error code detected 15 SCD - Start code detected 16-17 IDP - Intra DC precision 0=8 bits 1=9 bits 2=10 bits 20 AS - Scan pattern for BDEC 0=Zigzag 1=Alternate 21 IVF - Intra VLC format 0=MPEG1-compatible 1=Intra macro block 22 QST - Quantize step for BDEC 0=Linear 1=Nonlinear 23 MP1 - If set, treats bitstream as MPEG1. Otherwise, MPEG2 24-26 Picture type for VDEC 1=I-picture 2=P-picture 3=B-picture 4=D-picture 30 RST - Writing 1 to this resets the whole IPU 31 Busy |
0-6 BP - Position within the 128-bit quadword being decoded in bits 8-11 IFC - Size of data in input FIFO in quadwords 16-17 FP - Size of data in internal buffer in quadwords |
0-31 Next 32 bits in the bitstream 63 Busy/not enough data |
IPU Commands |
0-7 BP - Bitstream start |
0-5 FB - Bitstream skip 16-20 QSC - Quantizer step 24 DTD - When set, IDEC decodes DT 25 SGN - When set, output RGB is decremented by 128 for each channel. Underflow wraps around 26 DTE - Dither enable. Only applicable for RGB16 27 OFM - Output format 0=RGB32 1=RGB16 |
0-5 FB - Bitstream skip 16-20 QSC - Quantizer step 25 DT - Frame type 0=Frame 1=Field 26 DCR - When set, DC prediction value is reset 27 MBI - Intra bit 0=Non-intra macroblock 1=Intra macroblock |
0-5 FB - Bitstream skip 26-27 TBL - VLC table to read from 0=Macroblock Increment (MBI) 1=Macroblock Type 2=Motion Code 3=DMVector |
0-5 FB - Bitstream skip |
0-5 FB - Bitstream skip 27 IQM - Matrix type 0=Intra matrix 1=Non-intra matrix |
No option bits |
0-10 MBC - Macroblocks to decode 26 DTE - Dither enable. Only applicable for RGB16 27 OFM - Output format 0=RGB32 1=RGB16 |
0-10 MBC - Macroblocks to convert 26 DTE - Dither enable 27 OFM - Output format 0=INDX4 1=RGB16 |
0-8 TH0 - Transparent alpha threshold 16-24 TH1 - Translucent alpha threshold |
EE Interrupt Controller (INTC) |
0 IRQ0 GS interrupt 1 IRQ1 SBUS 2 IRQ2 VBLANK start 3 IRQ3 VBLANK end 4 IRQ4 VIF0 5 IRQ5 VIF1 6 IRQ6 VU0 7 IRQ7 VU1 8 IRQ8 IPU 9 IRQ9 Timer 0 10 IRQ10 Timer 1 11 IRQ11 Timer 2 12 IRQ12 Timer 3 13 IRQ13 SFIFO 14 IRQ14 VU0 Watchdog |
IOP Hardware and Peripherals |
CDVD Drive |
CDVD I/O Ports |
0 Error (1=error occurred) 1 Unknown/unused 2 DEV9 device connected (1=HDD/network adapter connected) 3 Unknown/unused 4 Test mode 5 Power off ready 6 Drive status (1=ready) 7 Busy executing NCMD |
0 Data ready? 1 (N?) Command complete 2 Power off pressed 3 Disk ejected 4 BS_Power DET? 5-7 Unused |
0 Tray status (1=open) 1 Spindle spinning (1=spinning) 2 Read status (1=reading data sectors) 3 Paused 4 Seek status (1=seeking) 5 Error (1=error occurred) 6-7 Unknown |
00h No disc 01h Detecting 02h Detecting CD 03h Detecting DVD 04h Detecting dual-layer DVD 05h Unknown 10h PSX CD 11h PSX CDDA 12h PS2 CD 13h PS2 CDDA 14h PS2 DVD FDh CDDA (Music) FEh DVDV (Movie disc) FFh Illegal |
0-5 Unknown 6 Result data available (0=available, 1=no data) 7 Busy |
CDVD N Commands |
0-3 Sector position |
0-3 Sector position 4-7 Sectors to read 10 Block size (1=2328 bytes, 2=2340 bytes, all others=2048 bytes) |
0-3 Sector position 4-7 Sectors to read |
0 1 Volume number + 0x20 1 3 Sector number - volume start + 0x30000, in big-endian. 4 8 ? (all zeroes) 12 2048 Raw sector data 2060 4 ? (all zeroes) |
CDVD Reads and Seeks |
block_timing = (IOP_CLOCK * block_size) / read_speed |
CDVD S Commands |
0 Subcommand number |
0-3 MECHACON version |
0 Update status (0=successful, 1=busy) |
0 Zero 1 Second 2 Minute 3 Hour 4 Zero 5 Day 6 Month 7 Year |
0 Ignored 1 Second 2 Minute 3 Hour 4 Ignored 5 Day 6 Month 7 Year |
0 Update status (0=successful, 1=busy) |
Sound Processing Unit (SPU2) |
SPU2 AutoDMA |
0 On core0, 1=start ADMA write/ADMA busy. No effect on core1 1 Same as above, but only works on core1 2 Start ADMA read on this core (1=start ADMA read). Unknown how ADMA reads work |
2000h-20FFh Core0 left buffer 0 2100h-21FFh Core0 left buffer 1 2200h-22FFh Core0 right buffer 0 2300h-23FFh Core0 right buffer 1 2400h-24FFh Core1 left buffer 0 2500h-25FFh Core1 left buffer 1 2600h-26FFh Core1 right buffer 0 2700h-27FFh Core1 right buffer 1 |
PS2 Serial Port (SIO2) |
SIO2 Registers |
0-1 Port 8-16 Fake command length, not used by SIO2 18-24 Real command length (counting peripheral byte) Other Unknown |
Write CTRL | 0Ch to CTRL. Write data to SEND1 and SEND2, then write data to SEND3. Write data to DATAIN if applicable, then start SIO2in and SIO2out DMA transfers if applicable. Write CTRL | 01h to CTRL, then wait for an SIO2 interrupt. After interrupt, read RECV1, RECV2, and RECV3, then read DATAOUT if applicable. |
SIO2 PS2 Memcards |
Command: 11 + 1 XX byte Reply: 2B + Terminator Length: 2 bytes |
Command: 12 + 1 XX byte Reply: 2B + Terminator Length: 2 bytes |
Command: 21 + 4-byte sector address + 2 XX bytes Reply: 5 XX bytes + 2Bh + Terminator Length: 7 bytes |
Command: 26 + 10 XX bytes Reply: 2B + 2-byte sector size in bytes + 2-byte erase block size + 4-byte sector count + 1-byte checksum + Terminator Length: 11 bytes |
2B 00 02 10 00 00 40 00 00 52 |
Command: 27 + 1-byte new terminator + 1 XX byte Reply: XX + 2B + Old terminator Length: 3 bytes |
Command: 28 + 2 XX bytes Reply: 2B + Terminator + 55 Length: 3 bytes |
Command: 42 + 1-byte write size + 128 data bytes + 2 XX bytes Reply: 2B + Terminator + 129 XX bytes + Terminator Length: 132 bytes |
Command: 42 + 1-byte read size + 130 XX bytes Reply: 2B + Terminator + 128 data bytes + 1-byte XOR checksum + Terminator Length: 132 bytes |
Command: 81 + 1 XX byte Reply: 2B + Terminator Length: 2 bytes |
Command: 82 + 1 XX byte Reply: 2B + Terminator Length: 2 bytes |
Command: 82 + 2 XX bytes Reply: 1 XX byte + 2B + Terminator Length: 3 bytes |
Command: F0 + 1-byte param + variable Reply: 1 XX byte + 2B + Variable + Terminator Length: 12 bytes |
Command: F3 + 2 XX bytes Reply: 1 XX byte + 2B + Terminator Length: 3 bytes |
Command: F7 + 2 XX bytes Reply: 1 XX byte + 2B + Terminator Length: 3 bytes |
SIO2 PS2 Memcard Filesystem |
Byte Name 0-27 Magic string. Should contain "Sony PS2 Memory Card Format " 28-39 Version string. Has the format "1.x.0.0", where x is the minor version 40-41 Size in bytes of a page. Default 512 42-43 Pages per cluster. Default 2 44-45 Pages per erase block. Default 16 46-47 Set to -256. Doesn't seem to be used 48-51 Total clusters in the card. Default 8192 52-55 Offset of the first allocatable cluster, in cluster units. Immediately after the FAT 56-59 Offset of the cluster after the last allocatable cluster, relative to the first 60-63 Offset of the root directory cluster, relative to the first. Should be 0 64-67 Backup erase block. Should be the last block in the card, default 1023 68-71 Second backup block, should be the second-last block in the card 80-207 Array of 32 indirect FAT cluster indices. On a standard card, only one indirect cluster is used 208-335 Array of 32 bad blocks, which cannot be used. -1 indicates no entry 384 Memory card type. Should be 2, indicating a PS2 memory card 385 Card flags. Default 52h Bit 0=ECC support if set Bit 3=Card has bad blocks Bit 4=Erased blocks have bits set to 0 if set |
SIO2 Controller Commands |
Command: 01 + command byte + 00 Reply: FF + depends on command + 5A Length: 3 |
Command: header + 5A + 5A + 5A + 5A + 5A + 5A If in digital mode or a nonstandard controller: Reply: header reply + zero bytes If in analog or DS2 mode: Reply: header reply + 3 mask bytes + 00 + 00 + 5A Length: 8 +---- (last byte is always 0x5A) |
Command: header + variable zero bytes If in digital mode or a nonstandard controller: Reply: header reply (returns mode byte) + 2 button state bytes Length: 4 If in analog or DS2 mode: Reply: header reply (returns mode byte) + 2 button state bytes + 4 analog button state bytes + (optional) 12 button pressure bytes Length: 8 or 20 depending if analog button pressures are requested. |
12h Mouse 23h NeGcon 41h DualShock Digital 73h DualShock Analog 79h DualShock 2 (analog+pressure) F3h In config mode |
Outside config mode: Command: header + 1 config byte (1=enter config) + zero bytes Reply: header reply (with mode byte) + same as Read Data (but without pressure values in DS2 mode) Length: Same as Read Data Inside config mode: Command: header + 1 config byte (0=exit config) + zero bytes Reply: header reply (with mode byte) + 6 zero bytes Length: 8 |
Command: header + 5A + 5A + 5A + 5A + 5A + 5A Reply: header reply + model + 02 + analog + 02 + 01 + 00 Length: 8 |
Command: header + index + 5A + 5A + 5A + 5A + 5A If index=0 Reply: header reply + 00 + 00 + 01 + 02 + 00 + 0A If index=1 Reply: header reply + 00 + 00 + 01 + 01 + 01 + 14 Length: 8 |
Command: header + 00 + 5A + 5A + 5A + 5A + 5A Reply: header reply + 00 + 00 + 02 + 00 + 01 + 00 Length: 8 |
Command: header + index + 5A + 5A + 5A + 5A + 5A Reply: header reply + 00 + 00 + 00 + val + 00 + 00 Length: 8 if index=0, val=4 if index=1, val=7 |
Command: header + aa + bb + cc + dd + ee + ff Reply: header reply + .. old rumble values .. Length: 8 |
SIO2 Command Sequence |
Cmd Reply 42h ID_lo ??h ID_hi ??h Buttons_lo ??h Buttons_hi ---- transfer stops here if digital ---- ??h Analog right joystick, y-axis (00h = upmost, 80h = centered, FFh = downmost) ??h Analog right joystick, x-axis (00h = leftmost, 80h = centered, FFh = rightmost) ??h Analog left joystick, y-axis (see above) ??h Analog right joystick, x-axis (see above) ---- transfer stops here if not DS2 ---- ??h D-pad right pressure (00h = no pressure, FFh = max pressure) ??h D-pad left pressure ??h D-pad up pressure ??h D-pad down pressure ??h Triangle pressure ??h Circle pressure ??h Cross pressure ??h Square pressure ??h L1 pressure ??h R1 pressure ??h L2 pressure ??h R2 pressure Button bits (0=pressed, 1=released): 0 Select 1 L3 2 R3 3 Start 4 D-pad Up 5 D-pad Right 6 D-pad Down 7 D-pad Left 8 L2 9 R2 10 L1 11 R1 12 Triangle 13 Circle 14 Cross 15 Square |
IOP Interrupts |
0 IRQ0 VBLANK start 1 IRQ1 GPU (used in PSX mode) 2 IRQ2 CDVD Drive 3 IRQ3 DMA 4 IRQ4 Timer 0 5 IRQ5 Timer 1 6 IRQ6 Timer 2 7 IRQ7 SIO0 8 IRQ8 SIO1 9 IRQ9 SPU2 10 IRQ10 PIO 11 IRQ11 VBLANK end 12 IRQ12 DVD? (unknown purpose) 13 IRQ13 PCMCIA (related to DEV9 expansion slot) 14 IRQ14 Timer 3 15 IRQ15 Timer 4 16 IRQ16 Timer 5 17 IRQ17 SIO2 18 IRQ18 HTR0? (unknown purpose) 19 IRQ19 HTR1? 20 IRQ20 HTR2? 21 IRQ21 HTR3? 22 IRQ22 USB 23 IRQ23 EXTR? (unknown purpose) 24 IRQ24 FWRE (related to FireWire) 25 IRQ25 FDMA? (FireWire DMA?) 26-31 Unused/garbage |
0 Enable all interrupts 1-31 Unused/garbage |
IOP DMA |
Old channels 1F80108xh 0 MDECin 1F80109xh 1 MDECout 1F8010Axh 2 SIF2 (EE<->IOP, GPU in PSX mode) 1F8010Bxh 3 CDVD (CDROM in PSX mode) 1F8010Cxh 4 SPU1 1F8010Dxh 5 PIO 1F8010Exh 6 OTC New channels 1F80150xh 7 SPU2 1F80151xh 8 DEV9 (expansion port) 1F80152xh 9 SIF0 (IOP->EE, uses TADR) 1F80153xh 10 SIF1 (EE->IOP) 1F80154xh 11 SIO2in 1F80155xh 12 SIO2out |
0-23 Start address of transfer in RAM 24-31 Unused, zero |
0-15 Block size in words (0=0x10000) 16-31 Block count |
0 Transfer direction (0=to RAM, 1=from RAM) 1 MADR increment per step (0=+4, 1=-4) 2-7 Unused 8 When 1: -Burst mode: enable "chopping" (cycle stealing by CPU) -Slice mode: Causes DMA to hang -Linked-list/Chain mode: Transfer header/tag before data 9-10 Transfer mode 0=Burst (transfer data all at once, only low 16 bits of BCR are valid) 1=Slice (transfer in units of BCR blocks and arbitrate) 2=Linked-list mode 3=Chain mode (uses TADR) 11 Unknown, used by iLink DMA 12-15 Unused 16-18 Chopping DMA window size (1 << N words) 19 Unused 20-22 Chopping CPU window size (1 << N cycles) 23 Unused 24 Start transfer (0=stopped/completed, 1=start/busy) 28 Force transfer start without waiting for DREQ 29 In forced-burst mode, pauses transfer while set. In other modes, stops bit 28 from being cleared after a slice is transferred. No effect when transfer was caused by a DREQ. 30 Perform bus snooping (allows DMA to read from IOP cache?) 31 iLink automatic response - unknown purpose |
0-23 Start address of list of tags 24-31 Unused, zero |
0-23 Start address of transfer in RAM 30 IRQ - raises IQE interrupt in DICR2 when all words in this tag are transferred 31 End of transfer, raises transfer completion interrupt 32-55 Size of transfer in words ... Optionally 2 words to transfer after tag ... |
Each 4 bits correspond to a channel. Bits 0-2 are priority, where 0=highest and 7=lowest. If two channels have the same priority, priority is determined by channel number, where higher channels have higher priority. Bit 3 is a channel enable, 0=disable, 1=enable. 0-3 Channel 0 (MDECin) 4-7 Channel 1 (MDECout) 8-11 Channel 2 (SIF2) 12-15 Channel 3 (CDVD) 16-19 Channel 4 (SPU1) 20-23 Channel 5 (PIO) 24-27 Channel 6 (OTC) 28-31 Channel 'C' (CPU priority. Bit 31 has no effect) Initial value on PS2 reset is 0x07777777. Initial value on PSX reset is 0x07654321. |
Works similarly to DPCR. 0-3 Channel 7 (SPU2) 4-7 Channel 8 (DEV9) 8-11 Channel 9 (SIF0) 12-15 Channel 10 (SIF1) 16-19 Channel 11 (SIO2in) 20-23 Channel 12 (SIO2out) 24-27 Channel 'U' (USB DMA, controlled through USB registers) 28-31 Unknown |
0-6 Controls channel 0-6 completion interrupts in bits 24-30. When 0, an interrupt only occurs when the entire transfer completes. When 1, interrupts can occur for every slice and linked-list transfer. No effect if the interrupt is masked by bits 16-22. 7-14 Unused 15 Bus error flag. Raised when transferring to/from an address outside of RAM. Forces bit 31 to be set. 16-22 Channel 0-6 interrupt mask. If enabled, channels cause interrupts as per bits 0-6. 23 Master channel interrupt enable. 24-30 Channel 0-6 interrupt flags. Writing 1 clears a flag. IMPORTANT: The flag only gets raised if the interrupt is enabled! INTRMAN relies on this behavior. 31 Master interrupt flag. When set, IRQ 3 is sent to the IOP's INTC. DICR.31 = DICR.15 | (DICR.23 && (DICR.24-30 || DICR2.24-29) |
0-12 Interrupt on tag bit. Corresponds to channels 0-12, but only bits 4, 9, and 10 can be set - this corresponds to SPU1, SIF0, and SIF1. When set, an interrupt is raised on an IRQ tag when the tag transfer completes. NOTE: This works independently of the channel's interrupt mask, so a tag interrupt can still happen even when the transfer interrupt is disabled. 13-15 Unused 16-21 Channel 7-12 interrupt mask. If enabled, channels cause interrupts upon transfer completion. 22-23 Unused 24-29 Channel 7-12 interrupt flags. Works same as DICR interrupt flags, including being masked by DICR.23 30-31 Unused |
0 0=All transfers disabled 1=All transfers enabled |
0 When 0, all channel interrupts disabled. Master interrupt flag is 0 in all cases but bus error interrupts. 1 When 1, DMA interrupts disabled - IRQ 3 is never sent to INTC. Does not affect master interrupt flag. |
IOP Timers |
0-15 Current value 16-31 Unused/garbage |
0-31 Current value |
0 Gate enable 1-2 Gate mode 3 Zero return - reset counter on interrupt 4 Compare interrupt enabled 5 Overflow interrupt enabled 6 Repeat interrupt - if unset, bit 10 is set to 0 after interrupt occurs. 7 LEVL - toggle bit 10 on IRQs if bit 6 is set. 8 Use external signal If set: Timer 0: pixel clock (13.5 MHz regardless of screen mode) Timer 1/3: HBLANK Others: sysclock (no effect) 9 Timer 2 prescaler 10 Interrupts enabled (R) 11 Compare interrupt raised (R) 12 Overflow interrupt raised (R) 13-14 Timer 4/5 prescalar 15-31 Unused/garbage |
0 normal 1 1/8 speed 2 1/16 speed 3 1/256 speed |
0-15 Value 16-31 Unused/garbage |
0-31 Value |
IOP Console |
if (PC == 0x12C48 || PC == 0x1420C || PC == 0x1430C) { uint32_t pointer = gpr[5]; uint32_t text_size = gpr[6]; while (text_size) { auto c = (char)ram[pointer & 0x1FFFFF]; putc(c); pointer++; text_size--; } } |
Subsystem Interface (SIF) |
SIF Registers |
0-31 Value |
0-31 Value |
10000h: SIF DMA/hardware initialized 20000h: SIFCMD initialized 40000h: IOP has finished booting (sent by EESYNC) |
1 Always 1? 8 Always 1 for EE, 0 for IOP? 28-31 Always 0xF? Other Unknown |
0-31 Unknown |
SIF DMA |
SIF RPC Basics |
SIF RPC Structs and Definitions |
typedef void (*SifCmdHandler)(void *data, void *harg); typedef void* (*SifRpcFunc)(int fno, void *buff, int length); typedef void (*SifRpcEndFunc)(void *end_param); |
struct SifCmdHeader { uint psize:8; //Size of the command packet uint dsize:24; //Size of the payload, if any void *dest; //Destination of the payload, if any int cid; //Command ID uint opt; } struct SifRpcPktHeader { struct SifCmdHeader sifcmd; int rec_id; void *pkt_addr; int rpc_id; } |
struct SifRpcClientData { struct SifRpcHeader hdr; u32 command; void *buff, *cbuff; SifRpcEndFunc end_function; void *end_param; struct SifRpcServerData *server; } |
struct SifRpcServerData { int sid; SifRpcFunc func; void *buff; int size; SifRpcFunc cfunc; void *cbuff; int size2; struct SifRpcClientData *client; void *pkt_addr; int rpc_number; void *receive; int rsize; int rmode; int rid; struct SifRpcServerData *link; struct SifRpcServerData *next; struct SifRpcDataQueue *base; } |
struct SifRpcDataQueue { int thread_id, active; struct SifRpcServerData *link, *start, *end; struct SifRpcDataQueue *next; } |
struct SifDmaTransfer { void *src, *dest; int size; int attr; } |
SIF RPC Commands |
struct SifSaddrPkt { struct SifCmdHeader header; void* buff; } |
struct SifCmdSRegData { SifCmdHeader header; int index; uint value; } |
struct SifInitPkt { struct SifCmdHeader header; //NOTE: The "opt" field is used by the IOP. void* buff; } |
struct SifIopResetPkt { struct SifCmdHeader header; int arglen; //Length of the command int mode; //Bit 31 enables debug logging, unknown what other values do char arg[80]; //The command to be passed to MODLOAD } |
struct SifRpcRendPkt { struct SifCmdHeader sifcmd; int rec_id; void *pkt_addr; int rpc_id; struct SifRpcClientData *client; uint cid; //ID of the command sent by the other side (e.g. the command that triggered a REND) struct SifRpcServerData *server; void *buff, *cbuff; } |
struct SifRpcBindPkt { struct SifCmdHeader sifcmd; int rec_id; void *pkt_addr; int rpc_id; struct SifRpcClientData *client; int sid; //ID of the server } |
struct SifRpcCallPkt { struct SifCmdHeader sifcmd; int rec_id; void *pkt_addr; int rpc_id; struct SifRpcClientData *client; int rpc_number; //ID of the function to call on the server int send_size; //Size of data to send to the server void *receive; //Buffer to hold reply data from the server int recv_size; //Size of reply buffer int rmode; struct SifRpcServerData *server; } |
struct SifRpcOtherDataPkt { struct SifCmdHeader sifcmd; int rec_id; void *pkt_addr; int rpc_id; struct SifRpcReceiveData *receive; void *src; void *dest; int size; } |
SIF RPC System Servers |
BIOS |
BIOS File Structure |
struct romdir_entry { char name[10]; //File name, must be null terminated ushort ext_info_size; //Size of the file's extended info in EXTINFO uint file_size; //Size of the file itself } |
0x00002740: 52455345 54000000 00000C00 40270000 RESET 0x00002750: 524F4D44 49520000 00005400 D0050000 ROMDIR 0x00002760: 45585449 4E464F00 00000000 80070000 EXTINFO 0x00002770: 524F4D56 45520000 00000000 10000000 ROMVER ... |
BIOS Boot Process |
BIOS EE Threading |
struct ThreadParam //Used as argument for CreateThread, ReferThreadStatus { int status; void *func; //function to execute when thread begins void *stack; int stack_size; void *gp_reg; int initial_priority; int current_priority; u32 attr; u32 option; } |
struct SemaParam //Used as argument for CreateSema { int count, //used by WaitSema and SignalSema max_count, init_count, //initial value for count wait_threads; //number of threads associated with this semaphore u32 attr, //not used by kernel option; //not used by kernel } |
//Thread statuses #define THS_RUN 0x01 #define THS_READY 0x02 #define THS_WAIT 0x04 #define THS_SUSPEND 0x08 #define THS_WAITSUSPEND 0x0C //THS_WAIT | THS_SUSPEND #define THS_DORMANT 0x10 struct TCB //Internal thread structure { struct TCB *prev; struct TCB *next; int status; void *func; void *current_stack; void *gp_reg; short current_priority; short init_priority; int wait_type; //0=not waiting, 1=sleeping, 2=waiting on semaphore int sema_id; int wakeup_count; int attr; int option; void *_func; //??? int argc; char **argv; void *initial_stack; int stack_size; int *root; //function to return to when exiting thread? void *heap_base; } |
struct thread_context //Stack context layout { u32 sa_reg; // Shift amount register u32 fcr_reg; // FCR[fs] (fp control register) u32 unkn; u32 unused; u128 at, v0, v1, a0, a1, a2, a3; u128 t0, t1, t2, t3, t4, t5, t6, t7; u128 s0, s1, s2, s3, s4, s5, s6, s7, t8, t9; u64 hi0, hi1, lo0, lo1; u128 gp, sp, fp, ra; u32 fp_regs[32]; } |
struct sema //Internal semaphore structure { struct sema *free; //pointer to empty slot for a new semaphore int count; int max_count; int attr; int option; int wait_threads; struct TCB *wait_next, *wait_prev; } |
void reschedule(uint32 EPC, uint32 stack) Set current thread entry function to EPC (instruction after exception) Set current thread stack base to stack Set current thread status to READY Loop through active thread priority list, starting from 0 (highest priority) If an active thread is found, set current thread to it and break If no active thread is found, print an error and call Exit(1) Set found thread's status to RUN and return its entry function and stack pointer |
BIOS EE Syscalls |
0 - DMAC 1 - VU1 2 - VIF1 3 - GIF 4 - VU0 5 - VIF0 6 - IPU |
No status (0), RUN, DORMANT - No effect. READY - Removes thread from active thread list, resets it, and gives it DORMANT status, forcing a thread reschedule. WAIT, WAITSUSPEND - Same as READY but also decrements the thread's semaphore's "wait_threads" by one. All other statuses - Resets the thread and gives the thread DORMANT status, forcing a thread reschedule. |
WAIT (sleeping) - Set to READY and re-added to active thread list, forcing a thread reschedule. WAITSUSPEND (sleeping) - Placed in SUSPEND status, forcing a thread reschedule. READY, SUSPEND, WAIT/WAITSUSPEND (semaphore) - Increments "wakeup_count", forcing a thread reschedule. Other statuses - No effect. |
READY, RUN - Removed from active thread list and placed in SUSPEND status. WAIT - Placed in WAITSUSPEND status. All other statuses - No effect. |
SUSPEND - Placed in READY or RUN status and added to active thread list, forcing a thread reschedule. WAITSUSPEND - Placed in WAIT status, forcing a thread reschedule. All other statuses - No effect |
Modes of operation mode=0: Flush data cache (invalidate+writeback dirty contents to memory) mode=1: Invalidate data cache mode=2: Invalidate instruction cache All other modes invalidate both caches. |
struct SifDmaTransfer //Internal semaphore structure { void* src; //EE source void* dest; //IOP destination int size; //Size in bytes int attr; } |
BIOS EE Patches |
BIOS PlayStation Compatibility |
BIOS IOP Module Linking |
struct export_table { uint magic; //Must equal 0x41C00000! export_table* next; //Internal data for LOADCORE ushort version; //0x101 would be version 1.01 ushort mode; //Unknown what this does char name[8]; //Name of the module. Must include a NULL terminator. void* export[0]; //An arbitrarily sized array of function pointers. } |
struct import_table { uint magic; //Must equal 0x41E00000! import_table* next; //Internal data for LOADCORE ushort version; ushort mode; char name[8]; void* import[0]; //An arbitrarily sized array of jr ra; addiu zero, zero, X instruction pairs. More on that below. } |
BIOS List of IOP Modules |
BIOS IOP IOPBOOT - Kernel Bootstrap |
@800 SYSMEM LOADCORE EXCEPMAN INTRMANP INTRMANI SSBUSC DMACMAN TIMEMANP TIMEMANI ... |
BIOS IOP SYSMEM - Memory Management |
BIOS IOP LOADCORE - Kernel Loader and Linker |
struct lc_params { uint ram_size; int boot_mode; //Determines what kind of reset has occurred, used by MODLOAD to start UDNL when rebooting the IOP. char* udnl_str; //Full argument list passed to UDNL u32* sysmem_start; void* img_pos; //Pointer to memory that should be allocated. Used by UDNL to contain the updated modules. int img_buff_size; int module_count; u32** module_addr_list; //List of all modules to load. This includes SYSMEM and LOADCORE } |
BIOS IOP EXCEPMAN - Exception Manager |
BIOS IOP INTRMAN - Interrupt Manager |
BIOS IOP SSBUSC - Subsystem Bus Controller |
BIOS IOP DMACMAN - DMA Manager |
BIOS IOP TIMRMAN - Timer Manager |
BIOS IOP SYSCLIB - Standard C Library |
BIOS IOP HEAPLIB - Heap Allocation Library |
BIOS IOP EECONF - EE Configuration |
BIOS IOP THREADMAN - Thread Manager |
BIOS IOP THBASE - Basic Threading |
BIOS IOP THEVENT - Event Flags |
BIOS IOP THSEMAP - Semaphores |
BIOS IOP THMSGBX - Message Boxes |
BIOS IOP THFPOOL - Fixed-length Memory Pools |
BIOS IOP THVPOOL - Variable-length Memory Pools |
BIOS IOP VBLANK - VBLANK Interrupt Manager |
BIOS IOP IOMAN - File Input/Output Manager |
BIOS IOP MODLOAD - Module Loader |
BIOS IOP ROMDRV - ROM File Driver |
BIOS IOP STDIO - C Standard Input/Output |
BIOS IOP SIFMAN - SIF Low-level Manager |
BIOS IOP IGREETING - Boot Info Display |
PlayStation 2 ======== Hard reset boot ROMGEN=2002-0207, IOP info (CPUID=1f, CACH_CONFIG=0, 2MB, IOP mode) <20020207-164243,ROMconf,PS20160AC20020207.bin:11552> |
BIOS IOP SIFCMD - SIF RPC Manager |
BIOS IOP REBOOT - SIF Reboot Server |
BIOS IOP LOADFILE - Module Loader RPC Server |
BIOS IOP CDVDMAN - CDVD Manager |
BIOS IOP CDVDFSV - CDVD RPC Server |
BIOS IOP SIFINIT - SIF Initialization |
BIOS IOP FILEIO - File Input/Output RPC Server |
BIOS IOP SECRMAN - Security Manager |
BIOS IOP EESYNC - Boot Finish Messager |
BIOS IOP LIBSD - Low-level Sound Library |
BIOS IOP SIO2MAN - SIO2 Manager |
BIOS IOP MCMAN - Memory Card Manager |
BIOS IOP MCSERV - Memory Card RPC Server |
BIOS IOP PADMAN - Pad Input Manager |