├── .clang-format ├── .github └── workflows │ └── compile.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── ee ├── Rules.make ├── ee_core │ ├── Makefile │ ├── include │ │ ├── asm.h │ │ ├── cheat_api.h │ │ ├── cheat_engine.h │ │ ├── ee_asm.h │ │ ├── ee_debug.h │ │ ├── ee_exception_l2.h │ │ ├── ee_regs.h │ │ ├── gsm_api.h │ │ ├── interface.h │ │ ├── iopmgr.h │ │ ├── patches.h │ │ └── util.h │ ├── linkfile │ └── src │ │ ├── asm.S │ │ ├── cheat_api.c │ │ ├── cheat_engine.S │ │ ├── crt0.S │ │ ├── ee_exception_l2.S │ │ ├── gsm_api.c │ │ ├── iopmgr.c │ │ ├── loadfile.c │ │ ├── main.c │ │ ├── patches.c │ │ ├── patches_asm.S │ │ └── util.c └── loader │ ├── Makefile │ ├── config │ ├── bsd-ata.toml │ ├── bsd-ilink.toml │ ├── bsd-mmce.toml │ ├── bsd-mx4sio.toml │ ├── bsd-udpbd-hdd.toml │ ├── bsd-udpbd.toml │ ├── bsd-usb-debug.toml │ ├── bsd-usb.toml │ ├── bsdfs-bd.toml │ ├── bsdfs-exfat.toml │ ├── bsdfs-hdl.toml │ ├── emu-ata-file.toml │ ├── emu-dvd-esr.toml │ ├── emu-dvd-file.toml │ ├── emu-mc-file.toml │ ├── i_bdm.toml │ ├── i_dev9_hidden.toml │ ├── i_dev9_ns.toml │ ├── rc-uya.toml │ └── system.toml │ └── src │ ├── compat.c │ ├── compat.h │ ├── elf.h │ ├── ioprp.c │ ├── ioprp.h │ ├── iso_cnf.c │ ├── iso_cnf.h │ ├── main.c │ ├── patch.c │ ├── patch.h │ ├── toml.c │ ├── toml.h │ ├── xparam.c │ └── xparam.h ├── iop ├── Rules.make ├── atad_emu │ ├── Makefile │ ├── include │ │ └── atad.h │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ └── ps2atad.c ├── bdfs │ ├── Makefile │ └── src │ │ ├── bdfs.c │ │ ├── imports.lst │ │ └── irx_imports.h ├── cdvdfsv │ ├── Makefile │ └── src │ │ ├── cdvdfsv-internal.h │ │ ├── cdvdfsv.c │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ ├── ncmd.c │ │ ├── scmd.c │ │ └── searchfile.c ├── cdvdman_emu │ ├── Makefile │ └── src │ │ ├── cdvdman.c │ │ ├── cdvdman_read.c │ │ ├── cdvdman_read.h │ │ ├── device-fhi.c │ │ ├── device.h │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── internal.h │ │ ├── ioman_add.h │ │ ├── ioops.c │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ ├── ncmd.c │ │ ├── scmd.c │ │ ├── searchfile.c │ │ └── streaming.c ├── cdvdman_esr1 │ ├── Makefile │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ ├── scecdvdv.c │ │ └── scecdvdv.h ├── cdvdman_esr2 │ ├── Makefile │ └── src │ │ ├── esrimp.h │ │ ├── imports.lst │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ └── pscecdvdv.c ├── common │ ├── cdvd_config.h │ ├── cdvdman_opl.h │ ├── fakemod.h │ ├── fhi.h │ ├── fhi_bd.h │ ├── fhi_bd_defrag.h │ ├── fhi_file.h │ ├── fhi_fileid.h │ └── mprintf.h ├── dev9 │ ├── Makefile │ ├── include │ │ └── dev9.h │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ └── ps2dev9.c ├── fakemod │ ├── Makefile │ └── src │ │ ├── elf.h │ │ ├── imports.lst │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ └── main.c ├── fhi_bd │ ├── Makefile │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ └── main.c ├── fhi_bd_defrag │ ├── Makefile │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ └── main.c ├── fhi_file │ ├── Makefile │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ └── main.c ├── gapfill │ ├── Makefile │ └── src │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ └── main.c ├── hdlfs │ ├── Makefile │ └── src │ │ ├── hdlfs.c │ │ ├── imports.lst │ │ └── irx_imports.h ├── imgdrv │ ├── Makefile │ └── src │ │ ├── imgdrv.c │ │ ├── imports.lst │ │ └── irx_imports.h ├── mc_emu │ ├── Makefile │ └── src │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ ├── mcemu.c │ │ ├── mcemu.h │ │ ├── mcemu_io.c │ │ ├── mcemu_rpc.c │ │ ├── mcemu_sys.c │ │ └── mcemu_var.c ├── memcheck │ ├── Makefile │ └── src │ │ ├── imports.lst │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ └── main.c ├── patch_freemem │ ├── Makefile │ └── src │ │ ├── imports.lst │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ └── main.c ├── patch_membo │ ├── Makefile │ └── src │ │ ├── imports.lst │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ └── main.c ├── patch_rc_uya │ ├── Makefile │ └── src │ │ ├── imports.lst │ │ ├── ioplib.c │ │ ├── ioplib.h │ │ ├── irx_imports.h │ │ └── main.c ├── smap_udpbd │ ├── Makefile │ ├── README │ ├── include │ │ ├── irx_imports.h │ │ ├── main.h │ │ └── xfer.h │ └── src │ │ ├── exports.tab │ │ ├── imports.lst │ │ ├── irx_imports.h │ │ ├── main.c │ │ ├── ministack.c │ │ ├── ministack.h │ │ ├── smap.c │ │ ├── udpbd.c │ │ ├── udpbd.h │ │ ├── udptty.c │ │ ├── udptty.h │ │ └── xfer.c ├── smap_udptty │ └── Makefile └── usbd_null │ ├── Makefile │ └── src │ ├── exports.tab │ ├── imports.lst │ ├── irx_imports.h │ └── main.c └── lab └── cdvd ├── Makefile ├── ee ├── Makefile └── main.c ├── iop ├── Makefile ├── imports.lst ├── irx_imports.h └── main.c └── results ├── ioprp000.txt ├── ioprp014.txt ├── ioprp015.txt ├── ioprp016.txt ├── ioprp165.txt ├── ioprp202.txt ├── ioprp205.txt ├── ioprp210.txt ├── ioprp211.txt ├── ioprp214.txt ├── ioprp224.txt ├── ioprp234.txt ├── ioprp241.txt ├── ioprp242.txt ├── ioprp243.txt ├── ioprp250.txt ├── ioprp253.txt ├── ioprp255.txt ├── ioprp260.txt ├── ioprp271.txt ├── ioprp271_2.txt ├── ioprp280.txt ├── ioprp300.txt ├── ioprp300_2.txt └── ioprp310.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.elf 3 | *.irx 4 | *.IRX 5 | *.map 6 | *_irx.c 7 | 8 | obj/ 9 | obj.*/ 10 | 11 | ee/loader/irx/ 12 | ee/loader/version.txt 13 | iop/patches/ 14 | iop/fileio/ 15 | lab/cdvd/ee/ioprp/ 16 | releases/ 17 | 18 | .* 19 | !.clang-format 20 | !.github 21 | -------------------------------------------------------------------------------- /ee/ee_core/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo 2 | # Copyright 2006-2008 Polo 3 | # Licenced under Academic Free License version 3.0 4 | # Review OPNPS2LD README & LICENSE files for further details. 5 | # 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # Standard Makefile 11 | 12 | EE_BIN = ee_core.elf 13 | EE_SRC_DIR = src/ 14 | EE_OBJS_DIR = obj/ 15 | 16 | GSMCORE_EE_OBJS = gsm_api.o ee_exception_l2.o 17 | CHEATCORE_EE_OBJS = cheat_engine.o cheat_api.o 18 | 19 | EE_OBJS = main.o iopmgr.o loadfile.o util.o patches.o patches_asm.o \ 20 | asm.o crt0.o $(GSMCORE_EE_OBJS) $(CHEATCORE_EE_OBJS) 21 | MAPFILE = ee_core.map 22 | 23 | EE_INCS := -I. -Iinclude -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I$(GSKIT)/include 24 | EE_CFLAGS = -D_EE -Os -G0 -Wall -Werror -fdata-sections -ffunction-sections $(EE_INCS) 25 | 26 | ifeq ($(EESIO_DEBUG),1) 27 | EE_CFLAGS += -D__EESIO_DEBUG 28 | endif 29 | 30 | ifeq ($(DTL_T10000),1) 31 | EE_CFLAGS += -D_DTL_T10000 32 | endif 33 | 34 | ifeq ($(LOAD_DEBUG_MODULES),1) 35 | EE_CFLAGS += -D__LOAD_DEBUG_MODULES 36 | ifeq ($(DECI2_DEBUG),1) 37 | EE_CFLAGS += -D__DECI2_DEBUG 38 | endif 39 | endif 40 | 41 | EE_OBJS := $(EE_OBJS:%=$(EE_OBJS_DIR)%) 42 | 43 | EE_LDFLAGS = -nostartfiles -nostdlib -Tlinkfile -L$(PS2SDK)/ee/lib -s -Wl,-Map,$(MAPFILE) -Wl,-zmax-page-size=128 -Wl,--gc-sections 44 | EE_LIBS += -lpatches 45 | 46 | EE_LIBS += -lkernel -lgcc 47 | 48 | $(EE_OBJS_DIR)%.o : $(EE_SRC_DIR)%.c 49 | @mkdir -p $(EE_OBJS_DIR) 50 | $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ 51 | 52 | $(EE_OBJS_DIR)%.o : $(EE_SRC_DIR)%.S 53 | @mkdir -p $(EE_OBJS_DIR) 54 | $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ 55 | 56 | $(EE_OBJS_DIR)%.o : $(EE_SRC_DIR)%.s 57 | @mkdir -p $(EE_OBJS_DIR) 58 | $(EE_AS) $(EE_ASFLAGS) $< -o $@ 59 | 60 | $(EE_BIN) : $(EE_OBJS) 61 | $(EE_CC) $(EE_CFLAGS) $(EE_LDFLAGS) -o $(EE_BIN) $(EE_OBJS) $(EE_LIBS) 62 | 63 | all: $(EE_BIN) 64 | 65 | clean: 66 | rm -f -r $(EE_OBJS_DIR) $(EE_BIN) $(MAPFILE) 67 | 68 | clean_all: 69 | rm -f -r $(EE_OBJS_DIR) $(EE_BIN) $(MAPFILE) 70 | 71 | include $(PS2SDK)/samples/Makefile.pref 72 | -------------------------------------------------------------------------------- /ee/ee_core/include/asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo 3 | Copyright 2006-2008 Polo 4 | Licenced under Academic Free License version 3.0 5 | Review Open-Ps2-Loader README & LICENSE files for further details. 6 | 7 | Some parts of the code are taken from HD Project by Polo 8 | */ 9 | 10 | #ifndef ASM_H 11 | #define ASM_H 12 | 13 | #include 14 | #include 15 | 16 | u32 Hook_SifSetDma(SifDmaTransfer_t *sdd, s32 len); 17 | void CleanExecPS2(void *epc, void *gp, int argc, char **argv); 18 | 19 | #endif /* ASM */ 20 | -------------------------------------------------------------------------------- /ee/ee_core/include/cheat_api.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHEATAPI_H_ 2 | #define _CHEATAPI_H_ 3 | 4 | void EnableCheats(void); 5 | void DisableCheats(void); 6 | 7 | /** 8 | * code_t - a code object 9 | * @addr: code address 10 | * @val: code value 11 | */ 12 | typedef struct 13 | { 14 | u32 addr; 15 | u32 val; 16 | } code_t; 17 | 18 | #endif /* _CHEATAPI_H_ */ 19 | -------------------------------------------------------------------------------- /ee/ee_core/include/cheat_engine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface to cheat engine 3 | * 4 | * Copyright (C) 2009-2010 Mathias Lafeldt 5 | * 6 | * This file is part of PS2rd, the PS2 remote debugger. 7 | * 8 | * PS2rd is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * PS2rd is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with PS2rd. If not, see . 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #ifndef _CHEATENGINE_H_ 25 | #define _CHEATENGINE_H_ 26 | 27 | #define MAX_HOOKS 5 28 | #define MAX_CODES 250 29 | #define MAX_CHEATLIST (MAX_HOOKS * 2 + MAX_CODES * 2) 30 | 31 | extern void (*Old_SetupThread)(void *gp, void *stack, s32 stack_size, void *args, void *root_func); 32 | extern void HookSetupThread(void *gp, void *stack, s32 stack_size, void *args, void *root_func); 33 | 34 | extern u32 numhooks; 35 | extern u32 numcodes; 36 | extern u32 hooklist[]; 37 | extern u32 codelist[]; 38 | 39 | #endif /* _CHEATENGINE_H_ */ 40 | -------------------------------------------------------------------------------- /ee/ee_core/include/ee_asm.h: -------------------------------------------------------------------------------- 1 | #ifndef EE_ASM_H 2 | #define EE_ASM_H 3 | 4 | 5 | #include 6 | #include 7 | 8 | 9 | // COP0 register getters and setters 10 | #define __ee_mfc0(reg) ({ u32 val; asm volatile("mfc0 %0, " #reg : "=r"(val)::"memory"); val; }) 11 | #define _ee_mfc0(reg) __ee_mfc0(reg) 12 | #define __ee_mtc0(reg, val) ({ asm volatile("mtc0 %0, " #reg :: "r"(val):"memory"); }) 13 | #define _ee_mtc0(reg, val) __ee_mtc0(reg, val) 14 | 15 | // DEBUG register getters and setters 16 | static inline u32 _ee_mfbpc() { u32 val; asm volatile("mfbpc %0":"=r"(val)::"memory"); return val; } 17 | static inline u32 _ee_mfiab() { u32 val; asm volatile("mfiab %0":"=r"(val)::"memory"); return val; } 18 | static inline u32 _ee_mfiabm(){ u32 val; asm volatile("mfiabm %0":"=r"(val)::"memory"); return val; } 19 | static inline u32 _ee_mfdab() { u32 val; asm volatile("mfdab %0":"=r"(val)::"memory"); return val; } 20 | static inline u32 _ee_mfdabm(){ u32 val; asm volatile("mfdabm %0":"=r"(val)::"memory"); return val; } 21 | static inline u32 _ee_mfdvb() { u32 val; asm volatile("mfdvb %0":"=r"(val)::"memory"); return val; } 22 | static inline u32 _ee_mfdvbm(){ u32 val; asm volatile("mfdvbm %0":"=r"(val)::"memory"); return val; } 23 | static inline void _ee_mtbpc (u32 val) { asm volatile("mtbpc %0"::"r"(val) :"memory"); } 24 | static inline void _ee_mtiab (u32 val) { asm volatile("mtiab %0"::"r"(val) :"memory"); } 25 | static inline void _ee_mtiabm(u32 val) { asm volatile("mtiabm %0"::"r"(val) :"memory"); } 26 | static inline void _ee_mtdab (u32 val) { asm volatile("mtdab %0"::"r"(val) :"memory"); } 27 | static inline void _ee_mtdabm(u32 val) { asm volatile("mtdabm %0"::"r"(val) :"memory"); } 28 | static inline void _ee_mtdvb (u32 val) { asm volatile("mtdvb %0"::"r"(val) :"memory"); } 29 | static inline void _ee_mtdvbm(u32 val) { asm volatile("mtdvbm %0"::"r"(val) :"memory"); } 30 | 31 | // SYNC instructions 32 | static inline void _mem_barrier() { asm volatile("" :::"memory"); } 33 | static inline void _ee_sync () { asm volatile("sync" :::"memory"); } // same as sync.l 34 | static inline void _ee_sync_l() { asm volatile("sync.l":::"memory"); } 35 | static inline void _ee_sync_p() { asm volatile("sync.p":::"memory"); } 36 | 37 | // Registers 38 | static inline u32 _ee_get_reg_sp() { u32 val; asm volatile("move %0, $sp":"=r"(val)::"memory"); return val; } 39 | static inline u32 _ee_get_reg_ra() { u32 val; asm volatile("move %0, $ra":"=r"(val)::"memory"); return val; } 40 | 41 | // COP1 / FPU 42 | static inline u32 _ee_cfc1_r31() { u32 val; asm volatile("cfc1 %0, $31":"=r"(val)::"memory"); return val; } 43 | 44 | // DEBUG enable/disable 45 | static inline u32 _ee_disable_bpc() { 46 | u32 val = _ee_mfbpc(); 47 | _ee_sync_l(); 48 | _ee_sync_p(); 49 | _ee_mtbpc(EE_BPC_BED); 50 | _ee_sync_p(); 51 | return val; 52 | } 53 | static inline void _ee_enable_bpc(u32 val) { 54 | _ee_mtbpc(val); 55 | _ee_sync_p(); 56 | } 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /ee/ee_core/include/ee_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef EE_DEBUG_H 2 | #define EE_DEBUG_H 3 | 4 | 5 | #include 6 | #include // BGCOLOR 7 | 8 | 9 | // PRINTF debugging 10 | #ifdef __EESIO_DEBUG 11 | #define DPRINTF(args...) _print(args) 12 | #define DINIT() InitDebug() 13 | #else 14 | #define DPRINTF(args...) \ 15 | do { \ 16 | } while (0) 17 | #define DINIT() \ 18 | do { \ 19 | } while (0) 20 | #endif 21 | 22 | #define GSCOLOR32(R, G, B) ( \ 23 | (u32)((R)&0x000000FF) << 0 | \ 24 | (u32)((G)&0x000000FF) << 8 | \ 25 | (u32)((B)&0x000000FF) << 16) 26 | 27 | // Background color debugging 28 | // BW 29 | #define COLOR_BLACK GSCOLOR32( 0, 0, 0) 30 | #define COLOR_WHITE GSCOLOR32(255, 255, 255) 31 | // RGB (1x255) 32 | #define COLOR_RED GSCOLOR32(255, 0, 0) // ERROR 33 | #define COLOR_GREEN GSCOLOR32( 0, 255, 0) 34 | #define COLOR_BLUE GSCOLOR32( 0, 0, 255) 35 | // 2x255 36 | #define COLOR_LBLUE GSCOLOR32( 0, 255, 255) // Before IOP reboot 1 37 | #define COLOR_MAGENTA GSCOLOR32(255, 0, 255) // Before IOP reboot 2 38 | #define COLOR_YELLOW GSCOLOR32(255, 255, 0) // Before IOP reboot 3 39 | // 2x128 40 | #define COLOR_TEAL GSCOLOR32( 0, 128, 128) 41 | #define COLOR_PURPLE GSCOLOR32(128, 0, 128) // IOP reboot errors 42 | #define COLOR_OLIVE GSCOLOR32(128, 128, 0) // GSM errors 43 | 44 | // Colors of function error codes 45 | #define COLOR_FUNC_IOPREBOOT COLOR_PURPLE 46 | #define COLOR_FUNC_GSM COLOR_OLIVE 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ee/ee_core/include/ee_exception_l2.h: -------------------------------------------------------------------------------- 1 | #ifndef EE_EXCEPTION_L2_H 2 | #define EE_EXCEPTION_L2_H 3 | 4 | 5 | // Level 2 exception handler 6 | extern void el2_asm_handler(); 7 | 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /ee/ee_core/include/ee_regs.h: -------------------------------------------------------------------------------- 1 | #ifndef EE_REGS_H 2 | #define EE_REGS_H 3 | 4 | 5 | #include 6 | 7 | 8 | /* 9 | * Struct containing 'all' registers needed to save/restore the program state 10 | * Note that we are not saving FP and COP0 registers, so keep them unchanged. 11 | */ 12 | typedef struct ee_registers 13 | { 14 | // 32 general purpose registers 15 | union { 16 | u128 gpr[32]; 17 | struct { 18 | // EABI64 register names 19 | u128 zero; 20 | u128 at; 21 | u128 v0; 22 | u128 v1; 23 | u128 a0; 24 | u128 a1; 25 | u128 a2; 26 | u128 a3; 27 | u128 t0; 28 | u128 t1; 29 | u128 t2; 30 | u128 t3; 31 | u128 t4; 32 | u128 t5; 33 | u128 t6; 34 | u128 t7; 35 | u128 s0; 36 | u128 s1; 37 | u128 s2; 38 | u128 s3; 39 | u128 s4; 40 | u128 s5; 41 | u128 s6; 42 | u128 s7; 43 | u128 t8; 44 | u128 t9; 45 | u128 k0; 46 | u128 k1; 47 | u128 gp; 48 | u128 sp; 49 | u128 fp; 50 | u128 ra; 51 | }; 52 | }; 53 | 54 | u128 hi; 55 | u128 lo; 56 | } ee_registers_t; 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /ee/ee_core/include/gsm_api.h: -------------------------------------------------------------------------------- 1 | #ifndef GSM_API_H 2 | #define GSM_API_H 3 | 4 | 5 | void EnableGSM(void); 6 | 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /ee/ee_core/include/interface.h: -------------------------------------------------------------------------------- 1 | #ifndef EE_CORE_INTERFACE_H 2 | #define EE_CORE_INTERFACE_H 3 | 4 | 5 | #include 6 | 7 | 8 | // Pointer to IRX module in hidden EE RAM area 9 | typedef struct 10 | { 11 | const void *ptr; 12 | unsigned int size; 13 | 14 | unsigned int arg_len; 15 | const char *args; 16 | } irxptr_t; 17 | 18 | // Table pointing to all IRX modules 19 | typedef struct 20 | { 21 | irxptr_t *modules; 22 | int count; 23 | } irxtab_t; 24 | 25 | // Magic number to find the interface struct 26 | #define MODULE_SETTINGS_MAGIC 0xf1f2f3f4 27 | 28 | // Compatibility flags 29 | #define EECORE_FLAG_UNHOOK (1<< 0) // Unhook syscalls, keep value the same as in asm.S! 30 | #define EECORE_FLAG_DBC (1<< 1) // Debug colors 31 | #define EECORE_FLAG_GSM_FLD_FP (1<<10) // GSM: Field Mode: Force Progressive 32 | #define EECORE_FLAG_GSM_FRM_FP1 (1<<11) // GSM: Frame Mode: Force Progressive (240p) 33 | #define EECORE_FLAG_GSM_FRM_FP2 (1<<12) // GSM: Frame Mode: Force Progressive (line-double) 34 | #define EECORE_FLAG_GSM_NO_576P (1<<13) // GSM: Disable GSM 576p mode 35 | #define EECORE_FLAG_GSM_C_1 (1<<14) // GSM: Enable FIELD flip type 1 36 | #define EECORE_FLAG_GSM_C_2 (1<<15) // GSM: Enable FIELD flip type 2 37 | #define EECORE_FLAG_GSM_C_3 (1<<16) // GSM: Enable FIELD flip type 3 38 | 39 | // Interface to loader 40 | #define EEC_MOD_CHECKSUM_COUNT 32 41 | struct ee_core_data 42 | { 43 | // Magic number to find 44 | uint32_t magic; 45 | 46 | uint32_t flags; 47 | char GameID[16]; 48 | 49 | int *CheatList; 50 | 51 | void *ModStorageStart; 52 | void *ModStorageEnd; 53 | // Checksums for modules at: 0x95000 - 0xb5000 = 128KiB 54 | uint32_t mod_checksum_4k[EEC_MOD_CHECKSUM_COUNT]; 55 | } __attribute__((packed, aligned(4))); 56 | 57 | extern struct ee_core_data eec; 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /ee/ee_core/include/iopmgr.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPMGR_H 2 | #define IOPMGR_H 3 | 4 | 5 | void services_start(void); 6 | void services_exit(void); 7 | 8 | void New_Reset_Iop(const char *arg, int arglen); 9 | 10 | void Install_Kernel_Hooks(void); 11 | 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ee/ee_core/include/patches.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006-2008 Polo 3 | Copyright 2009-2010, ifcaro, jimmikaelkael & Polo 4 | Copyright 2016 doctorxyz 5 | Licenced under Academic Free License version 3.0 6 | Review Open-Ps2-Loader README & LICENSE files for further details. 7 | 8 | Some parts of the code have been taken from Polo's HD Project and doctorxyz's GSM 9 | */ 10 | 11 | #ifndef PATCHES_H 12 | #define PATCHES_H 13 | 14 | void apply_patches(const char *path); 15 | 16 | #endif /* PATCHES */ 17 | -------------------------------------------------------------------------------- /ee/ee_core/include/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo 3 | Copyright 2006-2008 Polo 4 | Licenced under Academic Free License version 3.0 5 | Review Open-Ps2-Loader README & LICENSE files for further details. 6 | 7 | Some parts of the code are taken from HD Project by Polo 8 | */ 9 | 10 | #ifndef UTIL_H 11 | #define UTIL_H 12 | 13 | #include 14 | 15 | void _strcpy(char *dst, const char *src); 16 | void _strcat(char *dst, const char *src); 17 | int _strncmp(const char *s1, const char *s2, int length); 18 | int _strcmp(const char *s1, const char *s2); 19 | char *_strchr(const char *string, int c); 20 | char *_strrchr(const char *string, int c); 21 | char *_strtok(char *strToken, const char *strDelimit); 22 | char *_strstr(const char *string, const char *substring); 23 | int _islower(int c); 24 | int _toupper(int c); 25 | int _memcmp(const void *s1, const void *s2, unsigned int length); 26 | unsigned int _strtoui(const char *p); 27 | int _strtoi(const char *p); 28 | u64 _strtoul(const char *p); 29 | u32 *find_pattern_with_mask(u32 *buf, unsigned int bufsize, const u32 *pattern, const u32 *mask, unsigned int len); 30 | void CopyToIop(const void *eedata, unsigned int size, void *iopptr); 31 | void WipeUserMemory(void *start, void *end); 32 | void delay(int count); 33 | void BGERROR(u32 func_color, int count) __attribute__((noreturn)); 34 | 35 | #endif /* UTIL */ 36 | -------------------------------------------------------------------------------- /ee/ee_core/src/cheat_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Low-level cheat engine 3 | * 4 | * Copyright (C) 2009-2010 Mathias Lafeldt 5 | * 6 | * This file is part of PS2rd, the PS2 remote debugger. 7 | * 8 | * PS2rd is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * PS2rd is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with PS2rd. If not, see . 20 | * 21 | * $Id$ 22 | */ 23 | 24 | // PS2SDK 25 | #include 26 | #include 27 | #include 28 | 29 | // Neutrino 30 | #include "cheat_api.h" 31 | #include "cheat_engine.h" 32 | #include "interface.h" 33 | 34 | /*---------------------------------*/ 35 | /* Setup PS2RD Cheat Engine params */ 36 | /*---------------------------------*/ 37 | static void SetupCheats() 38 | { 39 | code_t code; 40 | 41 | int i, j, k, nextCodeCanBeHook; 42 | i = 0; 43 | j = 0; 44 | k = 0; 45 | nextCodeCanBeHook = 1; 46 | 47 | while (i < MAX_CHEATLIST) { 48 | 49 | code.addr = eec.CheatList[i]; 50 | code.val = eec.CheatList[i + 1]; 51 | i += 2; 52 | 53 | if ((code.addr == 0) && (code.val == 0)) 54 | break; 55 | 56 | if (((code.addr & 0xfe000000) == 0x90000000) && nextCodeCanBeHook == 1) { 57 | hooklist[j] = code.addr & 0x01FFFFFC; 58 | j++; 59 | hooklist[j] = code.val; 60 | j++; 61 | } else { 62 | codelist[k] = code.addr; 63 | k++; 64 | codelist[k] = code.val; 65 | k++; 66 | } 67 | // Discard any false positives from being possible hooks 68 | if ((code.addr & 0xf0000000) == 0x40000000 || (code.addr & 0xf0000000) == 0x30000000) { 69 | nextCodeCanBeHook = 0; 70 | } else { 71 | nextCodeCanBeHook = 1; 72 | } 73 | } 74 | numhooks = j / 2; 75 | numcodes = k / 2; 76 | } 77 | 78 | /*-----------------------------------------------------*/ 79 | /* Replace SetupThread in kernel. (PS2RD Cheat Engine) */ 80 | /*-----------------------------------------------------*/ 81 | static void Install_HookSetupThread(void) 82 | { 83 | Old_SetupThread = GetSyscallHandler(__NR_SetupThread); 84 | SetSyscall(__NR_SetupThread, HookSetupThread); 85 | } 86 | 87 | /*----------------------------------------------------*/ 88 | /* Restore original SetupThread. (PS2RD Cheat Engine) */ 89 | /*----------------------------------------------------*/ 90 | static void Remove_HookSetupThread(void) 91 | { 92 | SetSyscall(__NR_SetupThread, Old_SetupThread); 93 | } 94 | 95 | /*---------------------------*/ 96 | /* Enable PS2RD Cheat Engine */ 97 | /*---------------------------*/ 98 | void EnableCheats(void) 99 | { 100 | // Setup Cheats 101 | SetupCheats(); 102 | // Install Hook SetupThread 103 | Install_HookSetupThread(); 104 | } 105 | 106 | /*----------------------------*/ 107 | /* Disable PS2RD Cheat Engine */ 108 | /*----------------------------*/ 109 | void DisableCheats(void) 110 | { 111 | // Remove Hook SetupThread 112 | Remove_HookSetupThread(); 113 | } 114 | -------------------------------------------------------------------------------- /ee/ee_core/src/crt0.S: -------------------------------------------------------------------------------- 1 | # Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo 2 | # Copyright 2006-2008 Polo 3 | # Licenced under Academic Free License version 3.0 4 | # Review OPNPS2LD README & LICENSE files for further details. 5 | # 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # Modified crt0.s 11 | # Changed zerobss to only erase bss if not done once before. Otherwise, variables will lose their values whenever LoadExecPS2 is invoked. 12 | # Remove _ps2sdk_args_parse, _ps2sdk_libc_init and _ps2sdk_libc_deinit weak functions for size optimization 13 | 14 | .weak _init 15 | .type _init, @function 16 | 17 | .weak _fini 18 | .type _fini, @function 19 | 20 | .extern _heap_size 21 | .extern _stack 22 | .extern _stack_size 23 | .extern _isInit 24 | 25 | .set noat 26 | .set noreorder 27 | 28 | .text 29 | .align 2 30 | 31 | nop 32 | nop 33 | 34 | .globl _start 35 | .ent _start 36 | _start: 37 | la $4, isInit 38 | lw $5, ($4) 39 | 40 | bnez $5, 2f #Skip if already initialized. 41 | nop 42 | 43 | zerobss: 44 | # clear bss area 45 | 46 | la $2, _fbss 47 | la $3, _end 48 | 49 | 1: 50 | sltu $1, $2, $3 51 | beq $1, $0, 2f 52 | nop 53 | sq $0, ($2) 54 | addiu $2, $2, 16 55 | j 1b 56 | nop 57 | 2: 58 | 59 | setupthread: 60 | # setup current thread 61 | 62 | la $4, _gp 63 | la $5, _stack 64 | la $6, _stack_size 65 | la $7, _args 66 | la $8, _root 67 | move $gp, $4 68 | addiu $3, $0, 60 69 | syscall # SetupThread(_gp, _stack, _stack_size, _args, _root) 70 | move $sp, $2 71 | 72 | # initialize heap 73 | 74 | la $4, _end 75 | la $5, _heap_size 76 | addiu $3, $0, 61 77 | syscall # SetupHeap(_end, _heap_size) 78 | 79 | # writeback data cache 80 | 81 | move $4, $0 82 | addiu $3, $0, 100 83 | syscall # FlushCache(0) 84 | 85 | ctors: 86 | # call global constructors (weak) 87 | 88 | la $8, _init 89 | beqz $8, 1f 90 | nop 91 | jalr $8 # _init() 92 | nop 93 | 1: 94 | 95 | # call main 96 | ei 97 | la $2, _args 98 | lw $4, ($2) 99 | jal main # main(argc, argv) 100 | addiu $5, $2, 4 101 | 102 | # call _exit 103 | 104 | j _exit # _exit(retval) 105 | move $4, $2 106 | .end _start 107 | 108 | .align 3 109 | 110 | .globl _exit 111 | .ent _exit 112 | .text 113 | _exit: 114 | la $2, _retval 115 | sw $4, ($2) 116 | 117 | dtors: 118 | # call global destructors (weak) 119 | 120 | la $8, _fini 121 | beqz $8, 1f 122 | nop 123 | jalr $8 # _fini() 124 | nop 125 | 1: 126 | 127 | la $2, _retval 128 | lw $4, ($2) 129 | 130 | addiu $3, $0, 4 131 | syscall # Exit(retval) (noreturn) 132 | 133 | .end _exit 134 | 135 | .ent _root 136 | _root: 137 | addiu $3, $0, 35 138 | syscall # ExitThread() (noreturn) 139 | .end _root 140 | 141 | .bss 142 | .align 6 143 | _args: 144 | .space 4+16*4+256 # argc, 16 arguments, 256 bytes payload 145 | _retval: 146 | .space 4 147 | -------------------------------------------------------------------------------- /ee/ee_core/src/patches_asm.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010, jimmikaelkael 3 | Licenced under Academic Free License version 3.0 4 | Review Open PS2 Loader README & LICENSE files for further details. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define ABI_EABI64 // force all register names to EABI64 (legacy toolchain) 11 | #include "as_reg_compat.h" 12 | 13 | .set push 14 | .set noreorder 15 | .set noat 16 | # .set nomacro # Uncomment to set nomacro, to check for hidden macro instructions. 17 | 18 | /************************************************************************** 19 | * 20 | * .text section 21 | * 22 | **************************************************************************/ 23 | 24 | .text 25 | 26 | .globl SRWI_IncrementCntrlFlag 27 | .ent SRWI_IncrementCntrlFlag 28 | SRWI_IncrementCntrlFlag: 29 | # Wait for interrupts to be disabled, to avoid causing a hang if the di instruction binds within an interrupt handler. 30 | lui $at, 1 31 | 1: 32 | di 33 | sync.p 34 | mfc0 $v0, $12 35 | and $v0, $v0, $at # Wait until EIE == 0 36 | bne $v0, $zero, 1b 37 | nop 38 | lui $at, 0x003e 39 | lw $v0, -17388($at) 40 | addiu $v0, 1 41 | sw $v0, -17388($at) 42 | 43 | jr $ra 44 | ei 45 | .end SRWI_IncrementCntrlFlag 46 | 47 | .globl RnC3_AlwaysAllocMem 48 | .ent RnC3_AlwaysAllocMem 49 | RnC3_AlwaysAllocMem: # Read the comments on the "Ratchet and Clank: Up Your Arsenal" patch in patches.c 50 | addu $t0, $a0, $s1 51 | lui $v1, 0x2000 # Bypass the cache because the cache has already been flushed by the game. 52 | or $t0, $v1 53 | addiu $v1, $zero, 1 54 | jr $ra 55 | sb $v1, 0x3D8($t0) # Change "beqz $s7, 0x13" in iop_stash_daemon to "beqz $s7, 0x01" 56 | .end RnC3_AlwaysAllocMem 57 | 58 | .set pop 59 | 60 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-ata.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "ATA HDD BDM driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm", "i_dev9_ns"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "ata_bd.irx" 10 | env = ["LE", "EE"] 11 | 12 | # Modules of the game that are faked/blocked 13 | [[fake]] 14 | file = "ATAD.IRX" 15 | name = "atad_driver" 16 | version = 0x0207 17 | startrv = 0 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 18 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-ilink.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "iLink/FireWire/IEEE1394 BDM driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "iLinkman.irx" 10 | env = ["LE", "EE"] 11 | [[module]] 12 | file = "IEEE1394_bd_mini.irx" 13 | env = ["LE", "EE"] 14 | 15 | # Modules of the game that are faked/blocked 16 | [[fake]] 17 | file = "ILINK.IRX" 18 | name = "iLINK_HW_Manager" # is this correct? 19 | version = 0x0202 # is this correct? 20 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END # is this correct? 21 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-mmce.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "MMCEDRV" 3 | 4 | [[module]] 5 | file = "iomanX.irx" 6 | env = ["LE"] 7 | [[module]] 8 | file = "fileXio.irx" 9 | env = ["LE"] 10 | [[module]] 11 | file = "mmceman.irx" 12 | env = ["LE"] 13 | 14 | [[module]] 15 | file = "mmcefhi.irx" 16 | func = "FHI_FILEID" 17 | env = ["EE"] 18 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-mx4sio.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "MX4SIO in MC2 BDM driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "mx4sio_bd_mini.irx" 10 | env = ["LE", "EE"] 11 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-udpbd-hdd.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "UDPBD BDM driver with HDD support" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm", "i_dev9_ns"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "smap_udpbd.irx" 10 | args = ["ip=192.168.1.10"] 11 | env = ["LE", "EE"] 12 | 13 | # Faking strategy 14 | # --------------- 15 | # To allow games to use hdd: 16 | # - dev9 (no-shutdown) is resident, and can be used by hdd modules 17 | # - all networking modules are faked (we hope they are not used) 18 | [[fake]] 19 | file = "ENT_SMAP.IRX" 20 | name = "ent_smap" 21 | version = 0x021f 22 | loadrv = 0 # 0=ok, -xxx=error code (module not loaded) 23 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 24 | [[fake]] 25 | file = "SMAP.IRX" 26 | name = "INET_SMAP_driver" 27 | version = 0x0219 28 | loadrv = 0 # 0=ok, -xxx=error code (module not loaded) 29 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 30 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-udpbd.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "UDPBD BDM driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm", "i_dev9_hidden"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "smap_udpbd.irx" 10 | args = ["ip=192.168.1.10"] 11 | env = ["LE", "EE"] 12 | 13 | # Faking strategy 14 | # --------------- 15 | # To prevent games from trying to use networing: 16 | # - we try to simulate that there is no dev9 hardware present: 17 | # - dev9 returns NO_RESIDENT_END, module is hidden 18 | # - all modules depending on dev9 fail to load becouse dev9 is not resident 19 | [[fake]] 20 | file = "ENT_SMAP.IRX" 21 | name = "ent_smap" 22 | version = 0x021f 23 | loadrv = -200 # KE_LINKERR becouse dev9 does not exist 24 | startrv = 1 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 25 | [[fake]] 26 | file = "SMAP.IRX" 27 | name = "INET_SMAP_driver" 28 | version = 0x0219 29 | loadrv = -200 # KE_LINKERR becouse dev9 does not exist 30 | startrv = 1 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 31 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-usb-debug.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "USB BDM driver - with UDPTTY debugging" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm", "i_dev9_hidden"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "smap_udptty.irx" 10 | args = ["ip=192.168.1.10"] 11 | env = ["LE", "EE"] 12 | [[module]] 13 | file = "usbd_mini.irx" 14 | # Modules that emulate the sceCdRead function must operate at a higher 15 | # priority than the highest possible game priority. 16 | # 17 | # If the priority is lower (higher number) then some games will wait in 18 | # and endless loop for data, but the waiting thread will then cause the 19 | # data to never be processed. 20 | # 21 | # This causes some games to 'need' MODE2 (sync reads) to work. 22 | # 23 | # Supported parameters: 24 | # - dev = maxDevices 25 | # - ed = maxEndpoints 26 | # - gtd = maxTransfDesc 27 | # - itd = maxIsoTransfDesc 28 | # - ioreq = maxIoReqs 29 | # - conf = maxStaticDescSize 30 | # - hub = maxHubDevices 31 | # - port = maxPortsPerHub 32 | # - thpri = hcdThreadPrio,cbThreadPrio 33 | # USBD defaults 34 | #args = ["dev=32", "ed=64", "gtd=128", "itd=128", "hub=8", "port=8", "thpri=7,8"] 35 | # USBD defaults for 'mini' driver 36 | args = ["thpri=7,8"] 37 | # Save 13KiB IOP RAM extra compared to 'mini' 38 | #args = ["dev=4", "ed=8", "gtd=16", "itd=16", "hub=2", "port=4", "thpri=7,8"] 39 | env = ["LE", "EE"] 40 | [[module]] 41 | file = "usbmass_bd_mini.irx" 42 | env = ["LE", "EE"] 43 | 44 | # Modules of the game that are faked/blocked 45 | [[fake]] 46 | file = "USBD.IRX" 47 | name = "USB_driver" 48 | version = 0x0204 49 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 50 | 51 | # Faking strategy 52 | # --------------- 53 | # To prevent games from trying to use networing: 54 | # - we try to simulate that there is no dev9 hardware present: 55 | # - dev9 returns NO_RESIDENT_END, module is hidden 56 | # - all modules depending on dev9 fail to load becouse dev9 is not resident 57 | [[fake]] 58 | file = "ENT_SMAP.IRX" 59 | name = "ent_smap" 60 | version = 0x021f 61 | loadrv = -200 # KE_LINKERR becouse dev9 does not exist 62 | startrv = 1 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 63 | [[fake]] 64 | file = "SMAP.IRX" 65 | name = "INET_SMAP_driver" 66 | version = 0x0219 67 | loadrv = -200 # KE_LINKERR becouse dev9 does not exist 68 | startrv = 1 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 69 | -------------------------------------------------------------------------------- /ee/loader/config/bsd-usb.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "USB BDM driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | depends = ["i_bdm"] 6 | 7 | # Modules to load 8 | [[module]] 9 | file = "usbd_mini.irx" 10 | # Modules that emulate the sceCdRead function must operate at a higher 11 | # priority than the highest possible game priority. 12 | # 13 | # If the priority is lower (higher number) then some games will wait in 14 | # and endless loop for data, but the waiting thread will then cause the 15 | # data to never be processed. 16 | # 17 | # This causes some games to 'need' MODE2 (sync reads) to work. 18 | # 19 | # Supported parameters: 20 | # - dev = maxDevices 21 | # - ed = maxEndpoints 22 | # - gtd = maxTransfDesc 23 | # - itd = maxIsoTransfDesc 24 | # - ioreq = maxIoReqs 25 | # - conf = maxStaticDescSize 26 | # - hub = maxHubDevices 27 | # - port = maxPortsPerHub 28 | # - thpri = hcdThreadPrio,cbThreadPrio 29 | # USBD defaults 30 | #args = ["dev=32", "ed=64", "gtd=128", "itd=128", "hub=8", "port=8", "thpri=7,8"] 31 | # USBD defaults for 'mini' driver 32 | args = ["thpri=7,8"] 33 | # Save 13KiB IOP RAM extra compared to 'mini' 34 | #args = ["dev=4", "ed=8", "gtd=16", "itd=16", "hub=2", "port=4", "thpri=7,8"] 35 | env = ["LE", "EE"] 36 | [[module]] 37 | file = "usbmass_bd_mini.irx" 38 | env = ["LE", "EE"] 39 | 40 | # Modules of the game that are faked/blocked 41 | [[fake]] 42 | file = "USBD.IRX" 43 | name = "USB_driver" 44 | version = 0x0204 45 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 46 | -------------------------------------------------------------------------------- /ee/loader/config/bsdfs-bd.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "Block Device filesystem driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | #depends = ["i_bdm"] 6 | 7 | # Modules to load in load environment 8 | [[module]] 9 | file = "bdfs.irx" 10 | env = ["LE"] 11 | 12 | # Modules to load in emulation environment 13 | [[module]] 14 | file = "fhi_bd.irx" 15 | func = "FHI_BD" 16 | env = ["EE"] 17 | -------------------------------------------------------------------------------- /ee/loader/config/bsdfs-exfat.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "exFat filesystem driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | #depends = ["i_bdm"] 6 | 7 | # Modules to load in load environment 8 | [[module]] 9 | file = "bdmfs_fatfs.irx" 10 | env = ["LE"] 11 | 12 | # Modules to load in emulation environment 13 | [[module]] 14 | file = "fhi_bd_defrag.irx" 15 | func = "FHI_BD_DEFRAG" 16 | env = ["EE"] 17 | -------------------------------------------------------------------------------- /ee/loader/config/bsdfs-hdl.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "HDLoader filesystem driver" 3 | 4 | # Drivers this driver depends on (config file must exist) 5 | #depends = ["i_bdm"] 6 | 7 | # Modules to load in load environment 8 | [[module]] 9 | file = "ps2hdd-bdm.irx" 10 | args = ["-o", "4", "-n", "20"] 11 | env = ["LE"] 12 | [[module]] 13 | file = "hdlfs.irx" 14 | env = ["LE"] 15 | 16 | # Modules to load in emulation environment 17 | [[module]] 18 | file = "fhi_bd_defrag.irx" 19 | func = "FHI_BD_DEFRAG" 20 | env = ["EE"] 21 | -------------------------------------------------------------------------------- /ee/loader/config/emu-ata-file.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "ATA emulation using image file" 3 | 4 | # Modules to load 5 | [[module]] 6 | file = "atad_emu.irx" 7 | env = ["EE"] 8 | 9 | # Modules of the game that are faked/blocked 10 | [[fake]] 11 | file = "ATAD.IRX" 12 | name = "atad_driver" 13 | version = 0x0207 14 | startrv = 0 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 15 | 16 | # For booting rom0:OSDSYS, block the following?: 17 | # - rom0:ATAD (dev9 + atad combined driver) 18 | # - HDDLOAD 19 | # 20 | # What do these libraries do? Also block?: 21 | # - rom0:XDEV9 ? 22 | # - rom0:XDEV9SERV ? 23 | # - rom0:PS1ID ? 24 | # - rom0:PS1VERE ? 25 | # - rom1:DVDIDE ? 26 | -------------------------------------------------------------------------------- /ee/loader/config/emu-dvd-esr.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "Builtin DVD drive with ESR patched disk" 3 | 4 | # Modules to load 5 | [[module]] 6 | file = "cdvdman_esr1.irx" 7 | env = ["LE", "EE"] 8 | [[module]] 9 | file = "cdvdman_esr2.irx" 10 | env = ["LE", "EE"] 11 | -------------------------------------------------------------------------------- /ee/loader/config/emu-dvd-file.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "CD/DVD emulation using image file" 3 | 4 | # Modules to load 5 | [[module]] 6 | file = "cdvdman_emu.irx" 7 | ioprp = "CDVDMAN" 8 | env = ["EE"] 9 | [[module]] 10 | file = "cdvdfsv.irx" 11 | ioprp = "CDVDFSV" 12 | env = ["EE"] 13 | 14 | # Modules of the game that are faked/blocked 15 | [[fake]] 16 | file = "CDVDFSV.IRX" 17 | name = "cdvd_ee_driver" 18 | #unload = true // FIXME this is broken, can be tested with Jak X 19 | version = 0x0202 20 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 21 | [[fake]] 22 | file = "CDVDSTM.IRX" 23 | name = "cdvd_st_driver" 24 | version = 0x0202 25 | startrv = 2 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 26 | -------------------------------------------------------------------------------- /ee/loader/config/emu-mc-file.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "MC emulation using image file" 3 | 4 | # Modules to load 5 | [[module]] 6 | file = "mc_emu.irx" 7 | env = ["EE"] 8 | -------------------------------------------------------------------------------- /ee/loader/config/i_bdm.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "Block Device Manager" 3 | 4 | # Modules to load in load environment 5 | [[module]] 6 | file = "bdm.irx" 7 | env = ["LE"] 8 | [[module]] 9 | file = "iomanX.irx" 10 | env = ["LE"] 11 | [[module]] 12 | file = "fileXio.irx" 13 | env = ["LE"] 14 | -------------------------------------------------------------------------------- /ee/loader/config/i_dev9_hidden.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "DEV9 hidden driver" 3 | 4 | # Modules to load 5 | [[module]] 6 | file = "dev9_hidden.irx" # hidden version to hide from the game 7 | env = ["LE", "EE"] 8 | 9 | # Modules of the game that are faked/blocked 10 | [[fake]] 11 | file = "DEV9.IRX" 12 | name = "dev9" 13 | version = 0x0208 14 | loadrv = 0 # 0=ok, -xxx=error code (module not loaded) 15 | startrv = 1 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 16 | -------------------------------------------------------------------------------- /ee/loader/config/i_dev9_ns.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "DEV9 no-shutdown driver" 3 | 4 | # Modules to load 5 | [[module]] 6 | file = "dev9_ns.irx" # no-shutdown version, to prevent games shutting down the dev9 7 | env = ["LE", "EE"] 8 | 9 | # Modules of the game that are faked/blocked 10 | [[fake]] 11 | file = "DEV9.IRX" 12 | name = "dev9" 13 | version = 0x0208 14 | startrv = 0 # 0=RESIDENT_END, 1=NO_RESIDENT_END, 2=REMOVABLE_END 15 | -------------------------------------------------------------------------------- /ee/loader/config/rc-uya.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "Patches for Ratchet Clank 3 / Up Your Arsenal - ONLINE!" 3 | 4 | # For testing 5 | #default_bsd = "ata" 6 | #default_dvd = "mass:DVD/Ratchet Clank - Up Your Arsenal (U).iso" 7 | 8 | # Boot directly into online menu 9 | default_elf = "cdrom0:I5BOOTN.ELF;1" 10 | 11 | # Load patch module that fixes a game bug 12 | [[module]] 13 | file = "patch_rc_uya.irx" 14 | env = ["EE"] 15 | -------------------------------------------------------------------------------- /ee/loader/config/system.toml: -------------------------------------------------------------------------------- 1 | # Name of loaded config, to show to user 2 | name = "System settings and drivers" 3 | 4 | # Default argument values 5 | # Overwrite these from the command line 6 | default_bsd = "no" 7 | default_bsdfs = "exfat" 8 | default_dvd = "no" 9 | #default_ata0 = "mass:mydrive0.bin" 10 | #default_ata0id = "mass:mydrive0_id.bin" 11 | #default_ata1 = "mass:mydrive1.bin" 12 | #default_mc0 = "mass:mymc0.bin" 13 | #default_mc1 = "mass:mymc1.bin" 14 | default_elf = "auto" 15 | #default_mt = "dvd" 16 | #default_gc = "12" 17 | #default_gsm = "fp" 18 | #default_cfg = "" 19 | default_dbc = false 20 | default_logo = false 21 | 22 | # EE_CORE configuration 23 | eecore_elf = "ee_core.elf" 24 | eecore_mod_base = 0x95000 25 | #eecore_mod_base = 0xA7000 26 | 27 | # Select the number of sectors for the FS buffer 28 | # A small value can increase game compatibility 29 | # A large value can increase performce 30 | # Min=2, Max=128, Default=8 31 | cdvdman_fs_sectors = 8 32 | 33 | # Override the 8-byte string returned by: 34 | # - sceCdRI 35 | # This string is also used by: 36 | # - sceCdReadGUID 37 | # - sceCdReadModelID 38 | # 39 | # This string is used (for instance) by the sony network configuration 40 | # to verify if the config belongs to the specific console. 41 | # 42 | #ilink_id = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] 43 | 44 | # Use the 5-byte string returned by: 45 | # - sceCdReadDiskID 46 | #disk_id = [0x00, 0x00, 0x00, 0x00, 0x00] 47 | 48 | # Modules to load in emulation environment 49 | [[module]] 50 | file = "eesync.irx" 51 | ioprp = "EESYNC" 52 | env = ["EE"] 53 | [[module]] 54 | file = "imgdrv.irx" 55 | func = "IMGDRV" # used by EECORE durion IOP reboot 56 | env = ["EE"] 57 | # By default the system rom0:UDNL will be used, but this can be overruled here 58 | # Some games (like Auto Modellista) don't work over USB with the default UDNL. 59 | [[module]] 60 | file = "udnl.irx" 61 | #file = "udnl-t300.irx" 62 | func = "UDNL" # used by EECORE durion IOP reboot 63 | env = ["EE"] 64 | [[module]] 65 | file = "fakemod.irx" 66 | func = "FAKEMOD" # loaded last, so we don't fake our own modules 67 | env = ["EE"] 68 | 69 | #[[module]] 70 | #file = "patch_freemem.irx" 71 | #args = ["512", "X"] # "X" = block above limit (default no blocking), number is limit in KiB (default 512KiB) 72 | #env = ["EE"] 73 | 74 | #[[module]] 75 | #file = "memcheck.irx" 76 | #env = ["EE"] 77 | 78 | #[[module]] 79 | #file = "patch_membo.irx" 80 | #env = ["EE"] 81 | 82 | # It's best to load this module last (bottom of bsd-usb.toml for instance) 83 | #[[module]] 84 | #file = "gapfill.irx" 85 | #env = ["EE"] 86 | -------------------------------------------------------------------------------- /ee/loader/src/compat.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPAT_H 2 | #define COMPAT_H 3 | 4 | 5 | #include 6 | 7 | 8 | void get_compat_flag(uint32_t flags, uint32_t *eecore, uint32_t *cdvdman, const char **ioppatch); 9 | void get_compat_game(const char *id, uint32_t *eecore, uint32_t *cdvdman, const char **ioppatch); 10 | void *get_modstorage(const char *id); 11 | 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ee/loader/src/elf.h: -------------------------------------------------------------------------------- 1 | #ifndef ELF_H 2 | #define ELF_H 3 | 4 | 5 | #include 6 | 7 | 8 | #define ELF_MAGIC 0x464c457f // ".ELF" 9 | #define ELF_PT_LOAD 1 10 | 11 | 12 | typedef struct 13 | { 14 | uint8_t ident[16]; // struct definition for ELF object header 15 | uint16_t type; 16 | uint16_t machine; 17 | uint32_t version; 18 | uint32_t entry; 19 | uint32_t phoff; 20 | uint32_t shoff; 21 | uint32_t flags; 22 | uint16_t ehsize; 23 | uint16_t phentsize; 24 | uint16_t phnum; 25 | uint16_t shentsize; 26 | uint16_t shnum; 27 | uint16_t shstrndx; 28 | } elf_header_t; 29 | 30 | typedef struct 31 | { 32 | uint32_t type; // struct definition for ELF program section header 33 | uint32_t offset; 34 | void *vaddr; 35 | uint32_t paddr; 36 | uint32_t filesz; 37 | uint32_t memsz; 38 | uint32_t flags; 39 | uint32_t align; 40 | } elf_pheader_t; 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /ee/loader/src/ioprp.c: -------------------------------------------------------------------------------- 1 | #include "ioprp.h" 2 | #include 3 | 4 | 5 | void print_extinfo(const uint8_t *data, uint32_t size) 6 | { 7 | struct extinfo * ext; 8 | 9 | while (size > 0) { 10 | ext = (struct extinfo *)data; 11 | 12 | if (size < sizeof(struct extinfo)) { 13 | printf("- -> ERROR: extsize1 %ld < 4\n", size); 14 | return; 15 | } 16 | 17 | if (size < (sizeof(struct extinfo) + ext->ext_length)) { 18 | printf("- -> ERROR: extsize2 %ld < (4 + %d)\n", size, ext->ext_length); 19 | return; 20 | } 21 | 22 | switch(ext->type) { 23 | case EXTINFO_TYPE_DATE: 24 | if (ext->ext_length == 0) 25 | printf("- -> DATE = 0x%x\n", ext->value); 26 | else if (ext->ext_length == 4) 27 | printf("- -> DATE = 0x%lx\n", *(uint32_t *)&data[sizeof(struct extinfo)]); 28 | else 29 | printf("- -> DATE ???\n"); 30 | break; 31 | case EXTINFO_TYPE_VERSION: 32 | printf("- -> VERSION = 0x%x\n", ext->value); 33 | break; 34 | case EXTINFO_TYPE_COMMENT: 35 | printf("- -> COMMENT = %s\n", &data[sizeof(struct extinfo)]); 36 | break; 37 | case EXTINFO_TYPE_NULL: 38 | printf("- -> NULL\n"); 39 | break; 40 | default: 41 | printf("- -> ???\n"); 42 | }; 43 | 44 | size -= sizeof(struct extinfo) + ext->ext_length; 45 | data += sizeof(struct extinfo) + ext->ext_length; 46 | } 47 | } 48 | 49 | void print_romdir(const struct romdir_entry *romdir) 50 | { 51 | uint8_t *data = (uint8_t *)romdir; 52 | data += romdir[1].size; // FIXME: The offset where the extdata starts 53 | 54 | while (romdir->name[0] != '\0') { 55 | printf("- %s [size=%ld, extsize=%d]\n", romdir->name, romdir->size, romdir->extinfo_size); 56 | 57 | if (romdir->extinfo_size > 0) { 58 | print_extinfo(data, romdir->extinfo_size); 59 | data += romdir->extinfo_size; 60 | } 61 | 62 | romdir++; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ee/loader/src/ioprp.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPRP_H 2 | #define IOPRP_H 3 | 4 | 5 | #include 6 | 7 | 8 | typedef struct romdir_entry 9 | { 10 | char name[10]; 11 | uint16_t extinfo_size; 12 | uint32_t size; 13 | } romdir_entry_t; 14 | 15 | typedef struct extinfo { 16 | uint16_t value; /* Only applicable for the version field type. */ 17 | uint8_t ext_length; /* The length of data appended to the end of this entry. */ 18 | uint8_t type; 19 | } extinfo_t; 20 | 21 | enum EXTINFO_TYPE { 22 | EXTINFO_TYPE_DATE=1, 23 | EXTINFO_TYPE_VERSION, 24 | EXTINFO_TYPE_COMMENT, 25 | EXTINFO_TYPE_NULL=0x7F 26 | }; 27 | 28 | 29 | void print_extinfo(const uint8_t *data, uint32_t size); 30 | void print_romdir(const struct romdir_entry *romdir); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /ee/loader/src/iso_cnf.h: -------------------------------------------------------------------------------- 1 | #ifndef ISO_CNF_H 2 | #define ISO_CNF_H 3 | 4 | // Reads SYSTEM.CNF from ISO image and copies it into given buffer 5 | int read_system_cnf(const char *path, char *system_cnf_data, int bufSize); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /ee/loader/src/patch.c: -------------------------------------------------------------------------------- 1 | // libc/newlib 2 | #include 3 | 4 | // PS2SDK 5 | #include 6 | #include 7 | 8 | 9 | /* Returns the patch location of LoadExecPS2(), which resides in kernel memory. 10 | * Patches the kernel to use the EELOAD module at the specified location. 11 | * Must be run in kernel mode. 12 | */ 13 | void *sbvpp_replace_eeload(void *new_eeload) 14 | { 15 | void *result = NULL; 16 | uint32_t *p; 17 | 18 | /* The pattern of the code in LoadExecPS2() that prepares the kernel for copying EELOAD from rom0: */ 19 | static const unsigned int initEELOADCopyPattern[] = { 20 | 0x8FA30010, /* lw v1, 0x0010(sp) */ 21 | 0x0240302D, /* daddu a2, s2, zero */ 22 | 0x8FA50014, /* lw a1, 0x0014(sp) */ 23 | 0x8C67000C, /* lw a3, 0x000C(v1) */ 24 | 0x18E00009, /* blez a3, +9 <- The kernel will skip the EELOAD copying loop if the value in $a3 is less than, or equal to 0. Lets do that... */ 25 | }; 26 | 27 | DI(); 28 | ee_kmode_enter(); 29 | 30 | /* Find the part of LoadExecPS2() that initilizes the EELOAD copying loop's variables */ 31 | for (p = (uint32_t *)0x80001000; p < (uint32_t *)0x80030000; p++) { 32 | if (memcmp(p, &initEELOADCopyPattern, sizeof(initEELOADCopyPattern)) == 0) { 33 | p[1] = 0x3C120000 | (uint16_t)((uint32_t)new_eeload >> 16); /* lui s2, HI16(new_eeload) */ 34 | p[2] = 0x36520000 | (uint16_t)((uint32_t)new_eeload & 0xFFFF); /* ori s2, s2, LO16(new_eeload) */ 35 | p[3] = 0x24070000; /* li a3, 0 <- Disable the EELOAD copying loop */ 36 | result = (void *)p; 37 | break; /* All done. */ 38 | } 39 | } 40 | 41 | ee_kmode_exit(); 42 | EI(); 43 | 44 | return result; 45 | } 46 | 47 | void *sbvpp_patch_user_mem_clear(void *start) 48 | { 49 | void *ret = NULL; 50 | uint32_t *p; 51 | 52 | DI(); 53 | ee_kmode_enter(); 54 | 55 | for (p = (uint32_t *)0x80001000; p < (uint32_t *)0x80080000; p++) { 56 | /* 57 | * Search for function call and patch $a0 58 | * lui $a0, 0x0008 59 | * jal InitializeUserMemory 60 | * ori $a0, $a0, 0x2000 61 | */ 62 | if (p[0] == 0x3c040008 && (p[1] & 0xfc000000) == 0x0c000000 && p[2] == 0x34842000) { 63 | p[0] = 0x3c040000 | ((uint32_t)start >> 16); 64 | p[2] = 0x34840000 | ((uint32_t)start & 0xffff); 65 | ret = (void *)p; 66 | break; 67 | } 68 | } 69 | 70 | ee_kmode_exit(); 71 | EI(); 72 | 73 | return ret; 74 | } 75 | -------------------------------------------------------------------------------- /ee/loader/src/patch.h: -------------------------------------------------------------------------------- 1 | #ifndef PATCH_H 2 | #define PATCH_H 3 | 4 | 5 | void *sbvpp_replace_eeload(void *new_eeload); 6 | void *sbvpp_patch_user_mem_clear(void *start); 7 | 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /ee/loader/src/xparam.h: -------------------------------------------------------------------------------- 1 | #ifndef XPARAM_H 2 | #define XPARAM_H 3 | 4 | /* 5 | # 6 | # DECKARD Configs 7 | #-------------------------- 8 | # Copyright 2023 krat0s. 9 | # 10 | */ 11 | 12 | 13 | #define GM_IOP_TYPE (0x80000000) 14 | 15 | #define PARAM_MDEC_DELAY_CYCLE (0x00) 16 | #define PARAM_SPU_INT_DELAY_LIMIT (0x01) 17 | #define PARAM_SPU_INT_DELAY_PPC_COEFF (0x02) 18 | #define PARAM_SPU2_INT_DELAY_LIMIT (0x03) 19 | #define PARAM_SPU2_INT_DELAY_PPC_COEFF (0x04) 20 | #define PARAM_DMAC_CH10_INT_DELAY (0x05) 21 | #define PARAM_CPU_DELAY (0x06) 22 | #define PARAM_SPU_DMA_WAIT_LIMIT (0x07) 23 | #define PARAM_GPU_DMA_WAIT_LIMIT (0x08) 24 | #define PARAM_DMAC_CH10_INT_DELAY_DPC (0x09) 25 | #define PARAM_CPU_DELAY_DPC (0x0A) 26 | #define PARAM_USB_DELAYED_INT_ENABLE (0x0B) 27 | #define PARAM_TIMER_LOAD_DELAY (0x0C) 28 | #define PARAM_SIO0_DTR_SCK_DELAY (0x0D) 29 | #define PARAM_SIO0_DSR_SCK_DELAY_C (0x0E) 30 | #define PARAM_SIO0_DSR_SCK_DELAY_M (0x0F) 31 | #define PARAM_MIPS_DCACHE_ON (0x10) 32 | #define PARAM_CACHE_FLASH_CHANNELS (0x11) 33 | 34 | #define GM_IF ((volatile uint32_t *)0x1F801450) 35 | 36 | void ResetDeckardXParams(); 37 | void ApplyDeckardXParam(const char *title); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /iop/Rules.make: -------------------------------------------------------------------------------- 1 | IOP_SRC_DIR ?= src/ 2 | IOP_INC_DIR ?= src/ 3 | IOP_BIN_DIR ?= irx/ 4 | 5 | IOP_BIN ?= $(shell basename $(CURDIR)).irx 6 | IOP_BIN := $(IOP_BIN:%=$(IOP_BIN_DIR)%) 7 | 8 | all:: $(IOP_BIN) 9 | 10 | clean:: 11 | rm -f -r $(IOP_OBJS_DIR) $(IOP_BIN_DIR) 12 | 13 | include $(PS2SDK)/Defs.make 14 | include $(PS2SDK)/samples/Makefile.pref 15 | include $(PS2SDK)/samples/Makefile.iopglobal 16 | 17 | # include neutrino headers first. Some headers have the same name as ps2sdk ones. 18 | IOP_CFLAGS := -Iinclude -I../common $(IOP_CFLAGS) 19 | 20 | ifeq ($(DEBUG),1) 21 | IOP_CFLAGS += -DDEBUG 22 | endif 23 | -------------------------------------------------------------------------------- /iop/atad_emu/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = ps2atad.o imports.o exports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/atad_emu/src/exports.tab: -------------------------------------------------------------------------------- 1 | /* We conform to the 1.3 version of atad.irx exports. */ 2 | 3 | DECLARE_EXPORT_TABLE(atad, 1, 3) 4 | DECLARE_EXPORT(_start) 5 | DECLARE_EXPORT(_retonly) 6 | DECLARE_EXPORT(_exit) 7 | DECLARE_EXPORT(_retonly) 8 | 9 | DECLARE_EXPORT(ata_get_devinfo) 10 | DECLARE_EXPORT(ata_reset_devices) // 5 11 | DECLARE_EXPORT(ata_io_start) 12 | DECLARE_EXPORT(ata_io_finish) 13 | DECLARE_EXPORT(ata_get_error) 14 | DECLARE_EXPORT(ata_device_sector_io) 15 | DECLARE_EXPORT(ata_device_sce_sec_set_password) // 10 16 | DECLARE_EXPORT(ata_device_sce_sec_unlock) 17 | DECLARE_EXPORT(ata_device_sce_sec_erase) 18 | DECLARE_EXPORT(ata_device_idle) 19 | DECLARE_EXPORT(ata_device_sce_identify_drive) 20 | DECLARE_EXPORT(ata_device_smart_get_status) // 15 21 | DECLARE_EXPORT(ata_device_smart_save_attr) 22 | DECLARE_EXPORT(ata_device_flush_cache) 23 | DECLARE_EXPORT(ata_device_idle_immediate) 24 | END_EXPORT_TABLE 25 | 26 | void _retonly() {} 27 | -------------------------------------------------------------------------------- /iop/atad_emu/src/imports.lst: -------------------------------------------------------------------------------- 1 | fhi_IMPORTS_start 2 | I_fhi_size 3 | I_fhi_read 4 | I_fhi_write 5 | fhi_IMPORTS_end 6 | 7 | loadcore_IMPORTS_start 8 | I_RegisterLibraryEntries 9 | loadcore_IMPORTS_end 10 | 11 | #ifdef DEBUG 12 | stdio_IMPORTS_start 13 | I_printf 14 | stdio_IMPORTS_end 15 | #endif 16 | 17 | sysclib_IMPORTS_start 18 | I_memcpy 19 | I_memset 20 | sysclib_IMPORTS_end 21 | 22 | thbase_IMPORTS_start 23 | I_DelayThread 24 | I_SetAlarm 25 | I_CancelAlarm 26 | I_USec2SysClock 27 | thbase_IMPORTS_end 28 | 29 | thevent_IMPORTS_start 30 | I_CreateEventFlag 31 | I_iSetEventFlag 32 | I_ClearEventFlag 33 | I_WaitEventFlag 34 | thevent_IMPORTS_end 35 | -------------------------------------------------------------------------------- /iop/atad_emu/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /iop/bdfs/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = bdfs.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/bdfs/src/imports.lst: -------------------------------------------------------------------------------- 1 | bdm_IMPORTS_start 2 | I_bdm_get_bd 3 | bdm_IMPORTS_end 4 | 5 | iomanX_IMPORTS_start 6 | I_AddDrv 7 | iomanX_IMPORTS_end 8 | 9 | #ifdef DEBUG 10 | stdio_IMPORTS_start 11 | I_printf 12 | stdio_IMPORTS_end 13 | #endif 14 | 15 | sysclib_IMPORTS_start 16 | I_sprintf 17 | I_memcpy 18 | I_strcmp 19 | sysclib_IMPORTS_end 20 | -------------------------------------------------------------------------------- /iop/bdfs/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /iop/cdvdfsv/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = cdvdfsv.o searchfile.o ncmd.o scmd.o imports.o exports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/cdvdfsv/src/cdvdfsv-internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009, jimmikaelkael 3 | Licenced under Academic Free License version 3.0 4 | Review open-ps2-loader README & LICENSE files for further details. 5 | */ 6 | 7 | #ifndef __CDVDFSV_INTERNAL__ 8 | #define __CDVDFSV_INTERNAL__ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "cdvdman_opl.h" 22 | #include "mprintf.h" 23 | 24 | #define MODNAME "cdvd_ee_driver" 25 | 26 | extern void cdvdfsv_register_scmd_rpc(SifRpcDataQueue_t *rpc_DQ); 27 | extern void cdvdfsv_register_ncmd_rpc(SifRpcDataQueue_t *rpc_DQ); 28 | extern void cdvdfsv_register_searchfile_rpc(SifRpcDataQueue_t *rpc_DQ); 29 | extern void sysmemSendEE(void *buf, void *EE_addr, int size); 30 | extern int sceCdChangeThreadPriority(int priority); 31 | 32 | extern u8 *cdvdfsv_buf; 33 | extern int cdvdfsv_size; 34 | extern int cdvdfsv_sectors; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /iop/cdvdfsv/src/exports.tab: -------------------------------------------------------------------------------- 1 | void _retonly(void) {} 2 | 3 | int _dummy(void) { 4 | return 0; 5 | } 6 | 7 | // cdvdfsv export table 8 | DECLARE_EXPORT_TABLE(cdvdfsv, 1, 1) 9 | DECLARE_EXPORT(_start) 10 | DECLARE_EXPORT(_retonly) 11 | DECLARE_EXPORT(_retonly) 12 | DECLARE_EXPORT(_retonly) 13 | DECLARE_EXPORT(_dummy) 14 | DECLARE_EXPORT(sceCdChangeThreadPriority) 15 | END_EXPORT_TABLE 16 | 17 | -------------------------------------------------------------------------------- /iop/cdvdfsv/src/imports.lst: -------------------------------------------------------------------------------- 1 | cdvdman_IMPORTS_start 2 | I_sceCdInit 3 | I_sceCdStandby 4 | I_sceCdRead 5 | I_sceCdSeek 6 | I_sceCdGetError 7 | I_sceCdGetToc 8 | I_sceCdSearchFile 9 | I_sceCdSync 10 | I_sceCdGetDiskType 11 | I_sceCdDiskReady 12 | I_sceCdTrayReq 13 | I_sceCdStop 14 | I_sceCdReadClock 15 | I_sceCdStatus 16 | I_sceCdApplySCmd 17 | I_sceCdPause 18 | I_sceCdBreak 19 | I_sceCdGetReadPos 20 | I_sceGetFsvRbuf2 21 | I_sceCdSC 22 | I_sceCdStInit 23 | I_sceCdStRead 24 | I_sceCdStSeek 25 | I_sceCdStStart 26 | I_sceCdStStat 27 | I_sceCdStStop 28 | I_sceCdStPause 29 | I_sceCdStResume 30 | I_sceCdPowerOff 31 | I_sceCdMmode 32 | I_sceCdStSeekF 33 | I_sceCdReadDiskID 34 | I_sceCdReadGUID 35 | I_sceCdSetTimeout 36 | I_sceCdReadModelID 37 | I_sceCdReadDvdDualInfo 38 | I_sceCdLayerSearchFile 39 | cdvdman_IMPORTS_end 40 | 41 | intrman_IMPORTS_start 42 | I_CpuSuspendIntr 43 | I_CpuResumeIntr 44 | intrman_IMPORTS_end 45 | 46 | #ifdef DEBUG 47 | stdio_IMPORTS_start 48 | I_printf 49 | stdio_IMPORTS_end 50 | #endif 51 | 52 | loadcore_IMPORTS_start 53 | I_GetLoadcoreInternalData 54 | I_RegisterLibraryEntries 55 | I_ReleaseLibraryEntries 56 | loadcore_IMPORTS_end 57 | 58 | sifcmd_IMPORTS_start 59 | I_sceSifInitRpc 60 | I_sceSifSetRpcQueue 61 | I_sceSifRegisterRpc 62 | I_sceSifRpcLoop 63 | sifcmd_IMPORTS_end 64 | 65 | sifman_IMPORTS_start 66 | I_sceSifSetDma 67 | I_sceSifDmaStat 68 | sifman_IMPORTS_end 69 | 70 | sysclib_IMPORTS_start 71 | I_memcpy 72 | I_memset 73 | sysclib_IMPORTS_end 74 | 75 | thbase_IMPORTS_start 76 | I_CreateThread 77 | I_DeleteThread 78 | I_StartThread 79 | I_DelayThread 80 | I_ExitDeleteThread 81 | I_GetThreadId 82 | I_ChangeThreadPriority 83 | thbase_IMPORTS_end 84 | 85 | thevent_IMPORTS_start 86 | I_ClearEventFlag 87 | I_WaitEventFlag 88 | thevent_IMPORTS_end 89 | -------------------------------------------------------------------------------- /iop/cdvdfsv/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include 5 | 6 | #define I_sceGetFsvRbuf2 DECLARE_IMPORT(47, sceGetFsvRbuf2) 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /iop/cdvdfsv/src/searchfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009, jimmikaelkael 3 | Licenced under Academic Free License version 3.0 4 | Review open-ps2-loader README & LICENSE files for further details. 5 | */ 6 | 7 | #include "cdvdfsv-internal.h" 8 | 9 | typedef struct 10 | { // size =0x124 11 | sceCdlFILE cdfile; // 0x000 12 | char name[256]; // 0x020 13 | void *dest; // 0x120 14 | } SearchFilePkt_t; 15 | 16 | typedef struct 17 | { // size =0x128 18 | sceCdlFILE cdfile; // 0x000 19 | u32 flag; // 0x020 20 | char name[256]; // 0x024 21 | void *dest; // 0x124 22 | } SearchFilePkt2_t; 23 | 24 | typedef struct 25 | { // size =0x12c 26 | sceCdlFILE cdfile; // 0x000 27 | u32 flag; // 0x020 28 | char name[256]; // 0x024 29 | void *dest; // 0x124 30 | int layer; // 0x128 31 | } SearchFilePktl_t; 32 | 33 | static SifRpcServerData_t cdsearchfile_rpcSD; 34 | static u8 cdsearchfile_rpcbuf[304]; 35 | 36 | static void *cbrpc_cdsearchfile(int fno, void *buf, int size); 37 | 38 | //------------------------------------------------------------------------- 39 | static void *cbrpc_cdsearchfile(int fno, void *buf, int size) 40 | { // CD Search File RPC callback 41 | 42 | int r; 43 | void *ee_addr; 44 | char *p; 45 | SearchFilePkt_t *pkt = (SearchFilePkt_t *)buf; 46 | SearchFilePkt2_t *pkt2 = (SearchFilePkt2_t *)buf; 47 | SearchFilePktl_t *pktl = (SearchFilePktl_t *)buf; 48 | int pktsize; 49 | 50 | if (size == sizeof(SearchFilePkt2_t)) { 51 | ee_addr = (void *)pkt2->dest; // Search File: Called from Not Dual_layer Version 52 | p = (void *)&pkt2->name[0]; 53 | pktsize = sizeof(sceCdlFILE) + sizeof(u32); 54 | r = sceCdSearchFile((sceCdlFILE *)buf, p); 55 | pkt2->flag = 0; 56 | } else { 57 | if (size > sizeof(SearchFilePkt2_t)) { // Search File: Called from Dual_layer Version 58 | ee_addr = (void *)pktl->dest; 59 | p = (char *)&pktl->name[0]; 60 | pktsize = sizeof(sceCdlFILE) + sizeof(u32); 61 | r = sceCdLayerSearchFile((sceCdlFILE *)buf, p, pktl->layer); 62 | pktl->flag = 0; 63 | } else { // Search File: Called from Old Library 64 | ee_addr = (void *)pkt->dest; 65 | p = (char *)&pkt->name[0]; 66 | pktsize = sizeof(sceCdlFILE); 67 | r = sceCdSearchFile((sceCdlFILE *)buf, p); 68 | } 69 | } 70 | 71 | sysmemSendEE(buf, ee_addr, pktsize); 72 | 73 | *(int *)buf = r; 74 | 75 | return buf; 76 | } 77 | 78 | void cdvdfsv_register_searchfile_rpc(SifRpcDataQueue_t *rpc_DQ) 79 | { 80 | sceSifRegisterRpc(&cdsearchfile_rpcSD, 0x80000597, &cbrpc_cdsearchfile, cdsearchfile_rpcbuf, NULL, NULL, rpc_DQ); 81 | } 82 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = cdvdman.o cdvdman_read.o ioops.o ncmd.o scmd.o searchfile.o streaming.o ioplib.o device-fhi.o imports.o exports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/cdvdman_read.h: -------------------------------------------------------------------------------- 1 | #ifndef CDVDMAN_READ_H 2 | #define CDVDMAN_READ_H 3 | 4 | 5 | #include 6 | 7 | 8 | typedef void (*StmCallback_t)(void); 9 | 10 | 11 | extern volatile unsigned char sync_flag_locked; 12 | 13 | 14 | void cdvdman_read_init(); 15 | 16 | int sceCdRead_internal(u32 lsn, u32 sectors, void *buf, sceCdRMode *mode, enum ECallSource source); 17 | void cdvdman_read_set_stm0_callback(StmCallback_t callback); 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/device-fhi.c: -------------------------------------------------------------------------------- 1 | #include "internal.h" 2 | 3 | #include "device.h" 4 | #include "fhi.h" 5 | #include "ioplib.h" 6 | 7 | // FHI exported function pointer 8 | uint32_t (*fp_fhi_size)(int file_handle); 9 | int (*fp_fhi_read)(int file_handle, void *buffer, unsigned int sector_start, unsigned int sector_count); 10 | 11 | void DeviceFSInit(void) 12 | { 13 | uint64_t iso_size; 14 | iop_library_t *lib; 15 | 16 | // Connect to FHI functions 17 | lib = ioplib_getByName("fhi\0\0\0\0\0"); 18 | fp_fhi_size = lib->exports[4]; 19 | fp_fhi_read = lib->exports[5]; 20 | 21 | M_DEBUG("Waiting for device...\n"); 22 | 23 | while (1) { 24 | iso_size = fp_fhi_size(FHI_FID_CDVD); 25 | if (iso_size > 0) 26 | break; 27 | DelayThread(100 * 1000); // 100ms 28 | } 29 | 30 | mediaLsnCount = (iso_size + 3) / 4; 31 | 32 | M_DEBUG("Waiting for device...done! connected to %dMiB iso\n", mediaLsnCount/512); 33 | } 34 | 35 | int DeviceReadSectors(u32 vlsn, void *buffer, unsigned int sectors) 36 | { 37 | int rv = SCECdErNO; 38 | u32 fid = vlsn >> 23; 39 | u32 lsn = vlsn & ((1U << 23) - 1); 40 | 41 | // M_DEBUG("%s(%u-%u, 0x%p, %u)\n", __func__, (unsigned int)fid, (unsigned int)lsn, buffer, sectors); 42 | 43 | if (fp_fhi_read(fid, buffer, lsn * 4, sectors * 4) != (sectors * 4)) { 44 | #ifdef DEBUG 45 | M_DEBUG("%s(%u-%u, 0x%p, %u) FAILED!\n", __func__, (unsigned int)fid, (unsigned int)lsn, buffer, sectors); 46 | while(1){} 47 | #endif 48 | rv = SCECdErREAD; 49 | } 50 | 51 | return rv; 52 | } 53 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/device.h: -------------------------------------------------------------------------------- 1 | void DeviceFSInit(void); // Called when the filesystem layer is initialized 2 | int DeviceReadSectors(u32 lsn, void *buffer, unsigned int sectors); 3 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/imports.lst: -------------------------------------------------------------------------------- 1 | ioman_IMPORTS_start 2 | I_AddDrv 3 | I_DelDrv 4 | ioman_IMPORTS_end 5 | 6 | //#ifdef DEBUG 7 | stdio_IMPORTS_start 8 | I_printf 9 | stdio_IMPORTS_end 10 | //#endif 11 | 12 | dmacman_IMPORTS_start 13 | I_dmac_get_dpcr2 14 | I_dmac_set_dpcr2 15 | dmacman_IMPORTS_end 16 | 17 | intrman_IMPORTS_start 18 | I_CpuSuspendIntr 19 | I_CpuResumeIntr 20 | I_QueryIntrContext 21 | I_EnableIntr 22 | I_RegisterIntrHandler 23 | intrman_IMPORTS_end 24 | 25 | sysmem_IMPORTS_start 26 | I_AllocSysMemory 27 | I_QueryTotalFreeMemSize 28 | sysmem_IMPORTS_end 29 | 30 | loadcore_IMPORTS_start 31 | I_FlushDcache 32 | I_FlushIcache 33 | I_RegisterLibraryEntries 34 | I_GetLoadcoreInternalData 35 | I_QueryBootMode 36 | loadcore_IMPORTS_end 37 | 38 | sysclib_IMPORTS_start 39 | I_memcpy 40 | I_memset 41 | I_strcpy 42 | I_strlen 43 | I_strncmp 44 | I_strchr 45 | I_strrchr 46 | I_strncpy 47 | I_sprintf 48 | sysclib_IMPORTS_end 49 | 50 | thsemap_IMPORTS_start 51 | I_CreateSema 52 | I_SignalSema 53 | I_iSignalSema 54 | I_WaitSema 55 | I_DeleteSema 56 | I_PollSema 57 | thsemap_IMPORTS_end 58 | 59 | thbase_IMPORTS_start 60 | I_CheckThreadStack 61 | I_CreateThread 62 | I_StartThread 63 | I_DelayThread 64 | I_SetAlarm 65 | I_iSetAlarm 66 | I_CancelAlarm 67 | I_USec2SysClock 68 | I_SleepThread 69 | I_iWakeupThread 70 | I_GetSystemTime 71 | thbase_IMPORTS_end 72 | 73 | thevent_IMPORTS_start 74 | I_CreateEventFlag 75 | I_ClearEventFlag 76 | I_iClearEventFlag 77 | I_SetEventFlag 78 | I_iSetEventFlag 79 | I_WaitEventFlag 80 | I_PollEventFlag 81 | thevent_IMPORTS_end 82 | 83 | sifman_IMPORTS_start 84 | I_sceSifSetDma 85 | I_sceSifDmaStat 86 | sifman_IMPORTS_end 87 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/internal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CDVDMAN_INTERNAL__ 3 | #define __CDVDMAN_INTERNAL__ 4 | 5 | #include "dev9.h" 6 | #include "cdvdman_opl.h" 7 | #include "cdvd_config.h" 8 | #include "device.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "ioman_add.h" 24 | 25 | #include 26 | #include "mprintf.h" 27 | 28 | #define MODNAME "cdvd_driver" 29 | 30 | // Event flags 31 | #define CDVDEF_MAN_UNLOCKED 0x0001 32 | #define CDVDEF_POWER_OFF 0x0002 33 | #define CDVDEF_FSV_S596 0x0004 34 | #define CDVDEF_STM_DONE 0x0008 // Streaming read done 35 | #define CDVDEF_READ_END 0x1000 // Accurate reads timing event 36 | #define CDVDEF_CB_DONE 0x2000 37 | 38 | struct SteamingData 39 | { 40 | unsigned short int StBufmax; 41 | unsigned short int StBankmax; 42 | unsigned short int StBanksize; 43 | unsigned short int StWritePtr; 44 | unsigned short int StReadPtr; 45 | unsigned short int StStreamed; 46 | unsigned short int StStat; 47 | unsigned short int StIsReading; 48 | void *StIOP_bufaddr; 49 | u32 Stlsn; 50 | }; 51 | 52 | enum ECallSource { 53 | ECS_EXTERNAL = 0, 54 | ECS_SEARCHFILE, 55 | ECS_STREAMING, 56 | ECS_EE_RPC 57 | }; 58 | 59 | typedef struct 60 | { 61 | u32 lba; 62 | u32 sectors; 63 | u16 sector_size; 64 | void *buf; 65 | enum ECallSource source; 66 | } cdvdman_read_t; 67 | 68 | typedef struct 69 | { 70 | int err; 71 | u8 status; // SCECdvdDriveState 72 | struct SteamingData StreamingData; 73 | int intr_ef; 74 | int disc_type_reg; // SCECdvdMediaType 75 | cdvdman_read_t req; // Next requested read 76 | } cdvdman_status_t; 77 | 78 | struct dirTocEntry 79 | { 80 | short length; 81 | u32 fileLBA; // 2 82 | u32 fileLBA_bigend; // 6 83 | u32 fileSize; // 10 84 | u32 fileSize_bigend; // 14 85 | u8 dateStamp[6]; // 18 86 | u8 reserved1; // 24 87 | u8 fileProperties; // 25 88 | u8 reserved2[6]; // 26 89 | u8 filenameLength; // 32 90 | char filename[128]; // 33 91 | } __attribute__((packed)); 92 | 93 | // Internal (common) function prototypes 94 | extern int sceCdGetToc_internal(u8 *toc, enum ECallSource source); 95 | extern int sceCdSeek_internal(u32 lsn, enum ECallSource source); 96 | extern int sceCdStandby_internal(enum ECallSource source); 97 | extern int sceCdStop_internal(enum ECallSource source); 98 | extern int sceCdPause_internal(enum ECallSource source); 99 | extern int sceCdBreak_internal(enum ECallSource source); 100 | 101 | extern int cdvdman_sendSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 out_size); 102 | extern void cdvdman_cb_event(int reason); 103 | 104 | extern void cdvdman_init(void); 105 | extern void cdvdman_fs_init(void); 106 | extern void cdvdman_searchfile_init(void); 107 | extern void cdvdman_initdev(void); 108 | 109 | extern struct cdvdman_settings_common cdvdman_settings; 110 | 111 | // Normally this buffer is only used by 'searchfile', only 1 sector used 112 | #define CDVDMAN_BUF_SECTORS 1 113 | extern u8 cdvdman_buf[CDVDMAN_BUF_SECTORS * 2048]; 114 | #define CDVDMAN_FS_BUF_ALIGNMENT 64 115 | extern u8 *cdvdman_fs_buf; 116 | 117 | extern int cdrom_io_sema; 118 | extern int cdvdman_searchfilesema; 119 | 120 | extern cdvdman_status_t cdvdman_stat; 121 | 122 | extern volatile unsigned char cdvdman_cdinited; 123 | extern u32 mediaLsnCount; 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/ioman_add.h: -------------------------------------------------------------------------------- 1 | #ifndef _IOMAN_ADD_H_ 2 | #define _IOMAN_ADD_H_ 3 | 4 | #include 5 | 6 | #define IOP_DT_FSEXT 0x10000000 7 | 8 | typedef struct _iop_ext_device 9 | { 10 | const char *name; 11 | unsigned int type; 12 | unsigned int version; /* Not so sure about this one. */ 13 | const char *desc; 14 | struct _iop_ext_device_ops *ops; 15 | } iop_ext_device_t; 16 | 17 | typedef struct _iop_ext_device_ops 18 | { 19 | int (*init)(iop_device_t *); 20 | int (*deinit)(iop_device_t *); 21 | int (*format)(iop_file_t *); 22 | int (*open)(iop_file_t *, const char *, int); 23 | int (*close)(iop_file_t *); 24 | int (*read)(iop_file_t *, void *, int); 25 | int (*write)(iop_file_t *, void *, int); 26 | int (*lseek)(iop_file_t *, int, int); 27 | int (*ioctl)(iop_file_t *, unsigned long, void *); 28 | int (*remove)(iop_file_t *, const char *); 29 | int (*mkdir)(iop_file_t *, const char *); 30 | int (*rmdir)(iop_file_t *, const char *); 31 | int (*dopen)(iop_file_t *, const char *); 32 | int (*dclose)(iop_file_t *); 33 | int (*dread)(iop_file_t *, iox_dirent_t *); 34 | int (*getstat)(iop_file_t *, const char *, iox_stat_t *); 35 | int (*chstat)(iop_file_t *, const char *, iox_stat_t *, unsigned int); 36 | /* Extended ops start here. */ 37 | int (*rename)(iop_file_t *, const char *, const char *); 38 | int (*chdir)(iop_file_t *, const char *); 39 | int (*sync)(iop_file_t *, const char *, int); 40 | int (*mount)(iop_file_t *, const char *, const char *, int, void *, unsigned int); 41 | int (*umount)(iop_file_t *, const char *); 42 | long long (*lseek64)(iop_file_t *, long long, int); 43 | int (*devctl)(iop_file_t *, const char *, int, void *, unsigned int, void *, unsigned int); 44 | int (*symlink)(iop_file_t *, const char *, const char *); 45 | int (*readlink)(iop_file_t *, const char *, char *, unsigned int); 46 | int (*ioctl2)(iop_file_t *, int, void *, unsigned int, void *, unsigned int); 47 | 48 | } iop_ext_device_ops_t; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | #include 4 | 5 | iop_library_t *ioplib_getByName(const char *name) 6 | { 7 | iop_library_t *libptr; 8 | int i; 9 | 10 | // Get first loaded library 11 | libptr = GetLoadcoreInternalData()->let_next; 12 | // Loop through all loaded libraries 13 | while (libptr != NULL) { 14 | // Compare library name only 15 | for (i = 0; i < 8; i++) { 16 | if (libptr->name[i] != name[i]) 17 | break; 18 | } 19 | 20 | // Return if match 21 | if (i == 8) 22 | return libptr; 23 | 24 | // Next library 25 | libptr = libptr->prev; 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | unsigned int ioplib_getTableSize(iop_library_t *lib) 32 | { 33 | void **exp; 34 | unsigned int size; 35 | 36 | exp = NULL; 37 | if (lib != NULL) { 38 | exp = lib->exports; 39 | } 40 | size = 0; 41 | 42 | if (exp != NULL) 43 | while (*exp++ != NULL) 44 | size++; 45 | 46 | return size; 47 | } 48 | 49 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 50 | { 51 | if (entry < ioplib_getTableSize(lib)) { 52 | int oldstate; 53 | void **exp, *temp; 54 | 55 | exp = &lib->exports[entry]; 56 | 57 | CpuSuspendIntr(&oldstate); 58 | temp = *exp; 59 | *exp = func; 60 | func = temp; 61 | CpuResumeIntr(oldstate); 62 | 63 | return func; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | void ioplib_relinkExports(iop_library_t *lib) 70 | { 71 | struct irx_import_table *table; 72 | struct irx_import_stub *stub; 73 | 74 | // go through each table that imports the library 75 | for (table = lib->caller; table != NULL; table = table->next) { 76 | // go through each import in the table 77 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 78 | // patch the stub to jump to the address specified in the library export table for "fno" 79 | stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/cdvdman_emu/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | * irx_imports.h - Defines all IRX imports. 3 | * 4 | * Copyright (c) 2003 Marcus R. Brown 5 | * 6 | * See the file LICENSE included with this distribution for licensing terms. 7 | */ 8 | 9 | #ifndef IOP_IRX_IMPORTS_H 10 | #define IOP_IRX_IMPORTS_H 11 | 12 | #include "irx.h" 13 | 14 | /* Please keep these in alphabetical order! */ 15 | #include "dmacman.h" 16 | #include "intrman.h" 17 | #include "ioman.h" 18 | #include "loadcore.h" 19 | #include "sifman.h" 20 | #include "stdio.h" 21 | #include "sysclib.h" 22 | #include "sysmem.h" 23 | #include "thbase.h" 24 | #include "thevent.h" 25 | #ifdef ALT_READ_CORE 26 | #include "thmsgbx.h" 27 | #endif 28 | #include "thsemap.h" 29 | 30 | #endif /* IOP_IRX_IMPORTS_H */ 31 | -------------------------------------------------------------------------------- /iop/cdvdman_esr1/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = scecdvdv.o imports.o exports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/cdvdman_esr1/src/exports.tab: -------------------------------------------------------------------------------- 1 | /**/ 2 | 3 | DECLARE_EXPORT_TABLE(esr_sl, 1, 1) 4 | DECLARE_EXPORT(_start) 5 | DECLARE_EXPORT(_retnull) 6 | DECLARE_EXPORT(_retnull) 7 | DECLARE_EXPORT(_retnull) 8 | DECLARE_EXPORT(in_out_func) 9 | END_EXPORT_TABLE 10 | 11 | void _retnull(){} 12 | -------------------------------------------------------------------------------- /iop/cdvdman_esr1/src/imports.lst: -------------------------------------------------------------------------------- 1 | cdvdman_IMPORTS_start 2 | I_sceCdGetError 3 | I_sceCdRV 4 | cdvdman_IMPORTS_end 5 | 6 | loadcore_IMPORTS_start 7 | I_RegisterLibraryEntries 8 | loadcore_IMPORTS_end 9 | 10 | #ifdef DEBUG 11 | stdio_IMPORTS_start 12 | I_printf 13 | stdio_IMPORTS_end 14 | #endif 15 | 16 | sysmem_IMPORTS_start 17 | I_FreeSysMemory 18 | I_QueryMaxFreeMemSize 19 | sysmem_IMPORTS_end 20 | 21 | thbase_IMPORTS_start 22 | I_CreateThread 23 | I_StartThread 24 | I_DelayThread 25 | thbase_IMPORTS_end 26 | -------------------------------------------------------------------------------- /iop/cdvdman_esr1/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # $Id: irx_imports.h 577 2004-09-14 14:41:46Z pixel $ 11 | # Defines all IRX imports. 12 | */ 13 | 14 | #ifndef IOP_IRX_IMPORTS_H 15 | #define IOP_IRX_IMPORTS_H 16 | 17 | #include "irx.h" 18 | 19 | /* Please keep these in alphabetical order! */ 20 | #include "cdvdman.h" 21 | #include "loadcore.h" 22 | #include "stdio.h" 23 | #include "sysmem.h" 24 | #include "thbase.h" 25 | 26 | #endif /* IOP_IRX_IMPORTS_H */ 27 | -------------------------------------------------------------------------------- /iop/cdvdman_esr1/src/scecdvdv.h: -------------------------------------------------------------------------------- 1 | #ifndef __CDVD_DEFS_H 2 | #define __CDVD_DEFS_H 3 | 4 | enum outType { 5 | enum_def_sceCdCallback = 0, 6 | enum_hook_sceCdCallback, 7 | enum_def_sceCdstm0Cb, 8 | enum_hook_sceCdstm0Cb, 9 | enum_def_sceCdstm1Cb, 10 | enum_hook_sceCdstm1Cb, 11 | enum_def_sceCdRead0, 12 | enum_hook_sceCdRead0, 13 | enum_def_sceCdMmode, 14 | enum_hook_sceCdMmode, 15 | enum_discType, 16 | enum_def_RegisterIntrHandler, 17 | enum_hook_RegisterIntrHandler, 18 | enum_def_AllocSysMemory, 19 | enum_hook_AllocSysMemory 20 | }; 21 | 22 | void readCallback(int reason); 23 | 24 | #endif //__CDVD_DEFS_H 25 | -------------------------------------------------------------------------------- /iop/cdvdman_esr2/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = ioplib.o pscecdvdv.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/cdvdman_esr2/src/esrimp.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_ESRIMP_H 2 | #define IOP_ESRIMP_H 3 | 4 | #include "types.h" 5 | #include "irx.h" 6 | 7 | #define esrimp_IMPORTS_start DECLARE_IMPORT_TABLE(esr_sl, 1, 1) 8 | #define esrimp_IMPORTS_end END_IMPORT_TABLE 9 | 10 | void *in_out_func(int type); 11 | #define I_in_out_func DECLARE_IMPORT(4, in_out_func) 12 | 13 | #endif /* IOP_ESRIMP_H */ 14 | -------------------------------------------------------------------------------- /iop/cdvdman_esr2/src/imports.lst: -------------------------------------------------------------------------------- 1 | cdvdman_IMPORTS_start 2 | I_sceCdInit 3 | I_sceCdSync 4 | I_sceCdReadDVDV 5 | I_sceCdGetError 6 | cdvdman_IMPORTS_end 7 | 8 | esrimp_IMPORTS_start 9 | I_in_out_func 10 | esrimp_IMPORTS_end 11 | 12 | intrman_IMPORTS_start 13 | I_CpuSuspendIntr 14 | I_CpuResumeIntr 15 | intrman_IMPORTS_end 16 | 17 | loadcore_IMPORTS_start 18 | I_GetLoadcoreInternalData 19 | I_FlushIcache 20 | I_FlushDcache 21 | loadcore_IMPORTS_end 22 | 23 | #ifdef DEBUG 24 | stdio_IMPORTS_start 25 | I_printf 26 | stdio_IMPORTS_end 27 | #endif 28 | 29 | sysclib_IMPORTS_start 30 | I_memset 31 | I_memmove 32 | sysclib_IMPORTS_end 33 | -------------------------------------------------------------------------------- /iop/cdvdman_esr2/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | 4 | iop_library_t *ioplib_getByName(const char *name) 5 | { 6 | iop_library_t *libptr; 7 | int i; 8 | 9 | // Get first loaded library 10 | libptr = GetLoadcoreInternalData()->let_next; 11 | // Loop through all loaded libraries 12 | while (libptr != NULL) { 13 | // Compare library name only 14 | for (i = 0; i < 8; i++) { 15 | if (libptr->name[i] != name[i]) 16 | break; 17 | } 18 | 19 | // Return if match 20 | if (i == 8) 21 | return libptr; 22 | 23 | // Next library 24 | libptr = libptr->prev; 25 | } 26 | 27 | return NULL; 28 | } 29 | 30 | unsigned int ioplib_getTableSize(iop_library_t *lib) 31 | { 32 | void **exp; 33 | unsigned int size; 34 | 35 | exp = NULL; 36 | if (lib != NULL) { 37 | exp = lib->exports; 38 | } 39 | size = 0; 40 | 41 | if (exp != NULL) 42 | while (*exp++ != NULL) 43 | size++; 44 | 45 | return size; 46 | } 47 | 48 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 49 | { 50 | if (entry < ioplib_getTableSize(lib)) { 51 | int oldstate; 52 | void **exp, *temp; 53 | 54 | exp = &lib->exports[entry]; 55 | 56 | CpuSuspendIntr(&oldstate); 57 | temp = *exp; 58 | *exp = func; 59 | func = temp; 60 | CpuResumeIntr(oldstate); 61 | 62 | return func; 63 | } 64 | 65 | return NULL; 66 | } 67 | 68 | void ioplib_relinkExports(iop_library_t *lib) 69 | { 70 | struct irx_import_table *table; 71 | struct irx_import_stub *stub; 72 | 73 | // go through each table that imports the library 74 | for (table = lib->caller; table != NULL; table = table->next) { 75 | // go through each import in the table 76 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 77 | // patch the stub to jump to the address specified in the library export table for "fno" 78 | stub->jump = 0x08000000 | (((u32)lib->exports[stub->fno] << 4) >> 6); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /iop/cdvdman_esr2/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/cdvdman_esr2/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # $Id: irx_imports.h 577 2004-09-14 14:41:46Z pixel $ 11 | # Defines all IRX imports. 12 | */ 13 | 14 | #ifndef IOP_IRX_IMPORTS_H 15 | #define IOP_IRX_IMPORTS_H 16 | 17 | #include "irx.h" 18 | 19 | /* Please keep these in alphabetical order! */ 20 | #include "cdvdman.h" 21 | #include "esrimp.h" 22 | #include "intrman.h" 23 | #include "loadcore.h" 24 | #include "stdio.h" 25 | #include "sysclib.h" 26 | 27 | #endif /* IOP_IRX_IMPORTS_H */ 28 | -------------------------------------------------------------------------------- /iop/common/cdvd_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CDVD_CONFIG__ 2 | #define __CDVD_CONFIG__ 3 | 4 | #include 5 | 6 | // flags 7 | #define CDVDMAN_COMPAT_FAST_READ (1<<0) // ~MODE_1 8 | #define CDVDMAN_COMPAT_SYNC_READ (1<<1) // MODE_2 9 | #define CDVDMAN_COMPAT_EMU_DVDDL (1<<2) // MODE_5 10 | #define CDVDMAN_COMPAT_F1_2001 (1<<3) 11 | #define CDVDMAN_COMPAT_SYNC_CALLBACK (1<<4) // MODE_2 12 | 13 | #define MODULE_SETTINGS_MAGIC 0xf1f2f3f4 14 | struct cdvdman_settings_common 15 | { 16 | // Magic number to find 17 | u32 magic; 18 | 19 | u8 media; 20 | u8 fs_sectors; // Number of sectors to allocate for sector buffer 21 | u16 flags; 22 | u32 layer1_start; 23 | 24 | union { 25 | u8 ilink_id[8]; 26 | u64 ilink_id_int; 27 | }; 28 | 29 | union { 30 | u8 disk_id[5]; 31 | u64 disk_id_int; // 8 bytes, but that's ok for compare reasons 32 | }; 33 | } __attribute__((packed)); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /iop/common/cdvdman_opl.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CDVDMAN__ 3 | #define __CDVDMAN__ 4 | 5 | // PS2 CDVD hardware registers 6 | #define CDL_DATA_RDY 0x01 7 | #define CDL_DATA_COMPLETE 0x02 8 | #define CDL_DATA_END 0x04 9 | 10 | #define CDVDreg_NCOMMAND (*(volatile unsigned char *)0xBF402004) 11 | #define CDVDreg_READY (*(volatile unsigned char *)0xBF402005) 12 | #define CDVDreg_NDATAIN (*(volatile unsigned char *)0xBF402005) 13 | #define CDVDreg_ERROR (*(volatile unsigned char *)0xBF402006) 14 | #define CDVDreg_HOWTO (*(volatile unsigned char *)0xBF402006) 15 | #define CDVDreg_ABORT (*(volatile unsigned char *)0xBF402007) 16 | #define CDVDreg_PWOFF (*(volatile unsigned char *)0xBF402008) 17 | #define CDVDreg_9 (*(volatile unsigned char *)0xBF402009) 18 | #define CDVDreg_STATUS (*(volatile unsigned char *)0xBF40200A) 19 | #define CDVDreg_B (*(volatile unsigned char *)0xBF40200B) 20 | #define CDVDreg_C (*(volatile unsigned char *)0xBF40200C) 21 | #define CDVDreg_D (*(volatile unsigned char *)0xBF40200D) 22 | #define CDVDreg_E (*(volatile unsigned char *)0xBF40200E) 23 | #define CDVDreg_TYPE (*(volatile unsigned char *)0xBF40200F) 24 | #define CDVDreg_13 (*(volatile unsigned char *)0xBF402013) 25 | #define CDVDreg_SCOMMAND (*(volatile unsigned char *)0xBF402016) 26 | #define CDVDreg_SDATAIN (*(volatile unsigned char *)0xBF402017) 27 | #define CDVDreg_SDATAOUT (*(volatile unsigned char *)0xBF402018) 28 | #define CDVDreg_KEYSTATE (*(volatile unsigned char *)0xBF402038) 29 | #define CDVDreg_KEYXOR (*(volatile unsigned char *)0xBF402039) 30 | #define CDVDreg_DEC (*(volatile unsigned char *)0xBF40203A) 31 | 32 | #define CDIOC_FNUM(x) (('C' << 8) | (x)) 33 | 34 | enum CDIOC_CODE { 35 | CDIOC_READCLOCK = CDIOC_FNUM(0x0C), 36 | 37 | CDIOC_READGUID = CDIOC_FNUM(0x1D), 38 | CDIOC_READDISKGUID, 39 | CDIOC_GETDISKTYPE, 40 | CDIOC_GETERROR, 41 | CDIOC_TRAYREQ, 42 | CDIOC_STATUS, 43 | CDIOC_POWEROFF, 44 | CDIOC_MMODE, 45 | CDIOC_DISKRDY, 46 | CDIOC_READMODELID, 47 | CDIOC_STREAMINIT, 48 | CDIOC_BREAK, 49 | 50 | CDIOC_SPINNOM = CDIOC_FNUM(0x80), 51 | CDIOC_SPINSTM, 52 | CDIOC_TRYCNT, 53 | CDIOC_SEEK, 54 | CDIOC_STANDBY, 55 | CDIOC_STOP, 56 | CDIOC_PAUSE, 57 | CDIOC_GETTOC, 58 | CDIOC_SETTIMEOUT, 59 | CDIOC_READDVDDUALINFO, 60 | CDIOC_INIT, 61 | 62 | CDIOC_GETINTREVENTFLG = CDIOC_FNUM(0x91), 63 | }; 64 | 65 | void *sceGetFsvRbuf2(int *size); 66 | 67 | // Codes for use with sceCdSC() 68 | #define CDSC_GET_DEBUG_STATUS 0xFFFFFFF0 // Get debug status flag. 69 | #define CDSC_GET_INTRFLAG 0xFFFFFFF5 // Get interrupt flag. 70 | #define CDSC_IO_SEMA 0xFFFFFFF6 // Wait (param != 0) or signal (param == 0) high-level I/O semaphore. 71 | #define CDSC_GET_VERSION 0xFFFFFFF7 // Get CDVDMAN version. 72 | #define CDSC_SET_ERROR 0xFFFFFFFE // Used by CDVDFSV and CDVDSTM to set the error code (Typically READCF*). 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /iop/common/fakemod.h: -------------------------------------------------------------------------------- 1 | #ifndef FAKEMOD_H 2 | #define FAKEMOD_H 3 | 4 | 5 | #include 6 | 7 | 8 | struct FakeModule 9 | { 10 | char *fname; 11 | char *name; 12 | int id; 13 | 14 | uint16_t prop; 15 | uint16_t version; 16 | 17 | int16_t returnLoad; // Return value when loading the module 18 | int16_t returnStart; // Return value of module start function: RESIDENT END (0), NO RESIDENT END (1) or REMOVABLE END (2) 19 | uint16_t fill; 20 | } __attribute__((packed, aligned(4))); 21 | // Fake module properties 22 | #define FAKE_PROP_UNLOAD (1<<1) /// 'fake' module can be unloaded (note that re-loading is not possible!) 23 | 24 | #define MODULE_SETTINGS_MAGIC 0xf1f2f3f4 25 | #define MODULE_SETTINGS_MAX_DATA_SIZE 256 26 | #define MODULE_SETTINGS_MAX_FAKE_COUNT 10 27 | struct fakemod_data 28 | { 29 | // Magic number to find 30 | uint32_t magic; 31 | 32 | // Max 10 fake modules 33 | struct FakeModule fake[MODULE_SETTINGS_MAX_FAKE_COUNT]; 34 | 35 | // Strings used for fake module names 36 | const uint8_t data[MODULE_SETTINGS_MAX_DATA_SIZE]; 37 | } __attribute__((packed, aligned(4))); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /iop/common/fhi.h: -------------------------------------------------------------------------------- 1 | // File Handle Interface 2 | // For other modules to access neutrino/OPL files 3 | // Like ISO / VMC / ... 4 | #ifndef FHI_H 5 | #define FHI_H 6 | 7 | #define MODULE_SETTINGS_MAGIC 0xf1f2f3f4 8 | #define FHI_MAX_FILES 6 9 | 10 | #define FHI_FID_CDVD 0 11 | #define FHI_FID_ATA0 1 12 | #define FHI_FID_ATA0ID 2 13 | #define FHI_FID_ATA1 3 14 | #define FHI_FID_MC0 4 15 | #define FHI_FID_MC1 5 16 | 17 | #ifdef _IOP 18 | 19 | #include 20 | #include 21 | 22 | // Size of the file in SECTORS of 512b 23 | uint32_t fhi_size(int file_handle); 24 | // Read SECTORS from file 25 | int fhi_read(int file_handle, void *buffer, unsigned int sector_start, unsigned int sector_count); 26 | // Write SECTORS to file 27 | int fhi_write(int file_handle, const void *buffer, unsigned int sector_start, unsigned int sector_count); 28 | 29 | #define fhi_IMPORTS_start DECLARE_IMPORT_TABLE(fhi, 1, 1) 30 | #define fhi_IMPORTS_end END_IMPORT_TABLE 31 | 32 | #define I_fhi_size DECLARE_IMPORT(4, fhi_size) 33 | #define I_fhi_read DECLARE_IMPORT(5, fhi_read) 34 | #define I_fhi_write DECLARE_IMPORT(6, fhi_write) 35 | 36 | #endif // _IOP 37 | #endif // FHI_H 38 | -------------------------------------------------------------------------------- /iop/common/fhi_bd.h: -------------------------------------------------------------------------------- 1 | // File Handle Interface for Block Devices 2 | #ifndef FHI_BD_H 3 | #define FHI_BD_H 4 | 5 | 6 | #include 7 | #include "fhi.h" 8 | 9 | 10 | struct fhi_bd 11 | { 12 | // Magic number to find 13 | uint32_t magic; 14 | 15 | uint32_t drvName; /// Driver name: usb, ata, sdc, etc... 16 | uint32_t devNr; /// Device number: 0, 1, 2, etc... 17 | } __attribute__((packed)); 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /iop/common/fhi_bd_defrag.h: -------------------------------------------------------------------------------- 1 | // File Handle Interface for Block Devices with defragmentation 2 | #ifndef FHI_BD_DEFRAG_H 3 | #define FHI_BD_DEFRAG_H 4 | 5 | 6 | #include 7 | #include // bd_fragment_t 8 | #include "fhi.h" 9 | 10 | 11 | #define BDM_MAX_FRAGS 64 // 64 * 12bytes = 768bytes 12 | 13 | 14 | struct fhi_bd_defrag_info 15 | { 16 | uint8_t frag_start; /// First fragment in the fragment table 17 | uint8_t frag_count; /// Number of fragments in the fragment table 18 | uint64_t size; /// Size of the file in bytes 19 | } __attribute__((packed)); 20 | 21 | struct fhi_bd_defrag 22 | { 23 | // Magic number to find 24 | uint32_t magic; 25 | 26 | uint32_t drvName; /// Driver name: usb, ata, sdc, etc... 27 | uint32_t devNr; /// Device number: 0, 1, 2, etc... 28 | 29 | // Fragmented files: 30 | // 0 = ISO 31 | struct fhi_bd_defrag_info file[FHI_MAX_FILES]; 32 | 33 | // Fragment table, containing the fragments of all files 34 | bd_fragment_t frags[BDM_MAX_FRAGS]; 35 | } __attribute__((packed)); 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /iop/common/fhi_file.h: -------------------------------------------------------------------------------- 1 | // File Handle Interface for Files 2 | #ifndef FHI_FILE_H 3 | #define FHI_FILE_H 4 | 5 | 6 | #include 7 | #include "fhi.h" 8 | 9 | 10 | #define FHI_FILE_MAX_LEN 64 11 | 12 | 13 | struct fhi_file_info 14 | { 15 | char name[FHI_FILE_MAX_LEN]; /// File name to open, like "mass:file.iso" 16 | uint64_t size; /// Size of the file in bytes 17 | } __attribute__((packed)); 18 | 19 | struct fhi_file 20 | { 21 | // Magic number to find 22 | uint32_t magic; 23 | 24 | // Files: 25 | // 0 = ISO 26 | struct fhi_file_info file[FHI_MAX_FILES]; 27 | } __attribute__((packed)); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /iop/common/fhi_fileid.h: -------------------------------------------------------------------------------- 1 | // File Handle Interface for file ID's (already opened files) 2 | #ifndef FHI_FILEID_H 3 | #define FHI_FILEID_H 4 | 5 | 6 | #include 7 | #include "fhi.h" 8 | 9 | 10 | struct fhi_fileid_info 11 | { 12 | int id; /// File ID of already opened file 13 | uint64_t size; /// Size of the file in bytes 14 | } __attribute__((packed)); 15 | 16 | struct fhi_fileid 17 | { 18 | // Magic number to find 19 | uint32_t magic; 20 | 21 | uint32_t devNr; /// Device number: 0, 1, 2, etc... 22 | 23 | // Files: 24 | // 0 = ISO 25 | struct fhi_fileid_info file[FHI_MAX_FILES]; 26 | } __attribute__((packed)); 27 | 28 | #endif -------------------------------------------------------------------------------- /iop/common/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef MPRINTF_H 2 | #define MPRINTF_H 3 | 4 | 5 | #include 6 | 7 | #ifdef DEBUG 8 | #define DEBUG_VAL 1 9 | #else 10 | #define DEBUG_VAL 0 11 | #endif 12 | 13 | #define M_PRINTF(fmt, ...) \ 14 | printf(MODNAME ": " fmt, ##__VA_ARGS__) 15 | 16 | #define M_DEBUG(fmt, ...) \ 17 | do { if (DEBUG_VAL) M_PRINTF(fmt, ##__VA_ARGS__); } while (0) 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /iop/dev9/Makefile: -------------------------------------------------------------------------------- 1 | # Enable to disable initialization of SMAP within DEV9 (i.e. clone adaptor compatibility). 2 | DEV9_SKIP_SMAP_INIT ?= 0 3 | # Enable to enable support for the PSX's devices 4 | DEV9_PSX_SUPPORT ?= 1 5 | # Disable to disable the workaround (skip SMAP initialization) for bad GameStar compatible adaptors. 6 | DEV9_GAMESTAR_WORKAROUND ?= 1 7 | 8 | # Enable this to hide the module from games, needed by neutrino 9 | DEV9_HIDDEN ?= 0 10 | # Enable this to disable shutting down the DEV9, needed by neutrino 11 | DEV9_NO_SHUTDOWN ?= 0 12 | 13 | IOP_OBJS = ps2dev9.o exports.o imports.o 14 | 15 | ifeq ($(DEV9_SKIP_SMAP_INIT),1) 16 | IOP_CFLAGS += -DDEV9_SKIP_SMAP_INIT=1 17 | endif 18 | 19 | ifeq ($(DEV9_PSX_SUPPORT),1) 20 | IOP_CFLAGS += -DDEV9_PSX_SUPPORT=1 21 | endif 22 | 23 | ifeq ($(DEV9_GAMESTAR_WORKAROUND),1) 24 | IOP_CFLAGS += -DDEV9_GAMESTAR_WORKAROUND=1 25 | endif 26 | 27 | ifeq ($(DEV9_HIDDEN),1) 28 | IOP_CFLAGS += -DDEV9_NO_DEV9X 29 | IOP_OBJS_DIR = obj.hidden/ 30 | IOP_BIN = dev9_hidden.irx 31 | else ifeq ($(DEV9_NO_SHUTDOWN),1) 32 | IOP_CFLAGS += -DDEV9_NO_SHUTDOWN 33 | IOP_OBJS_DIR = obj.ns/ 34 | IOP_BIN = dev9_ns.irx 35 | endif 36 | 37 | include ../Rules.make 38 | -------------------------------------------------------------------------------- /iop/dev9/include/dev9.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright (c) 2003 Marcus R. Brown 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | */ 10 | 11 | /** 12 | * @file 13 | * DEV9 Device Driver definitions and imports. 14 | */ 15 | 16 | #ifndef __DEV9_H__ 17 | #define __DEV9_H__ 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | typedef int (*dev9_intr_cb_t)(int flag); 25 | typedef void (*dev9_shutdown_cb_t)(void); 26 | typedef void (*dev9_dma_cb_t)(int bcr, int dir); 27 | 28 | void dev9RegisterIntrCb(int intr, dev9_intr_cb_t cb); 29 | 30 | int dev9DmaTransfer(int ctrl, void *buf, int bcr, int dir); 31 | 32 | void dev9Shutdown(void); 33 | void dev9IntrEnable(int mask); 34 | void dev9IntrDisable(int mask); 35 | 36 | int dev9GetEEPROM(u16 *buf); 37 | 38 | void dev9LEDCtl(int ctl); 39 | void dev9LED2Ctl(int ctl); 40 | void dev9ControlPIO3(int ctl); 41 | 42 | int dev9RegisterShutdownCb(int idx, dev9_shutdown_cb_t cb); 43 | 44 | void dev9RegisterPreDmaCb(int ctrl, dev9_dma_cb_t cb); 45 | 46 | void dev9RegisterPostDmaCb(int ctrl, dev9_dma_cb_t cb); 47 | 48 | #define dev9_IMPORTS_start DECLARE_IMPORT_TABLE(dev9, 1, 9) 49 | #define dev9_IMPORTS_end END_IMPORT_TABLE 50 | 51 | #define I_dev9RegisterIntrCb DECLARE_IMPORT(4, dev9RegisterIntrCb) 52 | #define I_dev9DmaTransfer DECLARE_IMPORT(5, dev9DmaTransfer) 53 | #define I_dev9Shutdown DECLARE_IMPORT(6, dev9Shutdown) 54 | #define I_dev9IntrEnable DECLARE_IMPORT(7, dev9IntrEnable) 55 | #define I_dev9IntrDisable DECLARE_IMPORT(8, dev9IntrDisable) 56 | #define I_dev9GetEEPROM DECLARE_IMPORT(9, dev9GetEEPROM) 57 | #define I_dev9LEDCtl DECLARE_IMPORT(10, dev9LEDCtl) 58 | #define I_dev9RegisterShutdownCb DECLARE_IMPORT(11, dev9RegisterShutdownCb) 59 | #define I_dev9RegisterPreDmaCb DECLARE_IMPORT(12, dev9RegisterPreDmaCb) 60 | #define I_dev9RegisterPostDmaCb DECLARE_IMPORT(13, dev9RegisterPostDmaCb) 61 | #define I_dev9ControlPIO3 DECLARE_IMPORT(14, dev9ControlPIO3) 62 | #define I_dev9LED2Ctl DECLARE_IMPORT(15, dev9LED2Ctl) 63 | 64 | #endif /* __DEV9_H__ */ 65 | -------------------------------------------------------------------------------- /iop/dev9/src/exports.tab: -------------------------------------------------------------------------------- 1 | DECLARE_EXPORT_TABLE(dev9, 1, 9) 2 | DECLARE_EXPORT(_start) 3 | DECLARE_EXPORT(_retonly) 4 | DECLARE_EXPORT(_exit) 5 | DECLARE_EXPORT(_retonly) 6 | 7 | /* 4 */ 8 | DECLARE_EXPORT(dev9RegisterIntrCb) 9 | DECLARE_EXPORT(dev9DmaTransfer) 10 | DECLARE_EXPORT(dev9Shutdown) 11 | DECLARE_EXPORT(dev9IntrEnable) 12 | DECLARE_EXPORT(dev9IntrDisable) 13 | DECLARE_EXPORT(dev9GetEEPROM) 14 | DECLARE_EXPORT(dev9LEDCtl) 15 | DECLARE_EXPORT(dev9RegisterShutdownCb) 16 | DECLARE_EXPORT(dev9RegisterPreDmaCb) 17 | DECLARE_EXPORT(dev9RegisterPostDmaCb) 18 | DECLARE_EXPORT(dev9ControlPIO3) 19 | DECLARE_EXPORT(dev9LED2Ctl) 20 | END_EXPORT_TABLE 21 | 22 | void _retonly() {} 23 | -------------------------------------------------------------------------------- /iop/dev9/src/imports.lst: -------------------------------------------------------------------------------- 1 | dmacman_IMPORTS_start 2 | I_dmac_get_dpcr2 3 | I_dmac_set_dpcr2 4 | dmacman_IMPORTS_end 5 | 6 | intrman_IMPORTS_start 7 | I_RegisterIntrHandler 8 | I_EnableIntr 9 | I_DisableIntr 10 | I_CpuSuspendIntr 11 | I_CpuResumeIntr 12 | intrman_IMPORTS_end 13 | 14 | ioman_IMPORTS_start 15 | I_AddDrv 16 | I_DelDrv 17 | ioman_IMPORTS_end 18 | 19 | loadcore_IMPORTS_start 20 | I_RegisterLibraryEntries 21 | I_QueryBootMode 22 | loadcore_IMPORTS_end 23 | 24 | stdio_IMPORTS_start 25 | I_printf 26 | stdio_IMPORTS_end 27 | 28 | sysclib_IMPORTS_start 29 | I_strcmp 30 | I_strrchr 31 | sysclib_IMPORTS_end 32 | 33 | thbase_IMPORTS_start 34 | I_DelayThread 35 | thbase_IMPORTS_end 36 | 37 | thsemap_IMPORTS_start 38 | I_CreateSema 39 | I_SignalSema 40 | I_WaitSema 41 | thsemap_IMPORTS_end 42 | -------------------------------------------------------------------------------- /iop/dev9/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright (c) 2003 Marcus R. Brown 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # Defines all IRX imports. 11 | */ 12 | 13 | #ifndef IOP_IRX_IMPORTS_H 14 | #define IOP_IRX_IMPORTS_H 15 | 16 | #include "irx.h" 17 | 18 | /* Please keep these in alphabetical order! */ 19 | #include "dmacman.h" 20 | #include "intrman.h" 21 | #include "ioman.h" 22 | #include "loadcore.h" 23 | #include "stdio.h" 24 | #include "sysclib.h" 25 | #include "thbase.h" 26 | #include "thsemap.h" 27 | 28 | #endif /* IOP_IRX_IMPORTS_H */ 29 | -------------------------------------------------------------------------------- /iop/fakemod/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o ioplib.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/fakemod/src/elf.h: -------------------------------------------------------------------------------- 1 | #ifndef ELF_H 2 | #define ELF_H 3 | 4 | 5 | #include 6 | 7 | 8 | #define ELF_MAGIC 0x464c457f // ".ELF" 9 | #define ELF_PT_LOAD 1 10 | 11 | 12 | typedef struct 13 | { 14 | uint8_t ident[16]; // struct definition for ELF object header 15 | uint16_t type; 16 | uint16_t machine; 17 | uint32_t version; 18 | uint32_t entry; 19 | uint32_t phoff; 20 | uint32_t shoff; 21 | uint32_t flags; 22 | uint16_t ehsize; 23 | uint16_t phentsize; 24 | uint16_t phnum; 25 | uint16_t shentsize; 26 | uint16_t shnum; 27 | uint16_t shstrndx; 28 | } elf_header_t; 29 | 30 | typedef struct 31 | { 32 | uint32_t type; // struct definition for ELF program section header 33 | uint32_t offset; 34 | void *vaddr; 35 | uint32_t paddr; 36 | uint32_t filesz; 37 | uint32_t memsz; 38 | uint32_t flags; 39 | uint32_t align; 40 | } elf_pheader_t; 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /iop/fakemod/src/imports.lst: -------------------------------------------------------------------------------- 1 | intrman_IMPORTS_start 2 | I_CpuSuspendIntr 3 | I_CpuResumeIntr 4 | intrman_IMPORTS_end 5 | 6 | loadcore_IMPORTS_start 7 | I_GetLoadcoreInternalData 8 | loadcore_IMPORTS_end 9 | 10 | #ifdef DEBUG 11 | stdio_IMPORTS_start 12 | I_printf 13 | stdio_IMPORTS_end 14 | #endif 15 | 16 | sysclib_IMPORTS_start 17 | I_memset 18 | I_strcpy 19 | I_strstr 20 | sysclib_IMPORTS_end 21 | -------------------------------------------------------------------------------- /iop/fakemod/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | #include 4 | 5 | iop_library_t *ioplib_getByName(const char *name) 6 | { 7 | iop_library_t *libptr; 8 | int i; 9 | 10 | // Get first loaded library 11 | libptr = GetLoadcoreInternalData()->let_next; 12 | // Loop through all loaded libraries 13 | while (libptr != NULL) { 14 | // Compare library name only 15 | for (i = 0; i < 8; i++) { 16 | if (libptr->name[i] != name[i]) 17 | break; 18 | } 19 | 20 | // Return if match 21 | if (i == 8) 22 | return libptr; 23 | 24 | // Next library 25 | libptr = libptr->prev; 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | unsigned int ioplib_getTableSize(iop_library_t *lib) 32 | { 33 | void **exp; 34 | unsigned int size; 35 | 36 | exp = NULL; 37 | if (lib != NULL) { 38 | exp = lib->exports; 39 | } 40 | size = 0; 41 | 42 | if (exp != NULL) 43 | while (*exp++ != NULL) 44 | size++; 45 | 46 | return size; 47 | } 48 | 49 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 50 | { 51 | if (entry < ioplib_getTableSize(lib)) { 52 | int oldstate; 53 | void **exp, *temp; 54 | 55 | exp = &lib->exports[entry]; 56 | 57 | CpuSuspendIntr(&oldstate); 58 | temp = *exp; 59 | *exp = func; 60 | func = temp; 61 | CpuResumeIntr(oldstate); 62 | 63 | return func; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | void ioplib_relinkExports(iop_library_t *lib) 70 | { 71 | struct irx_import_table *table; 72 | struct irx_import_stub *stub; 73 | 74 | // go through each table that imports the library 75 | for (table = lib->caller; table != NULL; table = table->next) { 76 | // go through each import in the table 77 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 78 | // patch the stub to jump to the address specified in the library export table for "fno" 79 | stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /iop/fakemod/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/fakemod/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "intrman.h" 7 | #include "loadcore.h" 8 | #include "stdio.h" 9 | #include "sysclib.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /iop/fhi_bd/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o imports.o exports.o 2 | IOP_LIBS = -L$(PS2SDK)/iop/lib -lbdm 3 | 4 | include ../Rules.make 5 | -------------------------------------------------------------------------------- /iop/fhi_bd/src/exports.tab: -------------------------------------------------------------------------------- 1 | void _retonly(void) {} 2 | 3 | int _ret0(void) { 4 | return 0; 5 | } 6 | 7 | int _dummy(void) { 8 | return 1; 9 | } 10 | 11 | DECLARE_EXPORT_TABLE(bdm, 1, 1) 12 | DECLARE_EXPORT(_retonly) 13 | DECLARE_EXPORT(_retonly) 14 | DECLARE_EXPORT(_ret0) 15 | DECLARE_EXPORT(_retonly) 16 | DECLARE_EXPORT(bdm_connect_bd) 17 | DECLARE_EXPORT(bdm_disconnect_bd) 18 | // DECLARE_EXPORT(bdm_connect_fs) 19 | // DECLARE_EXPORT(bdm_disconnect_fs) 20 | // DECLARE_EXPORT(bdm_get_bd) 21 | // DECLARE_EXPORT(bdm_RegisterCallback) 22 | END_EXPORT_TABLE 23 | 24 | DECLARE_EXPORT_TABLE(fhi, 1, 1) 25 | DECLARE_EXPORT(_retonly) 26 | DECLARE_EXPORT(_retonly) 27 | DECLARE_EXPORT(_ret0) 28 | DECLARE_EXPORT(_retonly) 29 | DECLARE_EXPORT(fhi_size) 30 | DECLARE_EXPORT(fhi_read) 31 | DECLARE_EXPORT(fhi_write) 32 | END_EXPORT_TABLE 33 | -------------------------------------------------------------------------------- /iop/fhi_bd/src/imports.lst: -------------------------------------------------------------------------------- 1 | loadcore_IMPORTS_start 2 | I_RegisterLibraryEntries 3 | loadcore_IMPORTS_end 4 | 5 | #ifdef DEBUG 6 | stdio_IMPORTS_start 7 | I_printf 8 | stdio_IMPORTS_end 9 | #endif 10 | 11 | sysclib_IMPORTS_start 12 | I_strncmp 13 | sysclib_IMPORTS_end 14 | 15 | #ifdef DEBUG 16 | thbase_IMPORTS_start 17 | I_CreateThread 18 | I_StartThread 19 | I_DelayThread 20 | thbase_IMPORTS_end 21 | #endif 22 | 23 | thsemap_IMPORTS_start 24 | I_CreateSema 25 | I_SignalSema 26 | I_WaitSema 27 | thsemap_IMPORTS_end 28 | -------------------------------------------------------------------------------- /iop/fhi_bd/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "loadcore.h" 7 | #include "stdio.h" 8 | #include "sysclib.h" 9 | #include "thbase.h" 10 | #include "thsemap.h" 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /iop/fhi_bd_defrag/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o imports.o exports.o 2 | IOP_LIBS = -L$(PS2SDK)/iop/lib -lbdm 3 | 4 | include ../Rules.make 5 | -------------------------------------------------------------------------------- /iop/fhi_bd_defrag/src/exports.tab: -------------------------------------------------------------------------------- 1 | void _retonly(void) {} 2 | 3 | int _ret0(void) { 4 | return 0; 5 | } 6 | 7 | int _dummy(void) { 8 | return 1; 9 | } 10 | 11 | DECLARE_EXPORT_TABLE(bdm, 1, 1) 12 | DECLARE_EXPORT(_retonly) 13 | DECLARE_EXPORT(_retonly) 14 | DECLARE_EXPORT(_ret0) 15 | DECLARE_EXPORT(_retonly) 16 | DECLARE_EXPORT(bdm_connect_bd) 17 | DECLARE_EXPORT(bdm_disconnect_bd) 18 | // DECLARE_EXPORT(bdm_connect_fs) 19 | // DECLARE_EXPORT(bdm_disconnect_fs) 20 | // DECLARE_EXPORT(bdm_get_bd) 21 | // DECLARE_EXPORT(bdm_RegisterCallback) 22 | END_EXPORT_TABLE 23 | 24 | DECLARE_EXPORT_TABLE(fhi, 1, 1) 25 | DECLARE_EXPORT(_retonly) 26 | DECLARE_EXPORT(_retonly) 27 | DECLARE_EXPORT(_ret0) 28 | DECLARE_EXPORT(_retonly) 29 | DECLARE_EXPORT(fhi_size) 30 | DECLARE_EXPORT(fhi_read) 31 | DECLARE_EXPORT(fhi_write) 32 | END_EXPORT_TABLE 33 | -------------------------------------------------------------------------------- /iop/fhi_bd_defrag/src/imports.lst: -------------------------------------------------------------------------------- 1 | loadcore_IMPORTS_start 2 | I_RegisterLibraryEntries 3 | loadcore_IMPORTS_end 4 | 5 | stdio_IMPORTS_start 6 | I_printf // used by libbdm! 7 | stdio_IMPORTS_end 8 | 9 | sysclib_IMPORTS_start 10 | I_strncmp 11 | sysclib_IMPORTS_end 12 | 13 | #ifdef DEBUG 14 | thbase_IMPORTS_start 15 | I_CreateThread 16 | I_StartThread 17 | I_DelayThread 18 | thbase_IMPORTS_end 19 | #endif 20 | 21 | thsemap_IMPORTS_start 22 | I_CreateSema 23 | I_SignalSema 24 | I_WaitSema 25 | thsemap_IMPORTS_end 26 | -------------------------------------------------------------------------------- /iop/fhi_bd_defrag/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "loadcore.h" 7 | #include "stdio.h" 8 | #include "sysclib.h" 9 | #include "thbase.h" 10 | #include "thsemap.h" 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /iop/fhi_file/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o imports.o exports.o 2 | IOP_LIBS = -L$(PS2SDK)/iop/lib -lbdm 3 | 4 | include ../Rules.make 5 | -------------------------------------------------------------------------------- /iop/fhi_file/src/exports.tab: -------------------------------------------------------------------------------- 1 | void _retonly(void) {} 2 | 3 | int _ret0(void) { 4 | return 0; 5 | } 6 | 7 | int _dummy(void) { 8 | return 1; 9 | } 10 | 11 | DECLARE_EXPORT_TABLE(fhi, 1, 1) 12 | DECLARE_EXPORT(_retonly) 13 | DECLARE_EXPORT(_retonly) 14 | DECLARE_EXPORT(_ret0) 15 | DECLARE_EXPORT(_retonly) 16 | DECLARE_EXPORT(fhi_size) 17 | DECLARE_EXPORT(fhi_read) 18 | DECLARE_EXPORT(fhi_write) 19 | END_EXPORT_TABLE 20 | -------------------------------------------------------------------------------- /iop/fhi_file/src/imports.lst: -------------------------------------------------------------------------------- 1 | ioman_IMPORTS_start 2 | I_open 3 | I_lseek 4 | I_read 5 | I_close 6 | ioman_IMPORTS_end 7 | 8 | loadcore_IMPORTS_start 9 | I_RegisterLibraryEntries 10 | loadcore_IMPORTS_end 11 | 12 | stdio_IMPORTS_start 13 | I_printf // used by libbdm! 14 | stdio_IMPORTS_end 15 | 16 | sysclib_IMPORTS_start 17 | I_strncmp 18 | sysclib_IMPORTS_end 19 | 20 | #ifdef DEBUG 21 | thbase_IMPORTS_start 22 | I_CreateThread 23 | I_StartThread 24 | I_DelayThread 25 | thbase_IMPORTS_end 26 | #endif 27 | 28 | thsemap_IMPORTS_start 29 | I_CreateSema 30 | I_SignalSema 31 | I_WaitSema 32 | thsemap_IMPORTS_end 33 | -------------------------------------------------------------------------------- /iop/fhi_file/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include "ioman.h" 7 | #include "loadcore.h" 8 | #include "stdio.h" 9 | #include "sysclib.h" 10 | #include "thbase.h" 11 | #include "thsemap.h" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /iop/fhi_file/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "fhi_file.h" 9 | #include "mprintf.h" 10 | 11 | #define MODNAME "fhi" // give all fhi modules the same name 12 | IRX_ID(MODNAME, 1, 1); 13 | 14 | struct fhi_file fhi = {MODULE_SETTINGS_MAGIC}; 15 | 16 | extern struct irx_export_table _exp_fhi; 17 | 18 | //--------------------------------------------------------------------------- 19 | // FHI export #4 20 | u32 fhi_size(int file_handle) 21 | { 22 | if (file_handle < 0 || file_handle >= FHI_MAX_FILES) 23 | return 0; 24 | 25 | M_DEBUG("%s(%d)\n", __func__, file_handle); 26 | 27 | return fhi.file[file_handle].size / 512; 28 | } 29 | 30 | //--------------------------------------------------------------------------- 31 | // FHI export #5 32 | int fhi_read(int file_handle, void *buffer, unsigned int sector_start, unsigned int sector_count) 33 | { 34 | int rv = 0; 35 | struct fhi_file_info *ff; 36 | 37 | if (file_handle) 38 | M_DEBUG("%s(%d, 0x%x, %d, %d)\n", __func__, file_handle, buffer, sector_start, sector_count); 39 | 40 | if (file_handle < 0 || file_handle >= FHI_MAX_FILES) 41 | return -1; 42 | 43 | ff = &fhi.file[file_handle]; 44 | 45 | // Make nicer! 46 | int fd = open(ff->name, FIO_O_RDONLY); 47 | if (fd > 0) { 48 | lseek(fd, sector_start * 512, FIO_SEEK_SET); 49 | if (read(fd, buffer, sector_count * 512) == sector_count * 512) 50 | rv = sector_count; 51 | close(fd); 52 | } 53 | 54 | return rv; 55 | } 56 | 57 | //--------------------------------------------------------------------------- 58 | // FHI export #6 59 | int fhi_write(int file_handle, const void *buffer, unsigned int sector_start, unsigned int sector_count) 60 | { 61 | int rv; 62 | //struct fhi_file_info *ff; 63 | 64 | if (file_handle) 65 | M_DEBUG("%s(%d, 0x%x, %d, %d)\n", __func__, file_handle, buffer, sector_start, sector_count); 66 | 67 | if (file_handle < 0 || file_handle >= FHI_MAX_FILES) 68 | return -1; 69 | 70 | //ff = &fhi.file[file_handle]; 71 | 72 | // TODO! 73 | 74 | return rv; 75 | } 76 | 77 | //--------------------------------------------------------------------------- 78 | #ifdef DEBUG 79 | static void watchdog_thread() 80 | { 81 | while (1) { 82 | M_DEBUG("FHI alive\n"); 83 | DelayThread(5 * 1000 * 1000); // 5s 84 | } 85 | } 86 | #endif 87 | 88 | //--------------------------------------------------------------------------- 89 | int _start(int argc, char **argv) 90 | { 91 | #ifdef DEBUG 92 | int th; 93 | iop_thread_t ThreadData; 94 | #endif 95 | 96 | M_DEBUG("%s\n", __func__); 97 | 98 | #ifdef DEBUG 99 | ThreadData.attr = TH_C; 100 | ThreadData.thread = (void *)watchdog_thread; 101 | ThreadData.option = 0; 102 | ThreadData.priority = 40; 103 | ThreadData.stacksize = 0x1000; 104 | th = CreateThread(&ThreadData); 105 | StartThread(th, 0); 106 | #endif 107 | 108 | RegisterLibraryEntries(&_exp_fhi); 109 | 110 | return MODULE_RESIDENT_END; 111 | } 112 | -------------------------------------------------------------------------------- /iop/gapfill/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/gapfill/src/imports.lst: -------------------------------------------------------------------------------- 1 | #ifdef DEBUG 2 | stdio_IMPORTS_start 3 | I_printf 4 | stdio_IMPORTS_end 5 | #endif 6 | 7 | sysmem_IMPORTS_start 8 | I_AllocSysMemory 9 | I_FreeSysMemory 10 | I_QueryMaxFreeMemSize 11 | I_QueryTotalFreeMemSize 12 | sysmem_IMPORTS_end 13 | -------------------------------------------------------------------------------- /iop/gapfill/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include 7 | #include 8 | #ifdef DEBUG 9 | #include 10 | #endif 11 | #include 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /iop/gapfill/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "mprintf.h" 6 | 7 | #define MODNAME "gapfill" 8 | IRX_ID(MODNAME, 1, 1); 9 | 10 | int _start(int argc, char **argv) 11 | { 12 | //M_DEBUG("Total free: %dB/%dKiB\n", QueryTotalFreeMemSize(), QueryTotalFreeMemSize() / 1024); 13 | 14 | void *ptrs[10]; 15 | int idx=0; 16 | u32 size; 17 | 18 | while ((size = QueryMaxFreeMemSize()) > 0) { 19 | M_DEBUG("- Max free: %dB/%dKiB\n", QueryMaxFreeMemSize(), QueryMaxFreeMemSize() / 1024); 20 | ptrs[idx] = AllocSysMemory(0, size, NULL); 21 | 22 | // Free only large blocks, "memory leak" the small blocks 23 | if (size > (16*10242)) 24 | idx++; 25 | } 26 | 27 | int i; 28 | for (i=0; i 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /iop/imgdrv/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = imgdrv.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/imgdrv/src/imgdrv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define MODNAME "img_driver" 7 | IRX_ID(MODNAME, 1, 1); 8 | 9 | struct SPatchData { 10 | unsigned int magic; 11 | unsigned int ioprpimg; 12 | int ioprpsiz; 13 | } __attribute__((packed)) p = {0xDEC1DEC1, 0, 0}; 14 | 15 | static int dummy_fs() 16 | { 17 | return 0; 18 | } 19 | 20 | static int lseek_fs(iop_file_t *fd, int offset, int whence) 21 | { 22 | if (whence == SEEK_END) { 23 | return p.ioprpsiz; 24 | } else { 25 | return 0; 26 | } 27 | } 28 | 29 | static int read_fs(iop_file_t *fd, void *buffer, int size) 30 | { 31 | memcpy(buffer, (void *)p.ioprpimg, size); 32 | return size; 33 | } 34 | 35 | static iop_device_ops_t my_device_ops = 36 | { 37 | (void*)dummy_fs, // init 38 | (void*)dummy_fs, // deinit 39 | NULL, // format 40 | (void*)dummy_fs, // open 41 | (void*)dummy_fs, // close 42 | read_fs, // read 43 | NULL, // write 44 | lseek_fs, // lseek 45 | /* 46 | (void*)dummy_fs, // ioctl 47 | (void*)dummy_fs, // remove 48 | (void*)dummy_fs, // mkdir 49 | (void*)dummy_fs, // rmdir 50 | (void*)dummy_fs, // dopen 51 | (void*)dummy_fs, // dclose 52 | (void*)dummy_fs, // dread 53 | (void*)dummy_fs, // getstat 54 | (void*)dummy_fs, // chstat 55 | */ 56 | }; 57 | 58 | static const char name[] = "img"; 59 | static iop_device_t my_device = { 60 | name, 61 | IOP_DT_FS, 62 | 1, 63 | name, 64 | &my_device_ops}; 65 | 66 | int _start(int argc, char **argv) 67 | { 68 | // DelDrv("img"); 69 | AddDrv((iop_device_t *)&my_device); 70 | 71 | return MODULE_RESIDENT_END; 72 | } 73 | -------------------------------------------------------------------------------- /iop/imgdrv/src/imports.lst: -------------------------------------------------------------------------------- 1 | ioman_IMPORTS_start 2 | I_AddDrv 3 | /*I_DelDrv*/ 4 | ioman_IMPORTS_end 5 | 6 | sysclib_IMPORTS_start 7 | I_memcpy 8 | sysclib_IMPORTS_end 9 | -------------------------------------------------------------------------------- /iop/imgdrv/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | /* 2 | # _____ ___ ____ ___ ____ 3 | # ____| | ____| | | |____| 4 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 5 | #----------------------------------------------------------------------- 6 | # Copyright 2001-2004, ps2dev - http://www.ps2dev.org 7 | # Licenced under Academic Free License version 2.0 8 | # Review ps2sdk README & LICENSE files for further details. 9 | # 10 | # $Id: irx_imports.h 577 2004-09-14 14:41:46Z pixel $ 11 | # Defines all IRX imports. 12 | */ 13 | 14 | #ifndef IOP_IRX_IMPORTS_H 15 | #define IOP_IRX_IMPORTS_H 16 | 17 | #include "irx.h" 18 | 19 | /* Please keep these in alphabetical order! */ 20 | #include "ioman.h" 21 | #include "stdio.h" 22 | #include "sysclib.h" 23 | #include "thbase.h" 24 | 25 | #endif /* IOP_IRX_IMPORTS_H */ 26 | -------------------------------------------------------------------------------- /iop/mc_emu/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = mcemu.o mcemu_io.o mcemu_sys.o mcemu_var.o mcemu_rpc.o imports.o 2 | #IOP_CFLAGS += -DPADEMU 3 | 4 | include ../Rules.make 5 | -------------------------------------------------------------------------------- /iop/mc_emu/src/imports.lst: -------------------------------------------------------------------------------- 1 | dmacman_IMPORTS_start 2 | I_dmac_request 3 | I_dmac_transfer 4 | dmacman_IMPORTS_end 5 | 6 | fhi_IMPORTS_start 7 | I_fhi_size 8 | I_fhi_read 9 | I_fhi_write 10 | fhi_IMPORTS_end 11 | 12 | intrman_IMPORTS_start 13 | I_CpuSuspendIntr 14 | I_CpuResumeIntr 15 | intrman_IMPORTS_end 16 | 17 | loadcore_IMPORTS_start 18 | I_GetLoadcoreInternalData 19 | I_QueryLibraryEntryTable 20 | I_FlushIcache 21 | I_FlushDcache 22 | I_ReleaseLibraryEntries 23 | loadcore_IMPORTS_end 24 | 25 | sifcmd_IMPORTS_start 26 | I_sceSifCallRpc 27 | I_sceSifGetOtherData 28 | I_sceSifInitRpc 29 | I_sceSifBindRpc 30 | I_sceSifSendCmd 31 | sifcmd_IMPORTS_end 32 | 33 | sifman_IMPORTS_start 34 | I_sceSifInit 35 | I_sceSifSetDma 36 | I_sceSifCheckInit 37 | I_sceSifDmaStat 38 | sifman_IMPORTS_end 39 | 40 | #ifdef DEBUG 41 | stdio_IMPORTS_start 42 | I_printf 43 | stdio_IMPORTS_end 44 | #endif 45 | 46 | sysclib_IMPORTS_start 47 | I_strcmp 48 | I_memcpy 49 | I_memset 50 | sysclib_IMPORTS_end 51 | 52 | sysmem_IMPORTS_start 53 | I_AllocSysMemory 54 | I_FreeSysMemory 55 | sysmem_IMPORTS_end 56 | 57 | thbase_IMPORTS_start 58 | I_CreateThread 59 | I_StartThread 60 | I_DeleteThread 61 | I_DelayThread 62 | thbase_IMPORTS_end 63 | -------------------------------------------------------------------------------- /iop/mc_emu/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IRX_IMPORTS_H 2 | #define IRX_IMPORTS_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /iop/mc_emu/src/mcemu_io.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2006-2008, Romz 3 | Copyright 2010, Polo 4 | Licenced under Academic Free License version 3.0 5 | Review OpenUsbLd README & LICENSE files for further details. 6 | */ 7 | 8 | #include "mcemu.h" 9 | 10 | int mc_configure(MemoryCard *mcds) 11 | { 12 | int i; 13 | 14 | M_DEBUG("vmcSpec[0].active = %d\n", vmcSpec[0].active); 15 | M_DEBUG("vmcSpec[1].active = %d\n", vmcSpec[1].active); 16 | 17 | if (vmcSpec[0].active == 0 && vmcSpec[1].active == 0) 18 | return 0; 19 | 20 | for (i = 0; i < MCEMU_PORTS; i++, mcds++) { 21 | M_DEBUG("vmcSpec[%d].flags = 0x%X\n", i, vmcSpec[i].flags); 22 | M_DEBUG("vmcSpec[%d].cspec.PageSize = 0x%X\n", i, vmcSpec[i].cspec.PageSize); 23 | M_DEBUG("vmcSpec[%d].cspec.BlockSize = 0x%X\n", i, vmcSpec[i].cspec.BlockSize); 24 | M_DEBUG("vmcSpec[%d].cspec.CardSize = 0x%X\n", i, (unsigned int)vmcSpec[i].cspec.CardSize); 25 | 26 | if (vmcSpec[i].active == 1) { 27 | // Set virtual memorycard informations 28 | mcds->mcnum = i; 29 | mcds->tcode = 0x5A; /* 'Z' */ 30 | mcds->cbufp = &mceccbuf[i][0]; 31 | mcds->dbufp = &mcdatabuf[0]; 32 | mcds->flags = vmcSpec[i].flags; 33 | mcds->cspec.PageSize = vmcSpec[i].cspec.PageSize; 34 | mcds->cspec.BlockSize = vmcSpec[i].cspec.BlockSize; 35 | mcds->cspec.CardSize = vmcSpec[i].cspec.CardSize; 36 | } else 37 | mcds->mcnum = -1; 38 | } 39 | 40 | return 1; 41 | } 42 | -------------------------------------------------------------------------------- /iop/memcheck/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o ioplib.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/memcheck/src/imports.lst: -------------------------------------------------------------------------------- 1 | intrman_IMPORTS_start 2 | I_CpuSuspendIntr 3 | I_CpuResumeIntr 4 | intrman_IMPORTS_end 5 | 6 | loadcore_IMPORTS_start 7 | I_GetLoadcoreInternalData 8 | loadcore_IMPORTS_end 9 | 10 | #ifdef DEBUG 11 | stdio_IMPORTS_start 12 | I_printf 13 | stdio_IMPORTS_end 14 | #endif 15 | 16 | #ifdef DEBUG 17 | sysmem_IMPORTS_start 18 | I_QueryTotalFreeMemSize 19 | sysmem_IMPORTS_end 20 | #endif 21 | -------------------------------------------------------------------------------- /iop/memcheck/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | #include 4 | 5 | iop_library_t *ioplib_getByName(const char *name) 6 | { 7 | iop_library_t *libptr; 8 | int i; 9 | 10 | // Get first loaded library 11 | libptr = GetLoadcoreInternalData()->let_next; 12 | // Loop through all loaded libraries 13 | while (libptr != NULL) { 14 | // Compare library name only 15 | for (i = 0; i < 8; i++) { 16 | if (libptr->name[i] != name[i]) 17 | break; 18 | } 19 | 20 | // Return if match 21 | if (i == 8) 22 | return libptr; 23 | 24 | // Next library 25 | libptr = libptr->prev; 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | unsigned int ioplib_getTableSize(iop_library_t *lib) 32 | { 33 | void **exp; 34 | unsigned int size; 35 | 36 | exp = NULL; 37 | if (lib != NULL) { 38 | exp = lib->exports; 39 | } 40 | size = 0; 41 | 42 | if (exp != NULL) 43 | while (*exp++ != NULL) 44 | size++; 45 | 46 | return size; 47 | } 48 | 49 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 50 | { 51 | if (entry < ioplib_getTableSize(lib)) { 52 | int oldstate; 53 | void **exp, *temp; 54 | 55 | exp = &lib->exports[entry]; 56 | 57 | CpuSuspendIntr(&oldstate); 58 | temp = *exp; 59 | *exp = func; 60 | func = temp; 61 | CpuResumeIntr(oldstate); 62 | 63 | return func; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | void ioplib_relinkExports(iop_library_t *lib) 70 | { 71 | struct irx_import_table *table; 72 | struct irx_import_stub *stub; 73 | 74 | // go through each table that imports the library 75 | for (table = lib->caller; table != NULL; table = table->next) { 76 | // go through each import in the table 77 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 78 | // patch the stub to jump to the address specified in the library export table for "fno" 79 | stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /iop/memcheck/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/memcheck/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include 7 | #include 8 | #ifdef DEBUG 9 | #include 10 | #include 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /iop/patch_freemem/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o ioplib.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/patch_freemem/src/imports.lst: -------------------------------------------------------------------------------- 1 | intrman_IMPORTS_start 2 | I_CpuSuspendIntr 3 | I_CpuResumeIntr 4 | intrman_IMPORTS_end 5 | 6 | loadcore_IMPORTS_start 7 | I_GetLoadcoreInternalData 8 | loadcore_IMPORTS_end 9 | 10 | #ifdef DEBUG 11 | stdio_IMPORTS_start 12 | I_printf 13 | stdio_IMPORTS_end 14 | #endif 15 | 16 | #ifdef DEBUG 17 | sysmem_IMPORTS_start 18 | I_QueryTotalFreeMemSize 19 | sysmem_IMPORTS_end 20 | #endif 21 | -------------------------------------------------------------------------------- /iop/patch_freemem/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | #include 4 | 5 | iop_library_t *ioplib_getByName(const char *name) 6 | { 7 | iop_library_t *libptr; 8 | int i; 9 | 10 | // Get first loaded library 11 | libptr = GetLoadcoreInternalData()->let_next; 12 | // Loop through all loaded libraries 13 | while (libptr != NULL) { 14 | // Compare library name only 15 | for (i = 0; i < 8; i++) { 16 | if (libptr->name[i] != name[i]) 17 | break; 18 | } 19 | 20 | // Return if match 21 | if (i == 8) 22 | return libptr; 23 | 24 | // Next library 25 | libptr = libptr->prev; 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | unsigned int ioplib_getTableSize(iop_library_t *lib) 32 | { 33 | void **exp; 34 | unsigned int size; 35 | 36 | exp = NULL; 37 | if (lib != NULL) { 38 | exp = lib->exports; 39 | } 40 | size = 0; 41 | 42 | if (exp != NULL) 43 | while (*exp++ != NULL) 44 | size++; 45 | 46 | return size; 47 | } 48 | 49 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 50 | { 51 | if (entry < ioplib_getTableSize(lib)) { 52 | int oldstate; 53 | void **exp, *temp; 54 | 55 | exp = &lib->exports[entry]; 56 | 57 | CpuSuspendIntr(&oldstate); 58 | temp = *exp; 59 | *exp = func; 60 | func = temp; 61 | CpuResumeIntr(oldstate); 62 | 63 | return func; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | void ioplib_relinkExports(iop_library_t *lib) 70 | { 71 | struct irx_import_table *table; 72 | struct irx_import_stub *stub; 73 | 74 | // go through each table that imports the library 75 | for (table = lib->caller; table != NULL; table = table->next) { 76 | // go through each import in the table 77 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 78 | // patch the stub to jump to the address specified in the library export table for "fno" 79 | stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /iop/patch_freemem/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/patch_freemem/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include 7 | #include 8 | #ifdef DEBUG 9 | #include 10 | #include 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /iop/patch_freemem/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "mprintf.h" 6 | #include "ioplib.h" 7 | 8 | #define MODNAME "freemem" 9 | IRX_ID(MODNAME, 1, 1); 10 | 11 | typedef void * (*fp_AllocSysMemory)(int mode, int size, void *ptr); 12 | typedef u32 (*fp_QueryMaxFreeMemSize)(); 13 | fp_AllocSysMemory org_AllocSysMemory; 14 | fp_QueryMaxFreeMemSize org_QueryMaxFreeMemSize; 15 | static u32 limit; 16 | static u32 block; 17 | 18 | static void * hooked_AllocSysMemory(int mode, int size, void *ptr) 19 | { 20 | M_DEBUG("%s(%d, %dB/%dKiB, 0x%x)\n", __FUNCTION__, mode, size, size/1024, ptr); 21 | 22 | if (size == block) { 23 | M_DEBUG("-\n- HACK! denying requested memory!\n-\n"); 24 | return NULL; 25 | } 26 | 27 | return org_AllocSysMemory(mode, size, ptr); 28 | } 29 | 30 | static u32 hooked_QueryMaxFreeMemSize() 31 | { 32 | u32 rv = org_QueryMaxFreeMemSize(); 33 | 34 | M_DEBUG("%s() = %d (%dKiB) -> HACK! limit to %dKiB!\n", __FUNCTION__, rv, rv/1024, limit/1024); 35 | if (rv > limit) 36 | rv = limit; 37 | 38 | return rv; 39 | } 40 | 41 | int _start(int argc, char **argv) 42 | { 43 | int i; 44 | 45 | // Set defaults 46 | limit = 512; // Default 512KiB limit 47 | block = 0; // Default no blocking 48 | 49 | // Parse arguments 50 | for (i = 1; i < argc; i++) { 51 | if (argv[i][0] == 'X') { 52 | // Block max memory requests 53 | block = 1; 54 | } else { 55 | // Size in KiB 56 | // Note that there is NO checking for valid characters here! 57 | char *c = argv[i]; 58 | 59 | limit = 0; 60 | while (*c != 0) { 61 | limit *= 10; 62 | limit += (*c - '0'); 63 | c++; 64 | } 65 | } 66 | } 67 | limit *= 1024; // KiB to B 68 | if (block != 0) 69 | block = limit; 70 | 71 | // Hook sysmem functions 72 | iop_library_t * lib_sysmem = ioplib_getByName("sysmem"); 73 | if (block != 0) 74 | org_AllocSysMemory = ioplib_hookExportEntry(lib_sysmem, 4, hooked_AllocSysMemory); 75 | org_QueryMaxFreeMemSize = ioplib_hookExportEntry(lib_sysmem, 7, hooked_QueryMaxFreeMemSize); 76 | ioplib_relinkExports(lib_sysmem); 77 | 78 | return MODULE_RESIDENT_END; 79 | } 80 | -------------------------------------------------------------------------------- /iop/patch_membo/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o ioplib.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/patch_membo/src/imports.lst: -------------------------------------------------------------------------------- 1 | intrman_IMPORTS_start 2 | I_CpuSuspendIntr 3 | I_CpuResumeIntr 4 | intrman_IMPORTS_end 5 | 6 | loadcore_IMPORTS_start 7 | I_GetLoadcoreInternalData 8 | loadcore_IMPORTS_end 9 | -------------------------------------------------------------------------------- /iop/patch_membo/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | #include 4 | 5 | iop_library_t *ioplib_getByName(const char *name) 6 | { 7 | iop_library_t *libptr; 8 | int i; 9 | 10 | // Get first loaded library 11 | libptr = GetLoadcoreInternalData()->let_next; 12 | // Loop through all loaded libraries 13 | while (libptr != NULL) { 14 | // Compare library name only 15 | for (i = 0; i < 8; i++) { 16 | if (libptr->name[i] != name[i]) 17 | break; 18 | } 19 | 20 | // Return if match 21 | if (i == 8) 22 | return libptr; 23 | 24 | // Next library 25 | libptr = libptr->prev; 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | unsigned int ioplib_getTableSize(iop_library_t *lib) 32 | { 33 | void **exp; 34 | unsigned int size; 35 | 36 | exp = NULL; 37 | if (lib != NULL) { 38 | exp = lib->exports; 39 | } 40 | size = 0; 41 | 42 | if (exp != NULL) 43 | while (*exp++ != NULL) 44 | size++; 45 | 46 | return size; 47 | } 48 | 49 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 50 | { 51 | if (entry < ioplib_getTableSize(lib)) { 52 | int oldstate; 53 | void **exp, *temp; 54 | 55 | exp = &lib->exports[entry]; 56 | 57 | CpuSuspendIntr(&oldstate); 58 | temp = *exp; 59 | *exp = func; 60 | func = temp; 61 | CpuResumeIntr(oldstate); 62 | 63 | return func; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | void ioplib_relinkExports(iop_library_t *lib) 70 | { 71 | struct irx_import_table *table; 72 | struct irx_import_stub *stub; 73 | 74 | // go through each table that imports the library 75 | for (table = lib->caller; table != NULL; table = table->next) { 76 | // go through each import in the table 77 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 78 | // patch the stub to jump to the address specified in the library export table for "fno" 79 | stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /iop/patch_membo/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/patch_membo/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include 7 | #include 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /iop/patch_membo/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ioplib.h" 6 | 7 | #define MODNAME "pmembo" 8 | IRX_ID(MODNAME, 1, 1); 9 | 10 | /* 11 | * membo = Memory Buffer Overrun 12 | * ----------------------------- 13 | * This module tries to fix games that have a buffer overrun issue. 14 | * By allocating 256 bytes (the smallest amount) extra. 15 | */ 16 | 17 | typedef void * (*fp_AllocSysMemory)(int mode, int size, void *ptr); 18 | fp_AllocSysMemory org_AllocSysMemory; 19 | 20 | static void * hooked_AllocSysMemory(int mode, int size, void *ptr) 21 | { 22 | return org_AllocSysMemory(mode, size + 256, ptr); 23 | } 24 | 25 | int _start(int argc, char **argv) 26 | { 27 | // Hook sysmem functions 28 | iop_library_t * lib_sysmem = ioplib_getByName("sysmem"); 29 | org_AllocSysMemory = ioplib_hookExportEntry(lib_sysmem, 4, hooked_AllocSysMemory); 30 | ioplib_relinkExports(lib_sysmem); 31 | 32 | return MODULE_RESIDENT_END; 33 | } 34 | -------------------------------------------------------------------------------- /iop/patch_rc_uya/Makefile: -------------------------------------------------------------------------------- 1 | IOP_OBJS = main.o ioplib.o imports.o 2 | 3 | include ../Rules.make 4 | -------------------------------------------------------------------------------- /iop/patch_rc_uya/src/imports.lst: -------------------------------------------------------------------------------- 1 | intrman_IMPORTS_start 2 | I_CpuSuspendIntr 3 | I_CpuResumeIntr 4 | intrman_IMPORTS_end 5 | 6 | loadcore_IMPORTS_start 7 | I_GetLoadcoreInternalData 8 | loadcore_IMPORTS_end 9 | 10 | #ifdef DEBUG 11 | stdio_IMPORTS_start 12 | I_printf 13 | stdio_IMPORTS_end 14 | #endif 15 | 16 | #ifdef DEBUG 17 | sysmem_IMPORTS_start 18 | I_QueryTotalFreeMemSize 19 | sysmem_IMPORTS_end 20 | #endif 21 | -------------------------------------------------------------------------------- /iop/patch_rc_uya/src/ioplib.c: -------------------------------------------------------------------------------- 1 | #include "ioplib.h" 2 | #include 3 | #include 4 | 5 | iop_library_t *ioplib_getByName(const char *name) 6 | { 7 | iop_library_t *libptr; 8 | int i; 9 | 10 | // Get first loaded library 11 | libptr = GetLoadcoreInternalData()->let_next; 12 | // Loop through all loaded libraries 13 | while (libptr != NULL) { 14 | // Compare library name only 15 | for (i = 0; i < 8; i++) { 16 | if (libptr->name[i] != name[i]) 17 | break; 18 | } 19 | 20 | // Return if match 21 | if (i == 8) 22 | return libptr; 23 | 24 | // Next library 25 | libptr = libptr->prev; 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | unsigned int ioplib_getTableSize(iop_library_t *lib) 32 | { 33 | void **exp; 34 | unsigned int size; 35 | 36 | exp = NULL; 37 | if (lib != NULL) { 38 | exp = lib->exports; 39 | } 40 | size = 0; 41 | 42 | if (exp != NULL) 43 | while (*exp++ != NULL) 44 | size++; 45 | 46 | return size; 47 | } 48 | 49 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) 50 | { 51 | if (entry < ioplib_getTableSize(lib)) { 52 | int oldstate; 53 | void **exp, *temp; 54 | 55 | exp = &lib->exports[entry]; 56 | 57 | CpuSuspendIntr(&oldstate); 58 | temp = *exp; 59 | *exp = func; 60 | func = temp; 61 | CpuResumeIntr(oldstate); 62 | 63 | return func; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | void ioplib_relinkExports(iop_library_t *lib) 70 | { 71 | struct irx_import_table *table; 72 | struct irx_import_stub *stub; 73 | 74 | // go through each table that imports the library 75 | for (table = lib->caller; table != NULL; table = table->next) { 76 | // go through each import in the table 77 | for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { 78 | // patch the stub to jump to the address specified in the library export table for "fno" 79 | stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /iop/patch_rc_uya/src/ioplib.h: -------------------------------------------------------------------------------- 1 | #ifndef IOPLIB_H 2 | #define IOPLIB_H 3 | 4 | 5 | #include 6 | 7 | 8 | iop_library_t *ioplib_getByName(const char *name); 9 | unsigned int ioplib_getTableSize(iop_library_t *lib); 10 | void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); 11 | void ioplib_relinkExports(iop_library_t *lib); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iop/patch_rc_uya/src/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include "irx.h" 5 | 6 | #include 7 | #include 8 | #ifdef DEBUG 9 | #include 10 | #include 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /iop/patch_rc_uya/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "mprintf.h" 6 | #include "ioplib.h" 7 | 8 | #define MODNAME "rc_uya" 9 | IRX_ID(MODNAME, 1, 1); 10 | 11 | typedef void * (*fp_AllocSysMemory)(int mode, int size, void *ptr); 12 | fp_AllocSysMemory org_AllocSysMemory; 13 | 14 | static void * hooked_AllocSysMemory(int mode, int size, void *ptr) 15 | { 16 | M_DEBUG("%s(%d, %d, 0x%x), free=%dKiB\n", __FUNCTION__, mode, size, ptr, QueryTotalFreeMemSize()/1024); 17 | 18 | // RC3 / UYA - ONLINE! 19 | // 20 | // This game seems to assume a 321792 size buffer is always located at 0x4c900. 21 | // 22 | // This buffer is probably allocated from the EE side, and used to load 23 | // IOP modules. There seems to be a 'bug' in this game that assumes 24 | // this memory will always be located at 0x4c900. 25 | 26 | if (size == 321792) { 27 | M_DEBUG("-\n- HACK! forcing requested memory location to 0x4c900\n-\n"); 28 | return org_AllocSysMemory(ALLOC_ADDRESS, size, (void *)0x4c900); 29 | } 30 | else { 31 | return org_AllocSysMemory(mode, size, ptr); 32 | } 33 | } 34 | 35 | int _start(int argc, char **argv) 36 | { 37 | // hook AllocSysMemory 38 | iop_library_t * lib_sysmem = ioplib_getByName("sysmem"); 39 | org_AllocSysMemory = ioplib_hookExportEntry(lib_sysmem, 4, hooked_AllocSysMemory); 40 | ioplib_relinkExports(lib_sysmem); 41 | 42 | return MODULE_RESIDENT_END; 43 | } 44 | -------------------------------------------------------------------------------- /iop/smap_udpbd/Makefile: -------------------------------------------------------------------------------- 1 | IOP_CFLAGS += -mno-check-zero-division 2 | #IOP_CFLAGS += -DNO_BDM 3 | IOP_OBJS = main.o smap.o xfer.o ministack.o udpbd.o udptty.o imports.o exports.o 4 | 5 | include ../Rules.make 6 | -------------------------------------------------------------------------------- /iop/smap_udpbd/README: -------------------------------------------------------------------------------- 1 | SMAP (PlayStation 2 Ethernet interface) driver - 2013/07/29 2 | ------------------------------------------------------------ 3 | 4 | Usage: smap [