├── .gitignore ├── tests ├── cpu │ ├── ee │ │ ├── lsudelay.expected │ │ ├── alu.elf │ │ ├── lsu.elf │ │ ├── branch.elf │ │ ├── muldiv.elf │ │ ├── lsudelay.elf │ │ ├── branchdelay.elf │ │ ├── Makefile │ │ ├── branchdelay.expected │ │ ├── lsudelay.cpp │ │ └── shared.h │ ├── iop │ │ ├── alu.irx │ │ ├── lsu.irx │ │ ├── branch.irx │ │ ├── muldiv.irx │ │ ├── hilodelay.irx │ │ ├── lsudelay.irx │ │ ├── branchdelay.irx │ │ ├── hilodelay.expected │ │ ├── Makefile │ │ ├── lsudelay.expected │ │ ├── branchdelay.expected │ │ ├── hilodelay.c │ │ ├── lsu.expected │ │ └── lsudelay.c │ ├── ee_fpu │ │ ├── fcr.elf │ │ ├── branch.elf │ │ ├── muldiv.elf │ │ ├── sqrt.elf │ │ ├── compare.elf │ │ ├── convert.elf │ │ ├── transfer.elf │ │ ├── arithmetic.elf │ │ ├── branchdelay.elf │ │ ├── branchdelay.expected │ │ ├── Makefile │ │ ├── transfer.expected │ │ ├── branch.expected │ │ ├── branchdelay.cpp │ │ ├── shared.h │ │ ├── fcr.expected │ │ ├── branch.cpp │ │ ├── convert.expected │ │ ├── sqrt.expected │ │ ├── convert.cpp │ │ └── compare.cpp │ ├── ee_simd │ │ ├── logic.elf │ │ ├── compare.elf │ │ ├── funnel.elf │ │ ├── muldiv.elf │ │ ├── shuffle.elf │ │ ├── arithmetic.elf │ │ ├── Makefile │ │ ├── funnel.expected │ │ ├── shared.h │ │ └── compare.cpp │ ├── vu0_macro │ │ ├── integer.elf │ │ ├── transfer.elf │ │ ├── Makefile │ │ ├── shared.h │ │ ├── shared.cpp │ │ └── transfer.expected │ └── ee_cop0 │ │ ├── performance.elf │ │ ├── Makefile │ │ └── performance.expected ├── gs │ ├── label.elf │ ├── signal.elf │ ├── label.expected │ ├── Makefile │ ├── signal.expected │ ├── gsregs.cpp │ ├── gsregs.h │ ├── label.cpp │ ├── signal.cpp │ ├── emit_giftag.cpp │ └── emit_giftag.h ├── vu │ ├── lower │ │ ├── efu.elf │ │ ├── branch.elf │ │ ├── integer.elf │ │ ├── random.elf │ │ ├── fdivdelay.elf │ │ ├── branch.expected │ │ ├── Makefile │ │ ├── branch.cpp │ │ ├── random.expected │ │ └── random.cpp │ ├── upper │ │ ├── clip.elf │ │ ├── Makefile │ │ └── clip.expected │ ├── games │ │ ├── triace.elf │ │ ├── Makefile │ │ ├── triace.expected │ │ └── triace.cpp │ ├── assemble.h │ ├── test_runner.h │ └── assemble │ │ ├── encoding.h │ │ └── types.h ├── dma │ ├── spr │ │ ├── chain.elf │ │ ├── normal.elf │ │ ├── interleave.elf │ │ ├── Makefile │ │ ├── chain.expected │ │ └── normal.expected │ ├── vif │ │ ├── basic.elf │ │ ├── stcycl.elf │ │ ├── stmod.elf │ │ ├── unpack.elf │ │ ├── intstall.elf │ │ ├── mskpath3.elf │ │ ├── mskpath3.expected │ │ ├── Makefile │ │ ├── basic.expected │ │ ├── vifunits.h │ │ ├── intstall.expected │ │ ├── mskpath3.cpp │ │ ├── intstall.cpp │ │ ├── basic.cpp │ │ ├── stmod.cpp │ │ ├── vifregs.h │ │ ├── emit_vifcode.h │ │ └── unpack.expected │ ├── dmac │ │ ├── cpcond.elf │ │ ├── tagintr.elf │ │ ├── Makefile │ │ ├── cpcond.expected │ │ ├── tagintr.expected │ │ ├── cpcond.cpp │ │ └── tagintr.cpp │ ├── dmasend.h │ ├── dmasend.cpp │ ├── dmatags.h │ └── dmatags.cpp ├── memory │ └── ee │ │ ├── default.elf │ │ ├── Makefile │ │ ├── default.expected │ │ └── default.cpp └── kernel │ ├── ee │ ├── thread │ │ ├── exit.elf │ │ ├── sleep.elf │ │ ├── stat.elf │ │ ├── delete.elf │ │ ├── resume.elf │ │ ├── suspend.elf │ │ ├── wakeup.elf │ │ ├── terminate.elf │ │ ├── sleep.expected │ │ ├── Makefile │ │ ├── exit.expected │ │ ├── delete.expected │ │ ├── resume.expected │ │ ├── suspend.expected │ │ ├── wakeup.expected │ │ ├── terminate.expected │ │ ├── stat.expected │ │ ├── sleep.cpp │ │ └── exit.cpp │ └── interrupt │ │ ├── dmac_order.elf │ │ ├── intc_order.elf │ │ ├── Makefile │ │ ├── dmac_order.expected │ │ └── intc_order.expected │ └── iop │ ├── libc │ ├── strtok.irx │ ├── sprintf.irx │ ├── Makefile │ ├── sprintf.expected │ ├── strtok.expected │ ├── strtok.c │ └── sprintf.c │ ├── thread │ ├── stat.irx │ ├── create.irx │ ├── delete.irx │ ├── releasewait.irx │ ├── cancelwakeup.irx │ ├── irx_imports.h │ ├── Makefile │ ├── thread-common.h │ ├── imports.lst │ ├── cancelwakeup.expected │ ├── delete.expected │ ├── thread-common.c │ ├── releasewait.expected │ ├── create.expected │ ├── stat.expected │ ├── delete.c │ ├── cancelwakeup.c │ ├── create.c │ └── releasewait.c │ ├── vpool │ ├── create.irx │ ├── pallocate.irx │ ├── vpl-common.h │ ├── irx_imports.h │ ├── imports.lst │ ├── Makefile │ ├── vpl-common.c │ ├── create.expected │ ├── create.c │ └── pallocate.c │ ├── eventflag │ ├── delete.irx │ ├── poll.irx │ ├── Makefile │ ├── imports.lst │ ├── irx_imports.h │ ├── delete.expected │ ├── poll.expected │ └── delete.c │ ├── messagebox │ ├── poll.irx │ ├── send.irx │ ├── receive.irx │ ├── Makefile │ ├── irx_imports.h │ ├── imports.lst │ ├── mbx-common.h │ ├── receive.expected │ ├── poll.expected │ ├── send.expected │ ├── mbx-common.c │ ├── poll.c │ ├── receive.c │ └── send.c │ └── interrupt │ ├── register.irx │ ├── release.irx │ ├── Makefile │ ├── release.expected │ ├── register.expected │ └── release.c ├── .gitattributes ├── common ├── common-iop.h ├── common-ee.h ├── common-defines.mk ├── common-iop.c ├── xprintf.h ├── common-iop.mk ├── common-ee.mk └── common-ee.cpp ├── LICENSE.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.result 3 | -------------------------------------------------------------------------------- /tests/cpu/ee/lsudelay.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | lw: 13371337 3 | -- TEST END 4 | -------------------------------------------------------------------------------- /tests/gs/label.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/gs/label.elf -------------------------------------------------------------------------------- /tests/gs/signal.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/gs/signal.elf -------------------------------------------------------------------------------- /tests/cpu/ee/alu.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee/alu.elf -------------------------------------------------------------------------------- /tests/cpu/ee/lsu.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee/lsu.elf -------------------------------------------------------------------------------- /tests/cpu/iop/alu.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/alu.irx -------------------------------------------------------------------------------- /tests/cpu/iop/lsu.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/lsu.irx -------------------------------------------------------------------------------- /tests/vu/lower/efu.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/lower/efu.elf -------------------------------------------------------------------------------- /tests/cpu/ee/branch.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee/branch.elf -------------------------------------------------------------------------------- /tests/cpu/ee/muldiv.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee/muldiv.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/fcr.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/fcr.elf -------------------------------------------------------------------------------- /tests/cpu/iop/branch.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/branch.irx -------------------------------------------------------------------------------- /tests/cpu/iop/muldiv.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/muldiv.irx -------------------------------------------------------------------------------- /tests/dma/spr/chain.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/spr/chain.elf -------------------------------------------------------------------------------- /tests/dma/spr/normal.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/spr/normal.elf -------------------------------------------------------------------------------- /tests/dma/vif/basic.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/vif/basic.elf -------------------------------------------------------------------------------- /tests/dma/vif/stcycl.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/vif/stcycl.elf -------------------------------------------------------------------------------- /tests/dma/vif/stmod.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/vif/stmod.elf -------------------------------------------------------------------------------- /tests/dma/vif/unpack.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/vif/unpack.elf -------------------------------------------------------------------------------- /tests/vu/upper/clip.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/upper/clip.elf -------------------------------------------------------------------------------- /tests/cpu/ee/lsudelay.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee/lsudelay.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/branch.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/branch.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/muldiv.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/muldiv.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/sqrt.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/sqrt.elf -------------------------------------------------------------------------------- /tests/cpu/ee_simd/logic.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_simd/logic.elf -------------------------------------------------------------------------------- /tests/cpu/iop/hilodelay.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/hilodelay.irx -------------------------------------------------------------------------------- /tests/cpu/iop/lsudelay.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/lsudelay.irx -------------------------------------------------------------------------------- /tests/dma/dmac/cpcond.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/dmac/cpcond.elf -------------------------------------------------------------------------------- /tests/dma/dmac/tagintr.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/dmac/tagintr.elf -------------------------------------------------------------------------------- /tests/dma/vif/intstall.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/vif/intstall.elf -------------------------------------------------------------------------------- /tests/dma/vif/mskpath3.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/vif/mskpath3.elf -------------------------------------------------------------------------------- /tests/memory/ee/default.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/memory/ee/default.elf -------------------------------------------------------------------------------- /tests/vu/games/triace.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/games/triace.elf -------------------------------------------------------------------------------- /tests/vu/lower/branch.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/lower/branch.elf -------------------------------------------------------------------------------- /tests/vu/lower/integer.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/lower/integer.elf -------------------------------------------------------------------------------- /tests/vu/lower/random.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/lower/random.elf -------------------------------------------------------------------------------- /tests/cpu/ee/branchdelay.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee/branchdelay.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/compare.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/compare.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/convert.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/convert.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/transfer.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/transfer.elf -------------------------------------------------------------------------------- /tests/cpu/ee_simd/compare.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_simd/compare.elf -------------------------------------------------------------------------------- /tests/cpu/ee_simd/funnel.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_simd/funnel.elf -------------------------------------------------------------------------------- /tests/cpu/ee_simd/muldiv.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_simd/muldiv.elf -------------------------------------------------------------------------------- /tests/cpu/ee_simd/shuffle.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_simd/shuffle.elf -------------------------------------------------------------------------------- /tests/cpu/iop/branchdelay.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/iop/branchdelay.irx -------------------------------------------------------------------------------- /tests/dma/spr/interleave.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/dma/spr/interleave.elf -------------------------------------------------------------------------------- /tests/vu/lower/fdivdelay.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/vu/lower/fdivdelay.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/arithmetic.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/arithmetic.elf -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/branchdelay.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_fpu/branchdelay.elf -------------------------------------------------------------------------------- /tests/cpu/ee_simd/arithmetic.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_simd/arithmetic.elf -------------------------------------------------------------------------------- /tests/cpu/vu0_macro/integer.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/vu0_macro/integer.elf -------------------------------------------------------------------------------- /tests/cpu/vu0_macro/transfer.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/vu0_macro/transfer.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/exit.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/exit.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/sleep.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/sleep.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/stat.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/stat.elf -------------------------------------------------------------------------------- /tests/kernel/iop/libc/strtok.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/libc/strtok.irx -------------------------------------------------------------------------------- /tests/kernel/iop/thread/stat.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/thread/stat.irx -------------------------------------------------------------------------------- /tests/cpu/ee_cop0/performance.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/cpu/ee_cop0/performance.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/delete.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/delete.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/resume.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/resume.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/suspend.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/suspend.elf -------------------------------------------------------------------------------- /tests/kernel/ee/thread/wakeup.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/wakeup.elf -------------------------------------------------------------------------------- /tests/kernel/iop/libc/sprintf.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/libc/sprintf.irx -------------------------------------------------------------------------------- /tests/kernel/iop/thread/create.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/thread/create.irx -------------------------------------------------------------------------------- /tests/kernel/iop/thread/delete.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/thread/delete.irx -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/create.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/vpool/create.irx -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/branchdelay.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | bc1t: delay branch: 00000004 3 | bc1tl: delay branch: 00000002 4 | -- TEST END 5 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/terminate.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/thread/terminate.elf -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/delete.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/eventflag/delete.irx -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/poll.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/eventflag/poll.irx -------------------------------------------------------------------------------- /tests/kernel/iop/libc/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = sprintf strtok 2 | 3 | COMMON_DIR=../../../../common 4 | include $(COMMON_DIR)/common-iop.mk 5 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/poll.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/messagebox/poll.irx -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/send.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/messagebox/send.irx -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/pallocate.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/vpool/pallocate.irx -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/vpl-common.h: -------------------------------------------------------------------------------- 1 | #ifndef VPL_COMMON_H 2 | #define VPL_COMMON_H 3 | 4 | void printVpl(s32 vplId); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /tests/cpu/ee_cop0/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = performance 2 | EE_LIBS = 3 | 4 | COMMON_DIR=../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/cpu/iop/hilodelay.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | mfhi delay: 10 3 | mflo delay: 20 4 | div delay: 1 1 5 | mult delay: 0 6 6 | -- TEST END 7 | -------------------------------------------------------------------------------- /tests/kernel/iop/interrupt/register.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/interrupt/register.irx -------------------------------------------------------------------------------- /tests/kernel/iop/interrupt/release.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/interrupt/release.irx -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/receive.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/messagebox/receive.irx -------------------------------------------------------------------------------- /tests/kernel/iop/thread/releasewait.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/thread/releasewait.irx -------------------------------------------------------------------------------- /tests/memory/ee/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = default 2 | EE_LIBS = -lg 3 | 4 | COMMON_DIR=../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/kernel/ee/interrupt/dmac_order.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/interrupt/dmac_order.elf -------------------------------------------------------------------------------- /tests/kernel/ee/interrupt/intc_order.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/ee/interrupt/intc_order.elf -------------------------------------------------------------------------------- /tests/kernel/iop/interrupt/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = register release 2 | 3 | COMMON_DIR=../../../../common 4 | include $(COMMON_DIR)/common-iop.mk 5 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/cancelwakeup.irx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unknownbrackets/ps2autotests/HEAD/tests/kernel/iop/thread/cancelwakeup.irx -------------------------------------------------------------------------------- /tests/gs/label.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | Set label bits -> SIGLBLID: 000000f076543210 3 | Clear label bits -> SIGLBLID: 3333330333333333 4 | -- TEST END 5 | -------------------------------------------------------------------------------- /tests/kernel/ee/interrupt/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = dmac_order intc_order 2 | EE_LIBS = 3 | 4 | COMMON_DIR=../../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/cpu/ee/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = alu branch branchdelay lsu lsudelay muldiv 2 | EE_LIBS = 3 | 4 | COMMON_DIR=../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/cpu/iop/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = alu branch branchdelay hilodelay lsu lsudelay muldiv 2 | 3 | COMMON_DIR=../../../common 4 | include $(COMMON_DIR)/common-iop.mk 5 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/sleep.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | sleep result (wakeupCount == 0): thread id 3 | sleep result (wakeupCount > 0): thread id 4 | -- TEST END 5 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "thpool.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = delete poll 2 | 3 | EXTRA_OBJS = imports.o 4 | 5 | COMMON_DIR=../../../../common 6 | include $(COMMON_DIR)/common-iop.mk 7 | -------------------------------------------------------------------------------- /tests/cpu/ee_simd/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = arithmetic compare funnel logic muldiv shuffle 2 | EE_LIBS = 3 | 4 | COMMON_DIR=../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/cpu/vu0_macro/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = transfer integer 2 | EXTRA_OBJS = shared.o 3 | EE_LIBS = 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/imports.lst: -------------------------------------------------------------------------------- 1 | 2 | thvpool_IMPORTS_start 3 | I_CreateVpl 4 | I_DeleteVpl 5 | I_pAllocateVpl 6 | I_FreeVpl 7 | I_ReferVplStatus 8 | thvpool_IMPORTS_end 9 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = create pallocate 2 | 3 | EXTRA_OBJS = imports.o vpl-common.o 4 | 5 | COMMON_DIR=../../../../common 6 | include $(COMMON_DIR)/common-iop.mk 7 | -------------------------------------------------------------------------------- /tests/gs/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = label signal 2 | EXTRA_OBJS = emit_giftag.o gsregs.o ../dma/dmatags.o ../dma/dmasend.o 3 | 4 | COMMON_DIR=../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = delete exit resume sleep stat suspend terminate wakeup 2 | EE_LIBS = 3 | 4 | COMMON_DIR=../../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/imports.lst: -------------------------------------------------------------------------------- 1 | 2 | thbase_IMPORTS_start 3 | I_ReferThreadStatus 4 | thbase_IMPORTS_end 5 | 6 | thevent_IMPORTS_start 7 | I_PollEventFlag 8 | thevent_IMPORTS_end 9 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = poll receive send 2 | 3 | EXTRA_OBJS = imports.o mbx-common.o 4 | 5 | COMMON_DIR=../../../../common 6 | include $(COMMON_DIR)/common-iop.mk 7 | -------------------------------------------------------------------------------- /tests/dma/dmac/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = cpcond tagintr 2 | EXTRA_OBJS = ../dmatags.o ../dmasend.o 3 | EE_LIBS = -lg -ldma 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = arithmetic branch branchdelay compare convert fcr muldiv sqrt transfer 2 | EE_LIBS = 3 | 4 | COMMON_DIR=../../../common 5 | include $(COMMON_DIR)/common-ee.mk 6 | -------------------------------------------------------------------------------- /tests/dma/spr/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = chain interleave normal 2 | EXTRA_OBJS = ../dmatags.o ../dmasend.o 3 | EE_LIBS = -lg -ldma 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/dma/vif/mskpath3.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | mask value (initial): 00000000 3 | mask value (after mskpath3(true))): 00000002 4 | mask value (after mskpath3(false))): 00000000 5 | -- TEST END 6 | -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "thbase.h" 7 | #include "thevent.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "thbase.h" 7 | #include "thmsgbx.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "thbase.h" 7 | #include "thmsgbx.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /tests/vu/upper/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = clip 2 | EXTRA_OBJS = ../assemble/block.o ../assemble/ops.o ../test_runner.o 3 | EE_LIBS = -lg 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/vu/games/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = triace 2 | EXTRA_OBJS = ../assemble/block.o ../assemble/ops.o ../test_runner.o 3 | EE_LIBS = -lg 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = cancelwakeup create delete releasewait stat 2 | 3 | EXTRA_OBJS = imports.o thread-common.o 4 | 5 | COMMON_DIR=../../../../common 6 | include $(COMMON_DIR)/common-iop.mk 7 | -------------------------------------------------------------------------------- /tests/vu/lower/branch.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | JALR /w diff regs -> targetReg: 0006 returnReg: 0004 resultReg: 0001 3 | JALR /w same regs -> targetReg: 0004 returnReg: 0004 resultReg: 0001 4 | -- TEST END 5 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/thread-common.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_COMMON_H 2 | #define THREAD_COMMON_H 3 | 4 | s32 getThreadPriority(s32 threadId); 5 | s32 createTestThread(void *entry, s32 prio, u32 stackSize); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /tests/gs/signal.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | Set signal bits -> CSR[SIGNAL] = 0000000000000001, SIGLBLID: 76543210000000f0 3 | Clear signal bits -> CSR[SIGNAL] = 0000000000000001, SIGLBLID: 3333333333333303 4 | -- TEST END 5 | -------------------------------------------------------------------------------- /tests/dma/vif/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = basic intstall mskpath3 stcycl stmod unpack 2 | EXTRA_OBJS = emit_vifcode.o ../dmatags.o ../dmasend.o 3 | EE_LIBS = -lg -ldma 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/imports.lst: -------------------------------------------------------------------------------- 1 | 2 | thbase_IMPORTS_start 3 | I_CancelWakeupThread 4 | I_ReferThreadStatus 5 | thbase_IMPORTS_end 6 | 7 | thmsgbx_IMPORTS_start 8 | I_CreateMbx 9 | I_ReceiveMbx 10 | thmsgbx_IMPORTS_end 11 | -------------------------------------------------------------------------------- /tests/vu/lower/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = branch efu fdivdelay integer random 2 | EXTRA_OBJS = ../assemble/block.o ../assemble/ops.o ../test_runner.o 3 | EE_LIBS = -lg 4 | 5 | COMMON_DIR=../../../common 6 | include $(COMMON_DIR)/common-ee.mk 7 | -------------------------------------------------------------------------------- /tests/dma/dmac/cpcond.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | initial value: 1 3 | value after setting PCR.CPC: 0 4 | value after sending DMA: 1 5 | value after clearing PCR.CPC: 1 6 | value after restoring PCR.CPC: 1 7 | value after resetting STAT.CIS: 0 8 | -- TEST END 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c text 2 | *.h text 3 | *.cpp text 4 | *.S text 5 | *.mk text 6 | Makefile text 7 | *.expected text 8 | *.py text 9 | 10 | *.elf binary 11 | *.irx binary 12 | -------------------------------------------------------------------------------- /tests/gs/gsregs.cpp: -------------------------------------------------------------------------------- 1 | #include "gsregs.h" 2 | 3 | namespace GS { 4 | u64 SIGNAL(u32 id, u32 idmsk) { 5 | return ((u64)id) | ((u64)idmsk << 32); 6 | } 7 | 8 | u64 LABEL(u32 id, u32 idmsk) { 9 | return ((u64)id) | ((u64)idmsk << 32); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/cpu/iop/lsudelay.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | lb 0: 00000000 3 | lw 0: 00000000 4 | lb 1: 11223344 5 | lw 1: 11223344 6 | lb 2: 00000037 7 | lw 2: 13371337 8 | ld 1: 13371337 00000000 9 | ld 2: 13371337 13371337 10 | lw then branch: 2 11 | -- TEST END 12 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/imports.lst: -------------------------------------------------------------------------------- 1 | 2 | thbase_IMPORTS_start 3 | I_ReferThreadStatus 4 | thbase_IMPORTS_end 5 | 6 | thmsgbx_IMPORTS_start 7 | I_CreateMbx 8 | I_SendMbx 9 | I_ReceiveMbx 10 | I_PollMbx 11 | I_DeleteMbx 12 | I_ReferMbxStatus 13 | thmsgbx_IMPORTS_end 14 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/mbx-common.h: -------------------------------------------------------------------------------- 1 | #ifndef MBX_COMMON_H 2 | #define MBX_COMMON_H 3 | 4 | typedef struct { 5 | iop_message_t header; 6 | u32 payload; 7 | } MSG; 8 | 9 | u32 getThreadPriority(s32 threadId); 10 | void printMbx(s32 mbxId); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /tests/kernel/iop/interrupt/release.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | normal operation: 3 | release after handler registered: 0 4 | release after null handler was registered: -105 5 | release after release: 6 | release after handler released: -105 7 | invalid params: 8 | invalid interrupt line: -101 9 | -- TEST END 10 | -------------------------------------------------------------------------------- /tests/dma/dmasend.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_DMA_DMASEND_H 2 | #define PS2AUTOTESTS_DMA_DMASEND_H 3 | 4 | #include 5 | 6 | namespace DMA { 7 | void SendSimple(volatile DMA::Channel *chan, void *data, int size); 8 | void SendChain(volatile DMA::Channel *chan, void *dmatag, int size); 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /tests/cpu/iop/branchdelay.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | beq: delay branch did not crash 3 | jal: ra order: 00000002 4 | jalr: ra order: 00000002 5 | jalr: non-ra: OK 6 | jalr: non-ra order: 00000001 7 | jalr: rs/rd match: 00000002 8 | jalr: clobber rs: 00000002 9 | bltzal: ra order: 00000002 10 | bgezal: ra order: 00000002 11 | -- TEST END 12 | -------------------------------------------------------------------------------- /tests/memory/ee/default.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | Memory allocation limits: 3 | 32 MB: fail 4 | 30 MB: success 5 | 24 MB: success 6 | 16 MB: success 7 | Mirrors: 8 | Allocated in EE Cached 9 | Pointer is aligned 10 | Mirrors: cached=42, uncached=42, ucab=42 11 | Scratchpad: 12 | Scratchpad start: 42, end: 1 13 | -- TEST END 14 | -------------------------------------------------------------------------------- /tests/kernel/iop/libc/sprintf.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | %d: 32 3 | %03d: 045 4 | %3d: 12 5 | %3.3d: 087 6 | %+6d: +948 7 | %+6d: -948 8 | %6d: -948 9 | %06d: -00948 10 | %+06d: +00948 11 | %u: 4294966348 12 | %s%3.3d: myfile000 13 | %x: deadbeef 14 | %X: DEADBEEF 15 | %08x: 00000017 16 | %8x: c 17 | %p: 1234567 18 | %c: j 19 | -- TEST END 20 | -------------------------------------------------------------------------------- /tests/kernel/ee/interrupt/dmac_order.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | push back: 1, 2, 3, 1, 2, 3, 1, 2, 3 3 | push front: 3, 2, 1, 3, 2, 1, 3, 2, 1 4 | mixed front back: 4, 2, 1, 3, 4, 2, 1, 3, 4 5 | relative: 1, 4, 2, 3, 1, 4, 2, 3, 1 6 | remove: 1, 3, 1, 3, 1, 3, 1, 3, 1 7 | cancel: 1, 2, 1, 2, 1, 2, 1, 2, 1 8 | return value: 1, 2, 3, 1, 2, 3, 1, 2, 3 9 | -- TEST END 10 | -------------------------------------------------------------------------------- /tests/vu/games/triace.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | b063b75b/-0.00 8701ce82/-0.00 46fcc888/+32356.27 793cc535/+61259477699317514327946461014130688.00 3 | b3e2a618/-0.00 8b5b19e9/-0.00 4b1ed4a7/+10409127.00 7d1ca47b/+13013349922726739816220940519602126848.00 4 | 42546666/+53.10 c7f079b3/-123123.40 4b1ed5e7/+10409447.00 7d1ca47b/+13013349922726739816220940519602126848.00 5 | -- TEST END 6 | -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/delete.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | unused event flag: 3 | delete after creation: succeeded 4 | used event flag: 5 | delete while thread is waiting: succeeded 6 | WaitEventFlag returned: -425 7 | DeleteThread returned: 0 8 | corner cases: 9 | delete with invalid id: failed -> result: -409 10 | delete with deleted id: failed -> result: -409 11 | -- TEST END 12 | -------------------------------------------------------------------------------- /tests/kernel/iop/libc/strtok.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | strtok('val1, val2, val3,val4', ', ') -> 'val1' 3 | strtok('null', ', ') -> 'val2' 4 | strtok('null', ', ') -> 'val3' 5 | strtok('null', ', ') -> 'val4' 6 | strtok('null', ', ') -> 'null' 7 | strtok('val1,val2,val3,val4', 'null') -> 'val1,val2,val3,val4' 8 | strtok('null', 'null') -> 'null' 9 | strtok('null', 'null') -> 'null' 10 | -- TEST END 11 | -------------------------------------------------------------------------------- /tests/cpu/ee/branchdelay.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | beq: delay branch: 00000002 3 | jal: ra order: 00000002 4 | jalr: ra order: 00000002 5 | jalr: non-ra: 001003f8 6 | jalr: non-ra order: 00000001 7 | jalr: rs/rd match: 00000002 8 | jalr: clobber rs: 00000002 9 | bltzal: ra order: 00000002 10 | bltzall: ra order: 00000002 11 | bgezal: ra order: 00000002 12 | bgezall: ra order: 00000002 13 | -- TEST END 14 | -------------------------------------------------------------------------------- /tests/kernel/ee/interrupt/intc_order.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | push back: 1, 2, 3, 1, 2, 3, 1, 2, 3 3 | push front: 3, 2, 1, 3, 2, 1, 3, 2, 1 4 | mixed front back: 4, 2, 1, 3, 4, 2, 1, 3, 4 5 | relative: 1, 4, 2, 3, 1, 4, 2, 3, 1 6 | remove: 1, 3, 1, 3, 1, 3, 1, 3, 1 7 | cancel: 1, 2, 1, 2, 1, 2, 1, 2, 1 8 | return value: 1, 2, 3, 1, 2, 3, 1, 2, 3 9 | return value (using AddIntcHandler2): 1, 2, 3, 1, 2, 3, 1, 2, 3 10 | -- TEST END 11 | -------------------------------------------------------------------------------- /common/common-iop.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_COMMON_IOP_H 2 | #define PS2AUTOTESTS_COMMON_IOP_H 3 | 4 | // Defines for MSVC highlighting. Not intended to actually compile with msc. 5 | #ifdef _MSC_VER 6 | #define __STDC__ 7 | #define _IOP 8 | #define __attribute__(x) 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | void schedf(const char *format, ...); 15 | void flushschedf(); 16 | 17 | #define ARRAY_SIZE(a) (sizeof((a)) / (sizeof((a)[0]))) 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/cancelwakeup.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | cancel wakeup self thread: succeeded -> result: 4 4 | cancel wakeup self thread after cancelling: succeeded -> result: 0 5 | standard usage: 6 | cancel wakeup after starting: succeeded -> result: 0 7 | cancel wakeup after wakeups: succeeded -> result: 3 8 | cancel wakeup after cancelling: succeeded -> result: 0 9 | corner cases: 10 | cancel wakeup with invalid thread id: failed -> result: -407 11 | -- TEST END 12 | -------------------------------------------------------------------------------- /tests/dma/vif/basic.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | == VIF0 == 3 | FIFO: 1337c0de (1337c0de) - 1337c1de - 1337c2de - 1337c3de 4 | DMA simple: 1337c0de (1337c0de) - 1337c1de - 1337c2de - 1337c3de 5 | DMA chain (basic): 1337c0de (1337c0de) - 1337c1de - 1337c2de - 1337c3de 6 | 7 | == VIF1 == 8 | FIFO: 1337c0de (1337c0de) - 1337c1de - 1337c2de - 1337c3de 9 | DMA simple: 1337c0de (1337c0de) - 1337c1de - 1337c2de - 1337c3de 10 | DMA chain (basic): 1337c0de (1337c0de) - 1337c1de - 1337c2de - 1337c3de 11 | 12 | -- TEST END 13 | -------------------------------------------------------------------------------- /common/common-ee.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_COMMON_EE_H 2 | #define PS2AUTOTESTS_COMMON_EE_H 3 | 4 | // Defines for MSVC highlighting. Not intended to actually compile with msc. 5 | #ifdef _MSC_VER 6 | #define __STDC__ 7 | #define _EE 8 | #define __attribute__(x) 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | #undef main 15 | #define main test_main 16 | 17 | void schedf(const char *format, ...); 18 | void flushschedf(); 19 | 20 | int getThreadPriority(int threadId); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/vpl-common.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "vpl-common.h" 3 | 4 | void printVpl(s32 vplId) { 5 | iop_vpl_info_t vplInfo; 6 | memset(&vplInfo, 0, sizeof(iop_vpl_info_t)); 7 | s32 result = ReferVplStatus(vplId, &vplInfo); 8 | if(result >= 0) { 9 | printf("attr: %x, option: %x, wait threads: %d, size: %d, free size: %d\n", 10 | vplInfo.attr, vplInfo.option, vplInfo.numWaitThreads, vplInfo.size, vplInfo.freeSize); 11 | } else { 12 | printf("failed (%d)\n", result); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/dma/vif/vifunits.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_DMA_VIF_VIFUNITS_H 2 | #define PS2AUTOTESTS_DMA_VIF_VIFUNITS_H 3 | 4 | #include 5 | #include "vifregs.h" 6 | 7 | namespace VIF { 8 | 9 | struct Unit { 10 | u8 *vuMem; 11 | volatile VIFRegs *const regs; 12 | volatile u128 *fifo; 13 | volatile DMA::Channel *dmaChannel; 14 | }; 15 | 16 | static Unit Unit0 = { (u8*)0x11004000, VIF0, VIF0_FIFO, DMA::D0 }; 17 | static Unit Unit1 = { (u8*)0x1100C000, VIF1, VIF1_FIFO, DMA::D1 }; 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/exit.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | exit thread: 3 | start after thread exited -> returned thread id 4 | delete after thread exited -> returned thread id 5 | exit thread (priority change): 6 | stat after changing priority -> result: 01, init prio: 30, current prio: 20, status: 01 7 | stat after thread exited -> result: 10, init prio: 30, current prio: 30, status: 10 8 | exit delete thread: 9 | start after thread exited -> returned -1 10 | delete after thread exited -> returned -1 11 | -- TEST END 12 | -------------------------------------------------------------------------------- /common/common-defines.mk: -------------------------------------------------------------------------------- 1 | EE_PREFIX = ee- 2 | EE_CC = $(EE_PREFIX)gcc 3 | EE_CXX= $(EE_PREFIX)g++ 4 | EE_AS = $(EE_PREFIX)as 5 | EE_LD = $(EE_PREFIX)ld 6 | EE_AR = $(EE_PREFIX)ar 7 | EE_OBJCOPY = $(EE_PREFIX)objcopy 8 | EE_STRIP = $(EE_PREFIX)strip 9 | 10 | IOP_PREFIX = iop- 11 | IOP_CC = $(IOP_PREFIX)gcc 12 | IOP_AS = $(IOP_PREFIX)as 13 | IOP_LD = $(IOP_PREFIX)ld 14 | IOP_AR = $(IOP_PREFIX)ar 15 | IOP_OBJCOPY = $(IOP_PREFIX)objcopy 16 | IOP_STRIP = $(IOP_PREFIX)strip 17 | 18 | DVP_PREFIX = dvp- 19 | DVP_AS = $(DVP_PREFIX)as 20 | 21 | RM=rm -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/receive.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | receiving (fifo thread queuing): 3 | box contents: attr: 0, option: 0, wait threads: 3, messages: 0 4 | order: (thread: 1 -> message: 1) (thread: 2 -> message: 2) (thread: 3 -> message: 3) 5 | receiving (priority thread queuing): 6 | box contents: attr: 1, option: 0, wait threads: 3, messages: 0 7 | order: (thread: 3 -> message: 1) (thread: 2 -> message: 2) (thread: 1 -> message: 3) 8 | invalid params: 9 | receiving message from invalid box: -410 10 | -- TEST END 11 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/create.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | valid: 3 | succeeded -> attr: 200, option: 1234, wait threads: 0, size: 8152, free size: 8152 4 | bad attr (2): 5 | failed -> result: -401 6 | bad attr (~0): 7 | failed -> result: -401 8 | bad alloc (huge): 9 | succeeded -> attr: 200, option: 1234, wait threads: 0, size: -4, free size: -4 10 | bad alloc (negative): 11 | succeeded -> attr: 200, option: 1234, wait threads: 0, size: -4, free size: -4 12 | bad attr & bad alloc: 13 | failed -> result: -401 14 | -- TEST END 15 | -------------------------------------------------------------------------------- /tests/gs/gsregs.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_GS_GSREGS_H 2 | #define PS2AUTOTESTS_GS_GSREGS_H 3 | 4 | #include 5 | 6 | namespace GS 7 | { 8 | enum RegCSRBits { 9 | CSR_SIGNAL = 1 << 0, 10 | }; 11 | 12 | enum REGS 13 | { 14 | REG_SIGNAL = 0x60, 15 | REG_LABEL = 0x62 16 | }; 17 | 18 | u64 SIGNAL(u32 id, u32 idmsk); 19 | u64 LABEL(u32 id, u32 idmsk); 20 | 21 | static volatile u64 *const CSR = (volatile u64 *)0x12001000; 22 | static volatile u64 *const SIGLBLID = (volatile u64 *)0x12001080; 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/poll.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | basic polling: 3 | polling from empty box: -424 4 | box contents before polling: attr: 0, option: 0, wait threads: 0, messages: 3 -> { payload: 1, priority: 3 }, { payload: 2, priority: 2 }, { payload: 3, priority: 1 } 5 | polling from non-empty box: 0, message: 1 6 | box contents after polling: attr: 0, option: 0, wait threads: 0, messages: 2 -> { payload: 2, priority: 2 }, { payload: 3, priority: 1 } 7 | invalid params: 8 | polling message from invalid box: -410 9 | -- TEST END 10 | -------------------------------------------------------------------------------- /common/common-iop.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define SCHEDF_BUFFER_SIZE 65536 6 | 7 | char schedfBuffer[65536]; 8 | unsigned int schedfBufferPos = 0; 9 | 10 | void schedf(const char *format, ...) { 11 | va_list args; 12 | va_start(args, format); 13 | schedfBufferPos += vsnprintf(schedfBuffer + schedfBufferPos, SCHEDF_BUFFER_SIZE, format, args); 14 | va_end(args); 15 | } 16 | 17 | void flushschedf() { 18 | printf("%s", schedfBuffer); 19 | schedfBuffer[0] = '\0'; 20 | schedfBufferPos = 0; 21 | } 22 | -------------------------------------------------------------------------------- /tests/cpu/vu0_macro/shared.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | static inline void PRINT_R(const register u128 &rt, bool newline) { 6 | static u32 __attribute__((aligned(16))) result[4] = {0, 0, 0, 0}; 7 | *(vu128 *)result = rt; 8 | 9 | printf("%08x %08x %08x %08x", result[3], result[2], result[1], result[0]); 10 | if (newline) { 11 | printf("\n"); 12 | } 13 | } 14 | 15 | struct Vu0Flags { 16 | Vu0Flags(); 17 | 18 | void PrintChanges(bool newline = false); 19 | 20 | u32 status_; 21 | u32 mac_; 22 | u32 clipping_; 23 | }; 24 | -------------------------------------------------------------------------------- /tests/dma/vif/intstall.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | == VIF0 == 3 | NOP (I): 4 | Status after transfer - MASK: aaaaaaaa, STAT: 00000c02 5 | MARK (I): 6 | Status after transfer - MASK: cccccccc, STAT: 00000840 7 | STMASK (I): 8 | Status after transfer - MASK: ffffffff, STAT: 00000c02 9 | 10 | == VIF1 == 11 | NOP (I): 12 | Status after transfer - MASK: aaaaaaaa, STAT: 00000c02 13 | MARK (I): 14 | Status after transfer - MASK: cccccccc, STAT: 00000840 15 | STMASK (I): 16 | Status after transfer - MASK: ffffffff, STAT: 00000c02 17 | 18 | -- TEST END 19 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/delete.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | delete (with TH_SELF): failed -> result: -406 4 | delete (with current tid): failed -> result: -414 5 | low prio thread: 6 | delete before start: succeeded 7 | delete after start: failed -> result: -414 8 | delete after terminate: succeeded 9 | delete after delete: failed -> result: -407 10 | waiting thread: 11 | delete after start: failed -> result: -414 12 | delete after terminate: succeeded 13 | corner cases: 14 | delete with invalid tid: failed -> result: -407 15 | -- TEST END 16 | -------------------------------------------------------------------------------- /tests/dma/dmac/tagintr.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | Tag interrupt enabled, Tag IRQ enabled: 3 | CHCR(tag): b0000000, TADR offset: 00000010, CIS(before): 00000000, CIS(after): 00000200 4 | Tag interrupt enabled, Tag IRQ disabled: 5 | CHCR(tag): 70000000, TADR offset: 00000020, CIS(before): 00000000, CIS(after): 00000200 6 | Tag interrupt disabled, Tag IRQ enabled: 7 | CHCR(tag): 70000000, TADR offset: 00000020, CIS(before): 00000000, CIS(after): 00000200 8 | Tag interrupt disabled, Tag IRQ disabled: 9 | CHCR(tag): 70000000, TADR offset: 00000020, CIS(before): 00000000, CIS(after): 00000200 10 | -- TEST END 11 | -------------------------------------------------------------------------------- /tests/kernel/iop/interrupt/register.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | multiple register: 3 | register when no handler is present: 0 4 | register when handler is already present: -104 5 | handler result: 43690 6 | null handler: 7 | registering null handler: 0 8 | registering null handler after null handler was registered: 0 9 | registering null handler after non-null handler was registered: -104 10 | registering non-null handler after null handler was registered: 0 11 | invalid params: 12 | invalid interrupt line: -101 13 | invalid mode (INT_MIN): 0 14 | invalid mode (INT_MAX): 0 15 | -- TEST END 16 | -------------------------------------------------------------------------------- /tests/vu/assemble.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_VU_ASSEMBLE_H 2 | #define PS2AUTOTESTS_VU_ASSEMBLE_H 3 | 4 | #include "assemble/types.h" 5 | #include "assemble/block.h" 6 | #include "assemble/ops.h" 7 | 8 | static VU::LIW *const vu0_micro = (VU::LIW *)0x11000000; 9 | static const u32 vu0_micro_size = 0x00001000; 10 | static VU::LIW *const vu1_micro = (VU::LIW *)0x11008000; 11 | static const u32 vu1_micro_size = 0x00004000; 12 | 13 | static u8 *const vu0_mem = (u8 *)0x11004000; 14 | static const u32 vu0_mem_size = 0x1000; 15 | static u8 *const vu1_mem = (u8 *)0x1100C000; 16 | static const u32 vu1_mem_size = 0x4000; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /tests/cpu/ee/lsudelay.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void test_lw_delay() { 5 | const static u32 data = 0x13371337; 6 | register u32 res = 0; 7 | asm volatile ( 8 | ".set noreorder\n" 9 | "lui $t0, 0x1122\n" 10 | "ori $t0, $t0, 0x3344\n" 11 | "lw $t0, 0(%1)\n" 12 | "or %0, $0, $t0\n" 13 | "sync\n" 14 | : "+&r"(res) : "r"((u32)&data) : "t0" 15 | ); 16 | printf("lw: %08x\n", res); 17 | } 18 | 19 | int main(int argc, char *argv[]) { 20 | printf("-- TEST BEGIN\n"); 21 | 22 | // Just to show that the ee (r5900) has no load delay slots. 23 | test_lw_delay(); 24 | 25 | printf("-- TEST END\n"); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tests/vu/upper/clip.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | Basic test: FULL POS x -1 -> 0015 3 | Basic test: FULL NEG x -1 -> 002a 4 | Basic test: HALF POS x -1 -> 0019 5 | Basic test: HALF NEG x -1 -> 0026 6 | Basic test: HALF NEG x 0 -> 0026 7 | Basic test: HALF NEG x -0 -> 0026 8 | Basic test: 0 x -0 -> 0000 9 | Basic test: -0 x 0 -> 0000 10 | Basic test: FULL POS x FULL POS -> 0000 11 | Basic test: HALF NEG x HALF NEG -> 0000 12 | Basic test: MIN x 0 -> 002a 13 | Basic test: MAX x 0 -> 0015 14 | Basic test: 0 x MIN -> 0000 15 | Basic test: 0 x MAX -> 0000 16 | Multi test: 17 | 0000 18 | 0000 19 | 0000 20 | 0000 21 | 0015 22 | 056a 23 | 0a99 24 | 0666 25 | 0666 26 | 0666 27 | Multi test 2: 28 | 0555 29 | 0aaa 30 | 0659 31 | 09a6 32 | -- TEST END 33 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/thread-common.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "thread-common.h" 3 | 4 | s32 getThreadPriority(s32 threadId) { 5 | iop_thread_info_t threadStat; 6 | memset(&threadStat, 0, sizeof(iop_thread_info_t)); 7 | int result = ReferThreadStatus(threadId, &threadStat); 8 | if (result >= 0) { 9 | return threadStat.currentPriority; 10 | } else { 11 | return -1; 12 | } 13 | } 14 | 15 | s32 createTestThread(void *entry, s32 prio, u32 stackSize) { 16 | iop_thread_t threadParam; 17 | memset(&threadParam, 0, sizeof(iop_thread_t)); 18 | threadParam.attr = TH_C; 19 | threadParam.thread = entry; 20 | threadParam.priority = prio; 21 | threadParam.stacksize = stackSize; 22 | return CreateThread(&threadParam); 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, ps2autotests project contributors. 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/send.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | sending (fifo message queuing): 3 | box contents: attr: 0, option: 0, wait threads: 0, messages: 3 -> { payload: 1, priority: 3 }, { payload: 2, priority: 2 }, { payload: 3, priority: 1 } 4 | sending (prio message queuing): 5 | box contents: attr: 4, option: 0, wait threads: 0, messages: 3 -> { payload: 3, priority: 1 }, { payload: 2, priority: 2 }, { payload: 1, priority: 3 } 6 | send message linking behavior: 7 | after sending, msg1's next pointer refers to: msg1 8 | sending wakeup behavior: 9 | box contents after thread creation: attr: 0, option: 0, wait threads: 1, messages: 0 10 | box contents after send: attr: 0, option: 0, wait threads: 0, messages: 0 11 | received payload: 0xBEEF 12 | invalid params: 13 | sending message to invalid box: -410 14 | -- TEST END 15 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/delete.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | delete (with current tid): failed -> result: -1 4 | worse prio thread: 5 | delete before start: succeeded -> result: thread id 6 | delete after delete: failed -> result: -1 7 | delete after start: failed -> result: -1 8 | delete after suspend: failed -> result: -1 9 | delete after resume: failed -> result: -1 10 | delete after terminate: succeeded -> result: thread id 11 | sleeping thread: 12 | delete after start: failed -> result: -1 13 | delete after suspend: failed -> result: -1 14 | delete after resume: failed -> result: -1 15 | waiting thread: 16 | delete after start: failed -> result: -1 17 | delete after suspend: failed -> result: -1 18 | delete after resume: failed -> result: -1 19 | corner cases: 20 | delete with invalid tid: failed -> result: -1 21 | -- TEST END 22 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/transfer.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | lwc1: 3 | lwc1 +0: 4e0d159e/+591751040.00 4 | lwc1 +4: 4f2bcdef/+2882400000.00 5 | lwc1 -4: 4f40de13/+3235779328.00 6 | lwc1 +0: 4e0d159e/+591751040.00 7 | lwc1 +4: 4f2bcdef/+2882400000.00 8 | lwc1 +-4: 4f40de13/+3235779328.00 9 | 10 | swc1: 11 | swc1 +0: 3f800001/+1.00 12 | swc1 +4: 3f800001/+1.00 13 | swc1 -4: 3f800001/+1.00 14 | swc1 +0: 00001337/+0.00 15 | swc1 +4: 00001337/+0.00 16 | swc1 +-4: 00001337/+0.00 17 | 18 | cfc1: 12345678 12345678 00000000 01000001 19 | cfc1 -> $0: 00000000 00000000 00000000 00000000 20 | ctc1: ffffffff ffffffff 00000000 0183c079 21 | mfc1 negative: 80f0000f 80f0000f ffffffff bf800000 22 | mfc1 positive: 00f0000f 00f0000f 00000000 3f800000 23 | mfc1 -> $0: 00000000 00000000 00000000 00000000 24 | mtc1 negative: 80f0000f/-0.00 25 | mtc1 positive: 00f0000f/+0.00 26 | -- TEST END 27 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/resume.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | resume (with current tid): failed -> result: -1 4 | worse prio thread: 5 | resume before start: failed -> result: -1 6 | resume after start: failed -> result: -1 7 | resume after suspend: succeeded -> result: thread id, status -> result: 02, init prio: 50, current prio: 50, status: 02 8 | resume after terminate: failed -> result: -1 9 | sleeping thread: 10 | resume after start: failed -> result: -1 11 | resume after suspend: succeeded -> result: thread id, status -> result: 04, init prio: 30, current prio: 30, status: 04 12 | waiting thread: 13 | resume after start: failed -> result: -1 14 | resume after suspend: succeeded -> result: thread id, status -> result: 04, init prio: 30, current prio: 30, status: 04 15 | corner cases: 16 | resume with invalid tid: failed -> result: -1 17 | -- TEST END 18 | -------------------------------------------------------------------------------- /tests/dma/vif/mskpath3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../dmaregs.h" 4 | #include "../dmasend.h" 5 | #include "emit_vifcode.h" 6 | 7 | #define EE_GIF_STAT_M3P (0x02) 8 | 9 | int main(int argc, char *argv[]) { 10 | printf("-- TEST BEGIN\n"); 11 | 12 | printf("mask value (initial): %08X\n", *R_EE_GIF_STAT & EE_GIF_STAT_M3P); 13 | 14 | { 15 | VIF::Packet vifcode(16); 16 | vifcode.MSKPATH3(true); 17 | DMA::SendSimple(DMA::D1, vifcode.Raw(), 16); 18 | 19 | printf("mask value (after mskpath3(true))): %08X\n", *R_EE_GIF_STAT & EE_GIF_STAT_M3P); 20 | } 21 | 22 | { 23 | VIF::Packet vifcode(16); 24 | vifcode.MSKPATH3(false); 25 | DMA::SendSimple(DMA::D1, vifcode.Raw(), 16); 26 | 27 | printf("mask value (after mskpath3(false))): %08X\n", *R_EE_GIF_STAT & EE_GIF_STAT_M3P); 28 | } 29 | 30 | printf("-- TEST END\n"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/releasewait.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | running thread: failed -> result: -416 3 | dormant thread: failed -> result: -416 4 | invalid thread: failed -> result: -407 5 | sleeping thread: 6 | ReleaseWaitThread returned: succeeded -> result: 0 7 | wait function returned: -418 8 | delayed thread: 9 | ReleaseWaitThread returned: succeeded -> result: 0 10 | wait function returned: -418 11 | waiting semaphore thread: 12 | ReleaseWaitThread returned: succeeded -> result: 0 13 | wait function returned: -418 14 | waiting event flag thread: 15 | ReleaseWaitThread returned: succeeded -> result: 0 16 | wait function returned: -418 17 | waiting message box thread: 18 | ReleaseWaitThread returned: succeeded -> result: 0 19 | wait function returned: -418 20 | self thread: 21 | With TH_SELF: failed -> result: -406 22 | With current thread id: failed -> result: -406 23 | -- TEST END 24 | -------------------------------------------------------------------------------- /tests/cpu/ee_cop0/performance.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | setting pcr0: 89abcdef 3 | setting pcr1: 01234567 4 | setting pccr: 000ffbfe 5 | reading from even/odd numbered pcr specifier maps to pcr0/pcr1: 12121212121212121212121212121212 6 | writing to even/odd numbered pcr specifier maps to pcr0/pcr1: 45454545454545454545454545454545 7 | reading from any pccr specifier maps to pccr: 00008020 8 | writing to any pccr specifier other than 0 is no-op: 00000000 9 | counter 0 (all modes, processor cycles), counter 1 (no modes, 0): pcr0 -> changed, pcr1 -> unchanged 10 | counter 0 (no modes, 0), counter 1 (all modes, processor cycles): pcr0 -> unchanged, pcr1 -> changed 11 | counter 0 (all modes, processor cycles), counter 1 (all modes, processor cycles): pcr0 -> changed, pcr1 -> changed 12 | counter 0 (no modes, processor cycles), counter 1 (no modes, processor cycles): pcr0 -> unchanged, pcr1 -> unchanged 13 | -- TEST END 14 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/branch.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | bc1f: 3 | bc1f 1: skipped, ignored ra, ran delay slot 4 | bc1f 0: followed, ignored ra, ran delay slot 5 | bc1f c.eq: skipped, ignored ra, ran delay slot 6 | bc1f c.f: followed, ignored ra, ran delay slot 7 | 8 | bc1fl: 9 | bc1fl 1: skipped, ignored ra, skipped delay slot 10 | bc1fl 0: followed, ignored ra, ran delay slot 11 | bc1fl c.eq: skipped, ignored ra, skipped delay slot 12 | bc1fl c.f: followed, ignored ra, ran delay slot 13 | 14 | bc1t: 15 | bc1t 1: followed, ignored ra, ran delay slot 16 | bc1t 0: skipped, ignored ra, ran delay slot 17 | bc1t c.eq: followed, ignored ra, ran delay slot 18 | bc1t c.f: skipped, ignored ra, ran delay slot 19 | 20 | bc1tl: 21 | bc1tl 1: followed, ignored ra, ran delay slot 22 | bc1tl 0: skipped, ignored ra, skipped delay slot 23 | bc1tl c.eq: followed, ignored ra, ran delay slot 24 | bc1tl c.f: skipped, ignored ra, skipped delay slot 25 | 26 | -- TEST END 27 | -------------------------------------------------------------------------------- /common/xprintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xprinf.h 3 | * 4 | * Copyright (C) 2007-2009 misfire 5 | * 6 | * Licensed under the Academic Free License version 2.0. See file LICENSE. 7 | */ 8 | 9 | #ifndef _XPRINTF_H_ 10 | #define _XPRINTF_H_ 11 | 12 | #include 13 | 14 | /* Define available functions here */ 15 | #define F_vxprintf 16 | #define NOFLOATINGPOINT /* won't compile without it */ 17 | #define F___sout 18 | 19 | //#define F_sprintf 20 | //#define F_snprintf 21 | //#define F_vsprintf 22 | #define F_vsnprintf 23 | 24 | #ifdef F_sprintf 25 | int sprintf(char *str, const char *format, ...); 26 | #endif 27 | 28 | #ifdef F_snprintf 29 | int snprintf(char *str, size_t sz, const char *format, ...); 30 | #endif 31 | 32 | #ifdef F_vsprintf 33 | int vsprintf(char *buf, const char *fmt, va_list ap); 34 | #endif 35 | 36 | #ifdef F_vsnprintf 37 | int vsnprintf(char *buf, size_t n, const char *fmt, va_list ap); 38 | #endif 39 | 40 | #endif /* _XPRINTF_H_ */ 41 | -------------------------------------------------------------------------------- /tests/kernel/iop/libc/strtok.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const char *getStringRep(const char *str) { 5 | return str ? str : "null"; 6 | } 7 | 8 | void doStrtok(char *s, const char *delim) 9 | { 10 | printf("strtok('%s', '%s') -> ", getStringRep(s), getStringRep(delim)); 11 | char *result = strtok(s, delim); 12 | printf("'%s'\n", getStringRep(result)); 13 | } 14 | 15 | int _start(int argc, char **argv) { 16 | printf("-- TEST BEGIN\n"); 17 | 18 | { 19 | char inputString[] = "val1, val2, val3,val4"; 20 | static const char delim[] = ", "; 21 | 22 | doStrtok(inputString, delim); 23 | doStrtok(NULL, delim); 24 | doStrtok(NULL, delim); 25 | doStrtok(NULL, delim); 26 | doStrtok(NULL, delim); 27 | } 28 | 29 | { 30 | char inputString[] = "val1,val2,val3,val4"; 31 | doStrtok(inputString, NULL); 32 | doStrtok(NULL, NULL); 33 | } 34 | 35 | doStrtok(NULL, NULL); 36 | 37 | printf("-- TEST END\n"); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /tests/dma/spr/chain.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | SADR offsets: 3 | SADR updated: to=00000030, from=00000030 4 | Tag data updated: MADR=+00000010, TADR=+00000010 5 | SADR +0x10: 00000000 00000000 00000000 00000000 6 | SADR +0x20: 01234567 89abcdef deadbeef 1337c0de 7 | 8 | SADR updated: to=00000020, from=00000030 9 | Tag data updated: MADR=+00000010, TADR=+00000010 10 | SADR +0x14: deadbeef 89abcdef 01234567 1337c0de 11 | SADR +0x24: 01234567 89abcdef deadbeef 1337c0de 12 | 13 | SADR high bits: 14 | SADR updated: to=00000120, from=00000030 15 | Tag data updated: MADR=+00000100, TADR=+00000010 16 | SADR send with ignored bits: 01234567 89abcdef deadbeef 1337c0de 17 | 18 | SADR updated: to=00000120, from=00000030 19 | SADR receive with ignored bits: 01234567 89abcdef deadbeef 1337c0de 20 | 21 | Size zero: 22 | SADR updated: to=00000000, from=00000000 23 | Send zero 0x0000: 00000000 00000000 00000000 00000000 24 | Send zero 0x0010: 00000000 00000000 00000000 00000000 25 | -- TEST END 26 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/suspend.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | suspend (with current tid): succeeded -> result: thread id, status -> result: 08, init prio: 40, current prio: 40, status: 08 4 | self thread status after rescheduling: result: 01, init prio: 40, current prio: 40, status: 01 5 | worse prio thread: 6 | suspend before start: failed -> result: -1 7 | suspend after start: succeeded -> result: thread id, status -> result: 08, init prio: 50, current prio: 50, status: 08 8 | suspend after suspend: failed -> result: -1 9 | suspend after terminate: failed -> result: -1 10 | sleeping thread: 11 | suspend after start: succeeded -> result: thread id, status -> result: 0c, init prio: 30, current prio: 30, status: 0c 12 | suspend after suspend: failed -> result: -1 13 | waiting thread: 14 | suspend after start: succeeded -> result: thread id, status -> result: 0c, init prio: 30, current prio: 30, status: 0c 15 | suspend after suspend: failed -> result: -1 16 | corner cases: 17 | suspend with invalid tid: failed -> result: -1 18 | -- TEST END 19 | -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/poll.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | match success cases: 3 | poll with matching pattern, OR wait mode: succeeded, resultPattern: 0000000f 4 | poll with matching pattern, AND wait mode: succeeded, resultPattern: 0000000f 5 | match failure cases: 6 | poll with non-matching pattern, OR wait mode: failed -> result: -421, resultPattern: 0000cccc 7 | poll with non-matching pattern, AND wait mode: failed -> result: -421, resultPattern: 0000cccc 8 | clear on success: 9 | poll with matching pattern, OR and CLEAR wait mode: succeeded, resultPattern: 00003333 10 | poll a second time with matching pattern, OR wait mode: failed -> result: -421, resultPattern: 0000cccc 11 | test busy event flag: 12 | single wait event flag: failed -> result: -422, resultPattern: 0000cccc 13 | multi wait event flag: failed -> result: -422, resultPattern: 0000cccc 14 | corner cases: 15 | poll with zero pattern: failed -> result: -423, resultPattern: 0000cccc 16 | poll with null result pattern: succeeded 17 | poll with invalid tid: failed -> result: -409 18 | -- TEST END 19 | -------------------------------------------------------------------------------- /tests/cpu/vu0_macro/shared.cpp: -------------------------------------------------------------------------------- 1 | #include "shared.h" 2 | 3 | Vu0Flags::Vu0Flags() { 4 | // Grab the previous values. 5 | asm volatile ( 6 | // Try to clear them first, if possible. 7 | "vnop\n" 8 | "ctc2 $0, $16\n" 9 | "ctc2 $0, $17\n" 10 | "ctc2 $0, $18\n" 11 | // Then read. 12 | "vnop\n" 13 | "cfc2 %0, $16\n" 14 | "cfc2 %1, $17\n" 15 | "cfc2 %2, $18\n" 16 | : "=&r"(status_), "=&r"(mac_), "=&r"(clipping_) 17 | ); 18 | 19 | if (clipping_ != 0) { 20 | printf("WARNING: Clipping flag was not cleared.\n"); 21 | } 22 | } 23 | 24 | void Vu0Flags::PrintChanges(bool newline) { 25 | u32 status, mac, clipping; 26 | 27 | asm volatile ( 28 | "vnop\n" 29 | "cfc2 %0, $16\n" 30 | "cfc2 %1, $17\n" 31 | "cfc2 %2, $18\n" 32 | : "=&r"(status), "=&r"(mac), "=&r"(clipping) 33 | ); 34 | 35 | if (status == status_ && mac == mac_ && clipping == clipping_) { 36 | printf(" (no flag changes)"); 37 | } else { 38 | printf(" st=+%04x,-%04x, mac=+%04x,-%04x, clip=%08x", status & ~status_, ~status & status_, mac & ~mac_, ~mac & mac_, clipping); 39 | } 40 | if (newline) { 41 | printf("\n"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/kernel/iop/libc/sprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //vsprintf is not reliable on a real PS2, we can't use it. We rely on this macro instead. 5 | #define EXECUTE_TEST(output, format, ...) sprintf(output, format, __VA_ARGS__); printf("%s: %s\n", format, output); 6 | 7 | int _start(int argc, char **argv) { 8 | printf("-- TEST BEGIN\n"); 9 | 10 | char buffer[256]; 11 | 12 | EXECUTE_TEST(buffer, "%d", 32); 13 | EXECUTE_TEST(buffer, "%03d", 45); 14 | EXECUTE_TEST(buffer, "%3d", 12); 15 | EXECUTE_TEST(buffer, "%3.3d", 87); 16 | EXECUTE_TEST(buffer, "%+6d", 948); 17 | EXECUTE_TEST(buffer, "%+6d", -948); 18 | EXECUTE_TEST(buffer, "%6d", -948); 19 | EXECUTE_TEST(buffer, "%06d", -948); 20 | EXECUTE_TEST(buffer, "%+06d", 948); 21 | EXECUTE_TEST(buffer, "%u", -948); 22 | EXECUTE_TEST(buffer, "%s%3.3d", "myfile", 0); 23 | EXECUTE_TEST(buffer, "%x", 0xdeadbeef); 24 | EXECUTE_TEST(buffer, "%X", 0xDEADBEEF); 25 | EXECUTE_TEST(buffer, "%08x", 23); 26 | EXECUTE_TEST(buffer, "%8x", 12); 27 | EXECUTE_TEST(buffer, "%p", (void*)0x01234567); 28 | EXECUTE_TEST(buffer, "%c", 'j'); 29 | 30 | printf("-- TEST END\n"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/create.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vpl-common.h" 4 | 5 | void createVpl(u32 attr, u32 option, s32 size) { 6 | iop_vpl_param vplParam = {}; 7 | vplParam.attr = attr; 8 | vplParam.option = option; 9 | vplParam.size = size; 10 | 11 | s32 vplId = CreateVpl(&vplParam); 12 | 13 | if(vplId > 0) { 14 | printf(" succeeded -> "); 15 | printVpl(vplId); 16 | DeleteVpl(vplId); 17 | } else { 18 | printf(" failed -> result: %d\n", vplId); 19 | } 20 | } 21 | 22 | int _start(int argc, char **argv) { 23 | printf("-- TEST BEGIN\n"); 24 | 25 | printf("valid:\n"); 26 | createVpl(VA_THFIFO | VA_MEMBTM, 0x1234, 0x2000); 27 | 28 | printf("bad attr (2):\n"); 29 | createVpl(2, 0x1234, 0x2000); 30 | 31 | printf("bad attr (~0):\n"); 32 | createVpl(~0, 0x1234, 0x2000); 33 | 34 | printf("bad alloc (huge):\n"); 35 | createVpl(VA_THFIFO | VA_MEMBTM, 0x1234, 0x20000000); 36 | 37 | printf("bad alloc (negative):\n"); 38 | createVpl(VA_THFIFO | VA_MEMBTM, 0x1234, -0x2000); 39 | 40 | printf("bad attr & bad alloc:\n"); 41 | createVpl(~0, 0x1234, -0x2000); 42 | 43 | printf("-- TEST END\n"); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/create.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | valid: 3 | succeeded -> attr: 02000000, option: 01234567, stack size: 00000800, init prio: 0a, curr prio: 00, status: 10, entry: &nullThreadProc 4 | huge stack size (~0): 5 | failed -> result: -400 6 | small stack size (300): 7 | failed -> result: -404 8 | invalid attr (~0): 9 | failed -> result: -401 10 | known attribute (TH_NO_FILLSTACK): 11 | failed -> result: -401 12 | known attribute (TH_CLEAR_STACK): 13 | failed -> result: -401 14 | known valid attributes (TH_UMODE | TH_ASM | TH_C): 15 | succeeded -> attr: 03000008, option: 00000000, stack size: 00000800, init prio: 0a, curr prio: 00, status: 10, entry: &nullThreadProc 16 | invalid entry point (NULL): 17 | succeeded -> attr: 00000000, option: 00000000, stack size: 00000800, init prio: 0a, curr prio: 00, status: 10, entry: 00000000 18 | invalid entry point (3): 19 | failed -> result: -402 20 | invalid entry point (~3): 21 | succeeded -> attr: 00000000, option: 00000000, stack size: 00000800, init prio: 0a, curr prio: 00, status: 10, entry: fffffffc 22 | invalid priority (0): 23 | failed -> result: -403 24 | invalid priority (127): 25 | failed -> result: -403 26 | -- TEST END 27 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/stat.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | stat (with TH_SELF): succeeded -> result: 0, init prio: 08 current prio: 08, status: 01 4 | stat (with current tid): succeeded -> result: 0, init prio: 08 current prio: 08, status: 01 5 | low prio thread: 6 | stat before start: succeeded -> result: 0, init prio: 09 current prio: 00, status: 10 7 | stat after start: succeeded -> result: 0, init prio: 09 current prio: 09, status: 02 8 | stat after terminate: succeeded -> result: 0, init prio: 09 current prio: 09, status: 10 9 | waiting thread: 10 | stat after start (sleep): succeeded -> result: 0, init prio: 07 current prio: 07, status: 04, wait type: 1 11 | stat after start (delay): succeeded -> result: 0, init prio: 07 current prio: 07, status: 04, wait type: 2 12 | stat after start (semaphore): succeeded -> result: 0, init prio: 07 current prio: 07, status: 04, wait type: 3 13 | stat after start (event flag): succeeded -> result: 0, init prio: 07 current prio: 07, status: 04, wait type: 4 14 | stat after start (message box): succeeded -> result: 0, init prio: 07 current prio: 07, status: 04, wait type: 5 15 | corner cases: 16 | stat with invalid thread id: failed -> result: -407 17 | -- TEST END 18 | -------------------------------------------------------------------------------- /tests/vu/lower/branch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../test_runner.h" 3 | 4 | class BranchTestRunner : public TestRunner { 5 | public: 6 | BranchTestRunner(int vu) : TestRunner(vu) { 7 | } 8 | 9 | void Perform_JALR(const char *name, VU::Reg targetReg, VU::Reg returnReg, VU::Reg resultReg) { 10 | using namespace VU; 11 | 12 | Reset(); 13 | 14 | Wr(IADDI(resultReg, VI00, 0x0)); 15 | Wr(IADDI(targetReg, VI00, 0x6)); 16 | JALR(returnReg, targetReg); 17 | Label exitLabel = B(); 18 | //6 * 8 19 | Wr(IADDI(resultReg, VI00, 0x1)); 20 | L(exitLabel); 21 | Wr(NOP()); 22 | 23 | Execute(); 24 | 25 | printf(" %s ->", name); 26 | printf(" targetReg: "); 27 | PrintRegister(targetReg, false); 28 | printf(" returnReg: "); 29 | PrintRegister(returnReg, false); 30 | printf(" resultReg: "); 31 | PrintRegister(resultReg, false); 32 | 33 | printf("\n"); 34 | } 35 | }; 36 | 37 | int main(int argc, char *argv[]) { 38 | printf("-- TEST BEGIN\n"); 39 | 40 | BranchTestRunner runner(0); 41 | runner.Perform_JALR("JALR /w diff regs", VU::VI01, VU::VI02, VU::VI03); 42 | runner.Perform_JALR("JALR /w same regs", VU::VI01, VU::VI01, VU::VI03); 43 | 44 | printf("-- TEST END\n"); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /tests/gs/label.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../dma/dmaregs.h" 3 | #include "../dma/dmasend.h" 4 | #include "emit_giftag.h" 5 | #include "gsregs.h" 6 | 7 | void testSetBits() { 8 | *GS::SIGLBLID = 0x0000000076543210ULL; 9 | 10 | GIF::Tag tag; 11 | tag.SetLoops(1); 12 | tag.SetEop(); 13 | tag.SetRegDescs(GIF::REG_AD); 14 | 15 | GIF::PackedPacket packet(64); 16 | packet.WriteTag(tag); 17 | packet.AD(GS::REG_LABEL, GS::LABEL(0xF0, 0xF0)); 18 | 19 | DMA::SendSimple(DMA::D2, packet.Raw(), packet.Size()); 20 | 21 | printf("Set label bits -> SIGLBLID: %016lx\n", *GS::SIGLBLID); 22 | } 23 | 24 | void testClearBits() { 25 | *GS::SIGLBLID = 0x3333333333333333ULL; 26 | 27 | GIF::Tag tag; 28 | tag.SetLoops(1); 29 | tag.SetEop(); 30 | tag.SetRegDescs(GIF::REG_AD); 31 | 32 | GIF::PackedPacket packet(64); 33 | packet.WriteTag(tag); 34 | packet.AD(GS::REG_LABEL, GS::LABEL(0x00, 0xF0)); 35 | 36 | DMA::SendSimple(DMA::D2, packet.Raw(), packet.Size()); 37 | 38 | printf("Clear label bits -> SIGLBLID: %016lx\n", *GS::SIGLBLID); 39 | } 40 | 41 | int main(int argc, char *argv[]) { 42 | printf("-- TEST BEGIN\n"); 43 | 44 | testSetBits(); 45 | testClearBits(); 46 | 47 | printf("-- TEST END\n"); 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /tests/cpu/vu0_macro/transfer.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | lqc2: 3 | lqc2 +0: c0dec0de beefdead abcdef01 23456789 4 | lqc2 +16: 44556677 00112233 ccddeeff 8899aabb 5 | lqc2 -16: c0de1337 deadbeef 9abcdef0 45678123 6 | lqc2 -> $vf0: 3f800000 00000000 00000000 00000000 7 | 8 | sqc2: 9 | sqc2 +0: 01234567 01234567 01234567 01234567 10 | sqc2 +16: 89abcdef 89abcdef 89abcdef 89abcdef 11 | sqc2 -16: 76543210 76543210 76543210 76543210 12 | 13 | cfc2: 12345678 12345678 ffffffff ffffffff 14 | cfc2 -> $0: 00000000 00000000 00000000 00000000 15 | TPC's value after executing VU subroutine: 0000001f 16 | ctc2 -> vi00: 00000000 17 | ctc2 -> vi01: 0000ffff 18 | ctc2 -> vi16: 00000fc0 19 | ctc2 -> vi17: 00000000 20 | ctc2 -> vi18: 00ffffff 21 | ctc2 -> vi19: 00002e30 22 | ctc2 -> vi20: 007fffff 23 | ctc2 -> vi21: ffffffff 24 | ctc2 -> vi22: ffffffff 25 | ctc2 -> vi23: 00000000 26 | ctc2 -> vi24: 00000c0c 27 | ctc2 -> vi25: 00000000 28 | ctc2 -> vi27: 0000ffff 29 | ctc2 -> vi28: 00000000 30 | ctc2 -> vi29: 00000000 31 | ctc2 -> vi31: 0000ffff 32 | qmfc2: 3f800000 00000000 00000000 00000000 33 | qmfc2 -> $0: 00000000 00000000 00000000 00000000 34 | qmtc2: 12345678 12345678 12345678 12345678 35 | qmtc2 -> $vf0: 3f800000 00000000 00000000 00000000 36 | -- TEST END 37 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/mbx-common.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "mbx-common.h" 4 | 5 | u32 getThreadPriority(s32 threadId) { 6 | iop_thread_info_t threadInfo = {}; 7 | ReferThreadStatus(threadId, &threadInfo); 8 | return threadInfo.currentPriority; 9 | } 10 | 11 | void printMbx(s32 mbxId) { 12 | iop_mbx_status_t mbxInfo; 13 | memset(&mbxInfo, 0, sizeof(iop_mbx_status_t)); 14 | s32 result = ReferMbxStatus(mbxId, &mbxInfo); 15 | if (result >= 0) { 16 | MSG* message = (MSG*)mbxInfo.topPacket; 17 | u32 i = 0; 18 | //reserved[0] and reserved[1] from iop_mbx_status_t are not 19 | //logged because they are not set by ReferMbxStatus 20 | printf("attr: %x, option: %x, wait threads: %d, messages: %d", 21 | mbxInfo.attr, mbxInfo.option, mbxInfo.numWaitThreads, mbxInfo.numMessage); 22 | if (mbxInfo.numMessage != 0) { 23 | printf(" -> "); 24 | } 25 | for (i = 0; i < mbxInfo.numMessage; i++) { 26 | printf("{ payload: %d, priority: %d }", message->payload, message->header.priority); 27 | if((i + 1) != mbxInfo.numMessage) { 28 | printf(", "); 29 | } 30 | message = (MSG*)message->header.next; 31 | } 32 | printf("\n"); 33 | } else { 34 | printf(" failed (%d)\n", result); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/wakeup.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | wakeup (with tid 0): failed -> result: -1 4 | wakeup (with current tid): failed -> result: -1 5 | worse prio thread: 6 | wakeup before start: failed -> result: -1 7 | wakeup after start: succeeded -> result: thread id, status -> result: 02, init prio: 50, current prio: 50, status: 02, wait type: 0, wakeup count: 1 8 | wakeup after suspend: succeeded -> result: thread id, status -> result: 08, init prio: 50, current prio: 50, status: 08, wait type: 0, wakeup count: 2 9 | wakeup after terminate: failed -> result: -1 10 | sleeping thread: 11 | wakeup after start: succeeded -> result: thread id, status -> result: 10, init prio: 30, current prio: 30, status: 10, wait type: 0, wakeup count: 0 12 | wakeup after suspend: succeeded -> result: thread id, status -> result: 08, init prio: 30, current prio: 30, status: 08, wait type: 0, wakeup count: 0 13 | waiting thread: 14 | wakeup after start: succeeded -> result: thread id, status -> result: 04, init prio: 30, current prio: 30, status: 04, wait type: 2, wakeup count: 1 15 | wakeup after suspend: succeeded -> result: thread id, status -> result: 0c, init prio: 30, current prio: 30, status: 0c, wait type: 2, wakeup count: 2 16 | corner cases: 17 | wakeup with invalid tid: failed -> result: -1 18 | -- TEST END 19 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/terminate.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | terminate (with current tid): failed -> result: -1 4 | worse prio thread: 5 | terminate before start: failed -> result: -1 6 | terminate after start: succeeded -> result: thread id, status -> result: 10, init prio: 50, current prio: 50, status: 10 7 | start after terminate: succeeded -> result: thread id 8 | terminate after suspend: succeeded -> result: thread id, status -> result: 10, init prio: 50, current prio: 50, status: 10 9 | status after changing priority: result: 02, init prio: 50, current prio: 60, status: 02 10 | terminate after changing priority: succeeded -> result: thread id, status -> result: 10, init prio: 50, current prio: 50, status: 10 11 | terminate after terminate: failed -> result: -1 12 | sleeping thread: 13 | terminate after start: succeeded -> result: thread id, status -> result: 10, init prio: 30, current prio: 30, status: 10 14 | terminate after suspend: succeeded -> result: thread id, status -> result: 10, init prio: 30, current prio: 30, status: 10 15 | waiting thread: 16 | terminate after start: succeeded -> result: thread id, status -> result: 10, init prio: 30, current prio: 30, status: 10 17 | terminate after suspend: succeeded -> result: thread id, status -> result: 10, init prio: 30, current prio: 30, status: 10 18 | corner cases: 19 | terminate with invalid tid: failed -> result: -1 20 | -- TEST END 21 | -------------------------------------------------------------------------------- /tests/vu/games/triace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../test_runner.h" 3 | 4 | static const u32 __attribute__((aligned(16))) C_INIT[4] = {0xB063B75B, 0x8701CE82, 0x46FCC888, 0x793CC535}; 5 | 6 | static u32 *const CVI_INIT = (u32 *)(vu0_mem + 0x0000); 7 | 8 | static void setup_constants() { 9 | *(vu128 *)CVI_INIT = *(vu128 *)C_INIT; 10 | } 11 | 12 | class TriAceTestRunner : public TestRunner { 13 | public: 14 | TriAceTestRunner(int vu) : TestRunner(vu) { 15 | } 16 | 17 | void Perform() { 18 | using namespace VU; 19 | 20 | Reset(); 21 | 22 | WrLoadFloatRegister(DEST_XYZW, VF01, CVI_INIT); 23 | 24 | WrImm( 0x42FECCCD); 25 | WrImm(MULi(DEST_X, VF02, VF01), 0x42546666); 26 | WrImm(ADDi(DEST_X, VF03, VF02), 0x43D80D3E); 27 | WrImm(MULi(DEST_Y, VF02, VF01), 0xC7F079B3); 28 | WrImm(ADDi(DEST_Y, VF03, VF02), 0x43A0DA10); 29 | WrImm(MULi(DEST_Z, VF02, VF01), 0x43A02666); 30 | WrImm(ADDi(DEST_Z, VF03, VF02), 0x43546E14); 31 | WrImm(MULi(DEST_W, VF02, VF01), 0x42F23333); 32 | WrImm(ADDi(DEST_W, VF03, VF02), 0x3DD3DD98); 33 | 34 | Execute(); 35 | 36 | PrintRegister(VF01, true); 37 | PrintRegister(VF02, true); 38 | PrintRegister(VF03, true); 39 | } 40 | }; 41 | 42 | int main(int argc, char *argv[]) { 43 | printf("-- TEST BEGIN\n"); 44 | 45 | setup_constants(); 46 | 47 | TriAceTestRunner runner(0); 48 | 49 | runner.Perform(); 50 | 51 | printf("-- TEST END\n"); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /tests/dma/spr/normal.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | SADR offsets: 3 | toSPR SADR (0x10): 00000020 -> 00000030 4 | fromSPR SADR (0x20): 00000010 -> 00000030 5 | SADR +0x10: 00000000 00000000 00000000 00000000 6 | SADR +0x20: 01234567 89abcdef deadbeef 1337c0de 7 | 8 | fromSPR SADR (0x20): 00000010 -> 00000030 9 | SADR +0x14: 00000000 00000000 00000000 00000000 10 | SADR +0x24: 01234567 89abcdef deadbeef 1337c0de 11 | 12 | SADR high bits: 13 | toSPR SADR (0x10): 00000020 -> 00000030 14 | fromSPR SADR (0x10): 00000020 -> 00000030 15 | SADR send with ignored bits: 01234567 89abcdef deadbeef 1337c0de 16 | 17 | fromSPR SADR (0x10): 00000020 -> 00000030 18 | SADR receive with ignored bits: 01234567 89abcdef deadbeef 1337c0de 19 | 20 | MADR with high bit: 21 | WARNING: DMA transfer did not accept MADR: 80000000 22 | toSPR MADR: high bit set? no 23 | MADR send with SPR bit: 01234567 89abcdef deadbeef 1337c0de 24 | 25 | WARNING: DMA transfer did not accept MADR: 80000000 26 | fromSPR MADR: high bit set? no 27 | MADR receive with SPR bit: 01234567 89abcdef deadbeef 1337c0de 28 | 29 | Near end (wrapping): 30 | SADR updated: to=00000000, from=00003ff0 31 | Send near end 0x0000: fffcfcfc fffdfdfd fffefefe ffffffff 32 | Send near end 0x0010: 00000000 01010101 02020202 03030303 33 | SADR updated: to=00003ff0, from=00000000 34 | Read near end 0x0000: 04040404 05050505 06060606 07070707 35 | Read near end 0x0010: 08080808 09090909 0a0a0a0a 0b0b0b0b 36 | -- TEST END 37 | -------------------------------------------------------------------------------- /tests/gs/signal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../dma/dmaregs.h" 3 | #include "../dma/dmasend.h" 4 | #include "emit_giftag.h" 5 | #include "gsregs.h" 6 | 7 | void testSetBits() { 8 | //Signal must be cleared to unstall GIF 9 | *GS::CSR = GS::CSR_SIGNAL; 10 | *GS::SIGLBLID = 0x7654321000000000ULL; 11 | 12 | GIF::Tag tag; 13 | tag.SetLoops(1); 14 | tag.SetEop(); 15 | tag.SetRegDescs(GIF::REG_AD); 16 | 17 | GIF::PackedPacket packet(64); 18 | packet.WriteTag(tag); 19 | packet.AD(GS::REG_SIGNAL, GS::SIGNAL(0xF0, 0xF0)); 20 | 21 | DMA::SendSimple(DMA::D2, packet.Raw(), packet.Size()); 22 | 23 | printf("Set signal bits -> CSR[SIGNAL] = %016lx, SIGLBLID: %016lx\n", 24 | *GS::CSR & GS::CSR_SIGNAL, *GS::SIGLBLID); 25 | } 26 | 27 | void testClearBits() { 28 | //Signal must be cleared to unstall GIF 29 | *GS::CSR = GS::CSR_SIGNAL; 30 | *GS::SIGLBLID = 0x3333333333333333ULL; 31 | 32 | GIF::Tag tag; 33 | tag.SetLoops(1); 34 | tag.SetEop(); 35 | tag.SetRegDescs(GIF::REG_AD); 36 | 37 | GIF::PackedPacket packet(64); 38 | packet.WriteTag(tag); 39 | packet.AD(GS::REG_SIGNAL, GS::SIGNAL(0x00, 0xF0)); 40 | 41 | DMA::SendSimple(DMA::D2, packet.Raw(), packet.Size()); 42 | 43 | printf("Clear signal bits -> CSR[SIGNAL] = %016lx, SIGLBLID: %016lx\n", 44 | *GS::CSR & GS::CSR_SIGNAL, *GS::SIGLBLID); 45 | } 46 | 47 | int main(int argc, char *argv[]) { 48 | printf("-- TEST BEGIN\n"); 49 | 50 | testSetBits(); 51 | testClearBits(); 52 | 53 | printf("-- TEST END\n"); 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /tests/vu/test_runner.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_VU_TEST_RUNNER_H 2 | #define PS2AUTOTESTS_VU_TEST_RUNNER_H 3 | 4 | #include 5 | #include "assemble.h" 6 | 7 | class TestRunner : public VU::Block { 8 | public: 9 | // Create a test runner. For a single op test, just pass it in the constructor. 10 | // For the vu parameter, specify which vu unit to run the test on. 11 | TestRunner(int vu, VU::LowerOp l) 12 | : VU::Block(vu == 0 ? vu0_micro : vu1_micro), vu_(vu) { 13 | Wr(l); 14 | } 15 | TestRunner(int vu, VU::UpperOp u = VU::UpperOp()) 16 | : VU::Block(vu == 0 ? vu0_micro : vu1_micro), vu_(vu) { 17 | if (u != VU::UpperOp()) { 18 | Wr(u); 19 | } 20 | } 21 | 22 | // Write an exit and run the test. 23 | void Execute(); 24 | 25 | // Emit an exit. 26 | void RunnerExit(); 27 | 28 | // Emit code to set a float vector value. 29 | void WrLoadFloatRegister(VU::Dest dest, VU::Reg r, const u32 *val); 30 | 31 | // Emit code to set an integer value. 32 | void WrSetIntegerRegister(VU::Reg r, u32 val); 33 | void WrLoadIntegerRegister(VU::Dest dest, VU::Reg r, const u32 *val); 34 | 35 | // Print out any integer or float/vector register. 36 | void PrintRegister(VU::Reg r, bool newline); 37 | void PrintRegisterField(VU::Reg r, VU::Field field, bool newline); 38 | 39 | // Print out a summary of status register changes. 40 | void PrintStatus(bool newline); 41 | 42 | protected: 43 | void InitRegisters(); 44 | void InitFlags(); 45 | void PrintIntegerRegister(int r); 46 | void PrintVectorRegister(int r); 47 | 48 | u16 GetValueAddress(const u32 *val); 49 | 50 | int vu_; 51 | u32 status_; 52 | u32 mac_; 53 | u32 clipping_; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /tests/cpu/ee/shared.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static u32 __attribute__((aligned(16))) C_ZERO[4] = {0, 0, 0, 0}; 4 | static u32 __attribute__((aligned(16))) C_S16_MAX[4] = {0x7FFF, 0, 0, 0}; 5 | static u32 __attribute__((aligned(16))) C_S16_MIN[4] = {0xFFFF8000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 6 | static u32 __attribute__((aligned(16))) C_S32_MAX[4] = {0x7FFFFFFF, 0, 0, 0}; 7 | static u32 __attribute__((aligned(16))) C_S32_MIN[4] = {0x80000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 8 | static u32 __attribute__((aligned(16))) C_S64_MAX[4] = {0xFFFFFFFF, 0x7FFFFFFF, 0, 0 }; 9 | static u32 __attribute__((aligned(16))) C_S64_MIN[4] = {0, 0x80000000, 0xFFFFFFFF, 0xFFFFFFFF}; 10 | static u32 __attribute__((aligned(16))) C_NEGONE[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 11 | static u32 __attribute__((aligned(16))) C_ONE[4] = {1, 0, 0, 0}; 12 | static u32 __attribute__((aligned(16))) C_GARBAGE1[4] = {0x1337, 0x1338, 0x1339, 0x133A}; 13 | static u32 __attribute__((aligned(16))) C_GARBAGE2[4] = {0xDEADBEEF, 0xDEADBEEE, 0xDEADBEED, 0xDEADBEEC}; 14 | 15 | template 16 | static inline void SET_U32(register u128 &rd) { 17 | asm volatile ( 18 | "lui %0, %1\n" 19 | "ori %0, %0, %2\n" 20 | : "+r"(rd) : "K"((i >> 16) & 0xFFFF), "K"(i & 0xFFFF) 21 | ); 22 | } 23 | 24 | static inline void SET_M(register u128 &rd, u32 *p) { 25 | rd = *(vu128 *)p; 26 | } 27 | 28 | static inline void PRINT_R(const register u128 &rt, bool newline) { 29 | static u32 __attribute__((aligned(16))) result[4] = {0, 0, 0, 0}; 30 | *(vu128 *)result = rt; 31 | 32 | printf("%08x %08x %08x %08x", result[3], result[2], result[1], result[0]); 33 | if (newline) { 34 | printf("\n"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/dma/dmac/cpcond.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "../dmaregs.h" 7 | #include "../dmasend.h" 8 | #include "../dmatags.h" 9 | 10 | static volatile DMA::Channel *const toSPR = DMA::D9; 11 | 12 | u32 getCpCond() { 13 | u32 result = 0; 14 | asm volatile ( 15 | ".set noreorder\n" 16 | "sync.l\n" 17 | "sync.p\n" 18 | "bc0t done\n" 19 | "addiu %0, $0, 1\n" 20 | "b done\n" 21 | "addiu %0, $0, 0\n" 22 | "done:\n" 23 | : : "r"(result) 24 | ); 25 | return result; 26 | } 27 | 28 | int main(int argc, char *argv[]) { 29 | printf("-- TEST BEGIN\n"); 30 | 31 | u32 *buf = (u32 *)memalign(16, 16 * 1024); 32 | buf[0] = 0x01234567; 33 | buf[1] = 0x89ABCDEF; 34 | buf[2] = 0xDEADBEEF; 35 | buf[3] = 0x1337C0DE; 36 | 37 | u32 result = 0; 38 | 39 | result = getCpCond(); 40 | printf("initial value: %d\n", result); 41 | 42 | *DMA::D_PCR = DMA::D_PCR_CPC9; 43 | 44 | result = getCpCond(); 45 | printf("value after setting PCR.CPC: %d\n", result); 46 | 47 | DMA::SendSimple(toSPR, buf, 16 * 1024); 48 | 49 | result = getCpCond(); 50 | printf("value after sending DMA: %d\n", result); 51 | 52 | *DMA::D_PCR &= ~DMA::D_PCR_CPC9; 53 | 54 | result = getCpCond(); 55 | printf("value after clearing PCR.CPC: %d\n", result); 56 | 57 | *DMA::D_PCR = DMA::D_PCR_CPC9; 58 | 59 | result = getCpCond(); 60 | printf("value after restoring PCR.CPC: %d\n", result); 61 | 62 | *DMA::D_STAT = DMA::D_STAT_CIS9; 63 | 64 | result = getCpCond(); 65 | printf("value after resetting STAT.CIS: %d\n", result); 66 | 67 | free(buf); 68 | 69 | printf("-- TEST END\n"); 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/stat.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | self thread: 3 | stat (with tid 0): succeeded -> result: 01, init prio: 40, current prio: 40, status: 01, wait type: 0 4 | stat (with current tid): succeeded -> result: 01, init prio: 40, current prio: 40, status: 01, wait type: 0 5 | low prio thread: 6 | stat before start: succeeded -> result: 10, init prio: 50, current prio: 50, status: 10, wait type: 0 7 | stat after start: succeeded -> result: 02, init prio: 50, current prio: 50, status: 02, wait type: 0 8 | stat after suspend: succeeded -> result: 08, init prio: 50, current prio: 50, status: 08, wait type: 0 9 | stat after resume: succeeded -> result: 02, init prio: 50, current prio: 50, status: 02, wait type: 0 10 | stat after terminate: succeeded -> result: 10, init prio: 50, current prio: 50, status: 10, wait type: 0 11 | sleeping thread: 12 | stat after start: succeeded -> result: 04, init prio: 30, current prio: 30, status: 04, wait type: 1 13 | stat after suspend: succeeded -> result: 0c, init prio: 30, current prio: 30, status: 0c, wait type: 1 14 | stat after resume: succeeded -> result: 04, init prio: 30, current prio: 30, status: 04, wait type: 1 15 | waiting thread: 16 | stat after start: succeeded -> result: 04, init prio: 30, current prio: 30, status: 04, wait type: 2 17 | stat after suspend: succeeded -> result: 0c, init prio: 30, current prio: 30, status: 0c, wait type: 2 18 | stat after resume: succeeded -> result: 04, init prio: 30, current prio: 30, status: 04, wait type: 2 19 | corner cases: 20 | thread stat with invalid tid: failed -> result: -1 21 | self thread stat with null struct: 01 22 | self thread stat with struct in spr -> result: 01, status: 01 23 | -- TEST END 24 | -------------------------------------------------------------------------------- /tests/dma/dmac/tagintr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "../dmaregs.h" 7 | #include "../dmasend.h" 8 | #include "../dmatags.h" 9 | 10 | static volatile DMA::Channel *const toSPR = DMA::D9; 11 | 12 | void testTagIrq(u32 *buf, bool tagIntEnable, bool tagIrq) { 13 | *DMA::D_STAT = DMA::D_STAT_CIS9; 14 | 15 | static const u32 dmaPacketSize = 512; 16 | DMA::SrcChainPacket srcTag(dmaPacketSize); 17 | 18 | srcTag.Reset(); 19 | srcTag.REF(buf, 1, tagIrq); 20 | srcTag.REF(buf, 1); 21 | srcTag.END(0); 22 | 23 | if(tagIntEnable) { 24 | toSPR->chcr |= DMA::CHCR_TIE; 25 | } else { 26 | toSPR->chcr &= ~DMA::CHCR_TIE; 27 | } 28 | 29 | u32 cisBefore = *DMA::D_STAT & DMA::D_STAT_CIS9; 30 | DMA::SendChain(toSPR, srcTag.Raw(), dmaPacketSize); 31 | u32 cisAfter = *DMA::D_STAT & DMA::D_STAT_CIS9; 32 | 33 | u32 tadrOffset = (u8 *)toSPR->tadr - (u8 *)srcTag.Raw(); 34 | 35 | printf("Tag interrupt %s, Tag IRQ %s:\n", 36 | tagIntEnable ? "enabled" : "disabled", 37 | tagIrq ? "enabled" : "disabled"); 38 | printf(" CHCR(tag): %08x, TADR offset: %08x, CIS(before): %08x, CIS(after): %08x\n", 39 | toSPR->chcr & DMA::CHCR_TAG_MASK, tadrOffset, cisBefore, cisAfter); 40 | } 41 | 42 | int main(int argc, char *argv[]) { 43 | printf("-- TEST BEGIN\n"); 44 | 45 | u32 *buf = (u32 *)memalign(16, 16 * 1024); 46 | buf[0] = 0x01234567; 47 | buf[1] = 0x89ABCDEF; 48 | buf[2] = 0xDEADBEEF; 49 | buf[3] = 0x1337C0DE; 50 | 51 | testTagIrq(buf, true, true); 52 | testTagIrq(buf, true, false); 53 | testTagIrq(buf, false, true); 54 | testTagIrq(buf, false, false); 55 | 56 | free(buf); 57 | 58 | printf("-- TEST END\n"); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/poll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "mbx-common.h" 4 | 5 | typedef struct { 6 | s32 id; 7 | s32 mbxId; 8 | } THREAD_PARAM; 9 | 10 | void basicPollingTest() { 11 | static const int msgCount = 3; 12 | int i = 0; 13 | MSG msg[msgCount]; 14 | 15 | iop_mbx_t mbxInfo = {}; 16 | mbxInfo.option = 0; 17 | mbxInfo.attr = MBA_THFIFO | MBA_MSFIFO; 18 | s32 mbxId = CreateMbx(&mbxInfo); 19 | 20 | { 21 | s32 result = PollMbx(NULL, mbxId); 22 | printf(" polling from empty box: %d\n", result); 23 | } 24 | 25 | for (i = 0; i < msgCount; i++) { 26 | memset(&msg[i], 0, sizeof(MSG)); 27 | msg[i].header.priority = msgCount - i; 28 | msg[i].payload = i + 1; 29 | SendMbx(mbxId, &msg[i]); 30 | } 31 | 32 | printf(" box contents before polling: "); 33 | printMbx(mbxId); 34 | 35 | { 36 | MSG* msg = NULL; 37 | s32 result = PollMbx((void**)&msg, mbxId); 38 | printf(" polling from non-empty box: %d, message: %d\n", 39 | result, msg->payload); 40 | } 41 | 42 | printf(" box contents after polling: "); 43 | printMbx(mbxId); 44 | 45 | DeleteMbx(mbxId); 46 | } 47 | 48 | int _start(int argc, char **argv) { 49 | printf("-- TEST BEGIN\n"); 50 | 51 | printf("basic polling:\n"); 52 | basicPollingTest(); 53 | 54 | printf("invalid params:\n"); 55 | { 56 | s32 result = PollMbx(NULL, ~0); 57 | printf(" polling message from invalid box: %d\n", result); 58 | 59 | //Polling into a null pointer seems to work (returns 0 and message is dequeued) 60 | //but it will probably have dangerous side effects because memory at address 0 61 | //will be modified. 62 | //result = PollMbx(NULL, mbxId); 63 | } 64 | 65 | printf("-- TEST END\n"); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /tests/vu/assemble/encoding.h: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include 3 | 4 | namespace VU { 5 | 6 | // Helpers - these propagate later to encoding funcs. 7 | // These are used to force things into certain ranges. 8 | 9 | static inline Reg VI(Reg i) { 10 | assert(i >= VI00 && i <= VI15); 11 | return Reg(i - 32); 12 | } 13 | 14 | static inline u32 SIMM5(s8 imm) { 15 | assert(imm <= 0x0F && imm >= -0x10); 16 | return imm & 0x1F; 17 | } 18 | 19 | static inline u32 SIMM11(s16 imm) { 20 | assert(imm <= 0x03FF && imm >= -0x0400); 21 | return imm & 0x07FF; 22 | } 23 | 24 | // Actual encoding positions. 25 | 26 | static inline u32 VD(Reg v) { 27 | assert(v >= VF00 && v <= VF31); 28 | return v << 6; 29 | } 30 | 31 | static inline u32 VS(Reg v) { 32 | assert(v >= VF00 && v <= VF31); 33 | return v << 11; 34 | } 35 | 36 | static inline u32 VT(Reg v) { 37 | assert(v >= VF00 && v <= VF31); 38 | return v << 16; 39 | } 40 | 41 | static inline u32 DEST(Dest dest) { 42 | return dest << 21; 43 | } 44 | 45 | static inline u32 BC(Field f) { 46 | return f; 47 | } 48 | 49 | static inline u32 FSF(Field f) { 50 | return f << 21; 51 | } 52 | 53 | static inline u32 FTF(Field f) { 54 | return f << 23; 55 | } 56 | 57 | static inline u32 IMM5(u8 imm) { 58 | assert((imm & 0x1F) == imm); 59 | return imm << 6; 60 | } 61 | 62 | static inline u32 IMM11(u16 imm) { 63 | assert((imm & 0x07FF) == imm); 64 | return imm; 65 | } 66 | 67 | static inline u32 IMM15(u16 imm) { 68 | assert((imm & 0x7FFF) == imm); 69 | // The second half is at position 21 (10 right of the 11 we zero out.) 70 | return (imm & 0x07FF) | ((imm & 0x7800) << 10); 71 | } 72 | 73 | static inline u32 IMM24(u32 imm) { 74 | assert((imm & 0x00FFFFFF) == imm); 75 | return imm; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /tests/dma/vif/intstall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../dmaregs.h" 5 | #include "../dmasend.h" 6 | #include "../dmatags.h" 7 | #include "emit_vifcode.h" 8 | #include "vifunits.h" 9 | 10 | static VIF::Unit* g_units[2] = { &VIF::Unit0, &VIF::Unit1 }; 11 | 12 | typedef void (*WriteIntCodeFunction)(VIF::Packet&); 13 | 14 | void writeNopInt(VIF::Packet& vifcode) { 15 | vifcode.NOP(0, 0, VIF::CMD_ENABLE_INT); 16 | } 17 | 18 | void writeMarkInt(VIF::Packet& vifcode) { 19 | vifcode.MARK(0xBEEF, VIF::CMD_ENABLE_INT); 20 | } 21 | 22 | void writeStMaskInt(VIF::Packet& vifcode) { 23 | vifcode.STMASK(0xFFFFFFFF, VIF::CMD_ENABLE_INT); 24 | } 25 | 26 | void doTest(VIF::Unit* unit, const char* testName, WriteIntCodeFunction writeIntCode) { 27 | static const u32 vifPacketQwc = 3; 28 | static const u32 vifPacketSize = vifPacketQwc * 0x10; 29 | 30 | unit->regs->fbrst = VIF::FBRST_RST; 31 | 32 | VIF::Packet vifcode(vifPacketSize); 33 | 34 | vifcode.STMASK(0xAAAAAAAA); 35 | 36 | writeIntCode(vifcode); 37 | vifcode.STMASK(0xBBBBBBBB); 38 | 39 | vifcode.NOP(); 40 | vifcode.NOP(); 41 | vifcode.STMASK(0xCCCCCCCC); 42 | 43 | DMA::SendSimple(unit->dmaChannel, vifcode.Raw(), vifPacketSize); 44 | 45 | printf("%s:\n", testName); 46 | printf(" Status after transfer - MASK: %08x, STAT: %08x\n", unit->regs->mask, unit->regs->stat); 47 | } 48 | 49 | int main(int argc, char *argv[]) { 50 | printf("-- TEST BEGIN\n"); 51 | 52 | for(u32 i = 0; i < 2; i++) { 53 | VIF::Unit* unit = g_units[i]; 54 | printf("== VIF%d ==\n", i); 55 | doTest(unit, "NOP (I)", &writeNopInt); 56 | doTest(unit, "MARK (I)", &writeMarkInt); 57 | doTest(unit, "STMASK (I)", &writeStMaskInt); 58 | printf("\n"); 59 | } 60 | 61 | printf("-- TEST END\n"); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/branchdelay.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void __attribute__((noinline)) test_bc1t() { 4 | int result = -1; 5 | 6 | asm volatile ( 7 | ".set noreorder\n" 8 | 9 | "c.eq.s $f0, $f0\n" 10 | "bc1t target1_%=\n" 11 | "bc1t target2_%=\n" 12 | "bc1t target3_%=\n" 13 | "bc1t target4_%=\n" 14 | "nop\n" 15 | 16 | "target1_%=:\n" 17 | "li %0, 1\n" 18 | "j skip_%=\n" 19 | "nop\n" 20 | 21 | "target2_%=:\n" 22 | "li %0, 2\n" 23 | "j skip_%=\n" 24 | "nop\n" 25 | 26 | "target3_%=:\n" 27 | "li %0, 3\n" 28 | "j skip_%=\n" 29 | "nop\n" 30 | 31 | "target4_%=:\n" 32 | "li %0, 4\n" 33 | "j skip_%=\n" 34 | "nop\n" 35 | 36 | "skip_%=:\n" 37 | 38 | : "+r"(result) 39 | ); 40 | 41 | printf("bc1t: delay branch: %08x\n", result); 42 | } 43 | 44 | void __attribute__((noinline)) test_bc1tl() { 45 | int result = -1; 46 | 47 | asm volatile ( 48 | ".set noreorder\n" 49 | 50 | "c.eq.s $f0, $f0\n" 51 | "bc1tl target1_%=\n" 52 | "bc1tl target2_%=\n" 53 | "bc1tl target3_%=\n" 54 | "bc1tl target4_%=\n" 55 | "nop\n" 56 | 57 | "target1_%=:\n" 58 | "li %0, 1\n" 59 | "j skip_%=\n" 60 | "nop\n" 61 | 62 | "target2_%=:\n" 63 | "li %0, 2\n" 64 | "j skip_%=\n" 65 | "nop\n" 66 | 67 | "target3_%=:\n" 68 | "li %0, 3\n" 69 | "j skip_%=\n" 70 | "nop\n" 71 | 72 | "target4_%=:\n" 73 | "li %0, 4\n" 74 | "j skip_%=\n" 75 | "nop\n" 76 | 77 | "skip_%=:\n" 78 | 79 | : "+r"(result) 80 | ); 81 | 82 | printf("bc1tl: delay branch: %08x\n", result); 83 | } 84 | 85 | int main(int argc, char *argv[]) { 86 | printf("-- TEST BEGIN\n"); 87 | 88 | test_bc1t(); 89 | test_bc1tl(); 90 | 91 | printf("-- TEST END\n"); 92 | 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | A set of test programs run on a PS2, with accompanying results. 5 | 6 | Readers of these tests can become more familiar with how to write homebrew and 7 | other software, and can become more familiar with the operation of the hardware. 8 | 9 | These tests can also be used, in an automated fashion, for software intended to 10 | mimic the behavior of PS2 hardware. 11 | 12 | 13 | Running tests on hardware 14 | ========================= 15 | 16 | To execute a test on hardware, and to develop tests, the following is required: 17 | 18 | * A PS2 capable of running homebrew 19 | * ps2link.elf 20 | * Network connectivity to your PS2 21 | * A working ps2sdk setup 22 | 23 | Individual tests can be run using a command like this: 24 | 25 | ./gentest.py cpu/ee/alu 26 | 27 | This will automatically send the test to ps2link, and save its results to an 28 | expected file. 29 | 30 | 31 | Creating tests 32 | ============== 33 | 34 | Tests can be created quite simply by including a Makefile template. 35 | 36 | Pull requests are accepted. Please take care not to submit copyrighted material 37 | without proper licensing and permission. 38 | 39 | 40 | Automating tests 41 | ================ 42 | 43 | Tests will either end in `.elf` or `.irx`. The latter are tests meant to be 44 | run on the IOP (R3000) processor, rather than the EE (R5900). 45 | 46 | Tests will then send data to stdout. A test that has run accurately will 47 | produce the same data as contained in the `.expected` file. On Windows, take 48 | care to normalize newlines when making the comparison. 49 | 50 | 51 | Acknowledgements 52 | ================ 53 | 54 | PS2 is a registered trademark of Sony Computer Entertainment Inc. 55 | 56 | These tests would not be possible without the work done in [ps2sdk] (https://github.com/ps2dev/ps2sdk). 57 | -------------------------------------------------------------------------------- /tests/cpu/iop/hilodelay.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void test_mfhilo_wait() { 5 | register u32 hi = 0x1337; 6 | register u32 lo = 0x1337; 7 | 8 | asm volatile ( 9 | "ori $t8, $0, 0x10\n" 10 | "mthi $t8\n" 11 | "ori $t8, $0, 0x20\n" 12 | "mtlo $t8\n" 13 | "nop\n" 14 | 15 | "ori $t8, $0, 0x01\n" 16 | "mfhi $t8\n" 17 | "or %0, $t8, $0\n" 18 | 19 | "ori $t8, $0, 0x02\n" 20 | "mflo $t8\n" 21 | "or %1, $t8, $0\n" 22 | : "+&r"(hi), "+&r"(lo) : : "t8" 23 | ); 24 | 25 | printf("mfhi delay: %x\n", hi); 26 | printf("mflo delay: %x\n", lo); 27 | } 28 | 29 | static void test_div_wait() { 30 | register u32 hi = 0x1337; 31 | register u32 lo = 0x1337; 32 | 33 | asm volatile ( 34 | "ori $t8, $0, 0x10\n" 35 | "mthi $t8\n" 36 | "ori $t8, $0, 0x20\n" 37 | "mtlo $t8\n" 38 | "nop\n" 39 | 40 | "ori $t8, $0, 0x03\n" 41 | "ori $t9, $0, 0x02\n" 42 | 43 | ".word 0x0319001A\n" /* "div $t8, $t9\n" */ 44 | "mfhi %0\n" 45 | 46 | ".word 0x0319001A\n" /* "div $t8, $t9\n" */ 47 | "mflo %1\n" 48 | : "+&r"(hi), "+&r"(lo) : : "t8", "t9" 49 | ); 50 | 51 | printf("div delay: %x %x\n", hi, lo); 52 | } 53 | 54 | static void test_mult_wait() { 55 | register u32 hi = 0x1337; 56 | register u32 lo = 0x1337; 57 | 58 | asm volatile ( 59 | "ori $t8, $0, 0x10\n" 60 | "mthi $t8\n" 61 | "ori $t8, $0, 0x20\n" 62 | "mtlo $t8\n" 63 | "nop\n" 64 | 65 | "ori $t8, $0, 0x03\n" 66 | "ori $t9, $0, 0x02\n" 67 | 68 | "mult $t8, $t9\n" 69 | "mfhi %0\n" 70 | 71 | "mult $t8, $t9\n" 72 | "mflo %1\n" 73 | : "+&r"(hi), "+&r"(lo) : : "t8", "t9" 74 | ); 75 | 76 | printf("mult delay: %x %x\n", hi, lo); 77 | } 78 | 79 | int _start(int argc, char *argv[]) { 80 | printf("-- TEST BEGIN\n"); 81 | 82 | test_mfhilo_wait(); 83 | test_div_wait(); 84 | test_mult_wait(); 85 | 86 | printf("-- TEST END\n"); 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /tests/kernel/iop/interrupt/release.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void intrHandler(int value) { 5 | } 6 | 7 | void testNormalOperation() { 8 | int oldStat = 0; 9 | 10 | printf("normal operation:\n"); 11 | 12 | CpuSuspendIntr(&oldStat); 13 | { 14 | //Remove any previously registered handler 15 | ReleaseIntrHandler(IOP_IRQ_VBLANK); 16 | 17 | RegisterIntrHandler(IOP_IRQ_VBLANK, 0, (void *)&intrHandler, NULL); 18 | int resultValidHandler = ReleaseIntrHandler(IOP_IRQ_VBLANK); 19 | 20 | printf(" release after handler registered: %d\n", resultValidHandler); 21 | 22 | RegisterIntrHandler(IOP_IRQ_VBLANK, 0, NULL, NULL); 23 | int resultNullHandler = ReleaseIntrHandler(IOP_IRQ_VBLANK); 24 | 25 | printf(" release after null handler was registered: %d\n", resultNullHandler); 26 | } 27 | CpuResumeIntr(oldStat); 28 | } 29 | 30 | void testReleaseAfterRelease() { 31 | int oldStat = 0; 32 | 33 | printf("release after release:\n"); 34 | 35 | CpuSuspendIntr(&oldStat); 36 | { 37 | //Remove any previously registered handler 38 | ReleaseIntrHandler(IOP_IRQ_VBLANK); 39 | 40 | RegisterIntrHandler(IOP_IRQ_VBLANK, 0, (void *)&intrHandler, NULL); 41 | ReleaseIntrHandler(IOP_IRQ_VBLANK); 42 | int result = ReleaseIntrHandler(IOP_IRQ_VBLANK); 43 | printf(" release after handler released: %d\n", result); 44 | } 45 | CpuResumeIntr(oldStat); 46 | } 47 | 48 | void testInvalidParams() { 49 | int oldStat = 0; 50 | 51 | printf("invalid params:\n"); 52 | 53 | CpuSuspendIntr(&oldStat); 54 | { 55 | int invalidIntrLineResult = ReleaseIntrHandler(~0); 56 | printf(" invalid interrupt line: %d\n", invalidIntrLineResult); 57 | } 58 | CpuResumeIntr(oldStat); 59 | } 60 | 61 | int _start(int argc, char **argv) { 62 | printf("-- TEST BEGIN\n"); 63 | 64 | testNormalOperation(); 65 | testReleaseAfterRelease(); 66 | testInvalidParams(); 67 | 68 | printf("-- TEST END\n"); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /common/common-iop.mk: -------------------------------------------------------------------------------- 1 | # _____ ___ ____ ___ ____ 2 | # ____| | ____| | | |____| 3 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 4 | #----------------------------------------------------------------------- 5 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 6 | # Licenced under Academic Free License version 2.0 7 | # Review ps2sdk README & LICENSE files for further details. 8 | # 9 | # $Id: Makefile.eeglobal_cpp_sample 1525 2009-01-23 00:24:13Z radad $ 10 | 11 | # Define pefixes for the various toolchain binaries. 12 | include $(COMMON_DIR)/common-defines.mk 13 | 14 | ASFLAGS_TARGET = -mcpu=r3000 15 | 16 | CFLAGS_TARGET = -miop 17 | ASFLAGS_TARGET = -march=r3000 18 | LDFLAGS_TARGET = -miop 19 | 20 | # include dir 21 | IOP_INCS := -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include -I$(COMMON_DIR) \ 22 | -I. $(IOP_INCS) 23 | # C compiler flags 24 | IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 $(IOP_INCS) $(IOP_CFLAGS) 25 | 26 | # linker flags 27 | IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib -L$(PS2SDK)/iop/lib $(IOP_LDFLAGS) 28 | 29 | # asssembler flags 30 | IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS) 31 | 32 | # link with following libraries (libs need to be defined multiple times in order for linking to work!!) 33 | IOP_LIBS += -lkernel -lgcc 34 | 35 | EXTRA_OBJS += $(COMMON_DIR)/common-iop.o $(COMMON_DIR)/xprintf.o 36 | 37 | # Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB 38 | 39 | %.o : %.c 40 | $(IOP_CC) $(IOP_CFLAGS) -c $< -o $@ 41 | 42 | %.o : %.S 43 | $(IOP_CC) $(IOP_CFLAGS) -c $< -o $@ 44 | 45 | %.o : %.s 46 | $(IOP_AS) $(IOP_ASFLAGS) $< -o $@ 47 | 48 | %.o : %.lst 49 | echo "#include \"irx_imports.h\"" > build-imports.c 50 | cat $< >> build-imports.c 51 | $(IOP_CC) $(IOP_CFLAGS) -c build-imports.c -o $@ 52 | rm -f build-imports.c 53 | 54 | %.irx : %.o $(EXTRA_OBJS) 55 | $(IOP_CC) $(IOP_LDFLAGS) -o $@ $< $(EXTRA_OBJS) $(IOP_LIBS) 56 | 57 | all: $(TARGETS:=.irx) 58 | 59 | clean: 60 | -$(RM) -f $(TARGETS:=.irx) $(TARGETS:=.o) 61 | 62 | rebuild: clean all 63 | -------------------------------------------------------------------------------- /tests/cpu/ee_simd/funnel.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | mfsa: 3 | mfsa 0: 00000000 1234abcd 00000000 00000000 4 | mfsa 1: 00000000 1234abcd 00000000 00000001 5 | mfsa 8: 00000000 1234abcd 00000000 00000008 6 | mfsa 16: 00000000 1234abcd 00000000 00000000 7 | mfsa 0xFFFF: 00000000 1234abcd 00000000 0000000f 8 | mfsa C_ZERO: 00000000 1234abcd 00000000 00000000 9 | mfsa C_S16_MAX: 00000000 1234abcd 00000000 0000000f 10 | 11 | mtsa: 12 | mtsa immediately before qfsrv: 78deadbe ef112233 449abcde f0123456 13 | mtsa with nops before qfsrv: 78deadbe ef112233 449abcde f0123456 14 | 15 | mtsab: 16 | mtsab next to mfsa: 00000000 00000000 00000000 00000000 (00000000 1234abcd 00000000 00000001) 17 | mtsab with space after mfsa: 00000000 00000000 00000000 00000000 (00000000 1234abcd 00000000 00000001) 18 | mtsab 15: 00000000 1234abcd 00000000 0000000f 19 | mtsab 16: 00000000 1234abcd 00000000 00000000 20 | mtsab 17: 00000000 1234abcd 00000000 00000001 21 | mtsab 4 ^ 1: 00000000 1234abcd 00000000 00000005 22 | mtsab 5 ^ 1: 00000000 1234abcd 00000000 00000004 23 | 24 | mtsah: 25 | mtsah next to mfsa: 00000000 00000000 00000000 00000000 (00000000 1234abcd 00000000 00000002) 26 | mtsah with space after mfsa: 00000000 00000000 00000000 00000000 (00000000 1234abcd 00000000 00000002) 27 | mtsah 7: 00000000 1234abcd 00000000 0000000e 28 | mtsah 8: 00000000 1234abcd 00000000 00000000 29 | mtsah 9: 00000000 1234abcd 00000000 00000002 30 | mtsah 4 ^ 1: 00000000 1234abcd 00000000 0000000a 31 | mtsah 5 ^ 1: 00000000 1234abcd 00000000 00000008 32 | 33 | qdsrv: 34 | qdsrv 0: 1337c0de ffffffff 12121212 aabbccdd 35 | qdsrv 1: 781337c0 deffffff ff121212 12aabbcc 36 | qdsrv 2: 56781337 c0deffff ffff1212 1212aabb 37 | qdsrv 3: 34567813 37c0deff ffffff12 121212aa 38 | qdsrv 4: 12345678 1337c0de ffffffff 12121212 39 | qdsrv 7: bcdef012 34567813 37c0deff ffffff12 40 | qdsrv 8: 9abcdef0 12345678 1337c0de ffffffff 41 | qdsrv 9: 449abcde f0123456 781337c0 deffffff 42 | qdsrv 15: adbeef11 2233449a bcdef012 34567813 43 | qdsrv 16: 1337c0de ffffffff 12121212 aabbccdd 44 | qdsrv 17: 781337c0 deffffff ff121212 12aabbcc 45 | 46 | -- TEST END 47 | -------------------------------------------------------------------------------- /tests/kernel/iop/vpool/pallocate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "vpl-common.h" 4 | 5 | static const s32 g_allocSizes[] = { 6 | 0x80, 0x81, 0x82, 0x83, 7 | 0x84, 0x85, 0x86, 0x87, 8 | 0x88, 0x89, 0x8A, 0x8B, 9 | 0x8C, 0x8D, 0x8E, 0x8F, 10 | 0x100, 0x800, 0x1000, 0x8000, 11 | -0x1, -0x5, -0x8, -0x80 12 | }; 13 | 14 | void doAllocate(u32 vplId, s32 size) { 15 | void *ptr = pAllocateVpl(vplId, size); 16 | s32 result = (s32)ptr; 17 | if(result >= 0) { 18 | printf(" succeeded -> "); 19 | printVpl(vplId); 20 | FreeVpl(vplId, ptr); 21 | } else { 22 | printf(" failed -> result (%d)\n", result); 23 | } 24 | } 25 | 26 | void testSingleAllocs() { 27 | iop_vpl_param vplParam = {}; 28 | vplParam.attr = VA_THFIFO; 29 | vplParam.option = 0; 30 | vplParam.size = 0x1000; 31 | 32 | s32 vplId = CreateVpl(&vplParam); 33 | 34 | s32 i = 0; 35 | for(i = 0; i < ARRAY_SIZE(g_allocSizes); i++) { 36 | s32 allocSize = g_allocSizes[i]; 37 | printf(" allocate %d bytes:\n", allocSize); 38 | printf(" "); doAllocate(vplId, allocSize); 39 | } 40 | 41 | DeleteVpl(vplId); 42 | } 43 | 44 | void testMultiAllocs() { 45 | iop_vpl_param vplParam = {}; 46 | vplParam.attr = VA_THFIFO; 47 | vplParam.option = 0; 48 | vplParam.size = 0x1000; 49 | 50 | s32 vplId = CreateVpl(&vplParam); 51 | 52 | pAllocateVpl(vplId, 0x800); 53 | pAllocateVpl(vplId, 0x400); 54 | pAllocateVpl(vplId, 0x200); 55 | pAllocateVpl(vplId, 0x100); 56 | 57 | s32 i = 0; 58 | for(i = 0; i < ARRAY_SIZE(g_allocSizes); i++) { 59 | s32 allocSize = g_allocSizes[i]; 60 | printf(" allocate %d bytes:\n", allocSize); 61 | printf(" "); doAllocate(vplId, allocSize); 62 | } 63 | 64 | DeleteVpl(vplId); 65 | } 66 | 67 | int _start(int argc, char **argv) { 68 | printf("-- TEST BEGIN\n"); 69 | 70 | printf("single allocations:\n"); 71 | testSingleAllocs(); 72 | 73 | printf("multiple allocations:\n"); 74 | testMultiAllocs(); 75 | 76 | printf("alloc from invalid vpl:\n"); 77 | doAllocate(~0, 0x100); 78 | 79 | printf("alloc negative from invalid vpl:\n"); 80 | doAllocate(~0, -0x80); 81 | 82 | printf("-- TEST END\n"); 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /tests/dma/dmasend.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "dmaregs.h" 5 | #include "dmasend.h" 6 | 7 | namespace DMA { 8 | void SendSimple(volatile Channel *chan, void *data, int size) { 9 | // Must be aligned to 16 bytes. 10 | assert((size & 0xf) == 0 && (((u32)data) & 0xf) == 0); 11 | 12 | // First, we need to flush the dcache for this data. 13 | SyncDCache(data, (u8 *)data + size); 14 | 15 | // Enable DMA, and turn off release signal/cycle, MFIFO, and stall control. 16 | *D_CTRL = D_CTRL_DMAE; 17 | 18 | // Now set the packet address and size. 19 | chan->madr = data; 20 | chan->qwc = size / 16; 21 | chan->tadr = 0; 22 | 23 | if (chan->madr != data) { 24 | printf("WARNING: DMA transfer did not accept MADR: %08x\n", (u32)chan->madr ^ (u32)data); 25 | } 26 | const char *madrStart = (const char *)chan->madr; 27 | 28 | // And start the transfer. Let's keep it simple. 29 | chan->chcr |= CHCR_STR | CHCR_DIR; 30 | 31 | int i = 100000; 32 | while (--i > 0 && chan->chcr.Ongoing()) { 33 | continue; 34 | } 35 | 36 | if (chan->madr != madrStart + size) { 37 | printf("WARNING: DMA transfer MADR did not increase as expected: %08x\n", (u32)chan->madr - (u32)madrStart); 38 | } 39 | 40 | if (i == 0) { 41 | printf("ERROR: DMA transfer timed out.\n"); 42 | } 43 | } 44 | 45 | void SendChain(volatile Channel *chan, void *dmatag, int size) { 46 | // Must be aligned to 16 bytes. 47 | assert((size & 0xf) == 0 && (((u32)dmatag) & 0xf) == 0); 48 | 49 | // We need to flush the dcache for the tag. The caller will need to flush for the data. 50 | SyncDCache(dmatag, (u8 *)dmatag + size); 51 | 52 | // Here, we only need the tag address. 53 | chan->madr = 0; 54 | chan->qwc = 0; 55 | chan->tadr = dmatag; 56 | 57 | // Start the transfer in chain mode. 58 | chan->chcr = (chan->chcr & ~CHCR_MOD_ANY) | CHCR_MOD_CHAIN | CHCR_STR; 59 | 60 | int i = 100000; 61 | while (--i > 0 && chan->chcr.Ongoing()) { 62 | continue; 63 | } 64 | 65 | // Clear the mode back for next time. 66 | chan->chcr &= ~CHCR_MOD_ANY; 67 | 68 | if (i == 0) { 69 | printf("ERROR: DMA transfer timed out.\n"); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /common/common-ee.mk: -------------------------------------------------------------------------------- 1 | # _____ ___ ____ ___ ____ 2 | # ____| | ____| | | |____| 3 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 4 | #----------------------------------------------------------------------- 5 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 6 | # Licenced under Academic Free License version 2.0 7 | # Review ps2sdk README & LICENSE files for further details. 8 | # 9 | # $Id: Makefile.eeglobal_cpp_sample 1525 2009-01-23 00:24:13Z radad $ 10 | 11 | # Define pefixes for the various toolchain binaries. 12 | include $(COMMON_DIR)/common-defines.mk 13 | 14 | # Include directories 15 | EE_INCS := -I$(PS2DEV)/ee/ee/include -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I. -I$(COMMON_DIR) $(EE_INCS) 16 | 17 | # C compiler flags 18 | EE_CFLAGS := -D_EE -O2 -G0 -Wall $(EE_CFLAGS) 19 | 20 | # C++ compiler flags 21 | EE_CXXFLAGS := -D_EE -O2 -G0 -Wall $(EE_CXXFLAGS) 22 | 23 | # Linker flags 24 | EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS) 25 | 26 | # Assembler flags 27 | EE_ASFLAGS := -G0 $(EE_ASFLAGS) 28 | 29 | # Link with following libraries. This is a special case, and instead of 30 | # allowing the user to override the library order, we always make sure 31 | # libkernel is the last library to be linked. 32 | EE_LIBS += -lstdc++ -lc -lkernel 33 | 34 | EXTRA_OBJS += $(COMMON_DIR)/common-ee.o 35 | 36 | # These macros can be used to simplify certain build rules. 37 | EE_C_COMPILE = $(EE_CC) $(EE_CFLAGS) $(EE_INCS) 38 | EE_CXX_COMPILE = $(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS) 39 | 40 | %.o : %.c 41 | $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ 42 | 43 | %.o : %.cpp 44 | $(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS) -c $< -o $@ 45 | 46 | %.o : %.S 47 | $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ 48 | 49 | %.o : %.s 50 | $(EE_AS) $(EE_ASFLAGS) $< -o $@ 51 | 52 | %.vo : %.vsm 53 | $(DVP_AS) $(DVP_ASFLAGS) $< -o $@ 54 | 55 | %.elf : %.o $(EXTRA_OBJS) $(COMMON_DIR)/crt0-ee.o 56 | $(EE_CC) -mno-crt0 -T$(PS2SDK)/ee/startup/linkfile $(EE_CXXFLAGS) \ 57 | -o $@ $(COMMON_DIR)/crt0-ee.o $< $(EXTRA_OBJS) $(EE_LDFLAGS) $(EE_LIBS) 58 | $(EE_STRIP) --strip-all $@ 59 | 60 | all: $(TARGETS:=.elf) 61 | 62 | clean: 63 | -$(RM) -f $(TARGETS:=.elf) $(TARGETS:=.o) 64 | 65 | rebuild: clean all 66 | -------------------------------------------------------------------------------- /tests/dma/vif/basic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "../dmaregs.h" 7 | #include "../dmasend.h" 8 | #include "../dmatags.h" 9 | #include "emit_vifcode.h" 10 | #include "vifunits.h" 11 | 12 | void send_simple_fifo_vif(volatile u128 *fifo, void *vifcode, int size) { 13 | // Must be aligned to 16 bytes. 14 | assert((size & 0xf) == 0 && (((u32)vifcode) & 0xf) == 0); 15 | 16 | u128 *vif128 = (u128 *)vifcode; 17 | for (int i = 0; i < size / 16; ++i) { 18 | *fifo = vif128[i]; 19 | } 20 | } 21 | 22 | void doTest(VIF::Unit* unit) { 23 | u8 *vuMem = unit->vuMem; 24 | volatile u32 *vu_32 = (volatile u32 *)vuMem; 25 | 26 | VIF::Packet vifcode(64); 27 | vifcode.STCYCL(4, 4); 28 | vifcode.UNPACK(VIF::UNPACK_TYPE_S32, 4, 0); 29 | vifcode.Data32(0x1337C0DE); 30 | vifcode.Data32(0x1337C1DE); 31 | vifcode.Data32(0x1337C2DE); 32 | vifcode.Data32(0x1337C3DE); 33 | 34 | DMA::SrcChainPacket srcpacket(512); 35 | srcpacket.REFE(vifcode.Raw(), 2); 36 | 37 | memset(vuMem, 0, 16 * 4); 38 | SyncDCache(vuMem, vuMem + 16 * 4); 39 | 40 | send_simple_fifo_vif(unit->fifo, vifcode.Raw(), 32); 41 | SyncDCache(vuMem, vuMem + 16 * 4); 42 | 43 | printf("FIFO: %08x (%08x) - %08x - %08x - %08x\n", vu_32[0], vu_32[1], vu_32[4], vu_32[8], vu_32[12]); 44 | 45 | memset(vuMem, 0, 16 * 4); 46 | SyncDCache(vuMem, vuMem + 16 * 4); 47 | 48 | DMA::SendSimple(unit->dmaChannel, vifcode.Raw(), 32); 49 | SyncDCache(vuMem, vuMem + 16 * 4); 50 | 51 | printf("DMA simple: %08x (%08x) - %08x - %08x - %08x\n", vu_32[0], vu_32[1], vu_32[4], vu_32[8], vu_32[12]); 52 | 53 | memset(vuMem, 0, 16 * 4); 54 | SyncDCache(vuMem, vuMem + 16 * 4); 55 | 56 | DMA::SendChain(unit->dmaChannel, srcpacket.Raw(), 512); 57 | SyncDCache(vuMem, vuMem + 16 * 4); 58 | 59 | printf("DMA chain (basic): %08x (%08x) - %08x - %08x - %08x\n", vu_32[0], vu_32[1], vu_32[4], vu_32[8], vu_32[12]); 60 | } 61 | 62 | int main(int argc, char *argv[]) { 63 | printf("-- TEST BEGIN\n"); 64 | 65 | printf("== VIF0 ==\n"); 66 | doTest(&VIF::Unit0); 67 | printf("\n"); 68 | 69 | printf("== VIF1 ==\n"); 70 | doTest(&VIF::Unit1); 71 | printf("\n"); 72 | 73 | printf("-- TEST END\n"); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/shared.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | union FloatBits { 4 | float f; 5 | u32 u; 6 | }; 7 | 8 | static u32 __attribute__((unused)) CF_ZERO[1] = {0x00000000}; 9 | static u32 __attribute__((unused)) CF_NEGZERO[1] = {0x80000000}; 10 | static u32 __attribute__((unused)) CF_MAX[1] = {0x7FFFFFFF}; 11 | static u32 __attribute__((unused)) CF_MIN[1] = {0xFFFFFFFF}; 12 | static u32 __attribute__((unused)) CF_MAX_MANTISSA[1] = {0x3FFFFFFF}; 13 | static u32 __attribute__((unused)) CF_MAX_EXP[1] = {0x7F800001}; 14 | static u32 __attribute__((unused)) CF_MIN_EXP[1] = {0x00000001}; 15 | static u32 __attribute__((unused)) CF_NEGONE[1] = {0xBF800000}; 16 | static u32 __attribute__((unused)) CF_ONE[1] = {0x3F800000}; 17 | static u32 __attribute__((unused)) CF_GARBAGE1[4] = {0x00001337}; 18 | static u32 __attribute__((unused)) CF_GARBAGE2[4] = {0xDEADBEEF}; 19 | 20 | template 21 | static inline void SET_U32(register float &fd) { 22 | asm volatile ( 23 | "lui $t6, %1\n" 24 | "ori $t6, $t6, %2\n" 25 | "mtc1 $t6, %0\n" 26 | : "+f"(fd) : "K"((i >> 16) & 0xFFFF), "K"(i & 0xFFFF) : "t6" 27 | ); 28 | } 29 | 30 | static inline void SET_M(register float &fd, void *p) { 31 | fd = *(float *)p; 32 | } 33 | 34 | static inline void printFloatString(const FloatBits &bits) { 35 | // We want -0.0 and -NAN to show as negative. 36 | // So, let's just print the sign manually with an absolute value. 37 | FloatBits positive = bits; 38 | positive.u &= ~0x80000000; 39 | 40 | char sign = '+'; 41 | if (bits.u & 0x80000000) { 42 | sign = '-'; 43 | } 44 | 45 | printf("%c%0.2f", sign, positive.f); 46 | } 47 | 48 | static inline void PRINT_R(const register u128 &rt, bool newline) { 49 | static u32 __attribute__((aligned(16))) result[4] = {0, 0, 0, 0}; 50 | *(vu128 *)result = rt; 51 | 52 | printf("%08x %08x %08x %08x", result[3], result[2], result[1], result[0]); 53 | if (newline) { 54 | printf("\n"); 55 | } 56 | } 57 | 58 | static inline void PRINT_F(const register float &ft, bool newline) { 59 | static FloatBits result = {0}; 60 | 61 | asm volatile ( 62 | "swc1 %0, 0(%1)\n" 63 | : : "f"(ft), "r"((u32)&result.f) 64 | ); 65 | 66 | printf("%08x/", result.u); 67 | printFloatString(result); 68 | if (newline) { 69 | printf("\n"); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /tests/memory/ee/default.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const char *describePtr(void *p) { 5 | u32 v = (u32)p; 6 | if (v >= 0x80000000 && v < 0x80100000) { 7 | return "EE Kernel"; 8 | } 9 | if (v >= 0x80100000 && v < 0x82000000) { 10 | return "EE KSEG0"; 11 | } 12 | if (v >= 0xA0100000 && v < 0xA2000000) { 13 | return "EE KSEG1"; 14 | } 15 | if (v >= 0x00100000 && v < 0x02000000) { 16 | return "EE Cached"; 17 | } 18 | if (v >= 0x10000000 && v < 0x14000000) { 19 | return "HW Registers"; 20 | } 21 | if (v >= 0x20100000 && v < 0x22000000) { 22 | return "EE Uncached"; 23 | } 24 | if (v >= 0x30100000 && v < 0x32000000) { 25 | return "EE UCAB"; 26 | } 27 | if (v >= 0xBC000000 && v < 0xBC200000) { 28 | return "IOP"; 29 | } 30 | if (v >= 0x70000000 && v < 0x70004000) { 31 | return "Scratchpad"; 32 | } 33 | return "Other"; 34 | } 35 | 36 | static void tryAlloc(u32 mb) { 37 | void *p = malloc(mb * 1024 * 1024); 38 | printf(" %d MB: %s\n", mb, p ? "success" : "fail"); 39 | free(p); 40 | } 41 | 42 | static void verifyMirrors() { 43 | void *p = calloc(1, 1024 * 1024); 44 | 45 | printf(" Allocated in %s\n", describePtr(p)); 46 | printf(" Pointer is %s\n", ((u32)p & 0xF) == 0 ? "aligned" : "not aligned"); 47 | 48 | u8 *cached = (u8 *)((u32)p & 0x00FFFFFF); 49 | u8 *uncached = (u8 *)((u32)cached | 0x20000000); 50 | u8 *ucab = (u8 *)((u32)cached | 0x30000000); 51 | 52 | *uncached = 42; 53 | 54 | printf(" Mirrors: cached=%d, uncached=%d, ucab=%d\n", *cached, *uncached, *ucab); 55 | 56 | free(p); 57 | } 58 | 59 | void verifyScratchpad() { 60 | // TODO: Is there any system to allocate the scratchpad? Thread flag? 61 | 62 | u8 *sram = (u8 *)0x70000000; 63 | 64 | sram[0x0000] = 42; 65 | sram[0x3FFF] = 1; 66 | 67 | printf(" Scratchpad start: %d, end: %d\n", sram[0x0000], sram[0x3FFF]); 68 | } 69 | 70 | int main(int argc, char *argv[]) { 71 | printf("-- TEST BEGIN\n"); 72 | 73 | printf("Memory allocation limits:\n"); 74 | // Let's not be to exact, since the program size or other things may make this inexact. 75 | tryAlloc(32); 76 | tryAlloc(30); 77 | tryAlloc(24); 78 | tryAlloc(16); 79 | 80 | printf("Mirrors:\n"); 81 | verifyMirrors(); 82 | 83 | printf("Scratchpad:\n"); 84 | verifyScratchpad(); 85 | 86 | printf("-- TEST END\n"); 87 | return 0; 88 | } -------------------------------------------------------------------------------- /tests/kernel/iop/thread/delete.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "thread-common.h" 5 | 6 | #define STACK_SIZE 0x800 7 | 8 | void nullThreadProc(u32 param) { 9 | //Do nothing 10 | } 11 | 12 | void sleepThreadProc(u32 param) { 13 | SleepThread(); 14 | } 15 | 16 | void doDeleteThread(int threadId) { 17 | int result = DeleteThread(threadId); 18 | if(result == KE_OK) { 19 | schedf("succeeded\n"); 20 | } else { 21 | schedf("failed -> result: %d\n", result); 22 | } 23 | } 24 | 25 | int _start(int argc, char **argv) { 26 | printf("-- TEST BEGIN\n"); 27 | 28 | int currentThreadPriority = getThreadPriority(TH_SELF); 29 | 30 | { 31 | schedf("self thread:\n"); 32 | 33 | schedf(" delete (with TH_SELF): "); 34 | doDeleteThread(TH_SELF); 35 | 36 | schedf(" delete (with current tid): "); 37 | doDeleteThread(GetThreadId()); 38 | 39 | flushschedf(); 40 | } 41 | 42 | { 43 | schedf("low prio thread:\n"); 44 | 45 | int threadId = createTestThread((void*)&nullThreadProc, currentThreadPriority + 1, STACK_SIZE); 46 | schedf(" delete before start: "); 47 | doDeleteThread(threadId); 48 | 49 | threadId = createTestThread((void*)&nullThreadProc, currentThreadPriority + 1, STACK_SIZE); 50 | StartThread(threadId, 0); 51 | schedf(" delete after start: "); 52 | doDeleteThread(threadId); 53 | 54 | //Let the thread execute (terminate doesn't seem to work properly otherwise) 55 | DelayThread(1); 56 | 57 | TerminateThread(threadId); 58 | schedf(" delete after terminate: "); 59 | doDeleteThread(threadId); 60 | 61 | schedf(" delete after delete: "); 62 | doDeleteThread(threadId); 63 | 64 | flushschedf(); 65 | } 66 | 67 | { 68 | schedf("waiting thread:\n"); 69 | 70 | int threadId = createTestThread((void*)&sleepThreadProc, currentThreadPriority - 1, STACK_SIZE); 71 | StartThread(threadId, 0); 72 | 73 | schedf(" delete after start: "); 74 | doDeleteThread(threadId); 75 | 76 | TerminateThread(threadId); 77 | schedf(" delete after terminate: "); 78 | doDeleteThread(threadId); 79 | 80 | flushschedf(); 81 | } 82 | 83 | { 84 | schedf("corner cases:\n"); 85 | 86 | schedf(" delete with invalid tid: "); 87 | doDeleteThread(~0); 88 | 89 | flushschedf(); 90 | } 91 | 92 | printf("-- TEST END\n"); 93 | 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /common/common-ee.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | //Kernel tests will add and substract values as big as 0x20 to test thread priority, 7 | //so, make sure this constant will keep the priority values between [0x01, 0x7F] 8 | #define TEST_THREAD_PRIORITY 0x40 9 | 10 | #define TEST_THREAD_STACK_SIZE 0x8000 11 | 12 | char schedfBuffer[65536]; 13 | unsigned int schedfBufferPos = 0; 14 | 15 | void schedf(const char *format, ...) { 16 | va_list args; 17 | va_start(args, format); 18 | schedfBufferPos += vsprintf(schedfBuffer + schedfBufferPos, format, args); 19 | va_end(args); 20 | } 21 | 22 | void flushschedf() { 23 | printf("%s", schedfBuffer); 24 | schedfBuffer[0] = '\0'; 25 | schedfBufferPos = 0; 26 | } 27 | 28 | int getThreadPriority(int threadId) { 29 | ee_thread_status_t threadStat; 30 | memset(&threadStat, 0, sizeof(ee_thread_status_t)); 31 | int result = ReferThreadStatus(threadId, &threadStat); 32 | if (result >= 0) { 33 | return threadStat.current_priority; 34 | } else { 35 | return -1; 36 | } 37 | } 38 | 39 | u32 g_testThreadDoneSema = 0; 40 | 41 | extern int test_main(int argc, char *argv[]); 42 | 43 | char testThreadStack[TEST_THREAD_STACK_SIZE] __attribute__ ((aligned(16))); 44 | void testThreadProc() { 45 | //TODO: Print begin/end traces 46 | //TODO: Pass arguments from main thread to the test function 47 | test_main(0, NULL); 48 | SignalSema(g_testThreadDoneSema); 49 | } 50 | 51 | int main(int argc, char *argv[]) { 52 | //A thread is created to ensure the execution environment is the same 53 | //across all possible boot methods (direct hw boot, ps2link, emulator, etc.) 54 | 55 | ee_sema_t semaInfo; 56 | memset(&semaInfo, 0, sizeof(ee_sema_t)); 57 | semaInfo.init_count = 0; 58 | semaInfo.max_count = 1; 59 | semaInfo.option = 0; 60 | g_testThreadDoneSema = CreateSema(&semaInfo); 61 | 62 | u32 testThreadId = 0; 63 | ee_thread_t threadParam; 64 | memset(&threadParam, 0, sizeof(ee_thread_t)); 65 | threadParam.func = (void*)&testThreadProc; 66 | threadParam.initial_priority = TEST_THREAD_PRIORITY; 67 | threadParam.stack_size = TEST_THREAD_STACK_SIZE; 68 | threadParam.stack = testThreadStack; 69 | testThreadId = CreateThread(&threadParam); 70 | 71 | StartThread(testThreadId, NULL); 72 | WaitSema(g_testThreadDoneSema); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /tests/gs/emit_giftag.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "emit_giftag.h" 6 | 7 | namespace GIF { 8 | Tag::Tag() { 9 | tag_.raw.v0 = 0; 10 | tag_.raw.v1 = 0; 11 | } 12 | 13 | void Tag::SetLoops(u16 nloop) { 14 | tag_.typed.nloop = nloop; 15 | } 16 | 17 | void Tag::SetEop(bool eop) { 18 | tag_.typed.eop = eop ? 1 : 0; 19 | } 20 | 21 | void Tag::SetFormat(DataFormat fmt) { 22 | tag_.typed.flg = fmt; 23 | } 24 | 25 | void Tag::SetRegDescs( 26 | RegisterDescriptor r0, RegisterDescriptor r1, RegisterDescriptor r2, RegisterDescriptor r3, 27 | RegisterDescriptor r4, RegisterDescriptor r5, RegisterDescriptor r6, RegisterDescriptor r7, 28 | RegisterDescriptor r8, RegisterDescriptor r9, RegisterDescriptor r10, RegisterDescriptor r11, 29 | RegisterDescriptor r12, RegisterDescriptor r13, RegisterDescriptor r14, RegisterDescriptor r15 30 | ) { 31 | u32 regCount = 0; 32 | s32 regDescs[16]; 33 | #define ASSIGN_REG(rid) regDescs[rid] = r##rid; 34 | ASSIGN_REG(0); ASSIGN_REG(1); ASSIGN_REG(2); ASSIGN_REG(3); 35 | ASSIGN_REG(4); ASSIGN_REG(5); ASSIGN_REG(6); ASSIGN_REG(7); 36 | ASSIGN_REG(8); ASSIGN_REG(9); ASSIGN_REG(10); ASSIGN_REG(11); 37 | ASSIGN_REG(12); ASSIGN_REG(13); ASSIGN_REG(14); ASSIGN_REG(15); 38 | #undef ASSIGN_REG 39 | tag_.typed.regs = 0; 40 | for(u32 i = 0; i < 16; i++) { 41 | s32 regDesc = regDescs[i]; 42 | if(regDesc == REG_INVALID) break; 43 | tag_.typed.regs |= (regDesc & 0xF) << (i * 4); 44 | regCount++; 45 | } 46 | regCount &= 0xF; 47 | tag_.typed.nreg = regCount; 48 | } 49 | 50 | Packet::Packet(u32 size) { 51 | start_ = (u64 *)memalign(16, size); 52 | addr_ = start_; 53 | memset(start_, 0, size); 54 | } 55 | Packet::~Packet() { 56 | free(start_); 57 | } 58 | 59 | void Packet::Reset() { 60 | memset(start_, 0, (addr_ - start_) * sizeof(u32)); 61 | addr_ = start_; 62 | } 63 | 64 | void Packet::WriteTag(const Tag& tag) { 65 | Emit(tag.tag_.raw.v0); 66 | Emit(tag.tag_.raw.v1); 67 | } 68 | 69 | PackedPacket::PackedPacket(u32 size) 70 | : Packet(size) { 71 | 72 | } 73 | 74 | void PackedPacket::WriteTag(const Tag& tag) { 75 | Tag copyTag = tag; 76 | copyTag.SetFormat(FORMAT_PACKED); 77 | Packet::WriteTag(copyTag); 78 | } 79 | 80 | void PackedPacket::AD(u8 reg, u64 value) { 81 | Emit(value); 82 | Emit(reg); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/fcr.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | Initial: 3 | fcr0: 00002e30, fcr1: 00002e30, fcr2: 00002e30, fcr3: 00002e30, fcr4: 00002e30, fcr5: 00002e30, fcr6: 00002e30, fcr7: 00002e30, fcr8: 00002e30, fcr9: 00002e30, fcr10: 00002e30, fcr11: 00002e30, fcr12: 00002e30, fcr13: 00002e30, fcr14: 00002e30, fcr15: 00002e30, fcr16: 01000001, fcr17: 01000001, fcr18: 01000001, fcr19: 01000001, fcr20: 01000001, fcr21: 01000001, fcr22: 01000001, fcr23: 01000001, fcr24: 01000001, fcr25: 01000001, fcr26: 01000001, fcr27: 01000001, fcr28: 01000001, fcr29: 01000001, fcr30: 01000001, fcr31: 01000001 4 | Update fcr0: 5 | fcr0: 00002e30, fcr31: 01000001 6 | Update rounding mode (RM): 7 | fcr0: 00002e30, fcr31: 01000001 8 | Update flags: 9 | fcr0: 00002e30, fcr31: 01000079 10 | All regs: 11 | fcr0: 00002e30, fcr1: 00002e30, fcr2: 00002e30, fcr3: 00002e30, fcr4: 00002e30, fcr5: 00002e30, fcr6: 00002e30, fcr7: 00002e30, fcr8: 00002e30, fcr9: 00002e30, fcr10: 00002e30, fcr11: 00002e30, fcr12: 00002e30, fcr13: 00002e30, fcr14: 00002e30, fcr15: 00002e30, fcr16: 01000079, fcr17: 01000079, fcr18: 01000079, fcr19: 01000079, fcr20: 01000079, fcr21: 01000079, fcr22: 01000079, fcr23: 01000079, fcr24: 01000079, fcr25: 01000079, fcr26: 01000079, fcr27: 01000079, fcr28: 01000079, fcr29: 01000079, fcr30: 01000079, fcr31: 01000079 12 | Update enables: 13 | fcr0: 00002e30, fcr31: 01000001 14 | Update cause: 15 | fcr0: 00002e30, fcr31: 0101c001 16 | Update unimplemented (E): 17 | fcr0: 00002e30, fcr31: 01020001 18 | Update flushing (FS): 19 | fcr0: 00002e30, fcr31: 01000001 20 | Update flushing (FO): 21 | fcr0: 00002e30, fcr31: 01000001 22 | Update flushing (FN): 23 | fcr0: 00002e30, fcr31: 01000001 24 | Update FCC: 25 | fcr0: 00002e30, fcr31: 01800001 26 | Update FCC1-7: 27 | fcr0: 00002e30, fcr31: 01000001 28 | Update unknown: 29 | fcr0: 00002e30, fcr31: 01000001 30 | 31 | Flag situations: 32 | sqrt(-1): 33 | fcr0: 00002e30, fcr31: 01020041 34 | result = 1.000000 35 | Divide zero by zero: 36 | fcr0: 00002e30, fcr31: 01020041 37 | result = NaN 38 | Divide one by zero: 39 | fcr0: 00002e30, fcr31: 01010021 40 | result = NaN 41 | NAN math: 42 | fcr0: 00002e30, fcr31: 01008011 43 | result = NaN 44 | Overflow: 45 | fcr0: 00002e30, fcr31: 01008011 46 | result = NaN 47 | Underflow: 48 | fcr0: 00002e30, fcr31: 01000001 49 | result = 0.000000 50 | Inexact: 51 | fcr0: 00002e30, fcr31: 01000001 52 | result = 0.331606 53 | -- TEST END 54 | -------------------------------------------------------------------------------- /tests/dma/vif/stmod.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../dmaregs.h" 5 | #include "../dmasend.h" 6 | #include "../dmatags.h" 7 | #include "emit_vifcode.h" 8 | #include "vifunits.h" 9 | 10 | void testMode(VIF::Unit *unit, u32 mode, bool maskEnabled, u32 mask = 0) { 11 | u8 *vuMem = unit->vuMem; 12 | volatile u32 *vuMem_32 = (volatile u32 *)vuMem; 13 | 14 | memset(vuMem, 0, 16 * 4); 15 | SyncDCache(vuMem, vuMem + 16 * 4); 16 | 17 | VIF::Packet vifcode(16 * 7); 18 | 19 | vifcode.NOP(); 20 | vifcode.NOP(); 21 | vifcode.STCYCL(4, 4); 22 | vifcode.STROW(0x1000, 0x1000, 0x1000, 0x1000); 23 | 24 | vifcode.STMASK(mask); 25 | vifcode.STMOD(mode); 26 | vifcode.UNPACK(VIF::UNPACK_TYPE_V4_32, 4, 0, maskEnabled ? VIF::UNPACK_ENABLE_MASKS : VIF::UNPACK_NORMAL); 27 | for (int i = 0; i < 16; i++) { 28 | vifcode.Data32(i); 29 | } 30 | DMA::SendSimple(unit->dmaChannel, vifcode.Raw(), 16 * 7); 31 | 32 | SyncDCache(vuMem, vuMem + 16 * 4); 33 | 34 | for (int i = 0; i < 4; i++) { 35 | printf(" vumem(%02x): %08x - %08x - %08x - %08x\n", i * 0x10, 36 | vuMem_32[(i * 4) + 0], vuMem_32[(i * 4) + 1], vuMem_32[(i * 4) + 2], vuMem_32[(i * 4) + 3]); 37 | } 38 | 39 | printf(" row: %08x - %08x - %08x - %08x\n", 40 | unit->regs->r0, unit->regs->r1, unit->regs->r2, unit->regs->r3); 41 | printf(" mode: %08x\n", unit->regs->mode); 42 | 43 | printf("\n"); 44 | } 45 | 46 | void doTest(VIF::Unit *unit) { 47 | printf("normal (no mask):\n"); 48 | testMode(unit, VIF::MODE_NORMAL, false); 49 | 50 | printf("normal (mask diagonal):\n"); 51 | testMode(unit, VIF::MODE_NORMAL, true, 0x40100401); 52 | 53 | printf("offset (no mask):\n"); 54 | testMode(unit, VIF::MODE_OFFSET, false); 55 | 56 | printf("offset (mask diagonal):\n"); 57 | testMode(unit, VIF::MODE_OFFSET, true, 0x40100401); 58 | 59 | printf("difference (no mask):\n"); 60 | testMode(unit, VIF::MODE_DIFFERENCE, false); 61 | 62 | printf("difference (mask diagonal):\n"); 63 | testMode(unit, VIF::MODE_DIFFERENCE, true, 0x40100401); 64 | 65 | printf("mode 3 (no mask):\n"); 66 | testMode(unit, 3, false); 67 | 68 | printf("mode 3 (mask diagonal):\n"); 69 | testMode(unit, 3, true, 0x40100401); 70 | } 71 | 72 | int main(int argc, char *argv[]) { 73 | printf("-- TEST BEGIN\n"); 74 | 75 | printf("== VIF0 ==\n"); 76 | doTest(&VIF::Unit0); 77 | printf("\n"); 78 | 79 | printf("== VIF1 ==\n"); 80 | doTest(&VIF::Unit1); 81 | printf("\n"); 82 | 83 | printf("-- TEST END\n"); 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /tests/dma/dmatags.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_DMA_DMATAGS_H 2 | #define PS2AUTOTESTS_DMA_DMATAGS_H 3 | 4 | #include 5 | 6 | namespace DMA { 7 | enum SrcChainType { 8 | SRC_REFE = 0, 9 | SRC_CNT = 1, 10 | SRC_NEXT = 2, 11 | SRC_REF = 3, 12 | SRC_REFS = 4, 13 | SRC_CALL = 5, 14 | SRC_RET = 6, 15 | SRC_END = 7, 16 | }; 17 | 18 | struct SrcChainTag { 19 | union { 20 | struct { 21 | u16 QWC : 16; 22 | u16 : 10; 23 | u8 PCE : 2; 24 | SrcChainType ID : 3; 25 | u8 IRQ : 1; 26 | }; 27 | u32 bits; 28 | }; 29 | void *addr; 30 | u32 pad[2]; 31 | } __attribute__((aligned(16))); 32 | 33 | class SrcChainPacket { 34 | public: 35 | SrcChainPacket(u32 size); 36 | ~SrcChainPacket(); 37 | 38 | void Reset(); 39 | 40 | void CNT(u16 size, bool irq = false); 41 | void NEXT(u16 size, void *nextdma, u16 nextsize, bool irq = false); 42 | void REF(void *addr, u16 size, bool irq = false); 43 | void REFS(void *addr, u16 size, bool irq = false); 44 | void REFE(void *addr, u16 size, bool irq = false); 45 | void CALL(u16 size, void *nextdma, u16 nextsize, bool irq = false); 46 | void RET(u16 size, bool irq = false); 47 | void END(u16 size, bool irq = false); 48 | 49 | void DataQ(u128 v); 50 | void DataQPtr(const void *p, u16 size); 51 | 52 | void *Raw() { 53 | return start_; 54 | } 55 | 56 | protected: 57 | void Emit(u16 QWC, SrcChainType ID, void *addr, bool irq); 58 | 59 | SrcChainTag *start_; 60 | SrcChainTag *addr_; 61 | }; 62 | 63 | enum DstChainType { 64 | DST_CNTS = 0, 65 | DST_CNT = 1, 66 | DST_END = 7, 67 | }; 68 | 69 | struct DstChainTag { 70 | union { 71 | struct { 72 | u16 QWC : 16; 73 | u16 : 10; 74 | u8 PCE : 2; 75 | DstChainType ID : 3; 76 | u8 IRQ : 1; 77 | }; 78 | u32 bits; 79 | }; 80 | void *addr; 81 | u32 pad[2]; 82 | } __attribute__((aligned(16))); 83 | 84 | class DstChainPacket { 85 | public: 86 | DstChainPacket(u32 size); 87 | ~DstChainPacket(); 88 | 89 | void Reset(); 90 | 91 | void CNT(void *addr, u16 size); 92 | void CNTS(void *addr, u16 size); 93 | void END(void *addr, u16 size); 94 | 95 | void DataQ(u128 v); 96 | void DataQPtr(const void *p, u16 size); 97 | 98 | void *Raw() { 99 | return start_; 100 | } 101 | 102 | protected: 103 | void Emit(u16 QWC, DstChainType ID, void *addr); 104 | 105 | DstChainTag *start_; 106 | DstChainTag *addr_; 107 | }; 108 | } 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/sleep.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define STACK_SIZE 0x8000 6 | 7 | u32 g_threadResult = 0; 8 | 9 | char sleepingThreadStack[STACK_SIZE] __attribute__ ((aligned(16))); 10 | void sleepingThreadProc(u32) { 11 | g_threadResult = SleepThread(); 12 | } 13 | 14 | char waitSleepThreadStack[STACK_SIZE] __attribute__ ((aligned(16))); 15 | void waitSleepThreadProc(u32 waitSemaId) { 16 | WaitSema(waitSemaId); 17 | g_threadResult = SleepThread(); 18 | } 19 | 20 | int createTestThread(void *entry, int prio, void *stack, u32 stackSize) { 21 | ee_thread_t threadParam; 22 | memset(&threadParam, 0, sizeof(ee_thread_t)); 23 | threadParam.func = entry; 24 | threadParam.initial_priority = prio; 25 | threadParam.stack = stack; 26 | threadParam.stack_size = stackSize; 27 | return CreateThread(&threadParam); 28 | } 29 | 30 | u32 createSimpleSema() { 31 | ee_sema_t semaInfo; 32 | memset(&semaInfo, 0, sizeof(ee_sema_t)); 33 | semaInfo.init_count = 0; 34 | semaInfo.max_count = 1; 35 | semaInfo.option = 0; 36 | return CreateSema(&semaInfo); 37 | } 38 | 39 | void printThreadResult(u32 threadId) { 40 | if(g_threadResult == threadId) { 41 | schedf("thread id\n"); 42 | } else { 43 | schedf("something else (%d)\n", g_threadResult); 44 | } 45 | } 46 | 47 | int main(int argc, char *argv[]) { 48 | printf("-- TEST BEGIN\n"); 49 | 50 | int testThreadPriority = getThreadPriority(GetThreadId()); 51 | 52 | { 53 | g_threadResult = 0; 54 | int threadId = createTestThread((void*)&sleepingThreadProc, testThreadPriority - 0x10, sleepingThreadStack, STACK_SIZE); 55 | StartThread(threadId, NULL); 56 | 57 | WakeupThread(threadId); 58 | 59 | TerminateThread(threadId); 60 | DeleteThread(threadId); 61 | 62 | schedf("sleep result (wakeupCount == 0): "); 63 | printThreadResult(threadId); 64 | flushschedf(); 65 | } 66 | 67 | { 68 | g_threadResult = 0; 69 | u32 waitSemaId = createSimpleSema(); 70 | int threadId = createTestThread((void*)&waitSleepThreadProc, testThreadPriority - 0x10, waitSleepThreadStack, STACK_SIZE); 71 | StartThread(threadId, (u32*)waitSemaId); 72 | 73 | //Wakeup twice to set wakeupCount to 2 74 | WakeupThread(threadId); 75 | WakeupThread(threadId); 76 | 77 | SignalSema(waitSemaId); 78 | 79 | TerminateThread(threadId); 80 | DeleteThread(threadId); 81 | 82 | schedf("sleep result (wakeupCount > 0): "); 83 | printThreadResult(threadId); 84 | flushschedf(); 85 | 86 | DeleteSema(waitSemaId); 87 | } 88 | 89 | printf("-- TEST END\n"); 90 | 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/receive.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "mbx-common.h" 5 | 6 | #define STACK_SIZE 0x800 7 | 8 | typedef struct { 9 | s32 id; 10 | s32 mbxId; 11 | } THREAD_PARAM; 12 | 13 | void messageWaitThreadProc(THREAD_PARAM *param) { 14 | MSG* msg = NULL; 15 | ReceiveMbx((void**)&msg, param->mbxId); 16 | schedf("(thread: %d -> message: %d) ", param->id, msg->payload); 17 | } 18 | 19 | s32 createTestThread(u32 priority) { 20 | iop_thread_t threadInfo = {}; 21 | threadInfo.attr = TH_C; 22 | threadInfo.thread = (void*)&messageWaitThreadProc; 23 | threadInfo.priority = priority; 24 | threadInfo.stacksize = STACK_SIZE; 25 | return CreateThread(&threadInfo); 26 | } 27 | 28 | void testMultipleReceive(u32 mbxAttr) { 29 | static const int msgCount = 3; 30 | int i = 0; 31 | MSG msg[msgCount]; 32 | THREAD_PARAM threadParams[msgCount]; 33 | s32 threadIds[msgCount]; 34 | 35 | iop_mbx_t mbxInfo = {}; 36 | mbxInfo.option = 0; 37 | mbxInfo.attr = mbxAttr; 38 | s32 mbxId = CreateMbx(&mbxInfo); 39 | 40 | for (i = 0; i < msgCount; i++) { 41 | memset(&threadParams[i], 0, sizeof(MSG)); 42 | threadParams[i].id = i + 1; 43 | threadParams[i].mbxId = mbxId; 44 | threadIds[i] = createTestThread(getThreadPriority(TH_SELF) - (i + 1)); 45 | StartThread(threadIds[i], &threadParams[i]); 46 | } 47 | 48 | printf(" box contents: "); 49 | printMbx(mbxId); 50 | 51 | schedf(" order: "); 52 | for (i = 0; i < msgCount; i++) { 53 | memset(&msg[i], 0, sizeof(MSG)); 54 | msg[i].header.priority = msgCount - i; 55 | msg[i].payload = i + 1; 56 | SendMbx(mbxId, &msg[i]); 57 | } 58 | schedf("\n"); 59 | flushschedf(); 60 | 61 | for (i = 0; i < msgCount; i++) { 62 | TerminateThread(threadIds[i]); 63 | DeleteThread(threadIds[i]); 64 | } 65 | 66 | DeleteMbx(mbxId); 67 | } 68 | 69 | int _start(int argc, char **argv) { 70 | printf("-- TEST BEGIN\n"); 71 | 72 | printf("receiving (fifo thread queuing):\n"); 73 | testMultipleReceive(MBA_THFIFO | MBA_MSFIFO); 74 | 75 | printf("receiving (priority thread queuing):\n"); 76 | testMultipleReceive(MBA_THPRI | MBA_MSFIFO); 77 | 78 | printf("invalid params:\n"); 79 | { 80 | int result = ReceiveMbx(NULL, ~0); 81 | printf(" receiving message from invalid box: %d\n", result); 82 | 83 | //Receiving into a null pointer seems to work (returns 0 and message is dequeued) 84 | //but it will probably have dangerous side effects because memory at address 0 85 | //will be modified. 86 | //result = ReceiveMbx(NULL, mbxId); 87 | } 88 | 89 | printf("-- TEST END\n"); 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/cancelwakeup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "thread-common.h" 4 | 5 | #define STACK_SIZE 0x800 6 | 7 | void doCancelWakeupThread(int threadId) { 8 | int result = CancelWakeupThread(threadId); 9 | if(result >= 0) { 10 | schedf("succeeded -> result: %d\n", result); 11 | } else { 12 | schedf("failed -> result: %d\n", result); 13 | } 14 | } 15 | 16 | void nullThreadProc(u32 param) { 17 | //Do nothing 18 | } 19 | 20 | void cancelThreadProc(u32 param) { 21 | schedf(" cancel wakeup self thread: "); 22 | doCancelWakeupThread(TH_SELF); 23 | 24 | schedf(" cancel wakeup self thread after cancelling: "); 25 | doCancelWakeupThread(TH_SELF); 26 | } 27 | 28 | int generateDeletedThreadId() { 29 | int threadId = createTestThread((void*)&nullThreadProc, 64, STACK_SIZE); 30 | StartThread(threadId, 0); 31 | 32 | //Let the thread execute (terminate doesn't seem to work properly otherwise) 33 | DelayThread(1); 34 | 35 | TerminateThread(threadId); 36 | DeleteThread(threadId); 37 | 38 | return threadId; 39 | } 40 | 41 | int _start(int argc, char **argv) { 42 | printf("-- TEST BEGIN\n"); 43 | 44 | { 45 | schedf("self thread:\n"); 46 | 47 | int threadId = createTestThread((void*)&cancelThreadProc, 64, STACK_SIZE); 48 | 49 | StartThread(threadId, 0); 50 | WakeupThread(threadId); 51 | WakeupThread(threadId); 52 | WakeupThread(threadId); 53 | WakeupThread(threadId); 54 | DelayThread(100); 55 | 56 | TerminateThread(threadId); 57 | DeleteThread(threadId); 58 | 59 | flushschedf(); 60 | } 61 | 62 | { 63 | schedf("standard usage:\n"); 64 | 65 | int threadId = createTestThread((void*)&nullThreadProc, 64, STACK_SIZE); 66 | StartThread(threadId, 0); 67 | 68 | schedf(" cancel wakeup after starting: "); 69 | doCancelWakeupThread(threadId); 70 | 71 | WakeupThread(threadId); 72 | WakeupThread(threadId); 73 | WakeupThread(threadId); 74 | 75 | schedf(" cancel wakeup after wakeups: "); 76 | doCancelWakeupThread(threadId); 77 | 78 | schedf(" cancel wakeup after cancelling: "); 79 | doCancelWakeupThread(threadId); 80 | 81 | TerminateThread(threadId); 82 | DeleteThread(threadId); 83 | 84 | flushschedf(); 85 | } 86 | 87 | { 88 | int deletedThreadId = generateDeletedThreadId(); 89 | 90 | schedf("corner cases:\n"); 91 | 92 | schedf(" cancel wakeup with invalid thread id: "); 93 | doCancelWakeupThread(deletedThreadId); 94 | 95 | flushschedf(); 96 | } 97 | 98 | printf("-- TEST END\n"); 99 | 100 | return 0; 101 | } 102 | -------------------------------------------------------------------------------- /tests/cpu/iop/lsu.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | lb: 3 | lb +0: ffffff89 4 | lb +4: 00000001 5 | lb -4: 00000037 6 | lb +0: ffffff89 7 | lb +4: 00000001 8 | lb +-4: 00000037 9 | lb -> $0: 00000000 10 | 11 | lbu: 12 | lbu +0: 00000089 13 | lbu +4: 00000001 14 | lbu -4: 00000037 15 | lbu +0: 00000089 16 | lbu +4: 00000001 17 | lbu +-4: 00000037 18 | lbu -> $0: 00000000 19 | 20 | ld: 21 | ld +0: 88888888 22 | ld +4: 152231ac 23 | ld -4: e39b74be 24 | ld +0: 88888888 25 | ld +4: 152231ac 26 | ld +-4: e39b74be 27 | ld -> $0: 00000000 28 | 29 | lh: 30 | lh +0: 00006789 31 | lh +4: ffffef01 32 | lh -4: 00001337 33 | lh +0: 00006789 34 | lh +4: ffffef01 35 | lh +-4: 00001337 36 | lh -> $0: 00000000 37 | 38 | lhu: 39 | lhu +0: 00006789 40 | lhu +4: 0000ef01 41 | lhu -4: 00001337 42 | lhu +0: 00006789 43 | lhu +4: 0000ef01 44 | lhu +-4: 00001337 45 | lhu -> $0: 00000000 46 | 47 | lw: 48 | lw +0: 23456789 49 | lw +4: abcdef01 50 | lw -4: c0de1337 51 | lw +0: 23456789 52 | lw +4: abcdef01 53 | lw +-4: c0de1337 54 | lw -> $0: 00000000 55 | 56 | lwl / lwr: 57 | lwl +0: 89de1337 58 | lwr +0: 23456789 59 | lwl +1: 67896789 60 | lwr +1: 67234567 61 | lwl +0/lwr +3: 89234523 62 | lwl +0: 89234523 63 | lwr +0: 23456789 64 | lwl +1: 67896789 65 | lwr +1: 67234567 66 | lwl +0/lwr +3: 89234523 67 | lwl -> $0: 00000000 68 | lwr -> $0: 00000000 69 | 70 | sb: 71 | sb +0: 9abcde21 deadbeef 72 | sb +4: deadbe21 c0de1337 73 | sb -4: 45678121 9abcdef0 74 | sb +0: 9abcde37 deadbeef 75 | sb +4: deadbe37 c0de1337 76 | sb +-4: 45678137 9abcdef0 77 | 78 | sd: 79 | sd +0: abcd4321 00000000 80 | sd +4: abcd4321 00000000 81 | sd -4: abcd4321 00000000 82 | sd +0: 00001337 00000000 83 | sd +4: 00001337 00000000 84 | sd +-4: 00001337 00000000 85 | 86 | sh: 87 | sh +0: 9abc4321 deadbeef 88 | sh +4: dead4321 c0de1337 89 | sh -4: 45674321 9abcdef0 90 | sh +0: 9abc1337 deadbeef 91 | sh +4: dead1337 c0de1337 92 | sh +-4: 45671337 9abcdef0 93 | 94 | sw: 95 | sw +0: abcd4321 deadbeef 96 | sw +4: abcd4321 c0de1337 97 | sw -4: abcd4321 9abcdef0 98 | sw +0: 00001337 deadbeef 99 | sw +4: 00001337 c0de1337 100 | sw +-4: 00001337 9abcdef0 101 | 102 | swl / swr: 103 | swl +0: 9abcdeab deadbeef 104 | swr +0: abcd4321 deadbeef 105 | swl +1: 9abcabcd deadbeef 106 | swr +1: cd4321f0 deadbeef 107 | swl +0/swr +3: 21bcdeab deadbeef 108 | swl +0: 9abcde00 deadbeef 109 | swr +0: 00001337 deadbeef 110 | swl +1: 9abc0000 deadbeef 111 | swr +1: 001337f0 deadbeef 112 | swl +0/swr +3: 37bcde00 deadbeef 113 | 114 | -- TEST END 115 | -------------------------------------------------------------------------------- /tests/gs/emit_giftag.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_GS_EMIT_GIFTAG_H 2 | #define PS2AUTOTESTS_GS_EMIT_GIFTAG_H 3 | 4 | #include 5 | 6 | namespace GIF { 7 | 8 | enum RegisterDescriptor { 9 | REG_INVALID = -1, 10 | REG_PRIM = 0x0, 11 | REG_RGBAQ = 0x1, 12 | REG_ST = 0x2, 13 | REG_UV = 0x3, 14 | REG_XYZF2 = 0x4, 15 | REG_XYZ2 = 0x5, 16 | REG_TEX0_1 = 0x6, 17 | REG_TEX0_2 = 0x7, 18 | REG_CLAMP_1 = 0x8, 19 | REG_CLAMP_2 = 0x9, 20 | REG_FOG = 0xA, 21 | REG_XYZF3 = 0xC, 22 | REG_XYZ3 = 0xD, 23 | REG_AD = 0xE, 24 | REG_NOP = 0xF 25 | }; 26 | 27 | enum DataFormat { 28 | FORMAT_PACKED, 29 | FORMAT_REGLIST, 30 | FORMAT_IMAGE, 31 | FORMAT_IMAGE_3, 32 | }; 33 | 34 | class Tag { 35 | public: 36 | Tag(); 37 | 38 | void SetLoops(u16 nloop); 39 | void SetEop(bool eop = true); 40 | void SetPrimitive(u8 prim); 41 | void SetFormat(DataFormat fmt); 42 | void SetRegDescs( 43 | RegisterDescriptor r0 = REG_INVALID, RegisterDescriptor r1 = REG_INVALID, RegisterDescriptor r2 = REG_INVALID, RegisterDescriptor r3 = REG_INVALID, 44 | RegisterDescriptor r4 = REG_INVALID, RegisterDescriptor r5 = REG_INVALID, RegisterDescriptor r6 = REG_INVALID, RegisterDescriptor r7 = REG_INVALID, 45 | RegisterDescriptor r8 = REG_INVALID, RegisterDescriptor r9 = REG_INVALID, RegisterDescriptor r10 = REG_INVALID, RegisterDescriptor r11 = REG_INVALID, 46 | RegisterDescriptor r12 = REG_INVALID, RegisterDescriptor r13 = REG_INVALID, RegisterDescriptor r14 = REG_INVALID, RegisterDescriptor r15 = REG_INVALID 47 | ); 48 | 49 | union { 50 | struct { 51 | u64 v0; 52 | u64 v1; 53 | } raw; 54 | struct { 55 | u32 nloop : 15; 56 | u32 eop : 1; 57 | u32 padding0 : 16; 58 | u32 padding1 : 14; 59 | u32 pre : 1; 60 | u32 prim : 11; 61 | u32 flg : 2; 62 | u32 nreg : 4; 63 | u64 regs; 64 | } typed; 65 | } tag_; 66 | }; 67 | 68 | class Packet { 69 | public: 70 | Packet(u32 size); 71 | virtual ~Packet(); 72 | 73 | void Reset(); 74 | 75 | virtual void WriteTag(const Tag&); 76 | 77 | void *Raw() { 78 | return start_; 79 | } 80 | 81 | u32 Size() { 82 | return (u32)(addr_ - start_) * 8; 83 | } 84 | 85 | u32 Qwc() { 86 | return (Size() + 0xF) / 0x10; 87 | } 88 | 89 | void Emit(u64 v) { 90 | *addr_++ = v; 91 | } 92 | 93 | protected: 94 | u64 *start_; 95 | u64 *addr_; 96 | }; 97 | 98 | class PackedPacket : public Packet { 99 | public: 100 | PackedPacket(u32 size); 101 | 102 | virtual void WriteTag(const Tag&); 103 | void AD(u8 reg, u64 value); 104 | }; 105 | } 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/branch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | enum BranchResultFlags { 4 | BRANCH_SKIPPED = 0, 5 | BRANCH_FOLLOWED = 1, 6 | BRANCH_SET_RA = 2, 7 | BRANCH_DELAY_SLOT = 4, 8 | }; 9 | 10 | #define BO_OP_FUNC(OP) \ 11 | static inline void BO_##OP(u32 &result) { \ 12 | asm volatile ( \ 13 | ".set noreorder\n" \ 14 | "" \ 15 | "lui %0, 0\n" \ 16 | "or $t9, $0, $ra\n" \ 17 | "" \ 18 | #OP " " #OP "_branch%=\n" \ 19 | "ori %0, %0, 4\n" \ 20 | "" \ 21 | "b " #OP "_skip%=\n" \ 22 | "nop\n" \ 23 | "" \ 24 | #OP "_branch%=:\n" \ 25 | "ori %0, %0, 1\n" \ 26 | "" \ 27 | #OP "_skip%=:\n" \ 28 | "beq $t9, $ra, " #OP "_done%=\n" \ 29 | "nop\n" \ 30 | "" \ 31 | "or $ra, $0, $t9\n" \ 32 | "ori %0, %0, 2\n" \ 33 | "" \ 34 | #OP "_done%=:\n" \ 35 | "" \ 36 | : "=&r"(result) : : "t9" \ 37 | ); \ 38 | } 39 | 40 | static inline void PRINT_BRANCH(const u32 result, bool newline) { 41 | printf("%s, ", (result & BRANCH_FOLLOWED) != 0 ? "followed" : "skipped"); 42 | printf("%s, ", (result & BRANCH_SET_RA) != 0 ? "set ra" : "ignored ra"); 43 | printf("%s", (result & BRANCH_DELAY_SLOT) != 0 ? "ran delay slot" : "skipped delay slot"); 44 | if (newline) { 45 | printf("\n"); 46 | } 47 | } 48 | 49 | static inline void SET_FC_I(int flag) { 50 | register u32 mask = ~(1 << 23); 51 | register u32 bit = flag << 23; 52 | 53 | asm volatile ( 54 | "cfc1 $t6, $31\n" 55 | "and $t6, $t6, %0\n" 56 | "or $t6, $t6, %1\n" 57 | "ctc1 $t6, $31\n" 58 | : : "r"(mask), "r"(bit) : "t6" 59 | ); 60 | } 61 | 62 | static inline void SET_FC_CMP_TRUE() { 63 | asm volatile ( 64 | "c.eq.s $f0, $f0\n" 65 | ); 66 | } 67 | 68 | static inline void SET_FC_CMP_FALSE() { 69 | asm volatile ( 70 | "c.f.s $f0, $f0\n" 71 | ); 72 | } 73 | 74 | #define TEST_BO_FUNC(OP) \ 75 | BO_OP_FUNC(OP); \ 76 | static void test_##OP() { \ 77 | u32 res; \ 78 | \ 79 | printf("%s:\n", #OP); \ 80 | \ 81 | SET_FC_I(1); \ 82 | BO_##OP(res); \ 83 | printf(" %s 1: ", #OP); PRINT_BRANCH(res, true); \ 84 | \ 85 | SET_FC_I(0); \ 86 | BO_##OP(res); \ 87 | printf(" %s 0: ", #OP); PRINT_BRANCH(res, true); \ 88 | \ 89 | SET_FC_CMP_TRUE(); \ 90 | BO_##OP(res); \ 91 | printf(" %s c.eq: ", #OP); PRINT_BRANCH(res, true); \ 92 | \ 93 | SET_FC_CMP_FALSE(); \ 94 | BO_##OP(res); \ 95 | printf(" %s c.f: ", #OP); PRINT_BRANCH(res, true); \ 96 | \ 97 | printf("\n"); \ 98 | } 99 | 100 | TEST_BO_FUNC(bc1f); 101 | TEST_BO_FUNC(bc1fl); 102 | TEST_BO_FUNC(bc1t); 103 | TEST_BO_FUNC(bc1tl); 104 | 105 | int main(int argc, char **argv) { 106 | printf("-- TEST BEGIN\n"); 107 | 108 | test_bc1f(); 109 | test_bc1fl(); 110 | test_bc1t(); 111 | test_bc1tl(); 112 | 113 | printf("-- TEST END\n"); 114 | 115 | return 0; 116 | } 117 | -------------------------------------------------------------------------------- /tests/cpu/ee_simd/shared.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static u32 __attribute__((aligned(16), unused)) C_ZERO[4] = {0, 0, 0, 0}; 4 | static u32 __attribute__((aligned(16), unused)) C_S16_MAX[4] = {0x7FFF, 0, 0, 0}; 5 | static u32 __attribute__((aligned(16), unused)) C_S16_MIN[4] = {0xFFFF8000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 6 | static u32 __attribute__((aligned(16), unused)) C_S32_MAX[4] = {0x7FFFFFFF, 0, 0, 0}; 7 | static u32 __attribute__((aligned(16), unused)) C_S32_MIN[4] = {0x80000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 8 | static u32 __attribute__((aligned(16), unused)) C_S64_MAX[4] = {0xFFFFFFFF, 0x7FFFFFFF, 0, 0 }; 9 | static u32 __attribute__((aligned(16), unused)) C_S64_MIN[4] = {0, 0x80000000, 0xFFFFFFFF, 0xFFFFFFFF}; 10 | static u32 __attribute__((aligned(16), unused)) C_NEGONE[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; 11 | static u32 __attribute__((aligned(16), unused)) C_ONE[4] = {1, 0, 0, 0}; 12 | static u32 __attribute__((aligned(16), unused)) C_GARBAGE1[4] = {0x1337, 0x1338, 0x1339, 0x133A}; 13 | static u32 __attribute__((aligned(16), unused)) C_GARBAGE2[4] = {0xDEADBEEF, 0xDEADBEEE, 0xDEADBEED, 0xDEADBEEC}; 14 | static u32 __attribute__((aligned(16), unused)) C_P_S8_A[4] = {0x80808080, 0xFFFFFFFF, 0x12345678, 0x7F7F7F7F}; 15 | static u32 __attribute__((aligned(16), unused)) C_P_S8_B[4] = {0x80FF127F, 0xFF807F34, 0x567F80FF, 0x7F78FF80}; 16 | static u32 __attribute__((aligned(16), unused)) C_P_S16_A[4] = {0x80008000, 0xFFFFFFFF, 0x12345678, 0x7FFF7FFF}; 17 | static u32 __attribute__((aligned(16), unused)) C_P_S16_B[4] = {0x8000FFFF, 0x12347FFF, 0xFFFF8000, 0x7FFF5678}; 18 | static u32 __attribute__((aligned(16), unused)) C_P_S32_A[4] = {0x80000000, 0xFFFFFFFF, 0x12345678, 0x7FFFFFFF}; 19 | static u32 __attribute__((aligned(16), unused)) C_P_S32_B[4] = {0xFFFFFFFF, 0x80000000, 0x7FFFFFFF, 0x12345678}; 20 | static u32 __attribute__((aligned(16), unused)) C_P_S32_C[4] = {0x80000000, 0xFFFFFFFF, 0x12345678, 0x7FFFFFFF}; 21 | static u32 __attribute__((aligned(16), unused)) C_P_S32_D[4] = {0x7FFFFFFF, 0x12345678, 0xFFFFFFFF, 0x80000000}; 22 | static u32 __attribute__((aligned(16), unused)) C_P_S32_E[4] = {0x00000000, 0x7FFFFFFF, 0xFFFFFFFF, 0x80000000}; 23 | static u32 __attribute__((aligned(16), unused)) C_P_S32_F[4] = {0xFFFFFFFF, 0x80000000, 0x00000000, 0x7FFFFFFF}; 24 | 25 | template 26 | static inline void SET_U32(register u128 &rd) { 27 | asm volatile ( 28 | "lui %0, %1\n" 29 | "ori %0, %0, %2\n" 30 | "pcpyld %0, %0, %0\n" 31 | : "+r"(rd) : "K"((i >> 16) & 0xFFFF), "K"(i & 0xFFFF) 32 | ); 33 | } 34 | 35 | static inline void SET_M(register u128 &rd, u32 *p) { 36 | rd = *(vu128 *)p; 37 | } 38 | 39 | static inline void PRINT_R(const register u128 &rt, bool newline) { 40 | static u32 __attribute__((aligned(16))) result[4] = {0, 0, 0, 0}; 41 | *(vu128 *)result = rt; 42 | 43 | printf("%08x %08x %08x %08x", result[3], result[2], result[1], result[0]); 44 | if (newline) { 45 | printf("\n"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/dma/vif/vifregs.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_DMA_VIF_VIFREGS_H 2 | #define PS2AUTOTESTS_DMA_VIF_VIFREGS_H 3 | 4 | #include 5 | #include "../dmaregs.h" 6 | 7 | namespace VIF { 8 | 9 | #define BITWISE_ENUM(Enum) \ 10 | static inline Enum operator | (const Enum &lhs, const Enum &rhs) { \ 11 | return Enum((u32)lhs | (u32)rhs); \ 12 | } \ 13 | static inline Enum operator ~ (const Enum &rhs) { \ 14 | return Enum(~(u32)rhs); \ 15 | } 16 | 17 | enum RegSTATBits { 18 | STAT_VPS_MASK = 3 << 0, 19 | STAT_VPS_IDLE = 0 << 0, 20 | STAT_VPS_DATAWAIT = 1 << 0, 21 | STAT_VPS_DECODE = 2 << 0, 22 | STAT_VPS_TRANSFER = 3 << 0, 23 | 24 | STAT_VEW = 1 << 2, 25 | // VIF1 only. 26 | STAT_VGW = 1 << 3, 27 | STAT_MRK = 1 << 6, 28 | // VIF1 only. 29 | STAT_DBF = 1 << 7, 30 | STAT_VSS = 1 << 8, 31 | STAT_VFS = 1 << 9, 32 | STAT_VIS = 1 << 10, 33 | STAT_INT = 1 << 11, 34 | STAT_ER0 = 1 << 12, 35 | STAT_ER1 = 1 << 13, 36 | // VIF1 only. 37 | STAT_FDR = 1 << 23, 38 | 39 | STAT_FQC_SHIFT = 24, 40 | }; 41 | BITWISE_ENUM(RegSTATBits) 42 | 43 | enum RegFBRSTBits { 44 | FBRST_RST = 1 << 0, 45 | FBRST_FBK = 1 << 1, 46 | FBRST_STP = 1 << 2, 47 | FBRST_STC = 1 << 3, 48 | }; 49 | BITWISE_ENUM(RegFBRSTBits) 50 | 51 | enum RegERRBits { 52 | ERR_MII = 1 << 0, 53 | ERR_ME0 = 1 << 1, 54 | ERR_ME1 = 1 << 2, 55 | }; 56 | BITWISE_ENUM(RegERRBits) 57 | 58 | typedef DMA::Reg RegSTAT; 59 | typedef DMA::Reg RegFBRST; 60 | typedef DMA::Reg RegERR; 61 | 62 | struct VIFRegs { 63 | RegSTAT stat; 64 | u32 stat_pad[3]; 65 | RegFBRST fbrst; 66 | u32 fbrst_pad[3]; 67 | RegERR err; 68 | u32 err_pad[3]; 69 | u32 mrk; 70 | u32 mrk_pad[3]; 71 | 72 | u32 cycle; 73 | u32 cycle_pad[3]; 74 | u32 mode; 75 | u32 mode_pad[3]; 76 | u32 num; 77 | u32 num_pad[3]; 78 | u32 mask; 79 | u32 mask_pad[3]; 80 | u32 code; 81 | u32 code_pad[3]; 82 | u32 itops; 83 | u32 itops_pad[3]; 84 | // VIF1 only. 85 | u32 base; 86 | u32 base_pad[3]; 87 | // VIF1 only. 88 | u32 ofst; 89 | u32 ofst_pad[3]; 90 | // VIF1 only. 91 | u32 tops; 92 | u32 tops_pad[3]; 93 | u32 itop; 94 | u32 itop_pad[3]; 95 | u32 top; 96 | u32 top_pad[3]; 97 | u32 pad2[4]; 98 | u32 r0; 99 | u32 r0_pad[3]; 100 | u32 r1; 101 | u32 r1_pad[3]; 102 | u32 r2; 103 | u32 r2_pad[3]; 104 | u32 r3; 105 | u32 r3_pad[3]; 106 | u32 c0; 107 | u32 c0_pad[3]; 108 | u32 c1; 109 | u32 c1_pad[3]; 110 | u32 c2; 111 | u32 c2_pad[3]; 112 | u32 c3; 113 | u32 c3_pad[3]; 114 | }; 115 | 116 | static volatile VIFRegs *const VIF0 = (volatile VIFRegs *)0x10003800; 117 | static volatile VIFRegs *const VIF1 = (volatile VIFRegs *)0x10003C00; 118 | 119 | static volatile u128 *const VIF0_FIFO = (volatile u128 *)0x10004000; 120 | static volatile u128 *const VIF1_FIFO = (volatile u128 *)0x10005000; 121 | 122 | #undef BITWISE_ENUM 123 | } 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/create.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void nullThreadProc(u32 param) { 5 | //Do nothing 6 | } 7 | 8 | void printThreadInfo(s32 threadId) { 9 | iop_thread_info_t threadStat; 10 | memset(&threadStat, 0, sizeof(iop_thread_info_t)); 11 | s32 result = ReferThreadStatus(threadId, &threadStat); 12 | if (result >= 0) { 13 | printf("attr: %08x, option: %08x, stack size: %08x, init prio: %02x, curr prio: %02x, status: %02x, ", 14 | threadStat.attr, threadStat.option, threadStat.stackSize, 15 | threadStat.initPriority, threadStat.currentPriority, threadStat.status); 16 | if(threadStat.entry == &nullThreadProc) { 17 | printf("entry: &nullThreadProc"); 18 | } else { 19 | printf("entry: %08x", threadStat.entry); 20 | } 21 | printf("\n"); 22 | } else { 23 | printf("refer failed -> result: %d\n", result); 24 | } 25 | } 26 | 27 | 28 | void createThread(s32 attr, void *entry, s32 prio, s32 stackSize, u32 option) { 29 | iop_thread_t threadParam; 30 | memset(&threadParam, 0, sizeof(iop_thread_t)); 31 | threadParam.attr = attr; 32 | threadParam.thread = entry; 33 | threadParam.priority = prio; 34 | threadParam.stacksize = stackSize; 35 | threadParam.option = option; 36 | 37 | s32 thId = CreateThread(&threadParam); 38 | 39 | if(thId > 0) { 40 | printf(" succeeded -> "); 41 | printThreadInfo(thId); 42 | DeleteThread(thId); 43 | } else { 44 | printf(" failed -> result: %d\n", thId); 45 | } 46 | } 47 | 48 | int _start(int argc, char **argv) { 49 | printf("-- TEST BEGIN\n"); 50 | 51 | printf("valid:\n"); 52 | createThread(TH_C, &nullThreadProc, 10, 0x800, 0x01234567); 53 | 54 | printf("huge stack size (~0):\n"); 55 | createThread(0, &nullThreadProc, 10, ~0, 0); 56 | 57 | printf("small stack size (300):\n"); 58 | createThread(0, &nullThreadProc, 10, 300, 0); 59 | 60 | printf("invalid attr (~0):\n"); 61 | createThread(~0, &nullThreadProc, 10, 0x800, 0); 62 | 63 | //TH_NO_FILLSTACK and TH_CLEAR_STACK are defined in ps2sdk, but don't seem to be supported 64 | //(Might be due to BIOS version differences) 65 | 66 | printf("known attribute (TH_NO_FILLSTACK):\n"); 67 | createThread(TH_NO_FILLSTACK, &nullThreadProc, 10, 0x800, 0); 68 | 69 | printf("known attribute (TH_CLEAR_STACK):\n"); 70 | createThread(TH_CLEAR_STACK, &nullThreadProc, 10, 0x800, 0); 71 | 72 | printf("known valid attributes (TH_UMODE | TH_ASM | TH_C):\n"); 73 | createThread(TH_UMODE | TH_ASM | TH_C, &nullThreadProc, 10, 0x800, 0); 74 | 75 | printf("invalid entry point (NULL):\n"); 76 | createThread(0, NULL, 10, 0x800, 0); 77 | 78 | printf("invalid entry point (3):\n"); 79 | createThread(0, (void*)3, 10, 0x800, 0); 80 | 81 | printf("invalid entry point (~3):\n"); 82 | createThread(0, (void*)~3, 10, 0x800, 0); 83 | 84 | printf("invalid priority (0):\n"); 85 | createThread(0, &nullThreadProc, 0, 0x800, 0); 86 | 87 | printf("invalid priority (127):\n"); 88 | createThread(0, &nullThreadProc, 127, 0x800, 0); 89 | 90 | printf("-- TEST END\n"); 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /tests/vu/lower/random.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | RINIT: 3 | 3fa34567/+1.28 3fa34567/+1.28 3fa34567/+1.28 3fa34567/+1.28 4 | 3fabcdef/+1.34 3fabcdef/+1.34 3fabcdef/+1.34 3fabcdef/+1.34 5 | 3fdcba98/+1.72 3fdcba98/+1.72 3fdcba98/+1.72 3fdcba98/+1.72 6 | 3fd43210/+1.66 3fd43210/+1.66 3fd43210/+1.66 3fd43210/+1.66 7 | RXOR: 8 | 3fa34567/+1.28 3fa34567/+1.28 3fa34567/+1.28 3fa34567/+1.28 9 | 3f888888/+1.07 3f888888/+1.07 3f888888/+1.07 3f888888/+1.07 10 | 3fd43210/+1.66 3fd43210/+1.66 3fd43210/+1.66 3fd43210/+1.66 11 | 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 12 | RNEXT: 13 | CVF_ZEROONE[VU::FIELD_X]: 14 | 1: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 15 | 2: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 16 | 3: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 17 | 4: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 18 | CVF_ZEROONE[VU::FIELD_Y]: 19 | 1: 3ffffffe/+2.00 3ffffffe/+2.00 3ffffffe/+2.00 3ffffffe/+2.00 20 | 2: 3ffffffc/+2.00 3ffffffc/+2.00 3ffffffc/+2.00 3ffffffc/+2.00 21 | 3: 3ffffff8/+2.00 3ffffff8/+2.00 3ffffff8/+2.00 3ffffff8/+2.00 22 | 4: 3ffffff0/+2.00 3ffffff0/+2.00 3ffffff0/+2.00 3ffffff0/+2.00 23 | CVF_ZEROONE[VU::FIELD_Z]: 24 | 1: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 25 | 2: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 26 | 3: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 27 | 4: 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 3f800000/+1.00 28 | CVF_ZEROONE[VU::FIELD_W]: 29 | 1: 3ffffffe/+2.00 3ffffffe/+2.00 3ffffffe/+2.00 3ffffffe/+2.00 30 | 2: 3ffffffc/+2.00 3ffffffc/+2.00 3ffffffc/+2.00 3ffffffc/+2.00 31 | 3: 3ffffff8/+2.00 3ffffff8/+2.00 3ffffff8/+2.00 3ffffff8/+2.00 32 | 4: 3ffffff0/+2.00 3ffffff0/+2.00 3ffffff0/+2.00 3ffffff0/+2.00 33 | CVF_GARBAGE[VU::FIELD_X]: 34 | 1: 3fc68ace/+1.55 3fc68ace/+1.55 3fc68ace/+1.55 3fc68ace/+1.55 35 | 2: 3f8d159d/+1.10 3f8d159d/+1.10 3f8d159d/+1.10 3f8d159d/+1.10 36 | 3: 3f9a2b3b/+1.20 3f9a2b3b/+1.20 3f9a2b3b/+1.20 3f9a2b3b/+1.20 37 | 4: 3fb45677/+1.41 3fb45677/+1.41 3fb45677/+1.41 3fb45677/+1.41 38 | CVF_GARBAGE[VU::FIELD_Y]: 39 | 1: 3fd79bde/+1.68 3fd79bde/+1.68 3fd79bde/+1.68 3fd79bde/+1.68 40 | 2: 3faf37bc/+1.37 3faf37bc/+1.37 3faf37bc/+1.37 3faf37bc/+1.37 41 | 3: 3fde6f79/+1.74 3fde6f79/+1.74 3fde6f79/+1.74 3fde6f79/+1.74 42 | 4: 3fbcdef2/+1.48 3fbcdef2/+1.48 3fbcdef2/+1.48 3fbcdef2/+1.48 43 | CVF_GARBAGE[VU::FIELD_Z]: 44 | 1: 3fb97530/+1.45 3fb97530/+1.45 3fb97530/+1.45 3fb97530/+1.45 45 | 2: 3ff2ea61/+1.90 3ff2ea61/+1.90 3ff2ea61/+1.90 3ff2ea61/+1.90 46 | 3: 3fe5d4c3/+1.80 3fe5d4c3/+1.80 3fe5d4c3/+1.80 3fe5d4c3/+1.80 47 | 4: 3fcba987/+1.59 3fcba987/+1.59 3fcba987/+1.59 3fcba987/+1.59 48 | CVF_GARBAGE[VU::FIELD_W]: 49 | 1: 3fa86420/+1.32 3fa86420/+1.32 3fa86420/+1.32 3fa86420/+1.32 50 | 2: 3fd0c840/+1.63 3fd0c840/+1.63 3fd0c840/+1.63 3fd0c840/+1.63 51 | 3: 3fa19081/+1.26 3fa19081/+1.26 3fa19081/+1.26 3fa19081/+1.26 52 | 4: 3fc32102/+1.52 3fc32102/+1.52 3fc32102/+1.52 3fc32102/+1.52 53 | -- TEST END 54 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/convert.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | cvt.w.s: 3 | cvt.w.s 00000000/+0.00: 00000000/+0.00 4 | cvt.w.s 80000000/-0.00: 00000000/+0.00 5 | cvt.w.s 3f800000/+1.00: 00000001/+0.00 6 | cvt.w.s 40000000/+2.00: 00000002/+0.00 7 | cvt.w.s 40400000/+3.00: 00000003/+0.00 8 | cvt.w.s 7fffffff/+NaN: 7fffffff/+NaN 9 | cvt.w.s ffffffff/-NaN: 80000000/-0.00 10 | cvt.w.s 7f800000/+NaN: 7fffffff/+NaN 11 | cvt.w.s ff800000/-NaN: 80000000/-0.00 12 | cvt.w.s 00000005/+0.00: 00000000/+0.00 13 | cvt.w.s 0000ffff/+0.00: 00000000/+0.00 14 | cvt.w.s 4f000000/+2147483648.00: 7fffffff/+NaN 15 | cvt.w.s cf000000/-2147483648.00: 80000000/-0.00 16 | cvt.w.s 4effffff/+2147483520.00: 7fffff80/+NaN 17 | cvt.w.s ceffffff/-2147483520.00: 80000080/-0.00 18 | cvt.w.s 3fbeb852/+1.49: 00000001/+0.00 19 | cvt.w.s 3fc00000/+1.50: 00000001/+0.00 20 | cvt.w.s 3fc147ae/+1.51: 00000001/+0.00 21 | cvt.w.s bfbeb852/-1.49: ffffffff/-NaN 22 | cvt.w.s bfc00000/-1.50: ffffffff/-NaN 23 | cvt.w.s bfc147ae/-1.51: ffffffff/-NaN 24 | cvt.w.s CF_ZERO: 00000000/+0.00 25 | cvt.w.s CF_NEGZERO: 00000000/+0.00 26 | cvt.w.s CF_ONE: 00000001/+0.00 27 | cvt.w.s CF_NEGONE: ffffffff/-NaN 28 | cvt.w.s CF_MAX_MANTISSA: 00000001/+0.00 29 | cvt.w.s CF_MAX_EXP: 7fffffff/+NaN 30 | cvt.w.s CF_MIN_EXP: 00000000/+0.00 31 | cvt.w.s CF_MAX: 7fffffff/+NaN 32 | cvt.w.s CF_MIN: 80000000/-0.00 33 | cvt.w.s CF_GARBAGE1: 00000000/+0.00 34 | cvt.w.s CF_GARBAGE2: 80000000/-0.00 35 | 36 | cvt.s.w: 37 | cvt.s.w 00000000/+0.00: 00000000/+0.00 38 | cvt.s.w 80000000/-0.00: cf000000/-2147483648.00 39 | cvt.s.w 3f800000/+1.00: 4e7e0000/+1065353216.00 40 | cvt.s.w 40000000/+2.00: 4e800000/+1073741824.00 41 | cvt.s.w 40400000/+3.00: 4e808000/+1077936128.00 42 | cvt.s.w 7fffffff/+NaN: 4effffff/+2147483520.00 43 | cvt.s.w ffffffff/-NaN: bf800000/-1.00 44 | cvt.s.w 7f800000/+NaN: 4eff0000/+2139095040.00 45 | cvt.s.w ff800000/-NaN: cb000000/-8388608.00 46 | cvt.s.w 00000005/+0.00: 40a00000/+5.00 47 | cvt.s.w 0000ffff/+0.00: 477fff00/+65535.00 48 | cvt.s.w 4f000000/+2147483648.00: 4e9e0000/+1325400064.00 49 | cvt.s.w cf000000/-2147483648.00: ce440000/-822083584.00 50 | cvt.s.w 4effffff/+2147483520.00: 4e9dffff/+1325399936.00 51 | cvt.s.w ceffffff/-2147483520.00: ce440000/-822083584.00 52 | cvt.s.w 3fbeb852/+1.49: 4e7efae1/+1069463616.00 53 | cvt.s.w 3fc00000/+1.50: 4e7f0000/+1069547520.00 54 | cvt.s.w 3fc147ae/+1.51: 4e7f051e/+1069631360.00 55 | cvt.s.w bfbeb852/-1.49: ce80828f/-1078019968.00 56 | cvt.s.w bfc00000/-1.50: ce808000/-1077936128.00 57 | cvt.s.w bfc147ae/-1.51: ce807d70/-1077852160.00 58 | cvt.s.w CF_ZERO: 00000000/+0.00 59 | cvt.s.w CF_NEGZERO: cf000000/-2147483648.00 60 | cvt.s.w CF_ONE: 4e7e0000/+1065353216.00 61 | cvt.s.w CF_NEGONE: ce810000/-1082130432.00 62 | cvt.s.w CF_MAX_MANTISSA: 4e7fffff/+1073741760.00 63 | cvt.s.w CF_MAX_EXP: 4eff0000/+2139095040.00 64 | cvt.s.w CF_MIN_EXP: 3f800000/+1.00 65 | cvt.s.w CF_MAX: 4effffff/+2147483520.00 66 | cvt.s.w CF_MIN: bf800000/-1.00 67 | cvt.s.w CF_GARBAGE1: 4599b800/+4919.00 68 | cvt.s.w CF_GARBAGE2: ce054904/-559038720.00 69 | 70 | -- TEST END 71 | -------------------------------------------------------------------------------- /tests/cpu/ee_simd/compare.cpp: -------------------------------------------------------------------------------- 1 | #include "shared.h" 2 | 3 | #define RRR_OP_FUNC(OP) \ 4 | static inline void RRR_##OP(register u128 &rd, const register u128 &rs, const register u128 &rt) { \ 5 | asm volatile ( \ 6 | #OP " %0, %1, %2\n" \ 7 | : "+r"(rd) : "r"(rs), "r"(rt) \ 8 | ); \ 9 | } \ 10 | static inline void ZRR_##OP(register u128 &rd, const register u128 &rs, const register u128 &rt) { \ 11 | asm volatile ( \ 12 | #OP " $0, %1, %2\n" \ 13 | "por %0, $0, $0\n" \ 14 | : "+r"(rd) : "r"(rs), "r"(rt) \ 15 | ); \ 16 | } 17 | 18 | #define RRR_OP_DO_III(OP, d, s, t) \ 19 | SET_U32(rd); SET_U32(rs); SET_U32(rt); \ 20 | RRR_##OP(rd, rs, rt); \ 21 | printf(" %s %d, %d: ", #OP, (u32)rs, (u32)rt); PRINT_R(rd, true); 22 | 23 | #define RRR_OP_DO_MMM(OP, d, s, t) \ 24 | SET_M(rd, d); SET_M(rs, s); SET_M(rt, t); \ 25 | RRR_##OP(rd, rs, rt); \ 26 | printf(" %s %s, %s: ", #OP, #s, #t); PRINT_R(rd, true); 27 | 28 | #define TEST_RRR_FUNC(OP) \ 29 | RRR_OP_FUNC(OP); \ 30 | static void test_##OP() { \ 31 | register u128 rd, rs, rt; \ 32 | \ 33 | printf("%s:\n", #OP); \ 34 | \ 35 | RRR_OP_DO_III(OP, 0x1337, 0, 0); \ 36 | RRR_OP_DO_III(OP, 0x1337, 0, 1); \ 37 | RRR_OP_DO_III(OP, 0x1337, 1, 1); \ 38 | RRR_OP_DO_III(OP, 0x1337, 1, 0); \ 39 | RRR_OP_DO_III(OP, 0x1337, 2, 2); \ 40 | RRR_OP_DO_III(OP, 0x1337, 0xFFFFFFFF, 1); \ 41 | RRR_OP_DO_III(OP, 0x1337, 0xFFFFFFFF, 0xFFFFFFFF); \ 42 | \ 43 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_ZERO, C_ZERO); \ 44 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_ZERO, C_ONE); \ 45 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_ONE, C_ZERO); \ 46 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_ONE, C_ONE); \ 47 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_ONE, C_NEGONE); \ 48 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_S16_MAX, C_S16_MAX); \ 49 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_S16_MIN, C_S16_MIN); \ 50 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_S32_MAX, C_S32_MAX); \ 51 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_S32_MIN, C_S32_MIN); \ 52 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_S64_MAX, C_S64_MAX); \ 53 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_S64_MIN, C_S64_MIN); \ 54 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_GARBAGE1, C_GARBAGE2); \ 55 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S8_A, C_P_S8_B); \ 56 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S16_A, C_P_S16_B); \ 57 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S32_A, C_P_S32_B); \ 58 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S32_B, C_P_S32_A); \ 59 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S32_C, C_P_S32_D); \ 60 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S32_D, C_P_S32_C); \ 61 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S32_E, C_P_S32_F); \ 62 | RRR_OP_DO_MMM(OP, C_GARBAGE1, C_P_S32_F, C_P_S32_E); \ 63 | \ 64 | SET_M(rd, C_GARBAGE1); SET_M(rs, C_GARBAGE1); SET_M(rt, C_GARBAGE1); \ 65 | ZRR_##OP(rd, rs, rt); \ 66 | printf(" %s -> $0: ", #OP); PRINT_R(rd, true); \ 67 | printf("\n"); \ 68 | } 69 | 70 | TEST_RRR_FUNC(pceqb) 71 | TEST_RRR_FUNC(pceqh) 72 | TEST_RRR_FUNC(pceqw) 73 | TEST_RRR_FUNC(pcgtb) 74 | TEST_RRR_FUNC(pcgth) 75 | TEST_RRR_FUNC(pcgtw) 76 | 77 | int main(int argc, char **argv) { 78 | printf("-- TEST BEGIN\n"); 79 | 80 | test_pceqb(); 81 | test_pceqh(); 82 | test_pceqw(); 83 | test_pcgtb(); 84 | test_pcgth(); 85 | test_pcgtw(); 86 | 87 | printf("-- TEST END\n"); 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/sqrt.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | rsqrt: 3 | rsqrt 00000000/+0.00, 00000000/+0.00: 7fffffff/+NaN 4 | rsqrt 00000000/+0.00, 80000000/-0.00: 7fffffff/+NaN 5 | rsqrt 80000000/-0.00, 00000000/+0.00: ffffffff/-NaN 6 | rsqrt 80000000/-0.00, 80000000/-0.00: ffffffff/-NaN 7 | rsqrt 00000000/+0.00, 3f800000/+1.00: 00000000/+0.00 8 | rsqrt 3f800000/+1.00, 3f800000/+1.00: 3f800000/+1.00 9 | rsqrt 3f800000/+1.00, 00000000/+0.00: 7fffffff/+NaN 10 | rsqrt 40000000/+2.00, 40000000/+2.00: 3fb504f3/+1.41 11 | rsqrt 40400000/+3.00, 3f800000/+1.00: 40400000/+3.00 12 | rsqrt 40400000/+3.00, 40400000/+3.00: 3fddb3d7/+1.73 13 | rsqrt 7fffffff/+NaN, 7fffffff/+NaN: 5fb504f2/+26087633005171446676.00 14 | rsqrt 7fffffff/+NaN, ffffffff/-NaN: 5fb504f2/+26087633005171446676.00 15 | rsqrt ffffffff/-NaN, 7fffffff/+NaN: dfb504f2/-26087633005171446676.00 16 | rsqrt ffffffff/-NaN, ffffffff/-NaN: dfb504f2/-26087633005171446676.00 17 | rsqrt 7fffffff/+NaN, 00000000/+0.00: 7fffffff/+NaN 18 | rsqrt 00000000/+0.00, 7fffffff/+NaN: 00000000/+0.00 19 | rsqrt 00000000/+0.00, 7f800000/+NaN: 00000000/+0.00 20 | rsqrt 7f800000/+NaN, 7f800000/+NaN: 5f800000/+18446744073709558264.00 21 | rsqrt ff800000/-NaN, 7f800000/+NaN: df800000/-18446744073709558264.00 22 | rsqrt 3f800000/+1.00, 41c80000/+25.00: 3e4ccccd/+0.20 23 | rsqrt 40a00000/+5.00, 41c80000/+25.00: 3f800000/+1.00 24 | rsqrt 41c80000/+25.00, 41c80000/+25.00: 40a00000/+5.00 25 | rsqrt CF_ZERO, CF_ZERO: 7fffffff/+NaN 26 | rsqrt CF_ZERO, CF_NEGZERO: 7fffffff/+NaN 27 | rsqrt CF_ONE, CF_ONE: 3f800000/+1.00 28 | rsqrt CF_ONE, CF_NEGONE: 3f800000/+1.00 29 | rsqrt CF_MAX_MANTISSA, CF_ONE: 3fffffff/+2.00 30 | rsqrt CF_MAX_EXP, CF_ONE: 7f800001/+NaN 31 | rsqrt CF_MIN_EXP, CF_ONE: 00000000/+0.00 32 | rsqrt CF_ONE, CF_MAX_MANTISSA: 3f3504f3/+0.71 33 | rsqrt CF_ONE, CF_MAX_EXP: 1f800000/+0.00 34 | rsqrt CF_ONE, CF_MIN_EXP: 7fffffff/+NaN 35 | rsqrt CF_MAX, CF_ONE: 7fffffff/+NaN 36 | rsqrt CF_MIN, CF_ONE: ffffffff/-NaN 37 | rsqrt CF_ONE, CF_MAX: 1f3504f3/+0.00 38 | rsqrt CF_ONE, CF_MIN: 1f3504f3/+0.00 39 | rsqrt CF_MAX, CF_MAX: 5fb504f2/+26087633005171446676.00 40 | rsqrt CF_MIN, CF_MIN: dfb504f2/-26087633005171446676.00 41 | rsqrt CF_GARBAGE1, CF_GARBAGE2: 00000000/+0.00 42 | 43 | sqrt: 44 | sqrt 00000000/+0.00: 00000000/+0.00 45 | sqrt 80000000/-0.00: 00000000/+0.00 46 | sqrt 3f800000/+1.00: 3f800000/+1.00 47 | sqrt 40000000/+2.00: 3fb504f3/+1.41 48 | sqrt 40400000/+3.00: 3fddb3d7/+1.73 49 | sqrt 7fffffff/+NaN: 5fb504f3/+26087635204194699056.00 50 | sqrt ffffffff/-NaN: 5fb504f3/+26087635204194699056.00 51 | sqrt 7f800000/+NaN: 5f800000/+18446744073709558264.00 52 | sqrt ff800000/-NaN: 5f800000/+18446744073709558264.00 53 | sqrt 41c80000/+25.00: 40a00000/+5.00 54 | sqrt CF_ZERO: 00000000/+0.00 55 | sqrt CF_NEGZERO: 00000000/+0.00 56 | sqrt CF_ONE: 3f800000/+1.00 57 | sqrt CF_NEGONE: 3f800000/+1.00 58 | sqrt CF_MAX_MANTISSA: 3fb504f3/+1.41 59 | sqrt CF_MAX_EXP: 5f800000/+18446744073709558264.00 60 | sqrt CF_MIN_EXP: 00000000/+0.00 61 | sqrt CF_MAX: 5fb504f3/+26087635204194699056.00 62 | sqrt CF_MIN: 5fb504f3/+26087635204194699056.00 63 | sqrt CF_GARBAGE1: 00000000/+0.00 64 | sqrt CF_GARBAGE2: 4f152108/+2501969920.00 65 | 66 | -- TEST END 67 | -------------------------------------------------------------------------------- /tests/dma/dmatags.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "dmatags.h" 6 | 7 | namespace DMA { 8 | SrcChainPacket::SrcChainPacket(u32 size) { 9 | start_ = (SrcChainTag *)memalign(16, size); 10 | addr_ = start_; 11 | memset(start_, 0, size); 12 | } 13 | SrcChainPacket::~SrcChainPacket() { 14 | free(start_); 15 | } 16 | 17 | void SrcChainPacket::Reset() { 18 | memset(start_, 0, (addr_ - start_) * sizeof(SrcChainTag)); 19 | addr_ = start_; 20 | } 21 | 22 | void SrcChainPacket::CNT(u16 size, bool irq) { 23 | Emit(size, SRC_CNT, 0, irq); 24 | } 25 | 26 | void SrcChainPacket::NEXT(u16 size, void *nextdma, u16 nextsize, bool irq) { 27 | if (nextsize != 0) { 28 | SyncDCache(nextdma, (u8 *)nextdma + nextsize * 16); 29 | } 30 | Emit(size, SRC_NEXT, nextdma, irq); 31 | } 32 | 33 | void SrcChainPacket::REF(void *addr, u16 size, bool irq) { 34 | SyncDCache(addr, (u8 *)addr + size * 16); 35 | Emit(size, SRC_REF, addr, irq); 36 | } 37 | 38 | void SrcChainPacket::REFS(void *addr, u16 size, bool irq) { 39 | SyncDCache(addr, (u8 *)addr + size * 16); 40 | Emit(size, SRC_REFS, addr, irq); 41 | } 42 | 43 | void SrcChainPacket::REFE(void *addr, u16 size, bool irq) { 44 | SyncDCache(addr, (u8 *)addr + size * 16); 45 | Emit(size, SRC_REFE, addr, irq); 46 | } 47 | 48 | void SrcChainPacket::CALL(u16 size, void *nextdma, u16 nextsize, bool irq) { 49 | if (nextsize != 0) { 50 | SyncDCache(nextdma, (u8 *)nextdma + nextsize * 16); 51 | } 52 | Emit(size, SRC_CALL, nextdma, irq); 53 | } 54 | 55 | void SrcChainPacket::RET(u16 size, bool irq) { 56 | Emit(size, SRC_RET, 0, irq); 57 | } 58 | 59 | void SrcChainPacket::END(u16 size, bool irq) { 60 | Emit(size, SRC_END, 0, irq); 61 | } 62 | 63 | void SrcChainPacket::DataQ(u128 v) { 64 | *(u128 *)addr_ = v; 65 | addr_++; 66 | } 67 | void SrcChainPacket::DataQPtr(const void *p, u16 size) { 68 | memcpy(addr_, p, size * 16); 69 | addr_ += size; 70 | } 71 | 72 | void SrcChainPacket::Emit(u16 QWC, SrcChainType ID, void *addr, bool irq) { 73 | addr_->QWC = QWC; 74 | addr_->ID = ID; 75 | addr_->addr = addr; 76 | addr_->IRQ = irq ? 1 : 0; 77 | addr_++; 78 | } 79 | 80 | DstChainPacket::DstChainPacket(u32 size) { 81 | start_ = (DstChainTag *)memalign(16, size); 82 | addr_ = start_; 83 | memset(start_, 0, size); 84 | } 85 | DstChainPacket::~DstChainPacket() { 86 | free(start_); 87 | } 88 | 89 | void DstChainPacket::Reset() { 90 | memset(start_, 0, (addr_ - start_) * sizeof(DstChainTag)); 91 | addr_ = start_; 92 | } 93 | 94 | void DstChainPacket::CNT(void *addr, u16 size) { 95 | Emit(size, DST_CNT, addr); 96 | } 97 | 98 | void DstChainPacket::CNTS(void *addr, u16 size) { 99 | Emit(size, DST_CNTS, addr); 100 | } 101 | 102 | void DstChainPacket::END(void *addr, u16 size) { 103 | Emit(size, DST_END, addr); 104 | } 105 | 106 | void DstChainPacket::DataQ(u128 v) { 107 | *(u128 *)addr_ = v; 108 | addr_++; 109 | } 110 | void DstChainPacket::DataQPtr(const void *p, u16 size) { 111 | memcpy(addr_, p, size * 16); 112 | addr_ += size; 113 | } 114 | 115 | void DstChainPacket::Emit(u16 QWC, DstChainType ID, void *addr) { 116 | addr_->QWC = QWC; 117 | addr_->ID = ID; 118 | addr_->addr = addr; 119 | addr_++; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /tests/kernel/iop/eventflag/delete.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define STACK_SIZE 0x800 7 | 8 | typedef struct { 9 | int eventFlagId; 10 | s32 waitEventFlagResult; 11 | } WAIT_THREAD_PARAMS; 12 | 13 | void waitThreadProc(WAIT_THREAD_PARAMS* params) { 14 | params->waitEventFlagResult = WaitEventFlag(params->eventFlagId, ~0, WEF_OR | WEF_CLEAR, NULL); 15 | } 16 | 17 | int createTestThread(void *entry, int prio, u32 stackSize) { 18 | iop_thread_t threadParam; 19 | memset(&threadParam, 0, sizeof(iop_thread_t)); 20 | threadParam.attr = TH_C; 21 | threadParam.thread = entry; 22 | threadParam.priority = prio; 23 | threadParam.stacksize = stackSize; 24 | return CreateThread(&threadParam); 25 | } 26 | 27 | int getThreadPriority(int threadId) { 28 | iop_thread_info_t threadStat; 29 | memset(&threadStat, 0, sizeof(iop_thread_info_t)); 30 | int result = ReferThreadStatus(threadId, &threadStat); 31 | if (result >= 0) { 32 | return threadStat.currentPriority; 33 | } else { 34 | return -1; 35 | } 36 | } 37 | 38 | int createTestEventFlag() { 39 | iop_event_t eventFlagParams; 40 | memset(&eventFlagParams, 0, sizeof(eventFlagParams)); 41 | return CreateEventFlag(&eventFlagParams); 42 | } 43 | 44 | int generateDeletedEventFlagId() { 45 | int eventFlagId = createTestEventFlag(); 46 | DeleteEventFlag(eventFlagId); 47 | return eventFlagId; 48 | } 49 | 50 | void doDeleteEventFlag(int eventFlagId) { 51 | int result = DeleteEventFlag(eventFlagId); 52 | if(result == KE_OK) { 53 | schedf("succeeded\n"); 54 | } else { 55 | schedf("failed -> result: %d\n", result); 56 | } 57 | } 58 | 59 | int _start(int argc, char **argv) { 60 | printf("-- TEST BEGIN\n"); 61 | 62 | { 63 | schedf("unused event flag:\n"); 64 | 65 | int eventFlagId = createTestEventFlag(); 66 | 67 | schedf(" delete after creation: "); 68 | doDeleteEventFlag(eventFlagId); 69 | 70 | flushschedf(); 71 | } 72 | 73 | { 74 | schedf("used event flag:\n"); 75 | 76 | int eventFlagId = createTestEventFlag(); 77 | 78 | WAIT_THREAD_PARAMS waitThreadParams; 79 | waitThreadParams.eventFlagId = eventFlagId; 80 | waitThreadParams.waitEventFlagResult = 0; 81 | 82 | int currentThreadPriority = getThreadPriority(TH_SELF); 83 | int threadId = createTestThread((void*)&waitThreadProc, currentThreadPriority - 1, STACK_SIZE); 84 | StartThread(threadId, &waitThreadParams); 85 | 86 | schedf(" delete while thread is waiting: "); 87 | doDeleteEventFlag(eventFlagId); 88 | 89 | schedf(" WaitEventFlag returned: %d\n", waitThreadParams.waitEventFlagResult); 90 | 91 | //DeleteThread should succeed since WaitEventFlag will abort due to the 92 | //event flag being deleted and the thread being put in a dormant state 93 | int deleteThreadResult = DeleteThread(threadId); 94 | schedf(" DeleteThread returned: %d\n", deleteThreadResult); 95 | } 96 | 97 | { 98 | schedf("corner cases:\n"); 99 | 100 | schedf(" delete with invalid id: "); 101 | doDeleteEventFlag(0); 102 | 103 | schedf(" delete with deleted id: "); 104 | int eventFlagId = generateDeletedEventFlagId(); 105 | doDeleteEventFlag(eventFlagId); 106 | 107 | flushschedf(); 108 | } 109 | 110 | printf("-- TEST END\n"); 111 | 112 | return 0; 113 | } 114 | -------------------------------------------------------------------------------- /tests/vu/assemble/types.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_VU_ASSEMBLE_TYPES_H 2 | #define PS2AUTOTESTS_VU_ASSEMBLE_TYPES_H 3 | 4 | #include 5 | 6 | namespace VU { 7 | 8 | struct LowerOp { 9 | explicit LowerOp() { 10 | // This is an IADD vi00, vi00, vi00 (a NOP.) 11 | v = 0x80000030; 12 | } 13 | explicit LowerOp(u32 imm) { 14 | v = imm; 15 | } 16 | 17 | bool operator == (const LowerOp &rhs) { 18 | return v == rhs.v; 19 | } 20 | bool operator != (const LowerOp &rhs) { 21 | return v != rhs.v; 22 | } 23 | 24 | u32 v; 25 | }; 26 | 27 | struct UpperOp { 28 | explicit UpperOp() { 29 | // This is a NOP. 30 | v = 0x000002FF; 31 | } 32 | explicit UpperOp(u32 imm) { 33 | v = imm; 34 | } 35 | 36 | bool operator == (const UpperOp &rhs) { 37 | return v == rhs.v; 38 | } 39 | bool operator != (const UpperOp &rhs) { 40 | return v != rhs.v; 41 | } 42 | 43 | u32 v; 44 | }; 45 | 46 | typedef u64 LIW; 47 | 48 | // Or together flags to be used in instruction. Upper only. 49 | enum Flags { 50 | UPPER_NONE = 0, 51 | 52 | // Integer in lower. 53 | UPPER_I = 1 << 31, 54 | // End. 55 | UPPER_E = 1 << 30, 56 | // Interlock? 57 | UPPER_M = 1 << 29, 58 | // Debug. 59 | UPPER_D = 1 << 28, 60 | // Trap. 61 | UPPER_T = 1 << 27, 62 | }; 63 | 64 | static inline Flags operator | (const Flags &lhs, const Flags &rhs) { 65 | return Flags((u32)lhs | (u32)rhs); 66 | } 67 | 68 | // Destination masks. Can or together for multiple. 69 | enum Dest { 70 | DEST_X = 1 << 3, 71 | DEST_Y = 1 << 2, 72 | DEST_Z = 1 << 1, 73 | DEST_W = 1 << 0, 74 | 75 | DEST_NONE = 0, 76 | DEST_XY = DEST_X | DEST_Y, 77 | DEST_XYZ = DEST_XY | DEST_Z, 78 | DEST_XYZW = DEST_XYZ | DEST_W, 79 | }; 80 | 81 | static inline Dest operator | (const Dest &lhs, const Dest &rhs) { 82 | return Dest((u32)lhs | (u32)rhs); 83 | } 84 | 85 | // Field specification. Must pick one. 86 | enum Field { 87 | FIELD_X = 0, 88 | FIELD_Y = 1, 89 | FIELD_Z = 2, 90 | FIELD_W = 3, 91 | }; 92 | 93 | enum Reg { 94 | VF00, VF01, VF02, VF03, VF04, VF05, VF06, VF07, 95 | VF08, VF09, VF10, VF11, VF12, VF13, VF14, VF15, 96 | VF16, VF17, VF18, VF19, VF20, VF21, VF22, VF23, 97 | VF24, VF25, VF26, VF27, VF28, VF29, VF30, VF31, 98 | 99 | // Note that these are offset by 32. 100 | VI00, VI01, VI02, VI03, VI04, VI05, VI06, VI07, 101 | VI08, VI09, VI10, VI11, VI12, VI13, VI14, VI15, 102 | 103 | VF_CONST = VF00, 104 | 105 | VI_ZERO = VI00, 106 | VI_SP = VI14, 107 | VI_LR = VI15, 108 | }; 109 | 110 | // Branch type for label fixup. 111 | enum BranchType { 112 | BRANCH_B, 113 | BRANCH_BAL, 114 | BRANCH_IBEQ, 115 | BRANCH_IBGEZ, 116 | BRANCH_IBGTZ, 117 | BRANCH_IBLEZ, 118 | BRANCH_IBLTZ, 119 | BRANCH_IBNE, 120 | }; 121 | 122 | class Block; 123 | 124 | struct Label { 125 | protected: 126 | Label() : dest_(NULL), src_(NULL), upper_() { 127 | } 128 | 129 | void Setup(LIW *src, BranchType type, UpperOp u, Reg s = VF00, Reg t = VF00) { 130 | src_ = src; 131 | upper_ = u; 132 | type_ = type; 133 | s_ = s; 134 | t_ = t; 135 | } 136 | 137 | LIW *dest_; 138 | 139 | // For fixup. This allows writing the corrected instruction later. 140 | LIW *src_; 141 | UpperOp upper_; 142 | BranchType type_; 143 | Reg s_; 144 | Reg t_; 145 | 146 | // Only blocks can create these. 147 | friend class Block; 148 | }; 149 | 150 | } 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /tests/kernel/ee/thread/exit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define STACK_SIZE 0x8000 6 | #define TEST_THREAD_PRIORITY 0x40 7 | 8 | void printResult(u32 threadId, u32 result) { 9 | if(threadId == result) { 10 | schedf("returned thread id\n"); 11 | } else { 12 | schedf("returned %d\n", result); 13 | } 14 | } 15 | 16 | void printThreadStatus(int threadId) { 17 | ee_thread_status_t threadStat; 18 | memset(&threadStat, 0, sizeof(ee_thread_status_t)); 19 | int result = ReferThreadStatus(threadId, &threadStat); 20 | schedf("result: %02x, init prio: %02x, current prio: %02x, status: %02x\n", 21 | result, threadStat.initial_priority, threadStat.current_priority, threadStat.status); 22 | } 23 | 24 | char exitThreadStack[STACK_SIZE] __attribute__ ((aligned(16))); 25 | void exitThreadProc(u32) { 26 | ExitThread(); 27 | SleepThread(); 28 | } 29 | 30 | char exitThreadChangePriorityStack[STACK_SIZE] __attribute__ ((aligned(16))); 31 | void exitThreadChangePriorityProc(u32 newPriority) { 32 | ChangeThreadPriority(GetThreadId(), newPriority); 33 | schedf(" stat after changing priority -> "); 34 | printThreadStatus(GetThreadId()); 35 | ExitThread(); 36 | SleepThread(); 37 | } 38 | 39 | char exitDeleteThreadStack[STACK_SIZE] __attribute__ ((aligned(16))); 40 | void exitDeleteThreadProc(u32) { 41 | ExitDeleteThread(); 42 | SleepThread(); 43 | } 44 | 45 | int createTestThread(void *entry, int prio, void *stack, u32 stackSize) { 46 | ee_thread_t threadParam; 47 | memset(&threadParam, 0, sizeof(ee_thread_t)); 48 | threadParam.func = entry; 49 | threadParam.initial_priority = prio; 50 | threadParam.stack = stack; 51 | threadParam.stack_size = stackSize; 52 | return CreateThread(&threadParam); 53 | } 54 | 55 | int main(int argc, char *argv[]) { 56 | printf("-- TEST BEGIN\n"); 57 | 58 | { 59 | schedf("exit thread:\n"); 60 | 61 | int threadId = createTestThread((void*)&exitThreadProc, TEST_THREAD_PRIORITY - 0x10, exitThreadStack, STACK_SIZE); 62 | StartThread(threadId, NULL); 63 | 64 | s32 result = StartThread(threadId, NULL); 65 | schedf(" start after thread exited -> "); 66 | printResult(threadId, result); 67 | 68 | result = DeleteThread(threadId); 69 | schedf(" delete after thread exited -> "); 70 | printResult(threadId, result); 71 | 72 | flushschedf(); 73 | } 74 | 75 | { 76 | schedf("exit thread (priority change):\n"); 77 | 78 | int threadId = createTestThread((void*)&exitThreadChangePriorityProc, TEST_THREAD_PRIORITY - 0x10, exitThreadChangePriorityStack, STACK_SIZE); 79 | StartThread(threadId, (void*)(TEST_THREAD_PRIORITY - 0x20)); 80 | 81 | schedf(" stat after thread exited -> "); 82 | printThreadStatus(threadId); 83 | 84 | flushschedf(); 85 | } 86 | 87 | { 88 | schedf("exit delete thread:\n"); 89 | 90 | int threadId = createTestThread((void*)&exitDeleteThreadProc, TEST_THREAD_PRIORITY - 0x10, exitDeleteThreadStack, STACK_SIZE); 91 | StartThread(threadId, NULL); 92 | 93 | s32 result = StartThread(threadId, NULL); 94 | schedf(" start after thread exited -> "); 95 | printResult(threadId, result); 96 | 97 | result = DeleteThread(threadId); 98 | schedf(" delete after thread exited -> "); 99 | printResult(threadId, result); 100 | 101 | flushschedf(); 102 | } 103 | 104 | printf("-- TEST END\n"); 105 | 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/convert.cpp: -------------------------------------------------------------------------------- 1 | #include "shared.h" 2 | 3 | #define FF_OP_FUNC(OP, IDENT) \ 4 | static inline void FF_##IDENT(register float &fd, const register float &fs) { \ 5 | asm volatile ( \ 6 | OP " %0, %1\n" \ 7 | : "+f"(fd) : "f"(fs) \ 8 | ); \ 9 | } 10 | 11 | static inline void PRINT_ACC(bool newline) { 12 | static FloatBits result = {0}; 13 | static const float negz = -0.0f; 14 | static const float posz = 0.0f; 15 | 16 | asm volatile ( 17 | // To grab ACC, we use madd.s 0, 0 -> fd = ACC + 0 * 0. 18 | // We use negative zero to avoid changing the sign of ACC (note that it's a multiply, -0 * -0 = +0.) 19 | "madd.s $f4, %0, %1\n" 20 | "swc1 $f4, 0(%2)\n" 21 | : : "f"(negz), "f"(posz), "r"((u32)&result.f) : "$f4" 22 | ); 23 | 24 | printf("%08x/", result.u); 25 | printFloatString(result); 26 | if (newline) { 27 | printf("\n"); 28 | } 29 | } 30 | 31 | #define FF_OP_DO_II(OP, IDENT, d, s) \ 32 | SET_U32(fd); SET_U32(fs); \ 33 | FF_##IDENT(fd, fs); \ 34 | printf(" %s ", OP); \ 35 | PRINT_F(fs, false); \ 36 | printf(": "); \ 37 | PRINT_F(fd, true); 38 | 39 | #define FF_OP_DO_MM(OP, IDENT, d, s) \ 40 | SET_M(fd, d); SET_M(fs, s); \ 41 | FF_##IDENT(fd, fs); \ 42 | printf(" %s %s: ", OP, #s); PRINT_F(fd, true); 43 | 44 | #define TEST_FF_FUNC(OP, IDENT) \ 45 | FF_OP_FUNC(OP, IDENT); \ 46 | static void test_##IDENT() { \ 47 | register float fd, fs; \ 48 | \ 49 | printf("%s:\n", OP); \ 50 | \ 51 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x00000000); \ 52 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x80000000); \ 53 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x3F800000); \ 54 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x40000000); \ 55 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x40400000); \ 56 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x7FFFFFFF); \ 57 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xFFFFFFFF); \ 58 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x7F800000); \ 59 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xFF800000); \ 60 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x00000005); \ 61 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x0000FFFF); \ 62 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x4F000000); \ 63 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xCF000000); \ 64 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x4EFFFFFF); \ 65 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xCEFFFFFF); \ 66 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x3FBEB852); \ 67 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x3FC00000); \ 68 | FF_OP_DO_II(OP, IDENT, 0x1337, 0x3FC147AE); \ 69 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xBFBEB852); \ 70 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xBFC00000); \ 71 | FF_OP_DO_II(OP, IDENT, 0x1337, 0xBFC147AE); \ 72 | \ 73 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_ZERO); \ 74 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_NEGZERO); \ 75 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_ONE); \ 76 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_NEGONE); \ 77 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_MAX_MANTISSA); \ 78 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_MAX_EXP); \ 79 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_MIN_EXP); \ 80 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_MAX); \ 81 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_MIN); \ 82 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_GARBAGE1); \ 83 | FF_OP_DO_MM(OP, IDENT, CF_GARBAGE1, CF_GARBAGE2); \ 84 | \ 85 | printf("\n"); \ 86 | } 87 | 88 | TEST_FF_FUNC("cvt.w.s", cvtws) 89 | TEST_FF_FUNC("cvt.s.w", cvtsw) 90 | 91 | int main(int argc, char **argv) { 92 | printf("-- TEST BEGIN\n"); 93 | 94 | test_cvtws(); 95 | test_cvtsw(); 96 | 97 | printf("-- TEST END\n"); 98 | 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /tests/kernel/iop/messagebox/send.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "mbx-common.h" 5 | 6 | #define STACK_SIZE 0x800 7 | 8 | u32 g_receivedPayload = 0; 9 | 10 | void messageWaitThreadProc(u32 mbxId) { 11 | MSG* msg = NULL; 12 | ReceiveMbx((void**)&msg, mbxId); 13 | g_receivedPayload = msg->payload; 14 | } 15 | 16 | void testMultipleSend(u32 mbxAttr) { 17 | static const int msgCount = 3; 18 | int i = 0; 19 | MSG msg[msgCount]; 20 | 21 | iop_mbx_t mbxInfo = {}; 22 | mbxInfo.option = 0; 23 | mbxInfo.attr = mbxAttr; 24 | s32 mbxId = CreateMbx(&mbxInfo); 25 | 26 | for (i = 0; i < msgCount; i++) { 27 | memset(&msg[i], 0, sizeof(MSG)); 28 | msg[i].header.priority = msgCount - i; 29 | msg[i].payload = i + 1; 30 | SendMbx(mbxId, &msg[i]); 31 | } 32 | 33 | printf(" box contents: "); 34 | printMbx(mbxId); 35 | 36 | DeleteMbx(mbxId); 37 | } 38 | 39 | void testLinkUpdate() { 40 | iop_mbx_t mbxInfo = {}; 41 | mbxInfo.option = 0; 42 | mbxInfo.attr = MBA_THFIFO | MBA_MSFIFO; 43 | s32 mbxId = CreateMbx(&mbxInfo); 44 | 45 | MSG msg1, msg2; 46 | 47 | memset(&msg1, 0, sizeof(MSG)); 48 | memset(&msg2, 0, sizeof(MSG)); 49 | msg1.header.next = (struct iop_message*)&msg2; 50 | 51 | SendMbx(mbxId, &msg1); 52 | 53 | printf(" after sending, msg1's next pointer refers to: "); 54 | if (msg1.header.next == (struct iop_message*)&msg1) { 55 | printf("msg1\n"); 56 | } else if (msg1.header.next == (struct iop_message*)&msg2) { 57 | printf("msg2\n"); 58 | } else { 59 | printf("unknown (%p)\n", msg1.header.next); 60 | } 61 | 62 | DeleteMbx(mbxId); 63 | } 64 | 65 | void testSendWakeup() { 66 | iop_mbx_t mbxInfo = {}; 67 | mbxInfo.option = 0; 68 | mbxInfo.attr = MBA_THFIFO | MBA_MSFIFO; 69 | s32 mbxId = CreateMbx(&mbxInfo); 70 | 71 | iop_thread_t threadInfo = {}; 72 | threadInfo.attr = TH_C; 73 | threadInfo.thread = (void*)&messageWaitThreadProc; 74 | threadInfo.priority = getThreadPriority(TH_SELF) - 1; 75 | threadInfo.stacksize = STACK_SIZE; 76 | s32 thId = CreateThread(&threadInfo); 77 | StartThread(thId, (void*)mbxId); 78 | 79 | printf(" box contents after thread creation: "); 80 | printMbx(mbxId); 81 | 82 | MSG msg = {}; 83 | msg.payload = 0xBEEF; 84 | SendMbx(mbxId, &msg); 85 | 86 | printf(" box contents after send: "); 87 | printMbx(mbxId); 88 | 89 | printf(" received payload: 0x%X\n", g_receivedPayload); 90 | 91 | DeleteMbx(mbxId); 92 | } 93 | 94 | int _start(int argc, char **argv) { 95 | printf("-- TEST BEGIN\n"); 96 | 97 | printf("sending (fifo message queuing):\n"); 98 | testMultipleSend(MBA_THFIFO | MBA_MSFIFO); 99 | 100 | printf("sending (prio message queuing):\n"); 101 | testMultipleSend(MBA_THFIFO | MBA_MSPRI); 102 | 103 | printf("send message linking behavior:\n"); 104 | testLinkUpdate(); 105 | 106 | printf("sending wakeup behavior:\n"); 107 | testSendWakeup(); 108 | 109 | printf("invalid params:\n"); 110 | { 111 | int result = SendMbx(~0, NULL); 112 | printf(" sending message to invalid box: %d\n", result); 113 | 114 | //Sending a null message does seem to work even though it probably has 115 | //dangerous side effects since the message header at address 0 will be modified 116 | //int result = SendMbx(mbxId, NULL); 117 | //printf("sending null message: %d\n", result); 118 | //printMbx(mbxId); 119 | } 120 | 121 | printf("-- TEST END\n"); 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /tests/dma/vif/emit_vifcode.h: -------------------------------------------------------------------------------- 1 | #ifndef PS2AUTOTESTS_DMA_VIF_EMIT_VIFCODE_H 2 | #define PS2AUTOTESTS_DMA_VIF_EMIT_VIFCODE_H 3 | 4 | #include 5 | 6 | namespace VIF { 7 | enum UnpackType { 8 | UNPACK_TYPE_S32 = 0x60 << 24, 9 | UNPACK_TYPE_S16 = 0x61 << 24, 10 | UNPACK_TYPE_S8 = 0x62 << 24, 11 | UNPACK_TYPE_V2_32 = 0x64 << 24, 12 | UNPACK_TYPE_V2_16 = 0x65 << 24, 13 | UNPACK_TYPE_V2_8 = 0x66 << 24, 14 | UNPACK_TYPE_V3_32 = 0x68 << 24, 15 | UNPACK_TYPE_V3_16 = 0x69 << 24, 16 | UNPACK_TYPE_V3_8 = 0x6A << 24, 17 | UNPACK_TYPE_V4_32 = 0x6C << 24, 18 | UNPACK_TYPE_V4_16 = 0x6D << 24, 19 | UNPACK_TYPE_V4_8 = 0x6E << 24, 20 | UNPACK_TYPE_V4_5_5_5_1 = 0x6F << 24, 21 | }; 22 | 23 | enum CmdFlags { 24 | CMD_NORMAL = 0, 25 | CMD_ENABLE_INT = 0x80 << 24, 26 | }; 27 | 28 | enum UnpackFlags { 29 | UNPACK_NORMAL = 0, 30 | UNPACK_VIF1_USE_TOPS = 1 << 15, 31 | UNPACK_ZERO_EXTEND = 1 << 14, 32 | UNPACK_ENABLE_MASKS = 0x10 << 24, 33 | UNPACK_ENABLE_INT = 0x80 << 24, 34 | }; 35 | 36 | static inline UnpackFlags operator | (const UnpackFlags &lhs, const UnpackFlags &rhs) { 37 | return UnpackFlags((u32)lhs | (u32)rhs); 38 | } 39 | 40 | enum Mode { 41 | MODE_NORMAL, 42 | MODE_OFFSET, 43 | MODE_DIFFERENCE, 44 | }; 45 | 46 | class Packet { 47 | public: 48 | Packet(u32 size); 49 | ~Packet(); 50 | 51 | void Reset(); 52 | 53 | void NOP(u16 imm = 0, u8 num = 0, CmdFlags flags = CMD_NORMAL); 54 | void STCYCL(u8 cl, u8 wl, CmdFlags flags = CMD_NORMAL); 55 | // VIF1 only. 56 | void OFFSET(u16 off, CmdFlags flags = CMD_NORMAL); 57 | // VIF1 only. 58 | void BASE(u16 off, CmdFlags flags = CMD_NORMAL); 59 | void ITOP(u16 addr, CmdFlags flags = CMD_NORMAL); 60 | void STMOD(u8 mode, CmdFlags flags = CMD_NORMAL); 61 | // VIF1 only. 62 | void MSKPATH3(bool masked, CmdFlags flags = CMD_NORMAL); 63 | void MARK(u16 mark, CmdFlags flags = CMD_NORMAL); 64 | void FLUSHE(CmdFlags flags = CMD_NORMAL); 65 | // VIF1 only. Waits also for GIF stuff? 66 | void FLUSH(CmdFlags flags = CMD_NORMAL); 67 | // VIF1 only. Waits also for GIF stuff? 68 | void FLUSHA(CmdFlags flags = CMD_NORMAL); 69 | // Note that the address should be divided by 8 (like VU branches.) 70 | void MSCAL(u16 addr, CmdFlags flags = CMD_NORMAL); 71 | // VIF1 only? Same as MSCAL but waits for GIF first? 72 | void MSCALF(u16 addr, CmdFlags flags = CMD_NORMAL); 73 | // Resume execution after next / recent E bit. 74 | void MSCNT(u16 addr, CmdFlags flags = CMD_NORMAL); 75 | void STMASK(u32 mask, CmdFlags flags = CMD_NORMAL); 76 | void STROW(u32 r0, u32 r1, u32 r2, u32 r3, CmdFlags flags = CMD_NORMAL); 77 | void STCOL(u32 c0, u32 c1, u32 c2, u32 c3, CmdFlags flags = CMD_NORMAL); 78 | // Note that the address should be divided by 8 (like VU branches.) 79 | void MPG(u16 addr, u16 size, CmdFlags flags = CMD_NORMAL); 80 | // VIF1 only. Number of qwords to transfer. 81 | void DIRECT(u32 size, CmdFlags flags = CMD_NORMAL); 82 | // VIF1 only. Number of qwords to transfer. 83 | void DIRECTHL(u32 size, CmdFlags flags = CMD_NORMAL); 84 | void UNPACK(UnpackType cmd, u16 size, u16 addr, UnpackFlags flags = UNPACK_NORMAL); 85 | 86 | void Data32(u32 v); 87 | void DataPtr(const void *p, u32 size); 88 | 89 | void *Raw() { 90 | return start_; 91 | } 92 | 93 | protected: 94 | void Emit(u32 v) { 95 | *addr_++ = v; 96 | } 97 | 98 | u32 *start_; 99 | u32 *addr_; 100 | }; 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /tests/cpu/ee_fpu/compare.cpp: -------------------------------------------------------------------------------- 1 | #include "shared.h" 2 | 3 | #define FCMP_OP_FUNC(OP) \ 4 | static inline void FCMP_##OP(register float &fd, const register float &fs) { \ 5 | asm volatile ( \ 6 | "c." #OP ".s %0, %1\n" \ 7 | : "+f"(fd) : "f"(fs) \ 8 | ); \ 9 | } 10 | 11 | static inline void PRINT_FC(bool newline) { 12 | register u32 fcr31 = 0; 13 | 14 | asm volatile ( 15 | "cfc1 %0, $31\n" 16 | : "+r"(fcr31) 17 | ); 18 | 19 | if ((fcr31 >> 23) & 1) { 20 | printf("true"); 21 | } else { 22 | printf("false"); 23 | } 24 | if (newline) { 25 | printf("\n"); 26 | } 27 | } 28 | 29 | #define FCMP_OP_DO_II(OP, s, t) \ 30 | SET_U32(fs); SET_U32(ft); \ 31 | FCMP_##OP(fs, ft); \ 32 | printf(" %s ", #OP); \ 33 | PRINT_F(fs, false); \ 34 | printf(", "); \ 35 | PRINT_F(ft, false); \ 36 | printf(": "); \ 37 | PRINT_FC(true); 38 | 39 | #define FCMP_OP_DO_MM(OP, s, t) \ 40 | SET_M(fs, s); SET_M(ft, t); \ 41 | FCMP_##OP(fs, ft); \ 42 | printf(" %s %s, %s: ", #OP, #s, #t); \ 43 | PRINT_FC(true); 44 | 45 | #define TEST_FCMP_FUNC(OP) \ 46 | FCMP_OP_FUNC(OP); \ 47 | static void test_c_##OP() { \ 48 | register float fs, ft; \ 49 | \ 50 | printf("%s:\n", #OP); \ 51 | \ 52 | FCMP_OP_DO_II(OP, 0x00000000, 0x00000000); \ 53 | FCMP_OP_DO_II(OP, 0x00000000, 0x80000000); \ 54 | FCMP_OP_DO_II(OP, 0x80000000, 0x00000000); \ 55 | FCMP_OP_DO_II(OP, 0x80000000, 0x80000000); \ 56 | FCMP_OP_DO_II(OP, 0x00000000, 0x3F800000); \ 57 | FCMP_OP_DO_II(OP, 0x3F800000, 0x3F800000); \ 58 | FCMP_OP_DO_II(OP, 0x3F800000, 0x00000000); \ 59 | FCMP_OP_DO_II(OP, 0x40000000, 0x40000000); \ 60 | FCMP_OP_DO_II(OP, 0x40400000, 0x3F800000); \ 61 | FCMP_OP_DO_II(OP, 0x40400000, 0x40400000); \ 62 | FCMP_OP_DO_II(OP, 0x7FFFFFFF, 0x7FFFFFFF); \ 63 | FCMP_OP_DO_II(OP, 0x7FFFFFFF, 0xFFFFFFFF); \ 64 | FCMP_OP_DO_II(OP, 0xFFFFFFFF, 0x7FFFFFFF); \ 65 | FCMP_OP_DO_II(OP, 0xFFFFFFFF, 0xFFFFFFFF); \ 66 | FCMP_OP_DO_II(OP, 0x7FFFFFFF, 0x00000000); \ 67 | FCMP_OP_DO_II(OP, 0x00000000, 0x00000001); \ 68 | FCMP_OP_DO_II(OP, 0x00000001, 0x00000000); \ 69 | FCMP_OP_DO_II(OP, 0x00000000, 0x7FFFFFFF); \ 70 | FCMP_OP_DO_II(OP, 0x00000000, 0x7F800000); \ 71 | FCMP_OP_DO_II(OP, 0x7F800000, 0x7F800000); \ 72 | FCMP_OP_DO_II(OP, 0x7F800000, 0x7F800001); \ 73 | FCMP_OP_DO_II(OP, 0x7F800001, 0x7F800000); \ 74 | FCMP_OP_DO_II(OP, 0xFF800000, 0x7F800000); \ 75 | \ 76 | FCMP_OP_DO_MM(OP, CF_ZERO, CF_ZERO); \ 77 | FCMP_OP_DO_MM(OP, CF_ZERO, CF_NEGZERO); \ 78 | FCMP_OP_DO_MM(OP, CF_ONE, CF_ONE); \ 79 | FCMP_OP_DO_MM(OP, CF_ONE, CF_NEGONE); \ 80 | FCMP_OP_DO_MM(OP, CF_MAX_MANTISSA, CF_ONE); \ 81 | FCMP_OP_DO_MM(OP, CF_MAX_EXP, CF_ONE); \ 82 | FCMP_OP_DO_MM(OP, CF_MIN_EXP, CF_ONE); \ 83 | FCMP_OP_DO_MM(OP, CF_ONE, CF_MAX_MANTISSA); \ 84 | FCMP_OP_DO_MM(OP, CF_ONE, CF_MAX_EXP); \ 85 | FCMP_OP_DO_MM(OP, CF_ONE, CF_MIN_EXP); \ 86 | FCMP_OP_DO_MM(OP, CF_MAX, CF_ONE); \ 87 | FCMP_OP_DO_MM(OP, CF_MIN, CF_ONE); \ 88 | FCMP_OP_DO_MM(OP, CF_ONE, CF_MAX); \ 89 | FCMP_OP_DO_MM(OP, CF_ONE, CF_MIN); \ 90 | FCMP_OP_DO_MM(OP, CF_MAX, CF_MAX); \ 91 | FCMP_OP_DO_MM(OP, CF_MIN, CF_MIN); \ 92 | FCMP_OP_DO_MM(OP, CF_GARBAGE1, CF_GARBAGE2); \ 93 | \ 94 | printf("\n"); \ 95 | } 96 | 97 | TEST_FCMP_FUNC(eq) 98 | TEST_FCMP_FUNC(f) 99 | TEST_FCMP_FUNC(le) 100 | TEST_FCMP_FUNC(lt) 101 | 102 | int main(int argc, char **argv) { 103 | printf("-- TEST BEGIN\n"); 104 | 105 | test_c_eq(); 106 | test_c_f(); 107 | test_c_le(); 108 | test_c_lt(); 109 | 110 | printf("-- TEST END\n"); 111 | 112 | return 0; 113 | } 114 | -------------------------------------------------------------------------------- /tests/cpu/iop/lsudelay.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define LOAD_DELAY0_FUNC(OP) \ 5 | void test_delay0_##OP() { \ 6 | const static u32 data = 0x13371337; \ 7 | register u32 res = 0; \ 8 | asm volatile ( \ 9 | ".set noreorder\n" \ 10 | "lui $t0, 0x1122\n" \ 11 | "ori $t0, $t0, 0x3344\n" \ 12 | #OP " $t0, 0(%1)\n" \ 13 | "ori $t0, $0, 0\n" \ 14 | "or %0, $0, $t0\n" \ 15 | "nop\n" \ 16 | : "+&r"(res) : "r"((u32)&data) : "t0" \ 17 | ); \ 18 | printf("%s 0: %08x\n", #OP, res); \ 19 | } 20 | 21 | #define LOAD_DELAY1_FUNC(OP) \ 22 | void test_delay1_##OP() { \ 23 | const static u32 data = 0x13371337; \ 24 | register u32 res = 0; \ 25 | asm volatile ( \ 26 | ".set noreorder\n" \ 27 | "lui $t0, 0x1122\n" \ 28 | "ori $t0, $t0, 0x3344\n" \ 29 | #OP " $t0, 0(%1)\n" \ 30 | "or %0, $0, $t0\n" \ 31 | "nop\n" \ 32 | : "+&r"(res) : "r"((u32)&data) : "t0" \ 33 | ); \ 34 | printf("%s 1: %08x\n", #OP, res); \ 35 | } 36 | 37 | #define LOAD_DELAY2_FUNC(OP) \ 38 | void test_delay2_##OP() { \ 39 | const static u32 data = 0x13371337; \ 40 | register u32 res = 0; \ 41 | asm volatile ( \ 42 | ".set noreorder\n" \ 43 | "lui $t0, 0x1122\n" \ 44 | "ori $t0, $t0, 0x3344\n" \ 45 | #OP " $t0, 0(%1)\n" \ 46 | "nop\n" \ 47 | "or %0, $0, $t0\n" \ 48 | "nop\n" \ 49 | : "+&r"(res) : "r"((u32)&data) : "t0" \ 50 | ); \ 51 | printf("%s 2: %08x\n", #OP, res); \ 52 | } 53 | 54 | void test_delay_lw_branch() { 55 | const static u32 data = 0x13371337; 56 | register u32 res = 0; 57 | asm volatile ( 58 | ".set noreorder\n" 59 | "lui $t0, 0x1122\n" 60 | "ori $t0, $t0, 0x3344\n" 61 | "ori $t1, $t0, 0\n" 62 | "lw $t0, 0(%1)\n" 63 | "beq $t0, $t1, lw_branch_equal\n" 64 | "nop\n" 65 | 66 | "ori %0, $0, 1\n" 67 | "b lw_branch_done\n" 68 | "nop\n" 69 | 70 | "lw_branch_equal:\n" 71 | "ori %0, $0, 2\n" 72 | 73 | "lw_branch_done:\n" 74 | "nop\n" 75 | : "+&r"(res) : "r"((u32)&data) : "t0", "t1" 76 | ); 77 | printf("lw then branch: %d\n", res); 78 | } 79 | 80 | void test_delay1_ld() { 81 | const static u32 data[2] = {0x13371337, 0x13371337}; 82 | register u32 res1 = 0; 83 | register u32 res2 = 0; 84 | asm volatile ( 85 | ".set noreorder\n" 86 | "lui $t0, 0x1122\n" 87 | "ori $t0, $t0, 0x3344\n" 88 | "ori $t1, $t0, 0\n" 89 | "ld $t0, 0(%2)\n" 90 | "ori $t1, $0, 0\n" 91 | "move %0, $t0\n" 92 | "move %1, $t1\n" 93 | "nop\n" 94 | : "+&r"(res1), "+&r"(res2) : "r"((u32)&data[0]) : "t0", "t1" 95 | ); 96 | printf("ld 1: %08x %08x\n", res1, res2); 97 | } 98 | 99 | void test_delay2_ld() { 100 | const static u32 data[2] = {0x13371337, 0x13371337}; 101 | register u32 res1 = 0; 102 | register u32 res2 = 0; 103 | asm volatile ( 104 | ".set noreorder\n" 105 | "lui $t0, 0x1122\n" 106 | "ori $t0, $t0, 0x3344\n" 107 | "ori $t1, $t0, 0\n" 108 | "ld $t0, 0(%2)\n" 109 | "nop\n" 110 | "move %0, $t0\n" 111 | "move %1, $t1\n" 112 | "nop\n" 113 | : "+&r"(res1), "+&r"(res2) : "r"((u32)&data[0]) : "t0", "t1" 114 | ); 115 | printf("ld 2: %08x %08x\n", res1, res2); 116 | } 117 | 118 | LOAD_DELAY0_FUNC(lb) 119 | LOAD_DELAY0_FUNC(lw) 120 | LOAD_DELAY1_FUNC(lb) 121 | LOAD_DELAY1_FUNC(lw) 122 | LOAD_DELAY2_FUNC(lb) 123 | LOAD_DELAY2_FUNC(lw) 124 | 125 | int _start(int argc, char *argv[]) { 126 | printf("-- TEST BEGIN\n"); 127 | 128 | test_delay0_lb(); 129 | test_delay0_lw(); 130 | test_delay1_lb(); 131 | test_delay1_lw(); 132 | test_delay2_lb(); 133 | test_delay2_lw(); 134 | 135 | test_delay1_ld(); 136 | test_delay2_ld(); 137 | 138 | test_delay_lw_branch(); 139 | 140 | printf("-- TEST END\n"); 141 | 142 | return 0; 143 | } 144 | -------------------------------------------------------------------------------- /tests/vu/lower/random.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../test_runner.h" 3 | 4 | static const u32 __attribute__((aligned(16))) C_ZEROONE[4] = {0x3F800000, 0x3FFFFFFF, 0x00000000, 0xFFFFFFFF}; 5 | static const u32 __attribute__((aligned(16))) C_GARBAGE[4] = {0x01234567, 0x89ABCDEF, 0xFEDCBA98, 0x76543210}; 6 | 7 | static u32 *const CVF_ZEROONE = (u32 *)(vu1_mem + 0x0000); 8 | static u32 *const CVF_GARBAGE = (u32 *)(vu1_mem + 0x0010); 9 | 10 | static void setup_vf_constants() { 11 | *(vu128 *)CVF_ZEROONE = *(vu128 *)C_ZEROONE; 12 | *(vu128 *)CVF_GARBAGE = *(vu128 *)C_GARBAGE; 13 | } 14 | 15 | class RandomTestRunner : public TestRunner { 16 | public: 17 | RandomTestRunner(int vu) : TestRunner(vu) { 18 | } 19 | 20 | void PerformInit() { 21 | using namespace VU; 22 | 23 | Reset(); 24 | 25 | WrLoadFloatRegister(DEST_XYZW, VF16, CVF_GARBAGE); 26 | 27 | Wr(RINIT(FIELD_X, VF16)); 28 | Wr(RGET(DEST_XYZW, VF01)); 29 | Wr(RINIT(FIELD_Y, VF16)); 30 | Wr(RGET(DEST_XYZW, VF02)); 31 | Wr(RINIT(FIELD_Z, VF16)); 32 | Wr(RGET(DEST_XYZW, VF03)); 33 | Wr(RINIT(FIELD_W, VF16)); 34 | Wr(RGET(DEST_XYZW, VF04)); 35 | 36 | Execute(); 37 | 38 | printf("RINIT: \n"); 39 | printf(" "); PrintRegister(VF01, true); 40 | printf(" "); PrintRegister(VF02, true); 41 | printf(" "); PrintRegister(VF03, true); 42 | printf(" "); PrintRegister(VF04, true); 43 | } 44 | 45 | void PerformXor() { 46 | using namespace VU; 47 | 48 | Reset(); 49 | 50 | WrLoadFloatRegister(DEST_XYZW, VF16, CVF_GARBAGE); 51 | 52 | Wr(RINIT(FIELD_X, VF00)); 53 | Wr(RXOR(FIELD_X, VF16)); 54 | Wr(RGET(DEST_XYZW, VF01)); 55 | Wr(RXOR(FIELD_Y, VF16)); 56 | Wr(RGET(DEST_XYZW, VF02)); 57 | Wr(RXOR(FIELD_Z, VF16)); 58 | Wr(RGET(DEST_XYZW, VF03)); 59 | Wr(RXOR(FIELD_W, VF16)); 60 | Wr(RGET(DEST_XYZW, VF04)); 61 | 62 | Execute(); 63 | 64 | printf("RXOR: \n"); 65 | printf(" "); PrintRegister(VF01, true); 66 | printf(" "); PrintRegister(VF02, true); 67 | printf(" "); PrintRegister(VF03, true); 68 | printf(" "); PrintRegister(VF04, true); 69 | } 70 | 71 | void PerformNext_M(const char *fieldName, VU::Field field, const char *sname, const u32* s) { 72 | using namespace VU; 73 | 74 | printf(" %s[%s]: \n", sname, fieldName); 75 | 76 | Reset(); 77 | 78 | WrLoadFloatRegister(DEST_XYZW, VF16, s); 79 | 80 | Wr(RINIT(field, VF16)); 81 | Wr(RNEXT(DEST_XYZW, VF01)); 82 | Wr(RNEXT(DEST_XYZW, VF02)); 83 | Wr(RNEXT(DEST_XYZW, VF03)); 84 | Wr(RNEXT(DEST_XYZW, VF04)); 85 | 86 | Execute(); 87 | 88 | printf(" 1: "); PrintRegister(VF01, true); 89 | printf(" 2: "); PrintRegister(VF02, true); 90 | printf(" 3: "); PrintRegister(VF03, true); 91 | printf(" 4: "); PrintRegister(VF04, true); 92 | } 93 | 94 | #define PerformNext_M(field, s) PerformNext_M(#field, field, #s, s) 95 | 96 | void PerformNext() 97 | { 98 | printf("RNEXT:\n"); 99 | 100 | PerformNext_M(VU::FIELD_X, CVF_ZEROONE); 101 | PerformNext_M(VU::FIELD_Y, CVF_ZEROONE); 102 | PerformNext_M(VU::FIELD_Z, CVF_ZEROONE); 103 | PerformNext_M(VU::FIELD_W, CVF_ZEROONE); 104 | PerformNext_M(VU::FIELD_X, CVF_GARBAGE); 105 | PerformNext_M(VU::FIELD_Y, CVF_GARBAGE); 106 | PerformNext_M(VU::FIELD_Z, CVF_GARBAGE); 107 | PerformNext_M(VU::FIELD_W, CVF_GARBAGE); 108 | } 109 | 110 | #undef PerformNext_M 111 | }; 112 | 113 | int main(int argc, char *argv[]) { 114 | printf("-- TEST BEGIN\n"); 115 | 116 | setup_vf_constants(); 117 | 118 | RandomTestRunner runner(1); 119 | runner.PerformInit(); 120 | runner.PerformXor(); 121 | runner.PerformNext(); 122 | 123 | printf("-- TEST END\n"); 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /tests/dma/vif/unpack.expected: -------------------------------------------------------------------------------- 1 | -- TEST BEGIN 2 | == VIF0 == 3 | Simple UNPACK S8(signExtend) - ffffff88 - ffffff88 - ffffff88 - ffffff88 4 | Simple UNPACK S8(zeroExtend) - 00000088 - 00000088 - 00000088 - 00000088 5 | Simple UNPACK S16(signExtend) - ffff8888 - ffff8888 - ffff8888 - ffff8888 6 | Simple UNPACK S16(zeroExtend) - 00008888 - 00008888 - 00008888 - 00008888 7 | Simple UNPACK S32 - 88888888 - 88888888 - 88888888 - 88888888 8 | Simple UNPACK V2-8(signExtend) - ffffff88 - ffffff99 - ffffff88 - ffffff99 9 | Simple UNPACK V2-8(zeroExtend) - 00000088 - 00000099 - 00000088 - 00000099 10 | Simple UNPACK V2-16(signExtend) - ffff8888 - ffff9999 - ffff8888 - ffff9999 11 | Simple UNPACK V2-16(zeroExtend) - 00008888 - 00009999 - 00008888 - 00009999 12 | Simple UNPACK V2-32 - 88888888 - 99999999 - 88888888 - 99999999 13 | Simple UNPACK V3-8(signExtend) - ffffff88 - ffffff99 - ffffffaa - 00000000 14 | Simple UNPACK V3-8(zeroExtend) - 00000088 - 00000099 - 000000aa - 00000000 15 | Simple UNPACK V3-16(signExtend) - ffff8888 - ffff9999 - ffffaaaa - 00000000 16 | Simple UNPACK V3-16(zeroExtend) - 00008888 - 00009999 - 0000aaaa - 00000000 17 | Simple UNPACK V3-32 - 88888888 - 99999999 - aaaaaaaa - 00000000 18 | Simple UNPACK V4-8(signExtend) - ffffff88 - ffffff99 - ffffffaa - ffffffbb 19 | Simple UNPACK V4-8(zeroExtend) - 00000088 - 00000099 - 000000aa - 000000bb 20 | Simple UNPACK V4-16(signExtend) - ffff8888 - ffff9999 - ffffaaaa - ffffbbbb 21 | Simple UNPACK V4-16(zeroExtend) - 00008888 - 00009999 - 0000aaaa - 0000bbbb 22 | Simple UNPACK V4-32 - 88888888 - 99999999 - aaaaaaaa - bbbbbbbb 23 | Simple UNPACK V4-5 - 000000f8 - 000000f8 - 000000f8 - 00000080 24 | Set 4096 bytes UNPACK - ffeeddcc - ffeeddcc - 33221100 - 33221100 25 | No data UNPACK(NUM: 1) -> VPS before: 0, VPS after: 1, CODE: 62010000, NUM: 1 26 | No data UNPACK(NUM: 255) -> VPS before: 0, VPS after: 1, CODE: 62ff0000, NUM: 255 27 | No data UNPACK(NUM: 256) -> VPS before: 0, VPS after: 1, CODE: 62000000, NUM: 0 28 | 29 | == VIF1 == 30 | Simple UNPACK S8(signExtend) - ffffff88 - ffffff88 - ffffff88 - ffffff88 31 | Simple UNPACK S8(zeroExtend) - 00000088 - 00000088 - 00000088 - 00000088 32 | Simple UNPACK S16(signExtend) - ffff8888 - ffff8888 - ffff8888 - ffff8888 33 | Simple UNPACK S16(zeroExtend) - 00008888 - 00008888 - 00008888 - 00008888 34 | Simple UNPACK S32 - 88888888 - 88888888 - 88888888 - 88888888 35 | Simple UNPACK V2-8(signExtend) - ffffff88 - ffffff99 - ffffff88 - ffffff99 36 | Simple UNPACK V2-8(zeroExtend) - 00000088 - 00000099 - 00000088 - 00000099 37 | Simple UNPACK V2-16(signExtend) - ffff8888 - ffff9999 - ffff8888 - ffff9999 38 | Simple UNPACK V2-16(zeroExtend) - 00008888 - 00009999 - 00008888 - 00009999 39 | Simple UNPACK V2-32 - 88888888 - 99999999 - 88888888 - 99999999 40 | Simple UNPACK V3-8(signExtend) - ffffff88 - ffffff99 - ffffffaa - 00000000 41 | Simple UNPACK V3-8(zeroExtend) - 00000088 - 00000099 - 000000aa - 00000000 42 | Simple UNPACK V3-16(signExtend) - ffff8888 - ffff9999 - ffffaaaa - 00000000 43 | Simple UNPACK V3-16(zeroExtend) - 00008888 - 00009999 - 0000aaaa - 00000000 44 | Simple UNPACK V3-32 - 88888888 - 99999999 - aaaaaaaa - 00000000 45 | Simple UNPACK V4-8(signExtend) - ffffff88 - ffffff99 - ffffffaa - ffffffbb 46 | Simple UNPACK V4-8(zeroExtend) - 00000088 - 00000099 - 000000aa - 000000bb 47 | Simple UNPACK V4-16(signExtend) - ffff8888 - ffff9999 - ffffaaaa - ffffbbbb 48 | Simple UNPACK V4-16(zeroExtend) - 00008888 - 00009999 - 0000aaaa - 0000bbbb 49 | Simple UNPACK V4-32 - 88888888 - 99999999 - aaaaaaaa - bbbbbbbb 50 | Simple UNPACK V4-5 - 000000f8 - 000000f8 - 000000f8 - 00000080 51 | Set 4096 bytes UNPACK - ffeeddcc - ffeeddcc - 33221100 - 33221100 52 | No data UNPACK(NUM: 1) -> VPS before: 0, VPS after: 1, CODE: 62010000, NUM: 1 53 | No data UNPACK(NUM: 255) -> VPS before: 0, VPS after: 1, CODE: 62ff0000, NUM: 255 54 | No data UNPACK(NUM: 256) -> VPS before: 0, VPS after: 1, CODE: 62000000, NUM: 256 55 | 56 | -- TEST END 57 | -------------------------------------------------------------------------------- /tests/kernel/iop/thread/releasewait.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "thread-common.h" 7 | 8 | #define STACK_SIZE 0x800 9 | 10 | void nullThreadProc(u32 param) { 11 | //Do nothing 12 | } 13 | 14 | void sleepThreadProc(s32 *result) { 15 | *result = SleepThread(); 16 | } 17 | 18 | void delayThreadProc(s32 *result) { 19 | *result = DelayThread(~0); 20 | } 21 | 22 | void semaThreadProc(s32 *result) { 23 | iop_sema_t dummySemaInfo = {}; 24 | dummySemaInfo.attr = 0; 25 | dummySemaInfo.option = 0; 26 | dummySemaInfo.initial = 0; 27 | dummySemaInfo.max = 1; 28 | u32 dummySema = CreateSema(&dummySemaInfo); 29 | *result = WaitSema(dummySema); 30 | } 31 | 32 | void eventFlagThreadProc(s32 *result) { 33 | iop_event_t dummyEventFlagInfo = {}; 34 | dummyEventFlagInfo.attr = 0; 35 | dummyEventFlagInfo.bits = 0; 36 | u32 dummyEventFlag = CreateEventFlag(&dummyEventFlagInfo); 37 | *result = WaitEventFlag(dummyEventFlag, ~0, WEF_CLEAR | WEF_AND, NULL); 38 | } 39 | 40 | void messageBoxThreadProc(s32 *result) { 41 | iop_mbx_t dummyMessageBoxInfo = {}; 42 | dummyMessageBoxInfo.attr = 0; 43 | dummyMessageBoxInfo.option = 0; 44 | u32 dummyMessageBox = CreateMbx(&dummyMessageBoxInfo); 45 | *result = ReceiveMbx(NULL, dummyMessageBox); 46 | } 47 | 48 | void doReleaseWaitThread(s32 threadId) { 49 | s32 result = ReleaseWaitThread(threadId); 50 | if(result >= 0) { 51 | schedf("succeeded -> result: %d\n", result); 52 | } else { 53 | schedf("failed -> result: %d\n", result); 54 | } 55 | } 56 | 57 | void testRunningThread() { 58 | schedf("running thread: "); 59 | 60 | s32 currentThreadPriority = getThreadPriority(TH_SELF); 61 | s32 threadId = createTestThread(&nullThreadProc, currentThreadPriority + 1, STACK_SIZE); 62 | StartThread(threadId, 0); 63 | 64 | doReleaseWaitThread(threadId); 65 | 66 | //Let the thread execute (terminate doesn't seem to work properly otherwise) 67 | DelayThread(1); 68 | 69 | TerminateThread(threadId); 70 | DeleteThread(threadId); 71 | 72 | flushschedf(); 73 | } 74 | 75 | void testDormantThread() { 76 | schedf("dormant thread: "); 77 | 78 | s32 threadId = createTestThread(&nullThreadProc, 0x20, STACK_SIZE); 79 | 80 | doReleaseWaitThread(threadId); 81 | 82 | DeleteThread(threadId); 83 | 84 | flushschedf(); 85 | } 86 | 87 | void testInvalidThread() { 88 | schedf("invalid thread: "); 89 | 90 | doReleaseWaitThread(~0); 91 | 92 | flushschedf(); 93 | } 94 | 95 | void testWaitingThread(const char *waitType, void *threadProc) { 96 | schedf("%s thread:\n", waitType); 97 | 98 | s32 waitResult = 0; 99 | s32 currentThreadPriority = getThreadPriority(TH_SELF); 100 | s32 threadId = createTestThread(threadProc, currentThreadPriority - 1, STACK_SIZE); 101 | StartThread(threadId, &waitResult); 102 | 103 | schedf(" ReleaseWaitThread returned: "); 104 | doReleaseWaitThread(threadId); 105 | 106 | schedf(" wait function returned: %d\n", waitResult); 107 | 108 | TerminateThread(threadId); 109 | DeleteThread(threadId); 110 | 111 | flushschedf(); 112 | } 113 | 114 | void testSelf() { 115 | schedf("self thread:\n"); 116 | 117 | schedf(" With TH_SELF: "); 118 | doReleaseWaitThread(TH_SELF); 119 | 120 | schedf(" With current thread id: "); 121 | doReleaseWaitThread(GetThreadId()); 122 | 123 | flushschedf(); 124 | } 125 | 126 | int _start(int argc, char **argv) { 127 | printf("-- TEST BEGIN\n"); 128 | 129 | testRunningThread(); 130 | testDormantThread(); 131 | testInvalidThread(); 132 | testWaitingThread("sleeping", &sleepThreadProc); 133 | testWaitingThread("delayed", &delayThreadProc); 134 | testWaitingThread("waiting semaphore", &semaThreadProc); 135 | testWaitingThread("waiting event flag", &eventFlagThreadProc); 136 | testWaitingThread("waiting message box", &messageBoxThreadProc); 137 | testSelf(); 138 | 139 | printf("-- TEST END\n"); 140 | return 0; 141 | } 142 | --------------------------------------------------------------------------------