From a0bcd41b2674ea79eb94abfdada760241f098b14 Mon Sep 17 00:00:00 2001 From: israpps <57065102+israpps@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:21:11 -0300 Subject: [PATCH 1/4] add dogbait --- iop/Makefile | 1 + iop/system2x6/Makefile | 12 ++++++ iop/system2x6/dogbait/Makefile | 16 ++++++++ iop/system2x6/dogbait/README.md | 18 +++++++++ iop/system2x6/dogbait/src/imports.lst | 17 ++++++++ iop/system2x6/dogbait/src/irx_imports.h | 26 ++++++++++++ iop/system2x6/dogbait/src/main.c | 54 +++++++++++++++++++++++++ 7 files changed, 144 insertions(+) create mode 100644 iop/system2x6/Makefile create mode 100644 iop/system2x6/dogbait/Makefile create mode 100644 iop/system2x6/dogbait/README.md create mode 100644 iop/system2x6/dogbait/src/imports.lst create mode 100644 iop/system2x6/dogbait/src/irx_imports.h create mode 100644 iop/system2x6/dogbait/src/main.c diff --git a/iop/Makefile b/iop/Makefile index cca19a2d41c..002d78e3c5a 100644 --- a/iop/Makefile +++ b/iop/Makefile @@ -22,6 +22,7 @@ SUBDIRS = \ sound \ startup \ system \ + system2x6 \ tcpip \ usb diff --git a/iop/system2x6/Makefile b/iop/system2x6/Makefile new file mode 100644 index 00000000000..9cbef0f4855 --- /dev/null +++ b/iop/system2x6/Makefile @@ -0,0 +1,12 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +SUBDIRS = dogbait + +include $(PS2SDKSRC)/Defs.make +include $(PS2SDKSRC)/Rules.make diff --git a/iop/system2x6/dogbait/Makefile b/iop/system2x6/dogbait/Makefile new file mode 100644 index 00000000000..0010a652520 --- /dev/null +++ b/iop/system2x6/dogbait/Makefile @@ -0,0 +1,16 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2009, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +IOP_BIN = dogbait.irx +IOP_SRC_DIR = src/ +IOP_OBJS = main.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/system2x6/dogbait/README.md b/iop/system2x6/dogbait/README.md new file mode 100644 index 00000000000..5930fa1726f --- /dev/null +++ b/iop/system2x6/dogbait/README.md @@ -0,0 +1,18 @@ +# Dogbait + +This module provides a thread to trick the namco arcade system 246/256 watchdog, to avoit it from shutting down the machine if security dongle is not connected for some time. + +its implementation could be considered a fusion of `rom0:LED` and `rom0:DAEMON` (without dongle spamming) + +## How to use this module in your program + +Use `SifLoadStartModule` or `LoadModuleBuffer` directly. + +due to the purpose of this module, checking if the module loaded successfully and stayed resident on IOP is important + +like this: +```c +int ret, id; +id = LoadModuleBuffer(dogbait_irx, size_dogbait_irx, 0, NULL, &ret); +if (id<0 || ret == 1) we_have_an_error(); +``` diff --git a/iop/system2x6/dogbait/src/imports.lst b/iop/system2x6/dogbait/src/imports.lst new file mode 100644 index 00000000000..a2373cff023 --- /dev/null +++ b/iop/system2x6/dogbait/src/imports.lst @@ -0,0 +1,17 @@ +thbase_IMPORTS_start +I_CreateThread +I_StartThread +I_DelayThread +thbase_IMPORTS_end + +stdio_IMPORTS_start +I_printf +stdio_IMPORTS_end + +intrman_IMPORTS_start +I_CpuEnableIntr +intrman_IMPORTS_end + +cdvdman_IMPORTS_start +I_sceCdApplySCmd +cdvdman_IMPORTS_end diff --git a/iop/system2x6/dogbait/src/irx_imports.h b/iop/system2x6/dogbait/src/irx_imports.h new file mode 100644 index 00000000000..502d9f71970 --- /dev/null +++ b/iop/system2x6/dogbait/src/irx_imports.h @@ -0,0 +1,26 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2009, 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 +#include +#include +#include +#include + +#endif /* IOP_IRX_IMPORTS_H */ diff --git a/iop/system2x6/dogbait/src/main.c b/iop/system2x6/dogbait/src/main.c new file mode 100644 index 00000000000..690a3984bf6 --- /dev/null +++ b/iop/system2x6/dogbait/src/main.c @@ -0,0 +1,54 @@ +#include "irx_imports.h" + +#define MODNAME "dogbait" +#define MAJOR 1 +#define MINOR 0 + +#ifdef DEBUG +#define DPRINTF(fmt, x...) printf(MODNAME ": " fmt, ##x) +#else +#define DPRINTF(x...) +#endif + +IRX_ID(MODNAME, MAJOR, MINOR); +char rdata[16]; +char wdata[2] = {0x42, (char)(1 << 8)}; + +//the loop waiting was made to mirror what rom0:DAEMON did +void bait(void*) +{ + int x; + printf("DOGBAIT v%d.%d by El_isra\n", MAJOR, MINOR); + do { +#ifdef DEBUG + x = +#endif + //thanks uyjulian for the idea. arcade CDVDMAN has the blue led control export stubbed so directly calling the CMD was the only choice + sceCdApplySCmd(0x1c, wdata, sizeof(wdata), rdata); + DPRINTF("sceCdApplySCmd() ret %d\n", x); + x = 0x3c; + while (0 < x) { + DelayThread(1000000); + x = x + -1; + } + } while(1); +} + +int _start(int argc, char** argv) +{ + int x; + iop_thread_t T; + CpuEnableIntr(); + T.attr = 0x2000000; + T.thread = bait; + T.priority = 0x7e; + T.stacksize = 0x800; + T.option = 0; + x = CreateThread(&T); + if (x > 0) { + DPRINTF("Starting Thread\n"); + StartThread(x,0); + return MODULE_RESIDENT_END; + } else {DPRINTF("CreateThread: %d\n", x);} + return MODULE_NO_RESIDENT_END; +} From 75c18b700b2e17d7f58f617d1d30e4de086885a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Sat, 27 Apr 2024 20:51:29 -0300 Subject: [PATCH 2/4] [DOGBAIT]: switch led state instead of making it blink --- iop/system2x6/dogbait/src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iop/system2x6/dogbait/src/main.c b/iop/system2x6/dogbait/src/main.c index 690a3984bf6..4ab02a0da3a 100644 --- a/iop/system2x6/dogbait/src/main.c +++ b/iop/system2x6/dogbait/src/main.c @@ -12,7 +12,7 @@ IRX_ID(MODNAME, MAJOR, MINOR); char rdata[16]; -char wdata[2] = {0x42, (char)(1 << 8)}; +char wdata[1] = {0x0}; //the loop waiting was made to mirror what rom0:DAEMON did void bait(void*) @@ -20,12 +20,13 @@ void bait(void*) int x; printf("DOGBAIT v%d.%d by El_isra\n", MAJOR, MINOR); do { + wdata[0] = !wdata[0]; #ifdef DEBUG x = #endif //thanks uyjulian for the idea. arcade CDVDMAN has the blue led control export stubbed so directly calling the CMD was the only choice sceCdApplySCmd(0x1c, wdata, sizeof(wdata), rdata); - DPRINTF("sceCdApplySCmd() ret %d\n", x); + DPRINTF("sceCdApplySCmd(0x1c, %x) ret %d\n", wdata[0], x); x = 0x3c; while (0 < x) { DelayThread(1000000); From d0233d9f8041bafe9f6cee5bba00bbb92c18dc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:05:24 -0300 Subject: [PATCH 3/4] [dogbait] use blue led control subCMD from mechacon factory test CMD --- iop/system2x6/dogbait/src/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iop/system2x6/dogbait/src/main.c b/iop/system2x6/dogbait/src/main.c index 4ab02a0da3a..9932f5331da 100644 --- a/iop/system2x6/dogbait/src/main.c +++ b/iop/system2x6/dogbait/src/main.c @@ -12,7 +12,7 @@ IRX_ID(MODNAME, MAJOR, MINOR); char rdata[16]; -char wdata[1] = {0x0}; +char wdata[1] = {0x42}; //the loop waiting was made to mirror what rom0:DAEMON did void bait(void*) @@ -20,13 +20,12 @@ void bait(void*) int x; printf("DOGBAIT v%d.%d by El_isra\n", MAJOR, MINOR); do { - wdata[0] = !wdata[0]; #ifdef DEBUG x = #endif //thanks uyjulian for the idea. arcade CDVDMAN has the blue led control export stubbed so directly calling the CMD was the only choice - sceCdApplySCmd(0x1c, wdata, sizeof(wdata), rdata); - DPRINTF("sceCdApplySCmd(0x1c, %x) ret %d\n", wdata[0], x); + sceCdApplySCmd(0x03, wdata, sizeof(wdata), rdata); + DPRINTF("sceCdApplySCmd(0x03, %x) ret %d\n", wdata[0], x); x = 0x3c; while (0 < x) { DelayThread(1000000); From 33a0855a5d957b2fead169f3f5c043c7d32a79ea Mon Sep 17 00:00:00 2001 From: israpps <57065102+israpps@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:32:30 -0300 Subject: [PATCH 4/4] tweak dogbait README --- iop/system2x6/dogbait/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/iop/system2x6/dogbait/README.md b/iop/system2x6/dogbait/README.md index 5930fa1726f..a7e7d31e226 100644 --- a/iop/system2x6/dogbait/README.md +++ b/iop/system2x6/dogbait/README.md @@ -2,7 +2,7 @@ This module provides a thread to trick the namco arcade system 246/256 watchdog, to avoit it from shutting down the machine if security dongle is not connected for some time. -its implementation could be considered a fusion of `rom0:LED` and `rom0:DAEMON` (without dongle spamming) +it's main purpose is to prevent the watchdog from shutting down the system. while keeping a safe access to security dongle ## How to use this module in your program @@ -16,3 +16,13 @@ int ret, id; id = LoadModuleBuffer(dogbait_irx, size_dogbait_irx, 0, NULL, &ret); if (id<0 || ret == 1) we_have_an_error(); ``` + +If the module fails to load, please let know the user that the machine will shutdown in a few minutes. + +Of course, if your app does not involve access to any memory card/security dongle, then loading the following modules in order and keeping a security dongle plugged will also satisfy the watchdog +``` +rom0:SIO2MAN +rom0:MCMAN +rom0:LED +rom0:DAEMON +``` \ No newline at end of file