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..a7e7d31e226 --- /dev/null +++ b/iop/system2x6/dogbait/README.md @@ -0,0 +1,28 @@ +# 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. + +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 + +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(); +``` + +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 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..9932f5331da --- /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[1] = {0x42}; + +//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(0x03, wdata, sizeof(wdata), rdata); + DPRINTF("sceCdApplySCmd(0x03, %x) ret %d\n", wdata[0], 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; +}