From 2b7fbf33c5d21249187e7ae555789b9f032cbc65 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Mon, 1 Dec 2025 09:01:37 -0600 Subject: [PATCH 1/2] add: Implementation of rmreset module --- iop/system/rmreset/Makefile | 18 ++++ iop/system/rmreset/README.md | 15 +++ iop/system/rmreset/src/imports.lst | 4 + iop/system/rmreset/src/irx_imports.h | 22 ++++ iop/system/rmreset/src/rmreset.c | 154 +++++++++++++++++++++++++++ 5 files changed, 213 insertions(+) create mode 100644 iop/system/rmreset/Makefile create mode 100644 iop/system/rmreset/README.md create mode 100644 iop/system/rmreset/src/imports.lst create mode 100644 iop/system/rmreset/src/irx_imports.h create mode 100644 iop/system/rmreset/src/rmreset.c diff --git a/iop/system/rmreset/Makefile b/iop/system/rmreset/Makefile new file mode 100644 index 000000000000..f00d01ee82dd --- /dev/null +++ b/iop/system/rmreset/Makefile @@ -0,0 +1,18 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +IOP_IMPORT_INCS += \ + system/loadcore \ + system/stdio + +IOP_OBJS = rmreset.o imports.o + +include $(PS2SDKSRC)/Defs.make +include $(PS2SDKSRC)/iop/Rules.bin.make +include $(PS2SDKSRC)/iop/Rules.make +include $(PS2SDKSRC)/iop/Rules.release diff --git a/iop/system/rmreset/README.md b/iop/system/rmreset/README.md new file mode 100644 index 000000000000..ef10bedf6f13 --- /dev/null +++ b/iop/system/rmreset/README.md @@ -0,0 +1,15 @@ +# Remote Reset + +This module will reset the SCPH-10160 IR receiver to gamepad emulation mode. + +## Configurations + +There are multiple configurations of this library, allowing the choice of +balancing between size, speed, and features. + +* `rmreset` -> The recommended version. + +## How to use this module in your program + +In order to use this module in your program, use `LoadModule` or \ +`LoadModuleBuffer` with no arguments. diff --git a/iop/system/rmreset/src/imports.lst b/iop/system/rmreset/src/imports.lst new file mode 100644 index 000000000000..dbcef7a9f426 --- /dev/null +++ b/iop/system/rmreset/src/imports.lst @@ -0,0 +1,4 @@ + +stdio_IMPORTS_start +I_printf +stdio_IMPORTS_end diff --git a/iop/system/rmreset/src/irx_imports.h b/iop/system/rmreset/src/irx_imports.h new file mode 100644 index 000000000000..f95c60773386 --- /dev/null +++ b/iop/system/rmreset/src/irx_imports.h @@ -0,0 +1,22 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +# +# Defines all IRX imports. +*/ + +#ifndef IOP_IRX_IMPORTS_H +#define IOP_IRX_IMPORTS_H + +#include + +/* Please keep these in alphabetical order! */ + +#include + +#endif /* IOP_IRX_IMPORTS_H */ diff --git a/iop/system/rmreset/src/rmreset.c b/iop/system/rmreset/src/rmreset.c new file mode 100644 index 000000000000..5efefa4a19e1 --- /dev/null +++ b/iop/system/rmreset/src/rmreset.c @@ -0,0 +1,154 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +*/ + +#include "irx_imports.h" +#include +#include + +#ifdef _IOP +IRX_ID("rmreset", 1, 1); +#endif +// Based on the module from ROM 1.20+. + +static void sio2_ctrl_set(u32 val) +{ + USE_IOP_MMIO_HWPORT(); + + iop_mmio_hwport->sio2.ctrl = val; +} + +static u32 sio2_ctrl_get(void) +{ + USE_IOP_MMIO_HWPORT(); + + return iop_mmio_hwport->sio2.ctrl; +} + +static u32 sio2_stat6c_get(void) +{ + USE_IOP_MMIO_HWPORT(); + + return iop_mmio_hwport->sio2.recv1; +} + +static void sio2_portN_ctrl1_set(int N, u32 val) +{ + USE_IOP_MMIO_HWPORT(); + + iop_mmio_hwport->sio2.send1_2_buf[N * 2] = val; +} + +// Unused func removed + +static void sio2_portN_ctrl2_set(int N, u32 val) +{ + USE_IOP_MMIO_HWPORT(); + + iop_mmio_hwport->sio2.send1_2_buf[(N * 2) + 1] = val; +} + +// Unused func removed + +// Unused func removed + +static void sio2_regN_set(int N, u32 val) +{ + USE_IOP_MMIO_HWPORT(); + + iop_mmio_hwport->sio2.send3_buf[N] = val; +} + +// Unused func removed + +// Unused func removed + +// Unused func removed + +// Unused func removed + +// Unused func removed + +// Unused func removed + +static void sio2_data_out(u8 val) +{ + USE_IOP_MMIO_HWPORT(); + + iop_mmio_hwport->sio2.out_fifo = val; +} + +static u8 sio2_data_in(void) +{ + USE_IOP_MMIO_HWPORT(); + + return iop_mmio_hwport->sio2.in_fifo; +} + +// Unused func removed + +// Unused func removed + +int _start(int ac, char **av) +{ + u32 ctrl_save; + int i; + // Unofficial: shrink buffer + char inoutbuf[7]; + + (void)ac; + (void)av; + + printf("rmreset start\n"); + ctrl_save = sio2_ctrl_get(); + sio2_ctrl_set(0xCu); + for ( i = 0; i < 4; i += 1 ) + { + sio2_portN_ctrl1_set(i, 0xC0C0050F); + sio2_portN_ctrl2_set(i, 0x1060014u); + } + sio2_regN_set(0, 0x1C0740u); + sio2_regN_set(1, 0); + inoutbuf[0] = 0x61; + inoutbuf[1] = 6; + inoutbuf[2] = 3; + for ( i = 3; i < (int)(sizeof(inoutbuf)); i += 1 ) + inoutbuf[i] = 0; + for ( i = 0; i < (int)(sizeof(inoutbuf)); i += 1 ) + sio2_data_out(inoutbuf[i]); + sio2_ctrl_set(0xB1u); + while ( !((sio2_stat6c_get() >> 12) & 1) ) + ; + for ( i = 0; i < 7; i += 1 ) + sio2_data_in(); + sio2_ctrl_set(0xCu); + for ( i = 0; i < 4; i += 1 ) + { + sio2_portN_ctrl1_set(i, 0xC0C0050F); + sio2_portN_ctrl2_set(i, 0x1060014u); + } + sio2_regN_set(0, 0x1C0741u); + sio2_regN_set(1, 0); + inoutbuf[0] = 0x61; + inoutbuf[1] = 6; + inoutbuf[2] = 3; + for ( i = 3; i < (int)(sizeof(inoutbuf)); i += 1 ) + inoutbuf[i] = 0; + for ( i = 0; i < (int)(sizeof(inoutbuf)); i += 1 ) + sio2_data_out(inoutbuf[i]); + sio2_ctrl_set(0xB1u); + while ( !((sio2_stat6c_get() >> 12) & 1) ) + ; + for ( i = 0; i < 7; i += 1 ) + sio2_data_in(); + sio2_ctrl_set(0xCu); + sio2_ctrl_set(ctrl_save & ~1); + printf("rmreset end\n"); + return MODULE_NO_RESIDENT_END; +} From 4524bd400d79ea900ebaec2d566f70e7f1ecaba4 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Mon, 1 Dec 2025 09:01:41 -0600 Subject: [PATCH 2/2] buildsystem: Hook up newly-added modules to buildsystem --- iop/system/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/iop/system/Makefile b/iop/system/Makefile index bb6527afadf2..abadd53b1080 100644 --- a/iop/system/Makefile +++ b/iop/system/Makefile @@ -32,6 +32,7 @@ SUBDIRS = \ rmman \ rmman2 \ rmmanx \ + rmreset \ rmtapman \ rpadman \ sbusintr \