Skip to content

Commit

Permalink
Merge branch 'master' into easy-module-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
israpps authored Jul 10, 2024
2 parents 384fb3d + 6c8bdf0 commit 336006e
Show file tree
Hide file tree
Showing 15 changed files with 244 additions and 20 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ all:
$(MAKE) -C iop/imgdrv all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/isofs all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/mc_emu all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/patch_freemem all DEBUG=1
$(MAKE) -C iop/patch_rc_uya all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/smap_udpbd all DEBUG=$(IOPCORE_DEBUG)
$(MAKE) -C iop/usbd_null all DEBUG=$(IOPCORE_DEBUG)
Expand Down Expand Up @@ -47,6 +48,7 @@ clean:
$(MAKE) -C iop/imgdrv clean
$(MAKE) -C iop/isofs clean
$(MAKE) -C iop/mc_emu clean
$(MAKE) -C iop/patch_freemem clean
$(MAKE) -C iop/patch_rc_uya clean
$(MAKE) -C iop/smap_udpbd clean
$(MAKE) -C iop/usbd_null clean
Expand All @@ -63,11 +65,11 @@ sim:

# Mount first partition of block device used in PCSX2 testing (ATA or USB)
sim_mount:
sudo mount -o loop,offset=1048576 ee/loader/blockdev.raw mount
losetup /dev/loop1 ee/loader/blockdev.raw

# Unmount block device used in PCSX2 testing
sim_unmount:
sudo umount mount
losetup -d /dev/loop1

opl:
ps2client -h 192.168.1.10 execee host:OPNPS2LD.ELF
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ An environment in neutrino describes what IOP modules are loaded and defines wha
## Backing Store Driver
A backing store driver provides a storage location for storing virtual disk images. For instance of DVD's, HDD's or MC's.
The following backing storage devices are supported:
- USB
- MX4SIO
- ATA (internal HDD)
- UDPBD
- iLink / IEEE1394
- USB (`usb`)
- MX4SIO (`sdc`)
- ATA (internal HDD) (`ata`)
- UDPBD (`udp`)
- iLink / IEEE1394 (`sd`)
NOTE: Internal block device names between (parenthesis), these must be used for `bdfs:`

These are all BDM drivers, or "Block Devices". On all devices the following partitioning schemes are supported:
- MBR (Master Boot Record)
Expand All @@ -30,6 +31,7 @@ These are all BDM drivers, or "Block Devices". On all devices the following part
And the following file systems:
- exFat/FAT32, accessable as `mass:<file>.iso`
- HDLoader, accessable as `hdl:<file>`, `hdl:<file>.iso`, `hdl:<part>` or `hdl:<part>.iso`
- Block Devices, accessable as `bdfs:<blockdevice>`. Like `bdfs:udp0p0`

Note that the HDLoader backing store is currently read-ony, and limited to only emulating the DVD.

Expand Down
7 changes: 7 additions & 0 deletions ee/ee_core/include/ee_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ extern int GameMode;
extern int EnableDebug;
#define GS_BGCOLOUR *((volatile unsigned long int *)0x120000E0)

#define BGR_PURPLE 0xFF00FF
#define BGR_YELLOW 0x00FFFF
#define BGR_BLACK 0x000000
#define BGR_BLUE 0xFF0000
#define BGR_GREEN 0x00FF00
#define BGR_WHITE 0xFFFFFF

extern int *gCheatList; // Store hooks/codes addr+val pairs

#endif
6 changes: 3 additions & 3 deletions ee/ee_core/src/iopmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int New_Reset_Iop(const char *arg, int arglen)
#endif

if (EnableDebug)
GS_BGCOLOUR = 0xFF00FF; // Purple
GS_BGCOLOUR = BGR_PURPLE;

iop_reboot_count++;

Expand Down Expand Up @@ -168,7 +168,7 @@ int New_Reset_Iop(const char *arg, int arglen)
}

if (EnableDebug)
GS_BGCOLOUR = 0x00FFFF; // Yellow
GS_BGCOLOUR = BGR_YELLOW;

DPRINTF("Exiting services...\n");
SifExitIopHeap();
Expand All @@ -183,7 +183,7 @@ int New_Reset_Iop(const char *arg, int arglen)
}

if (EnableDebug)
GS_BGCOLOUR = 0x000000; // Black
GS_BGCOLOUR = BGR_BLACK;

return 1;
}
2 changes: 1 addition & 1 deletion ee/ee_core/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static int eecoreInit(int argc, char **argv)
Install_Kernel_Hooks();

if (EnableDebug)
GS_BGCOLOUR = 0xff0000; // Blue
GS_BGCOLOUR = BGR_BLUE;

SifExitRpc();

Expand Down
4 changes: 2 additions & 2 deletions ee/ee_core/src/syshook.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void sysLoadElf(char *filename, int argc, char **argv)
DPRINTF("t_loadElf: elf path = '%s'\n", filename);

if (EnableDebug)
GS_BGCOLOUR = 0x00ff00; // Green
GS_BGCOLOUR = BGR_GREEN;

DPRINTF("t_loadElf: cleaning user memory...");

Expand Down Expand Up @@ -114,7 +114,7 @@ void sysLoadElf(char *filename, int argc, char **argv)
DPRINTF(" failed, error code = -%x\n", -r);

// Error
GS_BGCOLOUR = 0xffffff; // White - shouldn't happen.
GS_BGCOLOUR = BGR_WHITE;
SleepThread();
}

Expand Down
4 changes: 2 additions & 2 deletions iop/cdvdfsv/src/scmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static inline void rpcSCmd_cdreadModelID(void *buf)

M_DEBUG("%s\n", __FUNCTION__);

r->result = sceCdReadModelID(&r->param1);
r->result = sceCdReadModelID((unsigned int *)&r->param1);
}

//-------------------------------------------------------------------------
Expand All @@ -132,7 +132,7 @@ static inline void rpcSCmd_cdreaddvddualinfo(void *buf)

M_DEBUG("%s\n", __FUNCTION__);

r->result = sceCdReadDvdDualInfo((int *)&r->param1, &r->param2);
r->result = sceCdReadDvdDualInfo((int *)&r->param1, (unsigned int *)&r->param2);
}

//-------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions iop/cdvdman_emu/src/scmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ int sceCdReadGUID(u64 *GUID)
}

//--------------------------------------------------------------
int sceCdReadModelID(unsigned long int *ModelID)
int sceCdReadModelID(unsigned int *ModelID)
{
M_DEBUG("%s(-)\n", __FUNCTION__);

return cdvdman_readID(1, (u8 *)ModelID);
}

//-------------------------------------------------------------------------
int sceCdReadDvdDualInfo(int *on_dual, u32 *layer1_start)
int sceCdReadDvdDualInfo(int *on_dual, unsigned int *layer1_start)
{
M_DEBUG("%s(-, -)\n", __FUNCTION__);

Expand Down
6 changes: 3 additions & 3 deletions iop/cdvdman_emu/src/searchfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static struct dirTocEntry *cdvdman_locatefile(char *name, u32 tocLBA, int tocLen

if (!(cdvdman_settings.flags & IOPCORE_COMPAT_EMU_DVDDL)) {
int on_dual;
u32 layer1_start;
unsigned int layer1_start;
sceCdReadDvdDualInfo(&on_dual, &layer1_start);

if (layer)
Expand Down Expand Up @@ -187,7 +187,7 @@ static int cdvdman_findfile(sceCdlFILE *pcdfile, const char *name, int layer)

lsn = tocEntryPointer->fileLBA;
if (layer) {
sceCdReadDvdDualInfo((int *)&pcdfile->lsn, &pcdfile->size);
sceCdReadDvdDualInfo((int *)&pcdfile->lsn, (unsigned int *)&pcdfile->size);
lsn += pcdfile->size;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ void cdvdman_searchfile_init(void)
// DVD DL support
if (!(cdvdman_settings.flags & IOPCORE_COMPAT_EMU_DVDDL)) {
int on_dual;
u32 layer1_start;
unsigned int layer1_start;
sceCdReadDvdDualInfo(&on_dual, &layer1_start);
if (on_dual) {
//u32 lsn0 = mediaLsnCount;
Expand Down
5 changes: 5 additions & 0 deletions iop/patch_freemem/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
IOP_OBJS = main.o ioplib.o imports.o

include ../../Defs.make
include ../Rules.bin.make
include ../Rules.make
20 changes: 20 additions & 0 deletions iop/patch_freemem/src/imports.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
intrman_IMPORTS_start
I_CpuSuspendIntr
I_CpuResumeIntr
intrman_IMPORTS_end

loadcore_IMPORTS_start
I_GetLoadcoreInternalData
loadcore_IMPORTS_end

#ifdef DEBUG
stdio_IMPORTS_start
I_printf
stdio_IMPORTS_end
#endif

#ifdef DEBUG
sysmem_IMPORTS_start
I_QueryTotalFreeMemSize
sysmem_IMPORTS_end
#endif
82 changes: 82 additions & 0 deletions iop/patch_freemem/src/ioplib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include "ioplib.h"
#include <intrman.h>
#include <stdint.h>

iop_library_t *ioplib_getByName(const char *name)
{
iop_library_t *libptr;
int i;

// Get first loaded library
libptr = GetLoadcoreInternalData()->let_next;
// Loop through all loaded libraries
while (libptr != NULL) {
// Compare library name only
for (i = 0; i < 8; i++) {
if (libptr->name[i] != name[i])
break;
}

// Return if match
if (i == 8)
return libptr;

// Next library
libptr = libptr->prev;
}

return NULL;
}

unsigned int ioplib_getTableSize(iop_library_t *lib)
{
void **exp;
unsigned int size;

exp = NULL;
if (lib != NULL) {
exp = lib->exports;
}
size = 0;

if (exp != NULL)
while (*exp++ != NULL)
size++;

return size;
}

void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func)
{
if (entry < ioplib_getTableSize(lib)) {
int oldstate;
void **exp, *temp;

exp = &lib->exports[entry];

CpuSuspendIntr(&oldstate);
temp = *exp;
*exp = func;
func = temp;
CpuResumeIntr(oldstate);

return func;
}

return NULL;
}

void ioplib_relinkExports(iop_library_t *lib)
{
struct irx_import_table *table;
struct irx_import_stub *stub;

// go through each table that imports the library
for (table = lib->caller; table != NULL; table = table->next) {
// go through each import in the table
for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) {
// patch the stub to jump to the address specified in the library export table for "fno"
stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6);
}
}
}
14 changes: 14 additions & 0 deletions iop/patch_freemem/src/ioplib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef IOPLIB_H
#define IOPLIB_H


#include <loadcore.h>


iop_library_t *ioplib_getByName(const char *name);
unsigned int ioplib_getTableSize(iop_library_t *lib);
void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func);
void ioplib_relinkExports(iop_library_t *lib);


#endif
13 changes: 13 additions & 0 deletions iop/patch_freemem/src/irx_imports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef IOP_IRX_IMPORTS_H
#define IOP_IRX_IMPORTS_H

#include "irx.h"

#include <intrman.h>
#include <loadcore.h>
#ifdef DEBUG
#include <stdio.h>
#include <sysmem.h>
#endif

#endif
Loading

0 comments on commit 336006e

Please sign in to comment.