Skip to content

Kernel Patches

Nicolas Noble edited this page Jan 1, 2021 · 4 revisions

Games will sometimes patch the kernel. This page will document these patches, and the way they work against OpenBIOS

Exception handler

This one replaces the first 14 instructions of the exception handler. See https://github.com/grumpycoders/pcsx-redux/blob/main/src/mips/openbios/kernel/vectors.s#L48 for the location of the patch.

OpenBIOS patch
nop nop
nop nop
nop li $k0, 0x0100
nop lw $k0, 0x08($k0)
li $k0, 0x0100 nop
lw $k0, 0x08($k0) lw $k0, 0x00($k0)
nop nop
lw $k0, 0x00($k0) addi $k0, 8
nop sw $at, 0x04($k0)
addi $k0, 8 sw $v0, 0x08($k0)
sw $at, 0x04($k0) sw $v1, 0x0c($k0)
sw $v0, 0x08($k0) sw $ra, 0x7c($k0)
sw $v1, 0x0c($k0) mfc0 $v0, Cause
sw $ra, 0x7c($k0) nop

The patch merely moves the first few instructions of the exception handler up by 2.

The interesting part about it is that it'll keep the jal getCop0CauseAndEPC after these instructions intact, which will be redundant. The patch is likely to be relevant only against an earlier version of the PSX Kernel.