mirror of https://github.com/PCSX2/pcsx2.git
IOP: HLE ioman functions for paths starting with host[0-9]*:
Only open, close, read and lseek implemented for now. Directories are not supported for now because of the need to match the dirent structure to the loaded ioman version. To allow access the host filesystem from homebrew and games, enable the new option on the main menu. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3092 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
1addaf5c69
commit
0fa3303be3
|
@ -313,7 +313,9 @@ static MutexRecursive Mutex_NewDiskCB;
|
||||||
// Sets ElfCRC to the CRC of the game bound to the CDVD plugin.
|
// Sets ElfCRC to the CRC of the game bound to the CDVD plugin.
|
||||||
static __forceinline ElfObject *loadElf( const wxString filename )
|
static __forceinline ElfObject *loadElf( const wxString filename )
|
||||||
{
|
{
|
||||||
// Note: calling loadElfFile here causes bad things to happen.
|
if (filename.StartsWith(L"host"))
|
||||||
|
return new ElfObject(filename.After(':'), Path::GetFileSize(filename.After(':')));
|
||||||
|
|
||||||
IsoFSCDVD isofs;
|
IsoFSCDVD isofs;
|
||||||
IsoFile file(isofs, filename);
|
IsoFile file(isofs, filename);
|
||||||
ElfObject *elfptr;
|
ElfObject *elfptr;
|
||||||
|
@ -361,8 +363,14 @@ static __forceinline void _reloadElfInfo(wxString elfpath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cdvdReloadElfInfo()
|
void cdvdReloadElfInfo(wxString elfoverride)
|
||||||
{
|
{
|
||||||
|
if (!elfoverride.IsEmpty())
|
||||||
|
{
|
||||||
|
_reloadElfInfo(elfoverride);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wxString elfpath;
|
wxString elfpath;
|
||||||
u32 discType = GetPS2ElfName(elfpath);
|
u32 discType = GetPS2ElfName(elfpath);
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,6 @@ extern void cdvdNewDiskCB();
|
||||||
extern u8 cdvdRead(u8 key);
|
extern u8 cdvdRead(u8 key);
|
||||||
extern void cdvdWrite(u8 key, u8 rt);
|
extern void cdvdWrite(u8 key, u8 rt);
|
||||||
|
|
||||||
extern void cdvdReloadElfInfo();
|
extern void cdvdReloadElfInfo(wxString elfoverride = wxEmptyString);
|
||||||
|
|
||||||
extern wxString DiscID;
|
extern wxString DiscID;
|
||||||
|
|
|
@ -495,7 +495,8 @@ struct Pcsx2Config
|
||||||
MultitapPort0_Enabled:1,
|
MultitapPort0_Enabled:1,
|
||||||
MultitapPort1_Enabled:1,
|
MultitapPort1_Enabled:1,
|
||||||
|
|
||||||
ConsoleToStdio:1;
|
ConsoleToStdio :1,
|
||||||
|
HostFs :1;
|
||||||
BITFIELD_END
|
BITFIELD_END
|
||||||
|
|
||||||
CpuOptions Cpu;
|
CpuOptions Cpu;
|
||||||
|
|
|
@ -24,9 +24,6 @@ using namespace std;
|
||||||
u32 ElfCRC;
|
u32 ElfCRC;
|
||||||
u32 ElfEntry;
|
u32 ElfEntry;
|
||||||
|
|
||||||
// uncomment this to enable pcsx2hostfs loading when using "load elf"
|
|
||||||
#define USE_HOSTFS
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// fixme: ELF command line option system.
|
// fixme: ELF command line option system.
|
||||||
// It parses a command line and pastes it into PS2 memory, and then points the a0 register at it.
|
// It parses a command line and pastes it into PS2 memory, and then points the a0 register at it.
|
||||||
|
@ -418,91 +415,6 @@ void ElfObject::loadHeaders()
|
||||||
loadSectionHeaders();
|
loadSectionHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads the elf binary data from the specified file into PS2 memory, and injects the ELF's
|
|
||||||
// starting execution point into cpuRegs.pc. If the filename is a cdrom URI in the form
|
|
||||||
// of "cdrom0:" or "cdrom1:" then the CDVD is used as the source; otherwise the ELF is loaded
|
|
||||||
// from the host filesystem.
|
|
||||||
//
|
|
||||||
// If it starts with "cdrom:", an exception is thrown, unless PS1 emulation is being attempted.
|
|
||||||
//
|
|
||||||
// If the specified filename is empty then no action is taken (PS2 will continue booting
|
|
||||||
// normally as if it has no CD.
|
|
||||||
//
|
|
||||||
// Throws exceptions on errors. Not called if not skipping the bios.
|
|
||||||
//
|
|
||||||
void loadElfFile(const wxString& _filename)
|
|
||||||
{
|
|
||||||
ScopedPtr<ElfObject> elfptr;
|
|
||||||
wxString filename = _filename;
|
|
||||||
|
|
||||||
if (filename.IsEmpty()) return;
|
|
||||||
Console.WriteLn( L"loadElfFile: " + filename );
|
|
||||||
|
|
||||||
#ifdef USE_HOSTFS
|
|
||||||
wxString parameters = filename;
|
|
||||||
bool bHostFs = true;
|
|
||||||
|
|
||||||
filename = wxT("pcsx2hostfs_ldr.elf");
|
|
||||||
int fSize = Path::GetFileSize(filename);
|
|
||||||
if (fSize == -1) {
|
|
||||||
wxString error1 = L"Error! pcsx2hostfs_ldr.elf was not found!";
|
|
||||||
wxString error2 = L"\n\nAttempting to load elf file without hostfs support...";
|
|
||||||
Console.Error(error1);
|
|
||||||
Msgbox::Alert(error1 + error2);
|
|
||||||
bHostFs = false;
|
|
||||||
filename = parameters;
|
|
||||||
elfptr = new ElfObject(filename, Path::GetFileSize(filename));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
elfptr = new ElfObject(filename, fSize);
|
|
||||||
filename = wxT("host:pcsx2hostfs_ldr.elf");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
elfptr = new ElfObject(filename, Path::GetFileSize(filename));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!elfptr->hasProgramHeaders())
|
|
||||||
{
|
|
||||||
throw Exception::BadStream(filename, wxLt("Invalid ELF file."));
|
|
||||||
}
|
|
||||||
|
|
||||||
elfptr->loadHeaders();
|
|
||||||
|
|
||||||
ElfCRC = elfptr->getCRC();
|
|
||||||
Console.WriteLn( L"loadElfFile: %s; CRC = %8.8X", filename.c_str(), ElfCRC );
|
|
||||||
ElfEntry = elfptr->header.e_entry;
|
|
||||||
elfptr.Delete();
|
|
||||||
|
|
||||||
//2002-09-19 (Florin)
|
|
||||||
//args_ptr = 0xFFFFFFFF; // big value, searching for minimum [used by parseCommandLine]
|
|
||||||
|
|
||||||
cpuRegs.pc = ElfEntry; //set pc to proper place
|
|
||||||
ELF_LOG( "PC set to: %8.8lx", cpuRegs.pc );
|
|
||||||
cpuRegs.GPR.n.sp.UL[0] = 0x81f00000;
|
|
||||||
cpuRegs.GPR.n.gp.UL[0] = 0x81f80000; // might not be 100% ok
|
|
||||||
//cpuRegs.GPR.n.a0.UL[0] = parseCommandLine( filename ); // see #ifdef'd out parseCommendLine for details.
|
|
||||||
|
|
||||||
#ifdef USE_HOSTFS
|
|
||||||
if (bHostFs) {
|
|
||||||
//HACK!!!!!!!!!!!!!
|
|
||||||
uptr params_addr = 0x1FFFC00; // elf loader will check this address for params
|
|
||||||
s8* params_ptr = (s8*)PSM(params_addr);
|
|
||||||
s8* params_magic = params_ptr + 0;
|
|
||||||
s8* params_argc = params_ptr + 4;
|
|
||||||
s8* params_argv = params_ptr + 8;
|
|
||||||
*(u32*)params_magic = 'PS2E';
|
|
||||||
*(u32*)params_argc = 2;
|
|
||||||
strcpy(params_argv,filename.ToAscii());
|
|
||||||
params_argv += strlen(params_argv)+1;
|
|
||||||
strcpy(params_argv,parameters.ToAscii());
|
|
||||||
params_argv += strlen(params_argv)+1;
|
|
||||||
strcpy(params_argv,"");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return value:
|
// return value:
|
||||||
// 0 - Invalid or unknown disc.
|
// 0 - Invalid or unknown disc.
|
||||||
// 1 - PS1 CD
|
// 1 - PS1 CD
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "IopCommon.h"
|
#include "IopCommon.h"
|
||||||
|
#include "R5900.h" // for g_GameStarted
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
namespace R3000A {
|
namespace R3000A {
|
||||||
|
|
||||||
|
@ -35,11 +37,280 @@ namespace R3000A {
|
||||||
#define Ra2 (iopVirtMemR<char>(a2))
|
#define Ra2 (iopVirtMemR<char>(a2))
|
||||||
#define Ra3 (iopVirtMemR<char>(a3))
|
#define Ra3 (iopVirtMemR<char>(a3))
|
||||||
|
|
||||||
|
// TODO: sandbox option, other permissions
|
||||||
|
class HostFile : public IOManFile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
HostFile(int hostfd)
|
||||||
|
{
|
||||||
|
fd = hostfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline int translate_error(int err)
|
||||||
|
{
|
||||||
|
if (err >= 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
switch(err)
|
||||||
|
{
|
||||||
|
case -ENOENT:
|
||||||
|
return -IOP_ENOENT;
|
||||||
|
case -EACCES:
|
||||||
|
return -IOP_EACCES;
|
||||||
|
case -EISDIR:
|
||||||
|
return -IOP_EISDIR;
|
||||||
|
case -EIO:
|
||||||
|
default:
|
||||||
|
return -IOP_EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int open(IOManFile **file, const char *name, s32 flags, u16 mode)
|
||||||
|
{
|
||||||
|
const char *path = strchr(name, ':') + 1;
|
||||||
|
|
||||||
|
if (flags != IOP_O_RDONLY)
|
||||||
|
return -IOP_EROFS;
|
||||||
|
|
||||||
|
int hostfd = ::open(path, O_BINARY | O_RDONLY);
|
||||||
|
if (hostfd < 0)
|
||||||
|
return translate_error(hostfd);
|
||||||
|
|
||||||
|
*file = new HostFile(hostfd);
|
||||||
|
if (!*file)
|
||||||
|
return -IOP_ENOMEM;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void close()
|
||||||
|
{
|
||||||
|
::close(fd);
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int lseek(s32 offset, s32 whence)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
switch (whence)
|
||||||
|
{
|
||||||
|
case IOP_SEEK_SET:
|
||||||
|
err = ::lseek(fd, offset, SEEK_SET);
|
||||||
|
break;
|
||||||
|
case IOP_SEEK_CUR:
|
||||||
|
err = ::lseek(fd, offset, SEEK_CUR);
|
||||||
|
break;
|
||||||
|
case IOP_SEEK_END:
|
||||||
|
err = ::lseek(fd, offset, SEEK_END);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -IOP_EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return translate_error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int read(void *buf, u32 count)
|
||||||
|
{
|
||||||
|
return translate_error(::read(fd, buf, count));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
namespace ioman {
|
namespace ioman {
|
||||||
|
const int firstfd = 0x100;
|
||||||
|
const int maxfds = 0x100;
|
||||||
|
int openfds = 0;
|
||||||
|
|
||||||
|
int freefdcount()
|
||||||
|
{
|
||||||
|
return maxfds - openfds;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct filedesc
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
FILE_FREE,
|
||||||
|
FILE_FILE,
|
||||||
|
FILE_DIR,
|
||||||
|
} type;
|
||||||
|
union {
|
||||||
|
IOManFile *file;
|
||||||
|
IOManDir *dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
operator bool() const { return type != FILE_FREE; }
|
||||||
|
operator IOManFile*() const { return type == FILE_FILE ? file : NULL; }
|
||||||
|
operator IOManDir*() const { return type == FILE_DIR ? dir : NULL; }
|
||||||
|
void operator=(IOManFile *f) { type = FILE_FILE; file = f; openfds++; }
|
||||||
|
void operator=(IOManDir *d) { type = FILE_DIR; dir = d; openfds++; }
|
||||||
|
|
||||||
|
void close()
|
||||||
|
{
|
||||||
|
if (type == FILE_FREE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case FILE_FILE:
|
||||||
|
file->close();
|
||||||
|
file = NULL;
|
||||||
|
break;
|
||||||
|
case FILE_DIR:
|
||||||
|
dir->close();
|
||||||
|
dir = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = FILE_FREE;
|
||||||
|
openfds--;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
filedesc fds[maxfds];
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* getfd(int fd)
|
||||||
|
{
|
||||||
|
fd -= firstfd;
|
||||||
|
|
||||||
|
if (fd < 0 || fd >= maxfds)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return fds[fd];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
int allocfd(T *obj)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < maxfds; i++)
|
||||||
|
{
|
||||||
|
if (!fds[i])
|
||||||
|
{
|
||||||
|
fds[i] = obj;
|
||||||
|
return firstfd + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->close();
|
||||||
|
return -IOP_EMFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void freefd(int fd)
|
||||||
|
{
|
||||||
|
fd -= firstfd;
|
||||||
|
|
||||||
|
if (fd < 0 || fd >= maxfds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fds[fd].close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < maxfds; i++)
|
||||||
|
fds[i].close();
|
||||||
|
}
|
||||||
|
|
||||||
|
int open_HLE()
|
||||||
|
{
|
||||||
|
IOManFile *file = NULL;
|
||||||
|
const char *name = Ra0;
|
||||||
|
s32 flags = a1;
|
||||||
|
u16 mode = a2;
|
||||||
|
|
||||||
|
if ((!g_GameStarted || EmuConfig.HostFs)
|
||||||
|
&& !strncmp(name, "host", 4) && name[4 + strspn(name + 4, "0123456789")] == ':')
|
||||||
|
{
|
||||||
|
if (!freefdcount())
|
||||||
|
{
|
||||||
|
v0 = -IOP_EMFILE;
|
||||||
|
pc = ra;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int err = HostFile::open(&file, name, flags, mode);
|
||||||
|
|
||||||
|
if (err != 0 || !file)
|
||||||
|
{
|
||||||
|
if (err == 0) // ???
|
||||||
|
err = -IOP_EIO;
|
||||||
|
if (file) // ??????
|
||||||
|
file->close();
|
||||||
|
v0 = err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v0 = allocfd(file);
|
||||||
|
if (v0 < 0)
|
||||||
|
file->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
pc = ra;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int close_HLE()
|
||||||
|
{
|
||||||
|
s32 fd = a0;
|
||||||
|
|
||||||
|
if (getfd<IOManFile>(fd))
|
||||||
|
{
|
||||||
|
freefd(fd);
|
||||||
|
v0 = 0;
|
||||||
|
pc = ra;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lseek_HLE()
|
||||||
|
{
|
||||||
|
s32 fd = a0;
|
||||||
|
s32 offset = a1;
|
||||||
|
s32 whence = a2;
|
||||||
|
|
||||||
|
if (IOManFile *file = getfd<IOManFile>(fd))
|
||||||
|
{
|
||||||
|
v0 = file->lseek(offset, whence);
|
||||||
|
pc = ra;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int read_HLE()
|
||||||
|
{
|
||||||
|
s32 fd = a0;
|
||||||
|
u32 buf = a1;
|
||||||
|
u32 count = a2;
|
||||||
|
|
||||||
|
if (IOManFile *file = getfd<IOManFile>(fd))
|
||||||
|
{
|
||||||
|
if (!iopVirtMemR<void>(buf))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
v0 = file->read(iopVirtMemW<void>(buf), count);
|
||||||
|
pc = ra;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int write_HLE()
|
int write_HLE()
|
||||||
{
|
{
|
||||||
|
int fd = a0;
|
||||||
|
|
||||||
#ifdef PCSX2_DEVBUILD
|
#ifdef PCSX2_DEVBUILD
|
||||||
if (a0 == 1) // stdout
|
if (fd == 1) // stdout
|
||||||
{
|
{
|
||||||
Console.Write(ConColor_IOP, L"%s", ShiftJIS_ConvertString(Ra1, a2).c_str());
|
Console.Write(ConColor_IOP, L"%s", ShiftJIS_ConvertString(Ra1, a2).c_str());
|
||||||
pc = ra;
|
pc = ra;
|
||||||
|
@ -225,7 +496,11 @@ irxHLE irxImportHLE(const char libname[8], u16 index)
|
||||||
#ifdef PCSX2_DEVBUILD
|
#ifdef PCSX2_DEVBUILD
|
||||||
// debugging output
|
// debugging output
|
||||||
MODULE(ioman)
|
MODULE(ioman)
|
||||||
|
EXPORT_H( 4, open)
|
||||||
|
EXPORT_H( 5, close)
|
||||||
|
EXPORT_H( 6, read)
|
||||||
EXPORT_H( 7, write)
|
EXPORT_H( 7, write)
|
||||||
|
EXPORT_H( 8, lseek)
|
||||||
END_MODULE
|
END_MODULE
|
||||||
MODULE(sysmem)
|
MODULE(sysmem)
|
||||||
EXPORT_H( 14, Kprintf)
|
EXPORT_H( 14, Kprintf)
|
||||||
|
|
|
@ -16,6 +16,43 @@
|
||||||
#ifndef __PSXBIOS_H__
|
#ifndef __PSXBIOS_H__
|
||||||
#define __PSXBIOS_H__
|
#define __PSXBIOS_H__
|
||||||
|
|
||||||
|
#define IOP_ENOENT 2
|
||||||
|
#define IOP_EIO 5
|
||||||
|
#define IOP_ENOMEM 12
|
||||||
|
#define IOP_EACCES 13
|
||||||
|
#define IOP_EISDIR 21
|
||||||
|
#define IOP_EMFILE 24
|
||||||
|
#define IOP_EROFS 30
|
||||||
|
|
||||||
|
#define IOP_O_RDONLY 0x001
|
||||||
|
#define IOP_O_WRONLY 0x002
|
||||||
|
#define IOP_O_RDWR 0x003
|
||||||
|
#define IOP_O_APPEND 0x100
|
||||||
|
#define IOP_O_CREAT 0x200
|
||||||
|
#define IOP_O_TRUNC 0x400
|
||||||
|
#define IOP_O_EXCL 0x800
|
||||||
|
|
||||||
|
#define IOP_SEEK_SET 0
|
||||||
|
#define IOP_SEEK_CUR 1
|
||||||
|
#define IOP_SEEK_END 2
|
||||||
|
|
||||||
|
class IOManFile {
|
||||||
|
public:
|
||||||
|
// int open(IOManFile **file, char *name, s32 flags, u16 mode);
|
||||||
|
|
||||||
|
virtual void close() = 0;
|
||||||
|
|
||||||
|
virtual int lseek(s32 offset, s32 whence) { return -IOP_EIO; }
|
||||||
|
virtual int read(void *buf, u32 count) { return -IOP_EIO; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class IOManDir {
|
||||||
|
// Don't think about it until we know the loaded ioman version.
|
||||||
|
// The dirent structure changed between versions.
|
||||||
|
public:
|
||||||
|
virtual void close();
|
||||||
|
};
|
||||||
|
|
||||||
typedef int (*irxHLE)(); // return 1 if handled, otherwise 0
|
typedef int (*irxHLE)(); // return 1 if handled, otherwise 0
|
||||||
typedef void (*irxDEBUG)();
|
typedef void (*irxDEBUG)();
|
||||||
|
|
||||||
|
@ -27,6 +64,11 @@ namespace R3000A
|
||||||
irxDEBUG irxImportDebug(const char libname[8], u16 index);
|
irxDEBUG irxImportDebug(const char libname[8], u16 index);
|
||||||
void __fastcall irxImportLog(const char libname[8], u16 index, const char *funcname);
|
void __fastcall irxImportLog(const char libname[8], u16 index, const char *funcname);
|
||||||
int __fastcall irxImportExec(const char libname[8], u16 index);
|
int __fastcall irxImportExec(const char libname[8], u16 index);
|
||||||
|
|
||||||
|
namespace ioman
|
||||||
|
{
|
||||||
|
void reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __PSXBIOS_H__ */
|
#endif /* __PSXBIOS_H__ */
|
||||||
|
|
|
@ -32,10 +32,6 @@ static const uint m_psxMemSize =
|
||||||
0x00010000 + // psxP
|
0x00010000 + // psxP
|
||||||
0x00000100 ; // psxS
|
0x00000100 ; // psxS
|
||||||
|
|
||||||
// TODO: move to a header
|
|
||||||
void Pcsx2HostFSwrite32(u32 addr, u32 value);
|
|
||||||
u32 Pcsx2HostFSread32(u32 addr);
|
|
||||||
|
|
||||||
void psxMemAlloc()
|
void psxMemAlloc()
|
||||||
{
|
{
|
||||||
if( m_psxAllMem == NULL )
|
if( m_psxAllMem == NULL )
|
||||||
|
@ -262,8 +258,6 @@ u32 __fastcall iopMemRead32(u32 mem)
|
||||||
case 0x60:
|
case 0x60:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case 0x800:
|
|
||||||
return Pcsx2HostFSread32(mem);
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = psxHu32(mem);
|
ret = psxHu32(mem);
|
||||||
|
@ -469,10 +463,6 @@ void __fastcall iopMemWrite32(u32 mem, u32 value)
|
||||||
psHu32(SBUS_F260) = 0;
|
psHu32(SBUS_F260) = 0;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x800:
|
|
||||||
Pcsx2HostFSwrite32(mem, value);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
psxSu32(mem) = value;
|
psxSu32(mem) = value;
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@ extern const uptr *psxMemRLUT;
|
||||||
// If the address maps to read-only memory, NULL is returned.
|
// If the address maps to read-only memory, NULL is returned.
|
||||||
// Hacky! This should really never be used, ever, since it bypasses the iop's Hardware
|
// Hacky! This should really never be used, ever, since it bypasses the iop's Hardware
|
||||||
// Register handler and SPU/DEV/USB maps.
|
// Register handler and SPU/DEV/USB maps.
|
||||||
/*template<typename T>
|
template<typename T>
|
||||||
static __forceinline T* iopVirtMemW( u32 mem )
|
static __forceinline T* iopVirtMemW( u32 mem )
|
||||||
{
|
{
|
||||||
return (psxMemWLUT[(mem) >> 16] == 0) ? NULL : (T*)(psxMemWLUT[(mem) >> 16] + ((mem) & 0xffff));
|
return (psxMemWLUT[(mem) >> 16] == 0) ? NULL : (T*)(psxMemWLUT[(mem) >> 16] + ((mem) & 0xffff));
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Obtains a read-safe pointer into the IOP's physical memory, with TLB address translation.
|
// Obtains a read-safe pointer into the IOP's physical memory, with TLB address translation.
|
||||||
// Returns NULL if the address maps to an invalid/unmapped physical address.
|
// Returns NULL if the address maps to an invalid/unmapped physical address.
|
||||||
|
|
|
@ -277,6 +277,7 @@ void Pcsx2Config::LoadSave( IniInterface& ini )
|
||||||
IniBitBool( EnablePatches );
|
IniBitBool( EnablePatches );
|
||||||
IniBitBool( EnableCheats );
|
IniBitBool( EnableCheats );
|
||||||
IniBitBool( ConsoleToStdio );
|
IniBitBool( ConsoleToStdio );
|
||||||
|
IniBitBool( HostFs );
|
||||||
|
|
||||||
IniBitBool( McdEnableEjection );
|
IniBitBool( McdEnableEjection );
|
||||||
IniBitBool( MultitapPort0_Enabled );
|
IniBitBool( MultitapPort0_Enabled );
|
||||||
|
|
|
@ -63,6 +63,8 @@ void psxReset()
|
||||||
g_psxNextBranchCycle = psxRegs.cycle + 4;
|
g_psxNextBranchCycle = psxRegs.cycle + 4;
|
||||||
|
|
||||||
psxHwReset();
|
psxHwReset();
|
||||||
|
|
||||||
|
ioman::reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void psxShutdown() {
|
void psxShutdown() {
|
||||||
|
|
|
@ -627,13 +627,7 @@ void __fastcall eeloadReplaceOSDSYS()
|
||||||
|
|
||||||
const wxString &elf_override = GetCoreThread().GetElfOverride();
|
const wxString &elf_override = GetCoreThread().GetElfOverride();
|
||||||
|
|
||||||
if (!elf_override.IsEmpty()) {
|
cdvdReloadElfInfo(L"host:" + elf_override);
|
||||||
loadElfFile(elf_override);
|
|
||||||
eeGameStarting();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cdvdReloadElfInfo();
|
|
||||||
|
|
||||||
// didn't recognise an ELF
|
// didn't recognise an ELF
|
||||||
if (ElfEntry == -1) {
|
if (ElfEntry == -1) {
|
||||||
|
@ -664,9 +658,24 @@ void __fastcall eeloadReplaceOSDSYS()
|
||||||
}
|
}
|
||||||
pxAssert(osdsys_p);
|
pxAssert(osdsys_p);
|
||||||
|
|
||||||
wxString elfname;
|
string elfname;
|
||||||
if (GetPS2ElfName(elfname) == 2) {
|
|
||||||
strcpy((char*)PSM(safemem), elfname.ToUTF8());
|
if (!elf_override.IsEmpty())
|
||||||
|
{
|
||||||
|
elfname += "host:";
|
||||||
|
elfname += elf_override.ToUTF8();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString boot2;
|
||||||
|
if (GetPS2ElfName(boot2) == 2)
|
||||||
|
elfname = boot2.ToUTF8();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!elfname.empty())
|
||||||
|
{
|
||||||
|
strcpy((char*)PSM(safemem), elfname.c_str());
|
||||||
memWrite32(osdsys_p, safemem);
|
memWrite32(osdsys_p, safemem);
|
||||||
}
|
}
|
||||||
|
// else... uh...?
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ enum MenuIdentifiers
|
||||||
MenuId_Sys_SaveStates, // Opens save states submenu
|
MenuId_Sys_SaveStates, // Opens save states submenu
|
||||||
MenuId_EnablePatches,
|
MenuId_EnablePatches,
|
||||||
MenuId_EnableCheats,
|
MenuId_EnableCheats,
|
||||||
|
MenuId_EnableHostFs,
|
||||||
|
|
||||||
MenuId_State_Load,
|
MenuId_State_Load,
|
||||||
MenuId_State_LoadOther,
|
MenuId_State_LoadOther,
|
||||||
|
|
|
@ -175,6 +175,7 @@ void MainEmuFrame::ConnectMenus()
|
||||||
ConnectMenu( MenuId_IsoBrowse, Menu_IsoBrowse_Click );
|
ConnectMenu( MenuId_IsoBrowse, Menu_IsoBrowse_Click );
|
||||||
ConnectMenu( MenuId_EnablePatches, Menu_EnablePatches_Click );
|
ConnectMenu( MenuId_EnablePatches, Menu_EnablePatches_Click );
|
||||||
ConnectMenu( MenuId_EnableCheats, Menu_EnableCheats_Click );
|
ConnectMenu( MenuId_EnableCheats, Menu_EnableCheats_Click );
|
||||||
|
ConnectMenu( MenuId_EnableHostFs, Menu_EnableHostFs_Click );
|
||||||
ConnectMenu( MenuId_Exit, Menu_Exit_Click );
|
ConnectMenu( MenuId_Exit, Menu_Exit_Click );
|
||||||
|
|
||||||
ConnectMenu( MenuId_Sys_SuspendResume, Menu_SuspendResume_Click );
|
ConnectMenu( MenuId_Sys_SuspendResume, Menu_SuspendResume_Click );
|
||||||
|
@ -387,6 +388,9 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
|
||||||
m_menuSys.Append(MenuId_EnableCheats, _("Enable Cheats"),
|
m_menuSys.Append(MenuId_EnableCheats, _("Enable Cheats"),
|
||||||
wxEmptyString, wxITEM_CHECK);
|
wxEmptyString, wxITEM_CHECK);
|
||||||
|
|
||||||
|
m_menuSys.Append(MenuId_EnableHostFs, _("Enable Host Filesystem"),
|
||||||
|
wxEmptyString, wxITEM_CHECK);
|
||||||
|
|
||||||
m_menuSys.AppendSeparator();
|
m_menuSys.AppendSeparator();
|
||||||
|
|
||||||
m_menuSys.Append(MenuId_Sys_Shutdown, _("Shutdown"),
|
m_menuSys.Append(MenuId_Sys_Shutdown, _("Shutdown"),
|
||||||
|
@ -607,6 +611,7 @@ void MainEmuFrame::ApplySettings()
|
||||||
|
|
||||||
menubar.Check( MenuId_EnablePatches, g_Conf->EmuOptions.EnablePatches );
|
menubar.Check( MenuId_EnablePatches, g_Conf->EmuOptions.EnablePatches );
|
||||||
menubar.Check( MenuId_EnableCheats, g_Conf->EmuOptions.EnableCheats );
|
menubar.Check( MenuId_EnableCheats, g_Conf->EmuOptions.EnableCheats );
|
||||||
|
menubar.Check( MenuId_EnableHostFs, g_Conf->EmuOptions.HostFs );
|
||||||
menubar.Check( MenuId_CDVD_Info, g_Conf->EmuOptions.CdvdVerboseReads );
|
menubar.Check( MenuId_CDVD_Info, g_Conf->EmuOptions.CdvdVerboseReads );
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
menubar.Check( MenuId_Console_Stdio, g_Conf->EmuOptions.ConsoleToStdio );
|
menubar.Check( MenuId_Console_Stdio, g_Conf->EmuOptions.ConsoleToStdio );
|
||||||
|
|
|
@ -171,6 +171,7 @@ protected:
|
||||||
void Menu_IsoBrowse_Click(wxCommandEvent &event);
|
void Menu_IsoBrowse_Click(wxCommandEvent &event);
|
||||||
void Menu_EnablePatches_Click(wxCommandEvent &event);
|
void Menu_EnablePatches_Click(wxCommandEvent &event);
|
||||||
void Menu_EnableCheats_Click(wxCommandEvent &event);
|
void Menu_EnableCheats_Click(wxCommandEvent &event);
|
||||||
|
void Menu_EnableHostFs_Click(wxCommandEvent &event);
|
||||||
|
|
||||||
void Menu_BootCdvd_Click(wxCommandEvent &event);
|
void Menu_BootCdvd_Click(wxCommandEvent &event);
|
||||||
void Menu_BootCdvd2_Click(wxCommandEvent &event);
|
void Menu_BootCdvd2_Click(wxCommandEvent &event);
|
||||||
|
|
|
@ -376,6 +376,12 @@ void MainEmuFrame::Menu_EnableCheats_Click( wxCommandEvent& )
|
||||||
SaveEmuOptions();
|
SaveEmuOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainEmuFrame::Menu_EnableHostFs_Click( wxCommandEvent& )
|
||||||
|
{
|
||||||
|
g_Conf->EmuOptions.HostFs = GetMenuBar()->IsChecked( MenuId_EnableHostFs );
|
||||||
|
SaveEmuOptions();
|
||||||
|
}
|
||||||
|
|
||||||
void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent&)
|
void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
ScopedCoreThreadClose stopped_core;
|
ScopedCoreThreadClose stopped_core;
|
||||||
|
|
|
@ -1,212 +0,0 @@
|
||||||
/* PCSX2 - PS2 Emulator for PCs
|
|
||||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
|
||||||
*
|
|
||||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
|
||||||
#include "IopCommon.h"
|
|
||||||
#include "Utilities/Console.h"
|
|
||||||
|
|
||||||
#ifndef __LINUX__
|
|
||||||
#include <io.h>
|
|
||||||
//#include "dirent.h"
|
|
||||||
#else
|
|
||||||
#include <dirent.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma optimize("", off)
|
|
||||||
|
|
||||||
#define PS2E_FIO_OPEN_CMD 0xcc2e0101
|
|
||||||
#define PS2E_FIO_CLOSE_CMD 0xcc2e0102
|
|
||||||
#define PS2E_FIO_READ_CMD 0xcc2e0103
|
|
||||||
#define PS2E_FIO_WRITE_CMD 0xcc2e0104
|
|
||||||
#define PS2E_FIO_LSEEK_CMD 0xcc2e0105
|
|
||||||
#define PS2E_FIO_OPENDIR_CMD 0xcc2e0106
|
|
||||||
#define PS2E_FIO_CLOSEDIR_CMD 0xcc2e0107
|
|
||||||
#define PS2E_FIO_READDIR_CMD 0xcc2e0108
|
|
||||||
#define PS2E_FIO_REMOVE_CMD 0xcc2e0109
|
|
||||||
#define PS2E_FIO_MKDIR_CMD 0xcc2e010a
|
|
||||||
#define PS2E_FIO_RMDIR_CMD 0xcc2e010b
|
|
||||||
|
|
||||||
#define PS2E_FIO_PRINTF_CMD 0xcc2e0201
|
|
||||||
|
|
||||||
#define PS2E_FIO_MAGIC 'E2SP'
|
|
||||||
|
|
||||||
u32 functionId;
|
|
||||||
u32 paramsAddress;
|
|
||||||
u32 paramsLength;
|
|
||||||
u32 returnValue;
|
|
||||||
|
|
||||||
#ifndef O_BINARY
|
|
||||||
# define O_BINARY 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IOP_RDONLY 0x0001
|
|
||||||
#define IOP_WRONLY 0x0002
|
|
||||||
#define IOP_RDWR 0x0003
|
|
||||||
#define IOP_NBLOCK 0x0010
|
|
||||||
#define IOP_APPEND 0x0100
|
|
||||||
#define IOP_CREAT 0x0200
|
|
||||||
#define IOP_TRUNC 0x0400
|
|
||||||
#define IOP_NOWAIT 0x8000
|
|
||||||
|
|
||||||
int pcsx2fio_open_file(char *path, int flags)
|
|
||||||
{
|
|
||||||
int mode = O_BINARY;
|
|
||||||
|
|
||||||
switch(flags&IOP_RDWR)
|
|
||||||
{
|
|
||||||
case IOP_RDONLY:
|
|
||||||
mode |= O_RDONLY;
|
|
||||||
break;
|
|
||||||
case IOP_WRONLY:
|
|
||||||
mode |= O_WRONLY;
|
|
||||||
break;
|
|
||||||
case IOP_RDWR:
|
|
||||||
mode |= O_RDWR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(flags&IOP_CREAT)
|
|
||||||
mode |= O_CREAT;
|
|
||||||
if(flags&IOP_APPEND)
|
|
||||||
mode |= O_APPEND;
|
|
||||||
if(flags&IOP_TRUNC)
|
|
||||||
mode |= O_TRUNC;
|
|
||||||
|
|
||||||
return open(path,mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_close_file(int fd)
|
|
||||||
{
|
|
||||||
return close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_lseek_file(int fd, unsigned int offset, int whence)
|
|
||||||
{
|
|
||||||
return lseek(fd,offset,whence);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_write_file(int fd, char *buf, int length)
|
|
||||||
{
|
|
||||||
return write(fd,buf,length);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_read_file(int fd, char *buf, int length)
|
|
||||||
{
|
|
||||||
return read(fd,buf,length);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_remove(char *name)
|
|
||||||
{
|
|
||||||
return unlink(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_mkdir(char *name, int mode)
|
|
||||||
{
|
|
||||||
#ifdef __LINUX__
|
|
||||||
return mkdir(name,mode);
|
|
||||||
#else
|
|
||||||
return mkdir(name);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_rmdir(char *name)
|
|
||||||
{
|
|
||||||
return rmdir(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_open_dir(char *path)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_read_dir(int fd, void *buf)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_close_dir(int fd)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_write_tty(const char* text, int length)
|
|
||||||
{
|
|
||||||
wxString s = wxString::FromUTF8(text,length);
|
|
||||||
|
|
||||||
return printf("%s",s.ToAscii().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PARAM(offset,type) (*(type*)(buffer+(offset)))
|
|
||||||
#define PARAMP(offset,type) (type*)iopPhysMem(PARAM(offset,u32))
|
|
||||||
#define PARAMSTR(offset) ((char*)(buffer+(offset)))
|
|
||||||
void Pcsx2HostFsExec()
|
|
||||||
{
|
|
||||||
u8* buffer = (u8*)iopPhysMem(paramsAddress);
|
|
||||||
|
|
||||||
switch(functionId)
|
|
||||||
{
|
|
||||||
case PS2E_FIO_OPEN_CMD: returnValue = pcsx2fio_open_file(PARAMSTR(4),PARAM(0,s32)); break;
|
|
||||||
case PS2E_FIO_CLOSE_CMD: returnValue = pcsx2fio_close_file(PARAM(0,s32)); break;
|
|
||||||
case PS2E_FIO_READ_CMD: returnValue = pcsx2fio_read_file(PARAM(0,s32),PARAMP(4,char),PARAM(8,s32)); break;
|
|
||||||
case PS2E_FIO_WRITE_CMD: returnValue = pcsx2fio_write_file(PARAM(0,s32),PARAMP(4,char),PARAM(8,s32)); break;
|
|
||||||
case PS2E_FIO_LSEEK_CMD: returnValue = pcsx2fio_lseek_file(PARAM(0,s32),PARAM(4,s32),PARAM(8,s32)); break;
|
|
||||||
case PS2E_FIO_REMOVE_CMD: returnValue = pcsx2fio_remove(PARAMSTR(0)); break;
|
|
||||||
case PS2E_FIO_OPENDIR_CMD: returnValue = pcsx2fio_open_dir(PARAMSTR(0)); break;
|
|
||||||
case PS2E_FIO_CLOSEDIR_CMD: returnValue = pcsx2fio_close_dir(PARAM(0,s32)); break;
|
|
||||||
case PS2E_FIO_READDIR_CMD: returnValue = pcsx2fio_read_dir(PARAM(0,s32),PARAMP(4,void)); break;
|
|
||||||
case PS2E_FIO_MKDIR_CMD: returnValue = pcsx2fio_mkdir(PARAMSTR(4),PARAM(0,s32)); break;
|
|
||||||
case PS2E_FIO_RMDIR_CMD: returnValue = pcsx2fio_rmdir(PARAMSTR(0)); break;
|
|
||||||
|
|
||||||
case PS2E_FIO_PRINTF_CMD: returnValue = pcsx2fio_write_tty(PARAMSTR(0),paramsLength); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pcsx2HostFSwrite32(u32 addr, u32 value)
|
|
||||||
{
|
|
||||||
switch(addr&0xF)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if(value==1)
|
|
||||||
Pcsx2HostFsExec();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
paramsLength = value;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
paramsAddress = value;
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
functionId = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 Pcsx2HostFSread32(u32 addr)
|
|
||||||
{
|
|
||||||
switch(addr&0xF)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return PS2E_FIO_MAGIC;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
return returnValue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1190,10 +1190,6 @@
|
||||||
RelativePath="..\..\IopSio2.h"
|
RelativePath="..\..\IopSio2.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\pcsx2hostfs.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\R3000A.cpp"
|
RelativePath="..\..\R3000A.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
PS2Link (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
(C) 2003,2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
(C) 2004 Lukasz Bruun (mail@lukasz.dk)
|
|
||||||
(C) 2006 Drakonite (makeshift_ps2dev@123mail.org)
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
2006-02-18 Version 1.46
|
|
||||||
- Added Cached Config support
|
|
||||||
- Extra config disabled, at least while cached config is enabled
|
|
||||||
- Some code cleanup and reordering
|
|
||||||
- More consistant environment (no longer has sio2man and mcman
|
|
||||||
loaded when booting from MC, assuming cached_cfg enabled)
|
|
||||||
- Boots from essentially anywhere now
|
|
||||||
- Some code uglyfications
|
|
||||||
- Elf in bin/ is now packed using ps2-packer
|
|
||||||
- Lots of version bumping from beta test versions
|
|
||||||
- Other stuff
|
|
||||||
|
|
||||||
2006-01-25 Version 1.32
|
|
||||||
- Cleaned up and repaired Makefiles
|
|
||||||
- Disabled 'check' dependency of make dist as it seems to
|
|
||||||
be broken, dist was broken anyways so it doesn't seem like
|
|
||||||
check is being used
|
|
||||||
- Builtin_irx made default out of svn
|
|
||||||
- Bumped version for tag
|
|
||||||
|
|
||||||
2004-09-25 Version 1.30
|
|
||||||
- Added IOP exception handling
|
|
||||||
- Changed IPCONFIG.DAT & EXTRA.CNF a little and added better
|
|
||||||
parsing code.
|
|
||||||
|
|
||||||
2004-05-24 Version 1.24
|
|
||||||
- Made changes for compiling with ps2sdk, introduction of imports.lst/.h
|
|
||||||
and many changes in IOP part to use ioman.h.
|
|
||||||
- Set default values for irx_mod pointers and sizes for cached modules
|
|
||||||
to ensure they were in .bss and not trashed on pko_reset.
|
|
||||||
- Set default values for ip parameters for the same reason as above.
|
|
||||||
- New command writemem
|
|
||||||
- Can load irx files from a defined file in IPCONFIG.DAT
|
|
||||||
- All-In-One elf (irx's embedded in the elf) build target.
|
|
||||||
|
|
||||||
2004-02-08 Version 1.23
|
|
||||||
- Some new commands stop/start vu, dump mem, dump reg, gsexec
|
|
||||||
|
|
||||||
2004-02-06 Version 1.22
|
|
||||||
- HOST: getdir support (so ps2 can get filelist from host:, using ioman calls)
|
|
||||||
|
|
||||||
2004-01-29 Version 1.21
|
|
||||||
- Fixed Host loading (both IRX and ipconfig) - prob with reset (CLEARSPU), but runs fine.
|
|
||||||
- Added sbv for prefix checking, to remove LMB for mc load.
|
|
||||||
- Added screen/console exception dump selection.
|
|
||||||
- Consistent IOP reset for both HOST and other FS load methods.
|
|
||||||
- Removed DMS specific loading, module loading made more general.
|
|
||||||
- Handles being run from ANY mc dir now.
|
|
||||||
- Cleaned up highloading version.
|
|
||||||
|
|
||||||
2003-12-31 Version 1.2
|
|
||||||
- Binary Release Version
|
|
||||||
|
|
||||||
2003-12-15 Version 1.1
|
|
||||||
- Made compatible with ps2drv, for eth and HDD access together.
|
|
||||||
|
|
||||||
2003-05-12 Version 1.0
|
|
||||||
- First release
|
|
|
@ -1,174 +0,0 @@
|
||||||
|
|
||||||
COPYRIGHT FOR PS2LINK
|
|
||||||
----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
(c) 2003 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
(c) 2004 Khaled Daham
|
|
||||||
(c) 2004 Nicolas 'Pixel' Noble
|
|
||||||
|
|
||||||
The Academic Free License
|
|
||||||
v. 2.0
|
|
||||||
|
|
||||||
This Academic Free License (the "License") applies to any original work
|
|
||||||
of authorship (the "Original Work") whose owner (the "Licensor") has
|
|
||||||
placed the following notice immediately following the copyright notice
|
|
||||||
for the Original Work:
|
|
||||||
|
|
||||||
*Licensed under the Academic Free License version 2.0*
|
|
||||||
|
|
||||||
1) *Grant of Copyright License.* Licensor hereby grants You a
|
|
||||||
world-wide, royalty-free, non-exclusive, perpetual, sublicenseable
|
|
||||||
license to do the following:
|
|
||||||
|
|
||||||
a) to reproduce the Original Work in copies;
|
|
||||||
|
|
||||||
b) to prepare derivative works ("Derivative Works") based upon the
|
|
||||||
Original Work;
|
|
||||||
|
|
||||||
c) to distribute copies of the Original Work and Derivative Works to
|
|
||||||
the public;
|
|
||||||
|
|
||||||
d) to perform the Original Work publicly; and
|
|
||||||
|
|
||||||
e) to display the Original Work publicly.
|
|
||||||
|
|
||||||
2) *Grant of Patent License.* Licensor hereby grants You a world-wide,
|
|
||||||
royalty-free, non-exclusive, perpetual, sublicenseable license, under
|
|
||||||
patent claims owned or controlled by the Licensor that are embodied in
|
|
||||||
the Original Work as furnished by the Licensor, to make, use, sell and
|
|
||||||
offer for sale the Original Work and Derivative Works.
|
|
||||||
|
|
||||||
3) *Grant of Source Code License.* The term "Source Code" means the
|
|
||||||
preferred form of the Original Work for making modifications to it and
|
|
||||||
all available documentation describing how to modify the Original Work.
|
|
||||||
Licensor hereby agrees to provide a machine-readable copy of the Source
|
|
||||||
Code of the Original Work along with each copy of the Original Work that
|
|
||||||
Licensor distributes. Licensor reserves the right to satisfy this
|
|
||||||
obligation by placing a machine-readable copy of the Source Code in an
|
|
||||||
information repository reasonably calculated to permit inexpensive and
|
|
||||||
convenient access by You for as long as Licensor continues to distribute
|
|
||||||
the Original Work, and by publishing the address of that information
|
|
||||||
repository in a notice immediately following the copyright notice that
|
|
||||||
applies to the Original Work.
|
|
||||||
|
|
||||||
4) *Exclusions From License Grant. *Neither the names of Licensor, nor
|
|
||||||
the names of any contributors to the Original Work, nor any of their
|
|
||||||
trademarks or service marks, may be used to endorse or promote products
|
|
||||||
derived from this Original Work without express prior written permission
|
|
||||||
of the Licensor. Nothing in this License shall be deemed to grant any
|
|
||||||
rights to trademarks, copyrights, patents, trade secrets or any other
|
|
||||||
intellectual property of Licensor except as expressly stated herein. No
|
|
||||||
patent license is granted to make, use, sell or offer to sell
|
|
||||||
embodiments of any patent claims other than the licensed claims defined
|
|
||||||
in Section 2. No right is granted to the trademarks of Licensor even if
|
|
||||||
such marks are included in the Original Work. Nothing in this License
|
|
||||||
shall be interpreted to prohibit Licensor from licensing under different
|
|
||||||
terms from this License any Original Work that Licensor otherwise would
|
|
||||||
have a right to license.
|
|
||||||
|
|
||||||
5) This section intentionally omitted.
|
|
||||||
|
|
||||||
6) *Attribution Rights.* You must retain, in the Source Code of any
|
|
||||||
Derivative Works that You create, all copyright, patent or trademark
|
|
||||||
notices from the Source Code of the Original Work, as well as any
|
|
||||||
notices of licensing and any descriptive text identified therein as an
|
|
||||||
"Attribution Notice." You must cause the Source Code for any Derivative
|
|
||||||
Works that You create to carry a prominent Attribution Notice reasonably
|
|
||||||
calculated to inform recipients that You have modified the Original Work.
|
|
||||||
|
|
||||||
7) *Warranty of Provenance and Disclaimer of Warranty.* Licensor
|
|
||||||
warrants that the copyright in and to the Original Work and the patent
|
|
||||||
rights granted herein by Licensor are owned by the Licensor or are
|
|
||||||
sublicensed to You under the terms of this License with the permission
|
|
||||||
of the contributor(s) of those copyrights and patent rights. Except as
|
|
||||||
expressly stated in the immediately proceeding sentence, the Original
|
|
||||||
Work is provided under this License on an "AS IS" BASIS and WITHOUT
|
|
||||||
WARRANTY, either express or implied, including, without limitation, the
|
|
||||||
warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
|
|
||||||
WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
|
|
||||||
part of this License. No license to Original Work is granted hereunder
|
|
||||||
except under this disclaimer.
|
|
||||||
|
|
||||||
8) *Limitation of Liability.* Under no circumstances and under no legal
|
|
||||||
theory, whether in tort (including negligence), contract, or otherwise,
|
|
||||||
shall the Licensor be liable to any person for any direct, indirect,
|
|
||||||
special, incidental, or consequential damages of any character arising
|
|
||||||
as a result of this License or the use of the Original Work including,
|
|
||||||
without limitation, damages for loss of goodwill, work stoppage,
|
|
||||||
computer failure or malfunction, or any and all other commercial damages
|
|
||||||
or losses. This limitation of liability shall not apply to liability for
|
|
||||||
death or personal injury resulting from Licensor's negligence to the
|
|
||||||
extent applicable law prohibits such limitation. Some jurisdictions do
|
|
||||||
not allow the exclusion or limitation of incidental or consequential
|
|
||||||
damages, so this exclusion and limitation may not apply to You.
|
|
||||||
|
|
||||||
9) *Acceptance and Termination.* If You distribute copies of the
|
|
||||||
Original Work or a Derivative Work, You must make a reasonable effort
|
|
||||||
under the circumstances to obtain the express assent of recipients to
|
|
||||||
the terms of this License. Nothing else but this License (or another
|
|
||||||
written agreement between Licensor and You) grants You permission to
|
|
||||||
create Derivative Works based upon the Original Work or to exercise any
|
|
||||||
of the rights granted in Section 1 herein, and any attempt to do so
|
|
||||||
except under the terms of this License (or another written agreement
|
|
||||||
between Licensor and You) is expressly prohibited by U.S. copyright law,
|
|
||||||
the equivalent laws of other countries, and by international treaty.
|
|
||||||
Therefore, by exercising any of the rights granted to You in Section 1
|
|
||||||
herein, You indicate Your acceptance of this License and all of its
|
|
||||||
terms and conditions.
|
|
||||||
|
|
||||||
10) *Termination for Patent Action.* This License shall terminate
|
|
||||||
automatically and You may no longer exercise any of the rights granted
|
|
||||||
to You by this License as of the date You commence an action, including
|
|
||||||
a cross-claim or counterclaim, for patent infringement (i) against
|
|
||||||
Licensor with respect to a patent applicable to software or (ii) against
|
|
||||||
any entity with respect to a patent applicable to the Original Work (but
|
|
||||||
excluding combinations of the Original Work with other software or
|
|
||||||
hardware).
|
|
||||||
|
|
||||||
11) *Jurisdiction, Venue and Governing Law.* Any action or suit relating
|
|
||||||
to this License may be brought only in the courts of a jurisdiction
|
|
||||||
wherein the Licensor resides or in which Licensor conducts its primary
|
|
||||||
business, and under the laws of that jurisdiction excluding its
|
|
||||||
conflict-of-law provisions. The application of the United Nations
|
|
||||||
Convention on Contracts for the International Sale of Goods is expressly
|
|
||||||
excluded. Any use of the Original Work outside the scope of this License
|
|
||||||
or after its termination shall be subject to the requirements and
|
|
||||||
penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et seq., the
|
|
||||||
equivalent laws of other countries, and international treaty. This
|
|
||||||
section shall survive the termination of this License.
|
|
||||||
|
|
||||||
12) *Attorneys Fees.* In any action to enforce the terms of this License
|
|
||||||
or seeking damages relating thereto, the prevailing party shall be
|
|
||||||
entitled to recover its costs and expenses, including, without
|
|
||||||
limitation, reasonable attorneys' fees and costs incurred in connection
|
|
||||||
with such action, including any appeal of such action. This section
|
|
||||||
shall survive the termination of this License.
|
|
||||||
|
|
||||||
13) *Miscellaneous.* This License represents the complete agreement
|
|
||||||
concerning the subject matter hereof. If any provision of this License
|
|
||||||
is held to be unenforceable, such provision shall be reformed only to
|
|
||||||
the extent necessary to make it enforceable.
|
|
||||||
|
|
||||||
14) *Definition of "You" in This License.* "You" throughout this
|
|
||||||
License, whether in upper or lower case, means an individual or a legal
|
|
||||||
entity exercising rights under, and complying with all of the terms of,
|
|
||||||
this License. For legal entities, "You" includes any entity that
|
|
||||||
controls, is controlled by, or is under common control with you. For
|
|
||||||
purposes of this definition, "control" means (i) the power, direct or
|
|
||||||
indirect, to cause the direction or management of such entity, whether
|
|
||||||
by contract or otherwise, or (ii) ownership of fifty percent (50%) or
|
|
||||||
more of the outstanding shares, or (iii) beneficial ownership of such
|
|
||||||
entity.
|
|
||||||
|
|
||||||
15) *Right to Use.* You may use the Original Work in all ways not
|
|
||||||
otherwise restricted or conditioned by this License or by law, and
|
|
||||||
Licensor promises not to interfere with or be responsible for such uses
|
|
||||||
by You.
|
|
||||||
|
|
||||||
This license is Copyright (C) 2003 Lawrence E. Rosen. All rights
|
|
||||||
reserved. Permission is hereby granted to copy and distribute this
|
|
||||||
license without modification. This license may not be modified without
|
|
||||||
the express written permission of its copyright owner.
|
|
||||||
|
|
|
@ -1,134 +0,0 @@
|
||||||
# Compilation variables
|
|
||||||
|
|
||||||
# Set this to 1 to enable debug mode
|
|
||||||
DEBUG = 0
|
|
||||||
|
|
||||||
# Set this to 1 to build a highloading version, 0 for normal low version
|
|
||||||
LOADHIGH = 1
|
|
||||||
|
|
||||||
# Set this to 1 to build ps2link with all the needed IRX builtins
|
|
||||||
BUILTIN_IRXS = 1
|
|
||||||
|
|
||||||
# Set this to 1 to enable caching of config files
|
|
||||||
CACHED_CFG = 1
|
|
||||||
|
|
||||||
# Set this to 1 to enable zero-copy on fileio writes.
|
|
||||||
ZEROCOPY = 0
|
|
||||||
|
|
||||||
# Set this to 1 to power off the ps2 when the reset button is tapped
|
|
||||||
# otherwise it will try and reset ps2link
|
|
||||||
PWOFFONRESET = 1
|
|
||||||
|
|
||||||
# Set this to 1 to hook the kernel CreateThread/DeleteThread calls.
|
|
||||||
# Note that this will cause problems when loading PS2LINK.ELF from PS2LINK...
|
|
||||||
HOOK_THREADS = 0
|
|
||||||
|
|
||||||
# Set this to 1 to enable screenshots.
|
|
||||||
# Note that this adds a dependency with libgraph and libdma
|
|
||||||
SCREENSHOTS = 0
|
|
||||||
|
|
||||||
# Set to the path where ps2eth is located
|
|
||||||
PS2ETH = $(PS2DEV)/ps2eth
|
|
||||||
|
|
||||||
SHELL=/usr/bin/env bash
|
|
||||||
BIN2O=$(PS2SDK)/bin/bin2o
|
|
||||||
RM=rm -f
|
|
||||||
|
|
||||||
#
|
|
||||||
# You shouldn't need to modify anything below this point
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(PS2SDK)/Defs.make
|
|
||||||
|
|
||||||
EEFILES=ee/pcsx2hostfs_ldr.elf
|
|
||||||
|
|
||||||
IRXFILES=iop/pcsx2hostfs.irx $(PS2SDK)/iop/irx/ioptrap.irx
|
|
||||||
|
|
||||||
VARIABLES=DEBUG=$(DEBUG) LOADHIGH=$(LOADHIGH) BUILTIN_IRXS=$(BUILTIN_IRXS) ZEROCOPY=$(ZEROCOPY) PWOFFONRESET=$(PWOFFONRESET) CACHED_CFG=$(CACHED_CFG) HOOK_THREADS=$(HOOK_THREADS) SCREENSHOTS=$(SCREENSHOTS)
|
|
||||||
|
|
||||||
ifeq ($(BUILTIN_IRXS),1)
|
|
||||||
TARGETS = iop builtins ee
|
|
||||||
else
|
|
||||||
TARGETS = ee iop
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: $(TARGETS)
|
|
||||||
ifneq ($(BUILTIN_IRXS),1)
|
|
||||||
@for file in $(IRXFILES); do \
|
|
||||||
new=`echo $${file/*\//}|tr "[:lower:]" "[:upper:]"`; \
|
|
||||||
cp $$file bin/$$new; \
|
|
||||||
done;
|
|
||||||
endif
|
|
||||||
@for file in $(EEFILES); do \
|
|
||||||
new=`echo $${file/*\//}|tr "[:lower:]" "[:upper:]"`; \
|
|
||||||
cp $$file bin/$$new; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
ee:
|
|
||||||
$(VARIABLES) $(MAKE) -C ee
|
|
||||||
|
|
||||||
iop:
|
|
||||||
$(VARIABLES) $(MAKE) -C iop
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(MAKE) -C ee clean
|
|
||||||
$(MAKE) -C iop clean
|
|
||||||
|
|
||||||
check:
|
|
||||||
$(VARIABLES) $(MAKE) -C ee check
|
|
||||||
|
|
||||||
# Creates a zip from what you have
|
|
||||||
dist: all
|
|
||||||
@rm -rf dist
|
|
||||||
@mkdir -p dist/ps2link
|
|
||||||
ifneq ($(BUILTIN_IRXS),1)
|
|
||||||
@for file in $(IRXFILES); do \
|
|
||||||
new=`echo $${file/*\//}|tr "[:lower:]" "[:upper:]"`; \
|
|
||||||
cp $$file dist/ps2link/$$new; \
|
|
||||||
done;
|
|
||||||
endif
|
|
||||||
@for file in $(EEFILES); do \
|
|
||||||
new=`echo $${file/*\//}|tr "[:lower:]" "[:upper:]"`; \
|
|
||||||
cp $$file dist/ps2link/$$new; \
|
|
||||||
done;
|
|
||||||
cd dist; \
|
|
||||||
tar -jcf ps2link.tar.bz2 ps2link/
|
|
||||||
|
|
||||||
RELEASE_FILES=bin/*IRX bin/*DAT bin/*cnf bin/*ELF LICENSE README
|
|
||||||
#
|
|
||||||
# Creates zip with iso and all necessary files of last release
|
|
||||||
release:
|
|
||||||
@rm -rf RELEASE
|
|
||||||
@mkdir -p RELEASE
|
|
||||||
@VERSION=`cvs log Makefile | grep -A 1 symbolic | tail -1 | awk '{print substr($$1, 0, length($$1)-1)}'`; \
|
|
||||||
cd RELEASE; \
|
|
||||||
cvs co -r $$VERSION ps2link; \
|
|
||||||
cd ps2link; \
|
|
||||||
make; \
|
|
||||||
make check; \
|
|
||||||
mkdir -p bin; \
|
|
||||||
for file in $(IRXFILES); do \
|
|
||||||
new=`echo $${file/*\//}|tr "[:lower:]" "[:upper:]"`; \
|
|
||||||
cp $$file bin/$$new; \
|
|
||||||
done; \
|
|
||||||
for file in $(EEFILES); do \
|
|
||||||
new=`echo $${file/*\//}|tr "[:lower:]" "[:upper:]"`; \
|
|
||||||
cp $$file bin/$$new; \
|
|
||||||
done; \
|
|
||||||
dd if=/dev/zero of=bin/dummy bs=1024 count=28672; \
|
|
||||||
ps2mkisofs -o ps2link_$$VERSION.iso bin/; \
|
|
||||||
rm bin/dummy; \
|
|
||||||
tar -jcf ps2link_$$VERSION.tbz $(RELEASE_FILES) ps2link_$$VERSION.iso
|
|
||||||
|
|
||||||
docs:
|
|
||||||
doxygen doxy.conf
|
|
||||||
|
|
||||||
builtins:
|
|
||||||
@for file in $(IRXFILES); do \
|
|
||||||
basefile=$${file/*\//}; \
|
|
||||||
basefile=$${basefile/\.*/}; \
|
|
||||||
echo "Embedding IRX file $$basefile"; \
|
|
||||||
$(BIN2O) $$file ee/$${basefile}_irx.o _binary_$${basefile}_irx; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
.PHONY: iop ee
|
|
|
@ -1,46 +0,0 @@
|
||||||
PS2Link (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
(C) 2003,2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
(C) 2003,2004,2005 Khaled (khaled@w-arts.com)
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Please read the file LICENSE regarding PS2Link licensing.
|
|
||||||
|
|
||||||
PS2Link is a 'bootloader' which, used together with an Ethernet driver and
|
|
||||||
a TCP/IP stack, enables you to download and execute software on your PS2.
|
|
||||||
|
|
||||||
It is designed to run from memory card, cdrom or host drives.
|
|
||||||
|
|
||||||
It loads all IRX's at startup and IPCONFIG.DAT for the network settings.
|
|
||||||
The IRX's and the IPCONFIG.DAT should be in the directory which PS2LINK is loaded from.
|
|
||||||
|
|
||||||
PS2Link requires the following IRX modules:
|
|
||||||
PS2LINK.IRX from: ps2link
|
|
||||||
PS2DEV9.IRX ps2sdk
|
|
||||||
PS2IP.IRX ps2sdk
|
|
||||||
IOPTRAP.IRX ps2sdk
|
|
||||||
POWEROFF.IRX ps2sdk
|
|
||||||
PS2SMAP.IRX ps2eth
|
|
||||||
|
|
||||||
Building ps2link requires two projects PS2SDK and PS2ETH.
|
|
||||||
|
|
||||||
For building against ps2sdk make sure PS2SDK is set to your ps2sdk release
|
|
||||||
dir. If you do not have ps2sdk built, check it out from cvs and set PS2SDK and
|
|
||||||
PS2SDKSRC = checked out ps2sdk dir, do 'make' and 'make release'.
|
|
||||||
|
|
||||||
Credit for the icon logo goes to Revolt from #ps2dev.
|
|
||||||
|
|
||||||
NOTES + WARNINGS:
|
|
||||||
ALL IRX FILENAMES SHOULD BE UPPERCASE.
|
|
||||||
IPCONFIG.DAT FILENAME SHOULD BE UPPERCASE.
|
|
||||||
|
|
||||||
IPCONFIG.DAT uses the following format:
|
|
||||||
PS2IPADDRESS NETMASK GATEWAYIP
|
|
||||||
seperated by a single space.
|
|
||||||
|
|
||||||
You can load addition IRX's by specifying EXTRACNF file in IPCONFIG.DAT. It
|
|
||||||
will load the EXTRACNF file and and load all irx's terminated with ';' in the order
|
|
||||||
they are listed in the EXTRACNF file. By default the EXTRACNF setting is
|
|
||||||
disabled (commented) with '#' in IPCONFIG.DAT, remove the '#' the load the
|
|
||||||
EXTRACNF file.
|
|
||||||
|
|
||||||
If you have any questions or bugreports about ps2link go to forums.ps2dev.org.
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,68 +0,0 @@
|
||||||
EE_BIN = pcsx2hostfs_ldr.elf
|
|
||||||
EE_OBJS = ps2link.o excepHandler.o exceptions.o cmdHandler.o
|
|
||||||
EE_INCS += -I../include
|
|
||||||
|
|
||||||
# This is for the sbv patch
|
|
||||||
SBVLITE = $(PS2SDK)/sbv
|
|
||||||
EE_INCS += -I$(SBVLITE)/include
|
|
||||||
EE_LDFLAGS += -L$(SBVLITE)/lib
|
|
||||||
EE_LIBS += -lpatches -ldebug
|
|
||||||
ifeq ($(SCREENSHOTS),1)
|
|
||||||
EE_LIBS += -lpacket -ldma
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Normal low loading version
|
|
||||||
ifeq ($(BUILTIN_IRXS),1)
|
|
||||||
LOADADDR = 0xa8000
|
|
||||||
else
|
|
||||||
LOADADDR = 0xc0000
|
|
||||||
endif
|
|
||||||
STACKADDR = 0x100000
|
|
||||||
|
|
||||||
# This is to build a highloading version
|
|
||||||
ifeq ($(LOADHIGH),1)
|
|
||||||
ifeq ($(BUILTIN_IRXS),1)
|
|
||||||
LOADADDR = 0x1ee8000
|
|
||||||
else
|
|
||||||
LOADADDR = 0x1f00000
|
|
||||||
endif
|
|
||||||
STACKADDR = 0x1f40000
|
|
||||||
EE_CFLAGS += -D_LOADHIGHVER
|
|
||||||
endif
|
|
||||||
|
|
||||||
# This is to builtin the IRXs into ps2link
|
|
||||||
ifeq ($(BUILTIN_IRXS),1)
|
|
||||||
EE_CFLAGS += -DBUILTIN_IRXS
|
|
||||||
EE_LDFLAGS += pcsx2hostfs_irx.o ioptrap_irx.o
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(BUILTIN_IRXS),1)
|
|
||||||
ifeq ($(CACHED_CFG),1)
|
|
||||||
EE_CFLAGS += -DUSE_CACHED_CFG
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# This is to enable the debug mode into ps2link
|
|
||||||
ifeq ($(DEBUG),1)
|
|
||||||
EE_CFLAGS += -DDEBUG -g
|
|
||||||
endif
|
|
||||||
|
|
||||||
LDPARAMS := -Wl,--defsym -Wl,_stack_size=0x8000 -Wl,--defsym -Wl,_stack=$(STACKADDR)
|
|
||||||
EE_LDFLAGS += -Wl,-Ttext -Wl,$(LOADADDR) $(LDPARAMS)
|
|
||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
|
||||||
EE_LDFLAGS += -g
|
|
||||||
else
|
|
||||||
EE_LDFLAGS += -s
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: $(EE_BIN)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f $(EE_OBJS) $(EE_BIN)
|
|
||||||
|
|
||||||
check: $(EE_BIN)
|
|
||||||
@ee-readelf -l $(EE_BIN) | awk ' /LOAD/ { if ((spare = (-($$4 + $$6) + ("'$(STACKADDR)'" - "0x8000"))) <= 0) { printf("PS2Link is too big, %i (0x%x) bytes missing\n", -spare, -spare); exit -1; } else { printf("PS2Link has %i (0x%x) spare bytes\n", spare, spare) } } '
|
|
||||||
|
|
||||||
include $(PS2SDK)/Defs.make
|
|
||||||
include Rules.make
|
|
|
@ -1,45 +0,0 @@
|
||||||
|
|
||||||
# Include directories
|
|
||||||
EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I. $(EE_INCS)
|
|
||||||
|
|
||||||
# C compiler flags
|
|
||||||
EE_CFLAGS := -D_EE -O2 -G0 -Wall $(EE_CFLAGS)
|
|
||||||
|
|
||||||
# C++ compiler flags
|
|
||||||
EE_CXXFLAGS := -D_EE -O2 -G0 -Wall $(EE_CXXFLAGS)
|
|
||||||
|
|
||||||
# Linker flags
|
|
||||||
EE_LDFLAGS := -L$(PS2SDK)/ee/lib $(EE_LDFLAGS)
|
|
||||||
|
|
||||||
# Assembler flags
|
|
||||||
EE_ASFLAGS := -G0 $(EE_ASFLAGS)
|
|
||||||
|
|
||||||
# Link with following libraries. This is a special case, and instead of
|
|
||||||
# allowing the user to override the library order, we always make sure
|
|
||||||
# libkernel is the last library to be linked.
|
|
||||||
EE_LIBS += -lc -lkernel
|
|
||||||
|
|
||||||
# Externally defined variables: EE_BIN, EE_OBJS, EE_LIB
|
|
||||||
|
|
||||||
# These macros can be used to simplify certain build rules.
|
|
||||||
EE_C_COMPILE = $(EE_CC) $(EE_CFLAGS) $(EE_INCS)
|
|
||||||
EE_CXX_COMPILE = $(EE_CC) $(EE_CXXFLAGS) $(EE_INCS)
|
|
||||||
|
|
||||||
%.o : %.c
|
|
||||||
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
|
|
||||||
|
|
||||||
%.o : %.cpp
|
|
||||||
$(EE_CXX) $(EE_CXXFLAGS) $(EE_INCS) -c $< -o $@
|
|
||||||
|
|
||||||
%.o : %.S
|
|
||||||
$(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@
|
|
||||||
|
|
||||||
%.o : %.s
|
|
||||||
$(EE_AS) $(EE_ASFLAGS) $< -o $@
|
|
||||||
|
|
||||||
$(EE_BIN) : $(EE_OBJS) $(PS2SDK)/ee/startup/crt0.o
|
|
||||||
$(EE_CC) -nostartfiles -T$(PS2SDK)/ee/startup/linkfile $(EE_LDFLAGS) \
|
|
||||||
-o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(EE_OBJS) $(EE_LIBS)
|
|
||||||
|
|
||||||
$(EE_LIB) : $(EE_OBJS)
|
|
||||||
$(EE_AR) cru $(EE_LIB) $(EE_OBJS)
|
|
|
@ -1,435 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* Copyright (C) 2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdio.h"
|
|
||||||
#include <tamtypes.h>
|
|
||||||
#include <kernel.h>
|
|
||||||
#include <sifrpc.h>
|
|
||||||
#include <loadfile.h>
|
|
||||||
#include <iopcontrol.h>
|
|
||||||
#include <fileio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
#include "excepHandler.h"
|
|
||||||
|
|
||||||
#include "byteorder.h"
|
|
||||||
#include "ps2regs.h"
|
|
||||||
#include "hostlink.h"
|
|
||||||
|
|
||||||
//#define scr_printf(args...) printf(args)
|
|
||||||
//#define init_scr() do { } while(0)
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define dbgprintf(args...) printf(args)
|
|
||||||
#else
|
|
||||||
#define dbgprintf(args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HOOK_THREADS
|
|
||||||
extern void KillActiveThreads(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Prototypes
|
|
||||||
static int cmdThread(void);
|
|
||||||
static int pkoStopVU(pko_pkt_stop_vu *);
|
|
||||||
static int pkoStartVU(pko_pkt_start_vu *);
|
|
||||||
static int pkoDumpMem(pko_pkt_mem_io *);
|
|
||||||
static int pkoDumpReg(pko_pkt_dump_regs *);
|
|
||||||
void pkoReset(void);
|
|
||||||
static int pkoLoadElf(char *path);
|
|
||||||
static int pkoGSExec(pko_pkt_gsexec_req *);
|
|
||||||
static int pkoWriteMem(pko_pkt_mem_io *);
|
|
||||||
|
|
||||||
|
|
||||||
// Flags for which type of boot (oh crap, make a header file dammit)
|
|
||||||
#define B_CD 1
|
|
||||||
#define B_MC 2
|
|
||||||
#define B_HOST 3
|
|
||||||
#define B_CC 4
|
|
||||||
#define B_UNKN 5
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Globals
|
|
||||||
extern u32 _start;
|
|
||||||
extern int _gp;
|
|
||||||
extern int boot;
|
|
||||||
extern char elfName[];
|
|
||||||
|
|
||||||
int userThreadID = 0;
|
|
||||||
static int cmdThreadID = 0;
|
|
||||||
static char userThreadStack[16*1024] __attribute__((aligned(16)));
|
|
||||||
static char cmdThreadStack[16*1024] __attribute__((aligned(64)));
|
|
||||||
static char dataBuffer[16384] __attribute__((aligned(16)));
|
|
||||||
|
|
||||||
// The 'global' argv string area
|
|
||||||
static char argvStrings[PKO_MAX_PATH];
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// How about that header file again?
|
|
||||||
#define MAX_ARGS 16
|
|
||||||
#define MAX_ARGLEN 256
|
|
||||||
|
|
||||||
struct argData
|
|
||||||
{
|
|
||||||
int flag; // Contains thread id atm
|
|
||||||
int argc;
|
|
||||||
char *argv[MAX_ARGS];
|
|
||||||
} __attribute__((packed)) userArgs;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
int sifCmdSema;
|
|
||||||
int sif0HandlerId = 0;
|
|
||||||
// XXX: Hardcoded address atm.. Should be configurable!!
|
|
||||||
unsigned int *sifDmaDataPtr =(unsigned int*)(0x20100000-2048);
|
|
||||||
int excepscrdump = 1;
|
|
||||||
|
|
||||||
extern int pkoExecEE(pko_pkt_execee_req *cmd);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Create the argument struct to send to the user thread
|
|
||||||
int
|
|
||||||
makeArgs(int cmdargc, char *cmdargv, struct argData *arg_data)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int t;
|
|
||||||
int argc;
|
|
||||||
|
|
||||||
argc = 0;
|
|
||||||
|
|
||||||
if (cmdargc > MAX_ARGS)
|
|
||||||
cmdargc = MAX_ARGS;
|
|
||||||
cmdargv[PKO_MAX_PATH-1] = '\0';
|
|
||||||
|
|
||||||
memcpy(argvStrings, cmdargv, PKO_MAX_PATH);
|
|
||||||
|
|
||||||
dbgprintf("cmd->argc %d, argv[0]: %s\n", cmdargc, cmdargv);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
t = 0;
|
|
||||||
do {
|
|
||||||
arg_data->argv[i] = &argvStrings[t];
|
|
||||||
dbgprintf("arg_data[%d]=%s\n", i, arg_data->argv[i]);
|
|
||||||
dbgprintf("argvStrings[%d]=%s\n", t, &argvStrings[t]);
|
|
||||||
t += strlen(&argvStrings[t]);
|
|
||||||
t++;
|
|
||||||
i++;
|
|
||||||
} while ((i < cmdargc) && (t < PKO_MAX_PATH));
|
|
||||||
|
|
||||||
arg_data->argc = i;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Load the actual elf, and create a thread for it
|
|
||||||
// Return the thread id
|
|
||||||
static int
|
|
||||||
pkoLoadElf(char *path)
|
|
||||||
{
|
|
||||||
ee_thread_t th_attr;
|
|
||||||
t_ExecData elfdata;
|
|
||||||
int ret;
|
|
||||||
int pid;
|
|
||||||
|
|
||||||
ret = SifLoadElf(path, &elfdata);
|
|
||||||
|
|
||||||
FlushCache(0);
|
|
||||||
FlushCache(2);
|
|
||||||
|
|
||||||
dbgprintf("EE: LoadElf returned %d\n", ret);
|
|
||||||
|
|
||||||
dbgprintf("EE: Creating user thread (ent: %x, gp: %x, st: %x)\n",
|
|
||||||
elfdata.epc, elfdata.gp, elfdata.sp);
|
|
||||||
|
|
||||||
if (elfdata.epc == 0) {
|
|
||||||
dbgprintf("EE: Could not load file\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
th_attr.func = (void *)elfdata.epc;
|
|
||||||
th_attr.stack = userThreadStack;
|
|
||||||
th_attr.stack_size = sizeof(userThreadStack);
|
|
||||||
th_attr.gp_reg = (void *)elfdata.gp;
|
|
||||||
th_attr.initial_priority = 64;
|
|
||||||
|
|
||||||
pid = CreateThread(&th_attr);
|
|
||||||
if (pid < 0) {
|
|
||||||
printf("EE: Create user thread failed %d\n", pid);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbgprintf("EE: Created user thread: %d\n", pid);
|
|
||||||
|
|
||||||
return pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Load and start the requested elf
|
|
||||||
extern int pkoExecEE(pko_pkt_execee_req *cmd)
|
|
||||||
{
|
|
||||||
char path[PKO_MAX_PATH];
|
|
||||||
int ret;
|
|
||||||
int pid;
|
|
||||||
|
|
||||||
if (userThreadID) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbgprintf("EE: Executing file %s...\n", cmd->argv);
|
|
||||||
memcpy(path, cmd->argv, PKO_MAX_PATH);
|
|
||||||
|
|
||||||
scr_printf("Executing file %s...\n", path);
|
|
||||||
|
|
||||||
pid = pkoLoadElf(path);
|
|
||||||
if (pid < 0) {
|
|
||||||
scr_printf("Could not execute file %s\n", path);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
FlushCache(0);
|
|
||||||
FlushCache(2);
|
|
||||||
|
|
||||||
userThreadID = pid;
|
|
||||||
|
|
||||||
makeArgs(ntohl(cmd->argc), path, &userArgs);
|
|
||||||
|
|
||||||
// Hack away..
|
|
||||||
userArgs.flag = (int)&userThreadID;
|
|
||||||
|
|
||||||
ret = StartThread(userThreadID, &userArgs);
|
|
||||||
if (ret < 0) {
|
|
||||||
printf("EE: Start user thread failed %d\n", ret);
|
|
||||||
cmdThreadID = 0;
|
|
||||||
DeleteThread(userThreadID);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// takes cmd->data and sends it to GIF via path1
|
|
||||||
static int
|
|
||||||
pkoGSExec(pko_pkt_gsexec_req *cmd) {
|
|
||||||
int fd;
|
|
||||||
int len;
|
|
||||||
fd = fioOpen(cmd->file, O_RDONLY);
|
|
||||||
if ( fd < 0 ) {
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
len = fioRead(fd, dataBuffer, 128);
|
|
||||||
fioClose(fd);
|
|
||||||
// stop/reset dma02
|
|
||||||
|
|
||||||
// dmasend via GIF channel
|
|
||||||
asm __volatile__(
|
|
||||||
"move $10, %0;"
|
|
||||||
"move $11, %1;"
|
|
||||||
"lui $8, 0x1001;"
|
|
||||||
"sw $11, -24544($8);"
|
|
||||||
"sw $10, -24560($8);"
|
|
||||||
"ori $9, $0, 0x101;"
|
|
||||||
"sw $9, -24576($8);"
|
|
||||||
:: "r" (dataBuffer), "r" ((ntohs(cmd->size))/16) );
|
|
||||||
|
|
||||||
// dmawait for GIF channel
|
|
||||||
asm __volatile__(
|
|
||||||
"lui $8, 0x1001;"
|
|
||||||
"dmawait:"
|
|
||||||
"lw $9, -24576($8);"
|
|
||||||
"nop;"
|
|
||||||
"andi $9, $9, 0x100;"
|
|
||||||
"nop;"
|
|
||||||
"bnez $9, dmawait;"
|
|
||||||
"nop;"
|
|
||||||
);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// command to dump cmd->size bytes of memory from cmd->offset
|
|
||||||
static int
|
|
||||||
pkoDumpMem(pko_pkt_mem_io *cmd) {
|
|
||||||
int fd;
|
|
||||||
int total, len;
|
|
||||||
unsigned int offset;
|
|
||||||
unsigned int size;
|
|
||||||
char path[PKO_MAX_PATH];
|
|
||||||
int ret = 0;
|
|
||||||
size = ntohl(cmd->size);
|
|
||||||
offset = ntohl(cmd->offset);
|
|
||||||
scr_printf("dump mem from 0x%x, size %d\n",
|
|
||||||
ntohl(cmd->offset), ntohl(cmd->size)
|
|
||||||
);
|
|
||||||
memcpy(path, cmd->argv, PKO_MAX_PATH);
|
|
||||||
fd = fioOpen(path, O_WRONLY|O_CREAT);
|
|
||||||
total = 0;
|
|
||||||
len = 16*1024;
|
|
||||||
if ( fd > 0 ) {
|
|
||||||
while(total < size) {
|
|
||||||
if ( size < len) {
|
|
||||||
len = size;
|
|
||||||
} else if ((size - total) < len) {
|
|
||||||
len = size - total;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(dataBuffer, (void *)offset, len);
|
|
||||||
|
|
||||||
if ((ret = fioWrite(fd, (void *)dataBuffer, len)) > 0) {
|
|
||||||
} else {
|
|
||||||
printf("EE: pkoDumpMem() fioWrite failed\n");
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
offset = offset + len;
|
|
||||||
total += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fioClose(fd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
pkoWriteMem(pko_pkt_mem_io *cmd) {
|
|
||||||
int fd, len, total;
|
|
||||||
unsigned int offset;
|
|
||||||
unsigned int size;
|
|
||||||
char path[PKO_MAX_PATH];
|
|
||||||
int ret = 0;
|
|
||||||
size = ntohl(cmd->size);
|
|
||||||
offset = ntohl(cmd->offset);
|
|
||||||
scr_printf("write mem to 0x%x, size %d\n",
|
|
||||||
ntohl(cmd->offset), ntohl(cmd->size)
|
|
||||||
);
|
|
||||||
memcpy(path, cmd->argv, PKO_MAX_PATH);
|
|
||||||
fd = fioOpen(path, O_RDONLY);
|
|
||||||
total = 0;
|
|
||||||
len = 16*1024;
|
|
||||||
if( fd > 0) {
|
|
||||||
while(total < size) {
|
|
||||||
if ( size < len) {
|
|
||||||
len = size;
|
|
||||||
} else if ((size - total) < len) {
|
|
||||||
len = size - total;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = fioRead(fd, (void *)dataBuffer, len)) > 0) {
|
|
||||||
} else {
|
|
||||||
printf("EE: pkoDumpMem() fioWrite failed\n");
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((void *)offset, dataBuffer, len);
|
|
||||||
offset = offset + len;
|
|
||||||
total += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fioClose(fd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// command to stop VU0/1 and VIF0/1
|
|
||||||
static int
|
|
||||||
pkoStopVU(pko_pkt_stop_vu *cmd) {
|
|
||||||
if ( ntohs(cmd->vpu) == 0 ) {
|
|
||||||
asm(
|
|
||||||
"ori $25, $0, 0x1;"
|
|
||||||
"ctc2 $25, $28;"
|
|
||||||
"sync.p;"
|
|
||||||
"vnop;"
|
|
||||||
);
|
|
||||||
VIF0_FBRST = 0x2;
|
|
||||||
} else if ( ntohs(cmd->vpu) == 1 ) {
|
|
||||||
asm(
|
|
||||||
"ori $25, $0, 0x100;"
|
|
||||||
"ctc2 $25, $28;"
|
|
||||||
"sync.p;"
|
|
||||||
"vnop;"
|
|
||||||
);
|
|
||||||
VIF1_FBRST = 0x2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// command to reset VU0/1 VIF0/1
|
|
||||||
static int
|
|
||||||
pkoStartVU(pko_pkt_start_vu *cmd) {
|
|
||||||
if ( ntohs(cmd->vpu) == 0 ) {
|
|
||||||
asm(
|
|
||||||
"ori $25, $0, 0x2;"
|
|
||||||
"ctc2 $25, $28;"
|
|
||||||
"sync.p;"
|
|
||||||
"vnop;"
|
|
||||||
);
|
|
||||||
VIF0_FBRST = 0x8;
|
|
||||||
} else if ( ntohs(cmd->vpu) == 1 ) {
|
|
||||||
asm(
|
|
||||||
"ori $25, $0, 0x200;"
|
|
||||||
"ctc2 $25, $28;"
|
|
||||||
"sync.p;"
|
|
||||||
"vnop;"
|
|
||||||
);
|
|
||||||
VIF1_FBRST = 0x8;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
|
||||||
pkoReset(void)
|
|
||||||
{
|
|
||||||
char *argv[1];
|
|
||||||
// Check if user thread is running, if so kill it
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
#if HOOK_THREADS
|
|
||||||
KillActiveThreads();
|
|
||||||
#else
|
|
||||||
if (userThreadID) {
|
|
||||||
TerminateThread(userThreadID);
|
|
||||||
DeleteThread(userThreadID);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
userThreadID = 0;
|
|
||||||
|
|
||||||
RemoveDmacHandler(5, sif0HandlerId);
|
|
||||||
sif0HandlerId = 0;
|
|
||||||
|
|
||||||
SifInitRpc(0);
|
|
||||||
//cdvdInit(CDVD_INIT_NOWAIT);
|
|
||||||
//cdvdInit(CDVD_EXIT);
|
|
||||||
SifIopReset(NULL, 0);
|
|
||||||
SifExitRpc();
|
|
||||||
while(SifIopSync());
|
|
||||||
#if 1
|
|
||||||
SifInitRpc(0);
|
|
||||||
//cdvdExit();
|
|
||||||
SifExitRpc();
|
|
||||||
#endif
|
|
||||||
FlushCache(0);
|
|
||||||
|
|
||||||
#ifdef USE_CACHED_CFG
|
|
||||||
argv[0] = elfName;
|
|
||||||
SifLoadFileExit();
|
|
||||||
ExecPS2(&_start, 0, 1, argv);
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((boot == B_MC) || (boot == B_HOST) || (boot == B_UNKN) || (boot == B_CC)) {
|
|
||||||
argv[0] = elfName;
|
|
||||||
SifLoadFileExit();
|
|
||||||
ExecPS2(&_start, 0, 1, argv);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LoadExecPS2(elfName, 0, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,113 +0,0 @@
|
||||||
.set noat
|
|
||||||
.set noreorder
|
|
||||||
|
|
||||||
.global _start
|
|
||||||
.global _exit
|
|
||||||
|
|
||||||
.text
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
_start:
|
|
||||||
lui $2,%hi(_args_ptr)
|
|
||||||
addiu $2,$2, %lo(_args_ptr)
|
|
||||||
sw $4,($2)
|
|
||||||
# Clear bss
|
|
||||||
zerobss:
|
|
||||||
lui $2,%hi(_fbss)
|
|
||||||
lui $3,%hi(_end)
|
|
||||||
addiu $2,$2,%lo(_fbss)
|
|
||||||
addiu $3,$3,%lo(_end)
|
|
||||||
loop:
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
sq $0,($2)
|
|
||||||
sltu $1,$2,$3
|
|
||||||
bne $1,$0,loop
|
|
||||||
addiu $2,$2,16
|
|
||||||
# Thread
|
|
||||||
lui $4,%hi(_gp)
|
|
||||||
lui $5,%hi(_stack)
|
|
||||||
lui $6,%hi(_stack_size)
|
|
||||||
lui $7,%hi(_args)
|
|
||||||
lui $8,%hi(_exit)
|
|
||||||
addiu $4,$4,%lo(_gp)
|
|
||||||
addiu $5,$5,%lo(_stack)
|
|
||||||
addiu $6,$6,%lo(_stack_size)
|
|
||||||
addiu $7,$7,%lo(_args)
|
|
||||||
addiu $8,$8,%lo(_exit)
|
|
||||||
move $28,$4
|
|
||||||
addiu $3,$0,60
|
|
||||||
syscall
|
|
||||||
move $29, $2
|
|
||||||
|
|
||||||
# Heap
|
|
||||||
addiu $3,$0,61
|
|
||||||
lui $4,%hi(_end)
|
|
||||||
addiu $4,$4,%lo(_end)
|
|
||||||
lui $5,%hi(_heap_size)
|
|
||||||
addiu $5,$5,%lo(_heap_size)
|
|
||||||
syscall
|
|
||||||
nop
|
|
||||||
|
|
||||||
# Cache
|
|
||||||
li $3, 100
|
|
||||||
move $4,$0
|
|
||||||
syscall
|
|
||||||
nop
|
|
||||||
|
|
||||||
# Jump main
|
|
||||||
ei
|
|
||||||
|
|
||||||
# Check if we got args from system
|
|
||||||
lui $2, %hi(_args)
|
|
||||||
addiu $2, %lo(_args)
|
|
||||||
lw $3, 0($2)
|
|
||||||
bnez $3, _gotArgv # Started w (Load)ExecPS2
|
|
||||||
nop
|
|
||||||
|
|
||||||
# Check args via $a0
|
|
||||||
lui $2,%hi(_args_ptr)
|
|
||||||
addiu $2,$2,%lo(_args_ptr)
|
|
||||||
lw $3,0($2)
|
|
||||||
|
|
||||||
beqzl $3, _goMain
|
|
||||||
addu $4, $0, $0
|
|
||||||
|
|
||||||
addiu $2, $3, 4
|
|
||||||
b _gotArgv
|
|
||||||
nop
|
|
||||||
|
|
||||||
_gotArgv:
|
|
||||||
lw $4, ($2)
|
|
||||||
addiu $5, $2, 4
|
|
||||||
_goMain:
|
|
||||||
jal main
|
|
||||||
nop
|
|
||||||
|
|
||||||
# Check if we got our args in $a0 again
|
|
||||||
la $4, _args_ptr
|
|
||||||
lw $5, 0($4)
|
|
||||||
beqz $5, _exit
|
|
||||||
nop
|
|
||||||
_root:
|
|
||||||
lw $6, 0($5)
|
|
||||||
sw $0, 0($6)
|
|
||||||
# Call ExitDeleteThread()
|
|
||||||
addiu $3, $0, 36
|
|
||||||
syscall
|
|
||||||
nop
|
|
||||||
_exit:
|
|
||||||
# Exit
|
|
||||||
# Should call Exit(retval) if not called by pukklink
|
|
||||||
addiu $3,$0,35
|
|
||||||
syscall
|
|
||||||
move $4, $2
|
|
||||||
nop
|
|
||||||
|
|
||||||
.bss
|
|
||||||
.align 6
|
|
||||||
_args: .space 256+16*4+4
|
|
||||||
|
|
||||||
.data
|
|
||||||
_args_ptr:
|
|
||||||
.space 4
|
|
|
@ -1,170 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* Copyright (C) 2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdio.h"
|
|
||||||
#include <tamtypes.h>
|
|
||||||
#include <kernel.h>
|
|
||||||
#include "excepHandler.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
extern int _gp;
|
|
||||||
int userThreadID;
|
|
||||||
int excepscrdump;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
unsigned int uint128 __attribute__(( mode(TI) ));
|
|
||||||
unsigned long uint64[2];
|
|
||||||
} eeReg __attribute((packed));
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Prototypes
|
|
||||||
void pkoDebug(int cause, int badvaddr, int status, int epc, eeReg *regs);
|
|
||||||
|
|
||||||
extern void pkoExceptionHandler(void);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static const unsigned char regName[32][5] =
|
|
||||||
{
|
|
||||||
"zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
|
||||||
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
|
||||||
"t8", "t9", "s0", "s1", "s2", "s3", "s4", "s5",
|
|
||||||
"s6", "s7", "k0", "k1", "gp", "sp", "fp", "ra"
|
|
||||||
};
|
|
||||||
|
|
||||||
static char codeTxt[14][24] =
|
|
||||||
{
|
|
||||||
"Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store",
|
|
||||||
"Address load/inst fetch", "Address store", "Bus error (instr)",
|
|
||||||
"Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction",
|
|
||||||
"Coprocessor unusable", "Arithmetic overflow", "Trap"
|
|
||||||
};
|
|
||||||
|
|
||||||
char _exceptionStack[8*1024] __attribute__((aligned(16)));
|
|
||||||
eeReg _savedRegs[32+4] __attribute__((aligned(16)));
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// The 'ee exception handler', only dumps registers to console or screen atm
|
|
||||||
void
|
|
||||||
pkoDebug(int cause, int badvaddr, int status, int epc, eeReg *regs)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int code;
|
|
||||||
// extern void printf(char *, ...);
|
|
||||||
static void (* excpPrintf)(const char *, ...);
|
|
||||||
|
|
||||||
FlushCache(0);
|
|
||||||
FlushCache(2);
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (userThreadID) {
|
|
||||||
TerminateThread(userThreadID);
|
|
||||||
DeleteThread(userThreadID);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
code = cause & 0x7c;
|
|
||||||
|
|
||||||
if (excepscrdump)
|
|
||||||
{
|
|
||||||
init_scr();
|
|
||||||
excpPrintf = scr_printf;
|
|
||||||
}
|
|
||||||
else excpPrintf = (void*)printf;
|
|
||||||
|
|
||||||
excpPrintf("\n\n EE Exception handler: %s exception\n\n",
|
|
||||||
codeTxt[code>>2]);
|
|
||||||
|
|
||||||
excpPrintf(" Cause %08X BadVAddr %08X Status %08X EPC %08X\n\n",
|
|
||||||
cause, badvaddr, status, epc);
|
|
||||||
|
|
||||||
for(i = 0; i < 32/2; i++) {
|
|
||||||
excpPrintf("%4s: %016lX%016lX %4s: %016lX%016lX\n",
|
|
||||||
regName[i], regs[i].uint64[1], regs[i].uint64[0],
|
|
||||||
regName[i+16], regs[i+16].uint64[1], regs[i+16].uint64[0]);
|
|
||||||
}
|
|
||||||
excpPrintf("\n");
|
|
||||||
SleepThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// The 'iop exception handler', only dumps registers to console or screen atm
|
|
||||||
|
|
||||||
void iopException(int cause, int badvaddr, int status, int epc, u32 *regs, int repc, char* name)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int code;
|
|
||||||
// extern void printf(char *, ...);
|
|
||||||
static void (* excpPrintf)(const char *, ...);
|
|
||||||
|
|
||||||
FlushCache(0);
|
|
||||||
FlushCache(2);
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (userThreadID) {
|
|
||||||
TerminateThread(userThreadID);
|
|
||||||
DeleteThread(userThreadID);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
code = cause & 0x7c;
|
|
||||||
|
|
||||||
if(excepscrdump)
|
|
||||||
{
|
|
||||||
init_scr();
|
|
||||||
excpPrintf = scr_printf;
|
|
||||||
}
|
|
||||||
else excpPrintf = (void*)printf;
|
|
||||||
|
|
||||||
excpPrintf("\n\n IOP Exception handler: %s exception\n\n",
|
|
||||||
codeTxt[code>>2]);
|
|
||||||
|
|
||||||
excpPrintf(" Module Name \"%s\" Relative EPC %08X\n\n",
|
|
||||||
name, repc);
|
|
||||||
|
|
||||||
|
|
||||||
excpPrintf(" Cause %08X BadVAddr %08X Status %08X EPC %08X\n\n",
|
|
||||||
cause, badvaddr, status, epc);
|
|
||||||
|
|
||||||
for(i = 0; i < 32/4; i++)
|
|
||||||
{
|
|
||||||
excpPrintf(" %4s: %08X %4s: %08X %4s: %08X %4s: %08X\n",
|
|
||||||
regName[i], regs[i], regName[i+8], regs[i+8],
|
|
||||||
regName[i+16], regs[i+16], regName[i+24], regs[i+24]);
|
|
||||||
}
|
|
||||||
|
|
||||||
excpPrintf("\n");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SleepThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Installs ee exception handlers for the 'usual' exceptions and iop
|
|
||||||
// exception callback
|
|
||||||
void
|
|
||||||
installExceptionHandlers(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// Skip exception #8 (syscall) & 9 (breakpoint)
|
|
||||||
for (i = 1; i < 4; i++) {
|
|
||||||
SetVTLBRefillHandler(i, pkoExceptionHandler);
|
|
||||||
}
|
|
||||||
for (i = 4; i < 8; i++) {
|
|
||||||
SetVCommonHandler(i, pkoExceptionHandler);
|
|
||||||
}
|
|
||||||
for (i = 10; i < 14; i++) {
|
|
||||||
SetVCommonHandler(i, pkoExceptionHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _EXCEPTION_H_
|
|
||||||
#define _EXCEPTION_H_
|
|
||||||
|
|
||||||
void installExceptionHandlers(void);
|
|
||||||
void iopException(int cause, int badvaddr, int status, int epc, u32 *regs, int repc, char* name);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,225 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# ASM exception handlers
|
|
||||||
|
|
||||||
#include "r5900_regs.h"
|
|
||||||
|
|
||||||
.set noat
|
|
||||||
.set noreorder
|
|
||||||
|
|
||||||
|
|
||||||
.text
|
|
||||||
.p2align 4
|
|
||||||
|
|
||||||
.global _savedRegs
|
|
||||||
|
|
||||||
.global pkoStepBP
|
|
||||||
.ent pkoStepBP
|
|
||||||
pkoStepBP:
|
|
||||||
# Should check for cause in cop0 Cause reg
|
|
||||||
# If Bp, increase EPC (DO NOT PUT 'break' in a branch delay slot!!!)
|
|
||||||
mfc0 k0, EPC # cop0 EPC
|
|
||||||
addiu k0, k0, 4 # Step over breakpoint
|
|
||||||
mtc0 k0, EPC
|
|
||||||
sync.p
|
|
||||||
eret
|
|
||||||
.end pkoStepBP
|
|
||||||
|
|
||||||
|
|
||||||
# Save all user regs
|
|
||||||
# Save HI/LO, SR, BadVAddr, Cause, EPC, ErrorEPC,
|
|
||||||
# ShiftAmount, cop0: $24, $25
|
|
||||||
# Save float regs??
|
|
||||||
# Set EPC to debugger
|
|
||||||
# Set stack to 'exception stack'
|
|
||||||
# eret
|
|
||||||
.global pkoExceptionHandler
|
|
||||||
.ent pkoExceptionHandler
|
|
||||||
pkoExceptionHandler:
|
|
||||||
la k0, _savedRegs
|
|
||||||
sq $0, 0x00(k0)
|
|
||||||
sq at, 0x10(k0)
|
|
||||||
sq v0, 0x20(k0)
|
|
||||||
sq v1, 0x30(k0)
|
|
||||||
sq a0, 0x40(k0)
|
|
||||||
sq a1, 0x50(k0)
|
|
||||||
sq a2, 0x60(k0)
|
|
||||||
sq a3, 0x70(k0)
|
|
||||||
sq t0, 0x80(k0)
|
|
||||||
sq t1, 0x90(k0)
|
|
||||||
sq t2, 0xa0(k0)
|
|
||||||
sq t3, 0xb0(k0)
|
|
||||||
sq t4, 0xc0(k0)
|
|
||||||
sq t5, 0xd0(k0)
|
|
||||||
sq t6, 0xe0(k0)
|
|
||||||
sq t7, 0xf0(k0)
|
|
||||||
sq t8, 0x100(k0)
|
|
||||||
sq t9, 0x110(k0)
|
|
||||||
sq s0, 0x120(k0)
|
|
||||||
sq s1, 0x130(k0)
|
|
||||||
sq s2, 0x140(k0)
|
|
||||||
sq s3, 0x150(k0)
|
|
||||||
sq s4, 0x160(k0)
|
|
||||||
sq s5, 0x170(k0)
|
|
||||||
sq s6, 0x180(k0)
|
|
||||||
sq s7, 0x190(k0)
|
|
||||||
# sq k0, 0x1a0(k0) # $k0
|
|
||||||
sq zero, 0x1a0(k0) # zero instead
|
|
||||||
sq k1, 0x1b0(k0) # $k1
|
|
||||||
sq gp, 0x1c0(k0)
|
|
||||||
sq sp, 0x1d0(k0) # sp
|
|
||||||
sq fp, 0x1e0(k0)
|
|
||||||
sq ra, 0x1f0(k0) # $ra
|
|
||||||
|
|
||||||
pmfhi t0 # HI
|
|
||||||
pmflo t1 # LO
|
|
||||||
sq t0, 0x200(k0)
|
|
||||||
sq t1, 0x210(k0)
|
|
||||||
|
|
||||||
mfc0 t0, BadVAddr # Cop0 state regs
|
|
||||||
mfc0 t1, Status
|
|
||||||
sw t0, 0x220(k0)
|
|
||||||
sw t1, 0x224(k0)
|
|
||||||
|
|
||||||
mfc0 t0, Cause
|
|
||||||
mfc0 t1, EPC
|
|
||||||
sw t0, 0x228(k0)
|
|
||||||
sw t1, 0x22c(k0)
|
|
||||||
|
|
||||||
# Kernel saves these two also..
|
|
||||||
mfc0 t0, DEPC
|
|
||||||
mfc0 t1, PerfCnt
|
|
||||||
sw t0, 0x230(k0)
|
|
||||||
sw t1, 0x234(k0)
|
|
||||||
|
|
||||||
mfsa t0
|
|
||||||
sw t0, 0x238(k0)
|
|
||||||
|
|
||||||
# Use our own stack..
|
|
||||||
la sp, _exceptionStack+0x2000-16
|
|
||||||
la gp, _gp # Use exception handlers _gp
|
|
||||||
|
|
||||||
# Return from exception and start 'debugger'
|
|
||||||
mfc0 a0, Cause # arg0
|
|
||||||
mfc0 a1, BadVAddr
|
|
||||||
mfc0 a2, Status
|
|
||||||
mfc0 a3, EPC
|
|
||||||
addu t0, zero, k0 # arg4 = registers
|
|
||||||
move t1, sp
|
|
||||||
la k0, pkoDebug
|
|
||||||
mtc0 k0, EPC # eret return address
|
|
||||||
sync.p
|
|
||||||
mfc0 k0, Status # check this out..
|
|
||||||
li v0, 0xfffffffe
|
|
||||||
and k0, v0
|
|
||||||
mtc0 k0, Status
|
|
||||||
sync.p
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
eret
|
|
||||||
nop
|
|
||||||
.end pkoExceptionHandler
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Put EE in kernel mode
|
|
||||||
# Restore all user regs etc
|
|
||||||
# Restore PC? & Stack ptr
|
|
||||||
# Restore interrupt sources
|
|
||||||
# Jump to EPC
|
|
||||||
.ent pkoReturnFromDebug
|
|
||||||
.global pkoReturnFromDebug
|
|
||||||
pkoReturnFromDebug:
|
|
||||||
|
|
||||||
lui t1, 0x1
|
|
||||||
_disable:
|
|
||||||
di
|
|
||||||
sync
|
|
||||||
mfc0 t0, Status
|
|
||||||
and t0, t1
|
|
||||||
beqz t0, _disable
|
|
||||||
nop
|
|
||||||
|
|
||||||
la k0, _savedRegs
|
|
||||||
|
|
||||||
lq t0, 0x200(k0)
|
|
||||||
lq t1, 0x210(k0)
|
|
||||||
pmthi t0 # HI
|
|
||||||
pmtlo t1 # LO
|
|
||||||
|
|
||||||
lw t0, 0x220(k0)
|
|
||||||
lw t1, 0x224(k0)
|
|
||||||
mtc0 t0, BadVAddr
|
|
||||||
mtc0 t1, Status
|
|
||||||
|
|
||||||
lw t0, 0x228(k0)
|
|
||||||
lw t1, 0x22c(k0)
|
|
||||||
mtc0 t0, Cause
|
|
||||||
mtc0 t1, EPC
|
|
||||||
|
|
||||||
# Kernel saves these two also..
|
|
||||||
lw t0, 0x230(k0)
|
|
||||||
lw t1, 0x234(k0)
|
|
||||||
mtc0 t0, DEPC
|
|
||||||
mtc0 t1, PerfCnt
|
|
||||||
|
|
||||||
# Shift Amount reg
|
|
||||||
lw t0, 0x238(k0)
|
|
||||||
mtsa t0
|
|
||||||
|
|
||||||
|
|
||||||
# ori t2, 0xff
|
|
||||||
# sw t2, 0(k1)
|
|
||||||
|
|
||||||
# lq $0, 0x00(k0)
|
|
||||||
lq $1, 0x10(k0)
|
|
||||||
lq $2, 0x20(k0)
|
|
||||||
lq $3, 0x30(k0)
|
|
||||||
lq $4, 0x40(k0)
|
|
||||||
lq $5, 0x50(k0)
|
|
||||||
lq $6, 0x60(k0)
|
|
||||||
lq $7, 0x70(k0)
|
|
||||||
lq $8, 0x80(k0)
|
|
||||||
lq $9, 0x90(k0)
|
|
||||||
lq $10, 0xa0(k0)
|
|
||||||
lq $11, 0xb0(k0)
|
|
||||||
lq $12, 0xc0(k0)
|
|
||||||
lq $13, 0xd0(k0)
|
|
||||||
lq $14, 0xe0(k0)
|
|
||||||
lq $15, 0xf0(k0)
|
|
||||||
lq $16, 0x100(k0)
|
|
||||||
lq $17, 0x110(k0)
|
|
||||||
lq $18, 0x120(k0)
|
|
||||||
lq $19, 0x130(k0)
|
|
||||||
lq $10, 0x140(k0)
|
|
||||||
lq $21, 0x150(k0)
|
|
||||||
lq $22, 0x160(k0)
|
|
||||||
lq $23, 0x170(k0)
|
|
||||||
lq $24, 0x180(k0)
|
|
||||||
lq $25, 0x190(k0)
|
|
||||||
# lq $26, 0x1a0(k0) # $k0
|
|
||||||
lq $27, 0x1b0(k0) # $k1
|
|
||||||
lq $28, 0x1c0(k0)
|
|
||||||
lq $29, 0x1d0(k0) # $sp
|
|
||||||
lq $30, 0x1e0(k0)
|
|
||||||
# lq $31, 0x1f0(k0) # $ra
|
|
||||||
|
|
||||||
lw ra, 0x22c(k0)
|
|
||||||
# Guess one should have some check here, and only advance PC if
|
|
||||||
# we are going to step over a Breakpoint or something
|
|
||||||
# (i.e. do stuff depending on Cause)
|
|
||||||
addiu ra, 4
|
|
||||||
sync.p
|
|
||||||
ei
|
|
||||||
sync.p
|
|
||||||
|
|
||||||
jr ra
|
|
||||||
nop
|
|
||||||
.end pkoReturnFromDebug
|
|
|
@ -1,53 +0,0 @@
|
||||||
_heap_size = 1*1024;
|
|
||||||
_stack_size = 0x2000;
|
|
||||||
|
|
||||||
ENTRY(_start);
|
|
||||||
SECTIONS {
|
|
||||||
|
|
||||||
.text 0xc0000 : {
|
|
||||||
*(.text)
|
|
||||||
*(.rodata)
|
|
||||||
}
|
|
||||||
.reginfo ALIGN(128) : {
|
|
||||||
*(.reginfo)
|
|
||||||
}
|
|
||||||
.data ALIGN(128) : {
|
|
||||||
*(.data)
|
|
||||||
}
|
|
||||||
.rdata ALIGN(128) : {
|
|
||||||
*(.rdata)
|
|
||||||
}
|
|
||||||
_gp = ALIGN(128) + 0x7ff0;
|
|
||||||
.lit4 ALIGN(128) : {
|
|
||||||
*(.lit4)
|
|
||||||
}
|
|
||||||
.lit8 ALIGN(128) : {
|
|
||||||
*(.lit8)
|
|
||||||
}
|
|
||||||
.sdata ALIGN(128) : {
|
|
||||||
*(.sdata)
|
|
||||||
}
|
|
||||||
|
|
||||||
.sbss ALIGN(128) (NOLOAD) : { /* uninitialized data */
|
|
||||||
_fbss = . ;
|
|
||||||
*(.scommon)
|
|
||||||
*(.sbss)
|
|
||||||
}
|
|
||||||
.bss ALIGN(128) (NOLOAD) : { /* uninitialized data */
|
|
||||||
*(.bss)
|
|
||||||
}
|
|
||||||
.COMMON ALIGN(128) (NOLOAD) : { /* uninitialized data */
|
|
||||||
*(COMMON)
|
|
||||||
}
|
|
||||||
_end_bss = .;
|
|
||||||
_end = . ;
|
|
||||||
PROVIDE (end = .);
|
|
||||||
__lc_bh = . ;
|
|
||||||
. += _heap_size ;
|
|
||||||
__lc_eh = .;
|
|
||||||
.stack ALIGN(128) (NOLOAD) : { /* stack space */
|
|
||||||
_stack = .;
|
|
||||||
. += _stack_size;
|
|
||||||
_stack_end = .;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,838 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* Copyright (C) 2003,2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <tamtypes.h>
|
|
||||||
#include <kernel.h>
|
|
||||||
#include <sifrpc.h>
|
|
||||||
#include <iopheap.h>
|
|
||||||
#include <loadfile.h>
|
|
||||||
#include <iopcontrol.h>
|
|
||||||
#include <fileio.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "debug.h"
|
|
||||||
#include "hostlink.h"
|
|
||||||
#include "excepHandler.h"
|
|
||||||
#include "stdio.h"
|
|
||||||
|
|
||||||
#include <sbv_patches.h>
|
|
||||||
|
|
||||||
#define WELCOME_STRING "Welcome to pcsx2hostfs v1.52\n"
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define dbgprintf(args...) printf(args)
|
|
||||||
#define dbgscr_printf(args...) scr_printf(args)
|
|
||||||
#else
|
|
||||||
#define dbgprintf(args...) do { } while(0)
|
|
||||||
#define dbgscr_printf(args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define BGCOLOR ((volatile unsigned long*)0x120000e0)
|
|
||||||
//#define GS_SET_BGCOLOR(R,G,B) *BGCOLOR = ((u64)(R)<< 0) | ((u64)(G)<< 8) | ((u64)(B)<< 16)
|
|
||||||
|
|
||||||
#define IRX_BUFFER_BASE 0x1F80000
|
|
||||||
int irx_buffer_addr = 0;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Globals
|
|
||||||
extern int userThreadID;
|
|
||||||
|
|
||||||
// Argv name+path & just path
|
|
||||||
char elfName[256] __attribute__((aligned(16)));
|
|
||||||
char elfPath[256];
|
|
||||||
|
|
||||||
#ifndef BUILTIN_IRXS
|
|
||||||
char ioptrap_path[PKO_MAX_PATH];
|
|
||||||
char pcsx2hostfs_path[PKO_MAX_PATH];
|
|
||||||
|
|
||||||
void *ioptrap_mod = NULL, *pcsx2hostfs_mod = NULL;
|
|
||||||
int ioptrap_size = 0, pcsx2hostfs_size = 0;
|
|
||||||
#else
|
|
||||||
extern unsigned char _binary_ioptrap_irx_start[], _binary_pcsx2hostfs_irx_start[];
|
|
||||||
extern unsigned char _binary_ioptrap_irx_end[], _binary_pcsx2hostfs_irx_end[];
|
|
||||||
static unsigned int _binary_ioptrap_irx_size, _binary_pcsx2hostfs_irx_size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *imgcmd = "rom0:UDNL rom0:EELOADCNF";
|
|
||||||
|
|
||||||
// Flags for which type of boot
|
|
||||||
#define B_CD 1
|
|
||||||
#define B_MC 2
|
|
||||||
#define B_HOST 3
|
|
||||||
#define B_CC 4
|
|
||||||
#define B_UNKN 5
|
|
||||||
int boot;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Prototypes
|
|
||||||
static void loadModules(void);
|
|
||||||
static void pkoLoadModule(char *path, int argc, char *argv);
|
|
||||||
static void getIpConfig(void);
|
|
||||||
|
|
||||||
extern int pkoExecEE(pko_pkt_execee_req *cmd);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
#define IPCONF_MAX_LEN 1024
|
|
||||||
|
|
||||||
char if_conf[IPCONF_MAX_LEN] = "";
|
|
||||||
char fExtraConfig[256];
|
|
||||||
int load_extra_conf = 0;
|
|
||||||
int if_conf_len = 0;
|
|
||||||
|
|
||||||
char ip[16] __attribute__((aligned(16))) = "192.168.0.10";
|
|
||||||
char netmask[16] __attribute__((aligned(16))) = "255.255.255.0";
|
|
||||||
char gw[16] __attribute__((aligned(16))) = "192.168.0.1";
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Parse network configuration from IPCONFIG.DAT
|
|
||||||
// Note: parsing really should be made more robust...
|
|
||||||
|
|
||||||
static int getBufferValue(char* result, char* buffer, u32 buffer_size, char* field)
|
|
||||||
{
|
|
||||||
u32 len = strlen(field);
|
|
||||||
u32 i = 0;
|
|
||||||
s32 j = 0;
|
|
||||||
char* start = 0;
|
|
||||||
char* end = 0;
|
|
||||||
|
|
||||||
while(strncmp(&buffer[i], field, len) != 0)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if(i == buffer_size) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for # comment
|
|
||||||
j = i;
|
|
||||||
|
|
||||||
while((j > 0) && (buffer[j] != '\n') && (buffer[j] !='\r'))
|
|
||||||
{
|
|
||||||
j--;
|
|
||||||
|
|
||||||
if(buffer[j] == '#')
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
while(buffer[i] != '=')
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if(i == buffer_size) return -3;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
|
|
||||||
while(buffer[i] == ' ')
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if(i == buffer_size) return -4;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if((buffer[i] != '\r') && (buffer[i] != '\n') && (buffer[i] != ';'))
|
|
||||||
{
|
|
||||||
start = &buffer[i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(buffer[i] != ';')
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
if(i == buffer_size) return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
end = &buffer[i];
|
|
||||||
|
|
||||||
len = end - start;
|
|
||||||
|
|
||||||
if(len > 256) return -6;
|
|
||||||
|
|
||||||
strncpy(result, start, len);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
getIpConfig(void)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
int i;
|
|
||||||
int t;
|
|
||||||
int len;
|
|
||||||
char c;
|
|
||||||
char buf[IPCONF_MAX_LEN+256];
|
|
||||||
static char path[256];
|
|
||||||
|
|
||||||
if (boot == B_CD) {
|
|
||||||
sprintf(path, "%s%s;1", elfPath, "IPCONFIG.DAT");
|
|
||||||
}
|
|
||||||
else if (boot == B_CC) {
|
|
||||||
strcpy(path, "mc0:/BOOT/IPCONFIG.DAT");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sprintf(path, "%s%s", elfPath, "IPCONFIG.DAT");
|
|
||||||
}
|
|
||||||
fd = fioOpen(path, O_RDONLY);
|
|
||||||
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
scr_printf("Could not find IPCONFIG.DAT, using defaults\n"
|
|
||||||
"Net config: %s %s %s\n", ip, netmask, gw);
|
|
||||||
// Set defaults
|
|
||||||
memset(if_conf, 0x00, IPCONF_MAX_LEN);
|
|
||||||
i = 0;
|
|
||||||
strncpy(&if_conf[i], ip, 15);
|
|
||||||
i += strlen(ip) + 1;
|
|
||||||
|
|
||||||
strncpy(&if_conf[i], netmask, 15);
|
|
||||||
i += strlen(netmask) + 1;
|
|
||||||
|
|
||||||
strncpy(&if_conf[i], gw, 15);
|
|
||||||
i += strlen(gw) + 1;
|
|
||||||
|
|
||||||
if_conf_len = i;
|
|
||||||
dbgscr_printf("conf len %d\n", if_conf_len);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(if_conf, 0x00, IPCONF_MAX_LEN);
|
|
||||||
memset(buf, 0x00, IPCONF_MAX_LEN+256);
|
|
||||||
|
|
||||||
len = fioRead(fd, buf, IPCONF_MAX_LEN + 256 - 1); // Let the last byte be '\0'
|
|
||||||
fioClose(fd);
|
|
||||||
|
|
||||||
if (len < 0) {
|
|
||||||
dbgprintf("Error reading ipconfig.dat\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbgscr_printf("ipconfig: Read %d bytes\n", len);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
// Clear out spaces (and potential ending CR/LF)
|
|
||||||
while ((c = buf[i]) != '\0') {
|
|
||||||
if ((c == ' ') || (c == '\r') || (c == '\n'))
|
|
||||||
buf[i] = '\0';
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
scr_printf("Net config: ");
|
|
||||||
for (t = 0, i = 0; t < 3; t++) {
|
|
||||||
strncpy(&if_conf[i], &buf[i], 15);
|
|
||||||
scr_printf("%s ", &if_conf[i]);
|
|
||||||
i += strlen(&if_conf[i]) + 1;
|
|
||||||
}
|
|
||||||
scr_printf("\n");
|
|
||||||
// get extra config filename
|
|
||||||
|
|
||||||
#ifndef USE_CACHED_CFG
|
|
||||||
if(getBufferValue(fExtraConfig, buf, len, "EXTRACNF") == 0)
|
|
||||||
{
|
|
||||||
scr_printf("extra conf: %s\n", fExtraConfig);
|
|
||||||
|
|
||||||
load_extra_conf = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
load_extra_conf = 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
load_extra_conf = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if_conf_len = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
getExtraConfig()
|
|
||||||
{
|
|
||||||
int fd, size, ret;
|
|
||||||
char *buf, *ptr, *ptr2;
|
|
||||||
fd = fioOpen(fExtraConfig, O_RDONLY);
|
|
||||||
|
|
||||||
if ( fd < 0 )
|
|
||||||
{
|
|
||||||
scr_printf("failed to open extra conf file\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = fioLseek(fd, 0, SEEK_END);
|
|
||||||
fioLseek(fd, 0, SEEK_SET);
|
|
||||||
buf = malloc(size + 1);
|
|
||||||
ret = fioRead(fd, buf, size);
|
|
||||||
buf[size] = 0;
|
|
||||||
fioClose(fd);
|
|
||||||
ptr = buf;
|
|
||||||
ptr2 = buf;
|
|
||||||
while(ptr < buf+size) {
|
|
||||||
ptr2 = strstr(ptr, ";");
|
|
||||||
if ( ptr2 == 0 ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ptr[ptr2-ptr] = 0;
|
|
||||||
scr_printf("loading %s\n", ptr);
|
|
||||||
pkoLoadModule(ptr, 0, NULL);
|
|
||||||
ptr = ptr2+1;
|
|
||||||
}
|
|
||||||
free(buf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Wrapper to load irx module from disc/rom
|
|
||||||
static void
|
|
||||||
pkoLoadModule(char *path, int argc, char *argv)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = SifLoadModule(path, argc, argv);
|
|
||||||
if (ret < 0) {
|
|
||||||
scr_printf("Could not load module %s: %d\n", path, ret);
|
|
||||||
SleepThread();
|
|
||||||
}
|
|
||||||
dbgscr_printf("[%d] returned\n", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef BUILTIN_IRXS
|
|
||||||
/* Load a module into RAM. */
|
|
||||||
void * modbuf_load(const char *filename, int *filesize)
|
|
||||||
{
|
|
||||||
void *res = NULL;
|
|
||||||
int fd = -1, size;
|
|
||||||
|
|
||||||
if ((fd = fioOpen(filename, O_RDONLY)) < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if ((size = fioLseek(fd, 0, SEEK_END)) < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
fioLseek(fd, 0, SEEK_SET);
|
|
||||||
fioLseek(fd, 0, SEEK_SET);
|
|
||||||
|
|
||||||
res = (void *)irx_buffer_addr;
|
|
||||||
irx_buffer_addr += size + 32 - (size % 16);
|
|
||||||
dbgscr_printf(" modbuf_load : %s , %d (0x%X)\n",filename,size,(int)res);
|
|
||||||
|
|
||||||
if (fioRead(fd, res, size) != size)
|
|
||||||
res = NULL;
|
|
||||||
|
|
||||||
if (filesize)
|
|
||||||
*filesize = size;
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (fd >= 0)
|
|
||||||
fioClose(fd);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int loadHostModBuffers()
|
|
||||||
{
|
|
||||||
if (irx_buffer_addr == 0)
|
|
||||||
{
|
|
||||||
irx_buffer_addr = IRX_BUFFER_BASE;
|
|
||||||
|
|
||||||
getIpConfig();
|
|
||||||
|
|
||||||
if (!(ioptrap_mod = modbuf_load(ioptrap_path, &ioptrap_size)))
|
|
||||||
{return -1;}
|
|
||||||
|
|
||||||
if (!(pcsx2hostfs_mod = modbuf_load(pcsx2hostfs_path, &pcsx2hostfs_size)))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dbgscr_printf("Using Cached Modules\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Load all the irx modules we need, according to 'boot mode'
|
|
||||||
static void
|
|
||||||
loadModules(void)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
#ifdef USE_CACHED_CFG
|
|
||||||
int i,t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dbgscr_printf("loadModules \n");
|
|
||||||
|
|
||||||
#ifdef USE_CACHED_CFG
|
|
||||||
if(if_conf_len==0)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
if ((boot == B_MC) || (boot == B_CC))
|
|
||||||
{
|
|
||||||
pkoLoadModule("rom0:SIO2MAN", 0, NULL);
|
|
||||||
pkoLoadModule("rom0:MCMAN", 0, NULL);
|
|
||||||
pkoLoadModule("rom0:MCSERV", 0, NULL);
|
|
||||||
}
|
|
||||||
#ifdef USE_CACHED_CFG
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUILTIN_IRXS
|
|
||||||
_binary_ioptrap_irx_size = _binary_ioptrap_irx_end - _binary_ioptrap_irx_start;
|
|
||||||
_binary_pcsx2hostfs_irx_size = _binary_pcsx2hostfs_irx_end - _binary_pcsx2hostfs_irx_start;
|
|
||||||
|
|
||||||
#ifdef USE_CACHED_CFG
|
|
||||||
if(if_conf_len==0)
|
|
||||||
{
|
|
||||||
getIpConfig();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i=0;
|
|
||||||
scr_printf("Net config: ");
|
|
||||||
for (t = 0, i = 0; t < 3; t++) {
|
|
||||||
scr_printf("%s ", &if_conf[i]);
|
|
||||||
i += strlen(&if_conf[i]) + 1;
|
|
||||||
}
|
|
||||||
scr_printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
getIpConfig();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dbgscr_printf("Exec ioptrap module. (%x,%d) ", (unsigned int)_binary_ioptrap_irx_start, _binary_ioptrap_irx_size);
|
|
||||||
SifExecModuleBuffer(_binary_ioptrap_irx_start, _binary_ioptrap_irx_size, 0, NULL,&ret);
|
|
||||||
dbgscr_printf("[%d] returned\n", ret);
|
|
||||||
dbgscr_printf("Exec pcsx2hostfs module. (%x,%d) ", (unsigned int)_binary_pcsx2hostfs_irx_start, _binary_pcsx2hostfs_irx_size);
|
|
||||||
SifExecModuleBuffer(_binary_pcsx2hostfs_irx_start, _binary_pcsx2hostfs_irx_size, 0, NULL,&ret);
|
|
||||||
dbgscr_printf("[%d] returned\n", ret);
|
|
||||||
dbgscr_printf("All modules loaded on IOP.\n");
|
|
||||||
#else
|
|
||||||
if (boot == B_HOST) {
|
|
||||||
|
|
||||||
dbgscr_printf("Exec ioptrap module. (%x,%d) ", (u32)ioptrap_mod, ioptrap_size);
|
|
||||||
SifExecModuleBuffer(ioptrap_mod, ioptrap_size, 0, NULL,&ret);
|
|
||||||
dbgscr_printf("[%d] returned\n", ret);
|
|
||||||
dbgscr_printf("Exec pcsx2hostfs module. (%x,%d) ", (u32)pcsx2hostfs_mod, pcsx2hostfs_size);
|
|
||||||
SifExecModuleBuffer(pcsx2hostfs_mod, pcsx2hostfs_size, 0, NULL,&ret);
|
|
||||||
dbgscr_printf("[%d] returned\n", ret);
|
|
||||||
|
|
||||||
|
|
||||||
dbgscr_printf("All modules loaded on IOP.\n");
|
|
||||||
} else {
|
|
||||||
getIpConfig();
|
|
||||||
dbgscr_printf("Exec ioptrap module. ");
|
|
||||||
pkoLoadModule(ioptrap_path, 0, NULL);
|
|
||||||
dbgscr_printf("Exec pcsx2hostfs module. ");
|
|
||||||
pkoLoadModule(pcsx2hostfs_path, 0, NULL);
|
|
||||||
dbgscr_printf("All modules loaded on IOP. ");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// C standard strrchr func..
|
|
||||||
char *strrchr(const char *s, int i)
|
|
||||||
{
|
|
||||||
const char *last = NULL;
|
|
||||||
char c = i;
|
|
||||||
|
|
||||||
while (*s) {
|
|
||||||
if (*s == c) {
|
|
||||||
last = s;
|
|
||||||
}
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*s == c) {
|
|
||||||
last = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (char *) last;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Split path (argv[0]) at the last '/', '\' or ':' and initialise
|
|
||||||
// elfName (whole path & name to the elf, for example 'cdrom:\pukklink.elf')
|
|
||||||
// elfPath (path to where the elf was started, for example 'cdrom:\')
|
|
||||||
static void
|
|
||||||
setPathInfo(char *path)
|
|
||||||
{
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
strncpy(elfName, path, 255);
|
|
||||||
strncpy(elfPath, path, 255);
|
|
||||||
elfName[255] = '\0';
|
|
||||||
elfPath[255] = '\0';
|
|
||||||
|
|
||||||
|
|
||||||
ptr = strrchr(elfPath, '/');
|
|
||||||
if (ptr == NULL) {
|
|
||||||
ptr = strrchr(elfPath, '\\');
|
|
||||||
if (ptr == NULL) {
|
|
||||||
ptr = strrchr(elfPath, ':');
|
|
||||||
if (ptr == NULL) {
|
|
||||||
scr_printf("Did not find path (%s)!\n", path);
|
|
||||||
SleepThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr++;
|
|
||||||
*ptr = '\0';
|
|
||||||
|
|
||||||
#ifndef BUILTIN_IRXS
|
|
||||||
/* Paths to modules. */
|
|
||||||
|
|
||||||
sprintf(pcsx2hostfs_path, "%s%s", elfPath, "PS2LINK.IRX");
|
|
||||||
sprintf(ioptrap_path, "%s%s", elfPath, "IOPTRAP.IRX");
|
|
||||||
|
|
||||||
if (boot == B_CD) {
|
|
||||||
strcat(ioptrap_path, ";1");
|
|
||||||
strcat(pcsx2hostfs_path, ";1");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dbgscr_printf("path is %s\n", elfPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Clear user memory
|
|
||||||
void
|
|
||||||
wipeUserMem(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
// Whipe user mem
|
|
||||||
for (i = 0x100000; i < 0x2000000 ; i += 64) {
|
|
||||||
asm (
|
|
||||||
"\tsq $0, 0(%0) \n"
|
|
||||||
"\tsq $0, 16(%0) \n"
|
|
||||||
"\tsq $0, 32(%0) \n"
|
|
||||||
"\tsq $0, 48(%0) \n"
|
|
||||||
:: "r" (i) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Clear user memory - Load High and Host version
|
|
||||||
void
|
|
||||||
wipeUserMemLoadHigh(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
// Whipe user mem, apart from last bit
|
|
||||||
for (i = 0x100000; i < 0x1F00000 ; i += 64) {
|
|
||||||
asm (
|
|
||||||
"\tsq $0, 0(%0) \n"
|
|
||||||
"\tsq $0, 16(%0) \n"
|
|
||||||
"\tsq $0, 32(%0) \n"
|
|
||||||
"\tsq $0, 48(%0) \n"
|
|
||||||
:: "r" (i) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
restartIOP()
|
|
||||||
{
|
|
||||||
fioExit();
|
|
||||||
SifExitIopHeap();
|
|
||||||
SifLoadFileExit();
|
|
||||||
SifExitRpc();
|
|
||||||
|
|
||||||
dbgscr_printf("reset iop\n");
|
|
||||||
SifIopReset(imgcmd, 0);
|
|
||||||
while (SifIopSync()) ;
|
|
||||||
|
|
||||||
dbgscr_printf("rpc init\n");
|
|
||||||
SifInitRpc(0);
|
|
||||||
|
|
||||||
scr_printf("Initializing...\n");
|
|
||||||
sio_printf("Initializing...\n");
|
|
||||||
sbv_patch_enable_lmb();
|
|
||||||
sbv_patch_disable_prefix_check();
|
|
||||||
|
|
||||||
// SifLoadFileReset();
|
|
||||||
dbgscr_printf("loading modules\n");
|
|
||||||
loadModules();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if HOOK_THREADS
|
|
||||||
|
|
||||||
// we can spare 1k to allow a generous number of threads..
|
|
||||||
#define MAX_MONITORED_THREADS 256
|
|
||||||
|
|
||||||
int _first_load = 1;
|
|
||||||
|
|
||||||
int th_count;
|
|
||||||
int active_threads[MAX_MONITORED_THREADS];
|
|
||||||
|
|
||||||
void *addr_LoadExecPS2;
|
|
||||||
void *addr_CreateThread;
|
|
||||||
void *addr_DeleteThread;
|
|
||||||
|
|
||||||
void InstallKernelHooks(void)
|
|
||||||
{
|
|
||||||
// get the current address of each syscall we want to hook then replace the entry
|
|
||||||
// in the syscall table with that of our hook function.
|
|
||||||
|
|
||||||
addr_LoadExecPS2 = GetSyscall(6);
|
|
||||||
SetSyscall(6, &Hook_LoadExecPS2);
|
|
||||||
|
|
||||||
addr_CreateThread = GetSyscall(32);
|
|
||||||
SetSyscall(32, &Hook_CreateThread);
|
|
||||||
|
|
||||||
addr_DeleteThread = GetSyscall(33);
|
|
||||||
SetSyscall(33, &Hook_DeleteThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveKernelHooks(void)
|
|
||||||
{
|
|
||||||
SetSyscall(6, addr_LoadExecPS2);
|
|
||||||
SetSyscall(32, addr_CreateThread);
|
|
||||||
SetSyscall(33, addr_DeleteThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Hook_LoadExecPS2(char *fname, int argc, char *argv[])
|
|
||||||
{
|
|
||||||
// kill any active threads
|
|
||||||
KillActiveThreads();
|
|
||||||
|
|
||||||
// remove our kernel hooks
|
|
||||||
RemoveKernelHooks();
|
|
||||||
|
|
||||||
// call the real LoadExecPS2 handler, this will never return
|
|
||||||
return(((int (*)(char *, int, char **)) (addr_LoadExecPS2))(fname, argc, argv));
|
|
||||||
}
|
|
||||||
|
|
||||||
int Hook_CreateThread(ee_thread_t *thread_p)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i = 0; i < MAX_MONITORED_THREADS; i++)
|
|
||||||
{
|
|
||||||
if(active_threads[i] < 0) { break; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i >= MAX_MONITORED_THREADS) { return(-1); }
|
|
||||||
|
|
||||||
// call the real CreateThread handler, saving the thread id in our list
|
|
||||||
return(active_threads[i] = ((int (*)(ee_thread_t *)) (addr_CreateThread))(thread_p));
|
|
||||||
}
|
|
||||||
|
|
||||||
int Hook_DeleteThread(int th_id)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < MAX_MONITORED_THREADS; i++)
|
|
||||||
{
|
|
||||||
if(active_threads[i] == th_id)
|
|
||||||
{
|
|
||||||
// remove the entry from the active thread list.
|
|
||||||
active_threads[i] = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// call the real DeleteThread handler
|
|
||||||
return(((int (*)(int)) (addr_DeleteThread))(th_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// kill all threads created and not deleted since PS2LINK.ELF started except for the calling thread.
|
|
||||||
void KillActiveThreads(void)
|
|
||||||
{
|
|
||||||
int my_id = GetThreadId();
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < MAX_MONITORED_THREADS; i++)
|
|
||||||
{
|
|
||||||
if((active_threads[i] >= 0) && (active_threads[i] != my_id))
|
|
||||||
{
|
|
||||||
TerminateThread(active_threads[i]);
|
|
||||||
DeleteThread(active_threads[i]);
|
|
||||||
active_threads[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetActiveThreads(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i = 0; i < MAX_MONITORED_THREADS; i++) { active_threads[i] = -1; }
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void _start(void);
|
|
||||||
extern int _end;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
// int ret;
|
|
||||||
char *bootPath;
|
|
||||||
|
|
||||||
init_scr();
|
|
||||||
scr_printf(WELCOME_STRING);
|
|
||||||
#ifdef _LOADHIGHVER
|
|
||||||
scr_printf("Highload version\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SCREENSHOTS
|
|
||||||
scr_printf("Screenshot capable\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
scr_printf("pcsx2hostfs loaded at 0x%08X-0x%08X\n", ((u32) _start) - 8, (u32) &_end);
|
|
||||||
|
|
||||||
installExceptionHandlers();
|
|
||||||
|
|
||||||
#if HOOK_THREADS
|
|
||||||
if(_first_load)
|
|
||||||
{
|
|
||||||
_first_load = 0;
|
|
||||||
InstallKernelHooks();
|
|
||||||
}
|
|
||||||
|
|
||||||
ResetActiveThreads();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// argc == 0 usually means naplink..
|
|
||||||
if (argc == 0) {
|
|
||||||
bootPath = "host:";
|
|
||||||
}
|
|
||||||
// reload1 usually gives an argc > 60000 (yea, this is kinda a hack..)
|
|
||||||
else if (argc != 1) {
|
|
||||||
bootPath = "mc0:/BWLINUX/";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bootPath = argv[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
SifInitRpc(0);
|
|
||||||
dbgscr_printf("Checking argv\n");
|
|
||||||
boot = 0;
|
|
||||||
|
|
||||||
setPathInfo(bootPath);
|
|
||||||
|
|
||||||
if(!strncmp(bootPath, "mc", strlen("mc"))) {
|
|
||||||
// Booting from my mc
|
|
||||||
scr_printf("Booting from mc dir (%s)\n", bootPath);
|
|
||||||
boot = B_MC;
|
|
||||||
}
|
|
||||||
else if(!strncmp(bootPath, "host", strlen("host"))) {
|
|
||||||
// Host
|
|
||||||
scr_printf("Booting from host (%s)\n", bootPath);
|
|
||||||
boot = B_HOST;
|
|
||||||
}
|
|
||||||
else if(!strncmp(bootPath, "rom0:OSDSYS", strlen("rom0:OSDSYS"))) {
|
|
||||||
// From CC's firmware
|
|
||||||
scr_printf("Booting as CC firmware\n");
|
|
||||||
boot = B_CC;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Unknown
|
|
||||||
scr_printf("Booting from unrecognized place %s\n", bootPath);
|
|
||||||
boot = B_UNKN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_CACHED_CFG
|
|
||||||
if(if_conf_len==0)
|
|
||||||
{
|
|
||||||
scr_printf("Initial boot, will load config then reset\n");
|
|
||||||
if(boot == B_MC || boot == B_CC)
|
|
||||||
restartIOP();
|
|
||||||
|
|
||||||
getIpConfig();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scr_printf("Using cached config\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// System initalisation
|
|
||||||
#ifndef BUILTIN_IRXS
|
|
||||||
if (boot == B_HOST) {
|
|
||||||
if (loadHostModBuffers() < 0) {
|
|
||||||
dbgscr_printf("Unable to load modules from host:!\n");
|
|
||||||
SleepThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
restartIOP();
|
|
||||||
|
|
||||||
// CLEARSPU seems to cause exceptions in the Multi_Thread_Manager module.
|
|
||||||
// I suspect this is caused by the interrupt handlers or some such.
|
|
||||||
/*
|
|
||||||
dbgscr_printf("clearing spu\n");
|
|
||||||
if (SifLoadModule("rom0:CLEARSPU", 0, NULL)<0)
|
|
||||||
{
|
|
||||||
scr_printf("rom0:CLEARSPU failed\n");
|
|
||||||
sio_printf("rom0:CLEARSPU failed\n");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// get extra config
|
|
||||||
if(load_extra_conf)
|
|
||||||
{
|
|
||||||
dbgscr_printf("getting extra config\n");
|
|
||||||
getExtraConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
scr_printf("Ready\n");
|
|
||||||
sio_printf("Ready\n");
|
|
||||||
nprintf("Ready\n");
|
|
||||||
|
|
||||||
const char elfFile[PS2E_FIO_MAX_PATH];
|
|
||||||
|
|
||||||
if(argc<2 || strlen(argv[1]) == 0)
|
|
||||||
{
|
|
||||||
nprintf("No elf specified. Trying PS2E Hack.\n");
|
|
||||||
|
|
||||||
char* params_ptr = (char*)0x1FFFC00;
|
|
||||||
int* params_magic = params_ptr + 0;
|
|
||||||
int* params_argc = params_ptr + 4;
|
|
||||||
char* params_argv = params_ptr + 8;
|
|
||||||
|
|
||||||
nprintf("Magic = %c%c%c%c, argc=%d, argv[0]=%s\n", params_ptr[0], params_ptr[1], params_ptr[2], params_ptr[3], *params_argc, params_argv );
|
|
||||||
|
|
||||||
if(params_ptr[0] == 'E' && params_ptr[1] == '2' && params_ptr[2] == 'S' && params_ptr[3] == 'P')
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
argc = *params_argc;
|
|
||||||
for(i=0;i<=argc;i++)
|
|
||||||
{
|
|
||||||
argv[i] = params_argv;
|
|
||||||
params_argv += strlen(params_argv)+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nprintf("No elf to run. Looping infinitely.\n");
|
|
||||||
for(;;);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(elfFile,"host0:");
|
|
||||||
strcat(elfFile,argv[1]);
|
|
||||||
|
|
||||||
nprintf("Loading elf '%s'...", elfFile);
|
|
||||||
|
|
||||||
pko_pkt_execee_req cmd;
|
|
||||||
|
|
||||||
cmd.argc = 1;
|
|
||||||
strcpy(cmd.argv, elfFile);
|
|
||||||
cmd.argv[strlen(cmd.argv)+1] = 0; // second null char to end argv
|
|
||||||
|
|
||||||
pkoExecEE(&cmd);
|
|
||||||
|
|
||||||
// SleepThread();
|
|
||||||
ExitDeleteThread();
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,286 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PS2REGS_H
|
|
||||||
#define PS2REGS_H
|
|
||||||
|
|
||||||
/* TIMERS */
|
|
||||||
#define T0_COUNT *((volatile unsigned int *)0x10000000)
|
|
||||||
#define T0_MODE *((volatile unsigned short *)0x10000010)
|
|
||||||
#define T0_COMP *((volatile unsigned short *)0x10000020)
|
|
||||||
#define T0_HOLD *((volatile unsigned short *)0x10000030)
|
|
||||||
|
|
||||||
#define T1_COUNT *((volatile unsigned int *)0x10000800)
|
|
||||||
#define T1_MODE *((volatile unsigned short *)0x10000810)
|
|
||||||
#define T1_COMP *((volatile unsigned short *)0x10000820)
|
|
||||||
#define T1_HOLD *((volatile unsigned short *)0x10000830)
|
|
||||||
|
|
||||||
#define T2_COUNT *((volatile unsigned int *)0x10001000)
|
|
||||||
#define T2_MODE *((volatile unsigned short *)0x10001010)
|
|
||||||
#define T2_COMP *((volatile unsigned short *)0x10001020)
|
|
||||||
|
|
||||||
#define T3_COUNT *((volatile unsigned int *)0x10001800)
|
|
||||||
#define T3_MODE *((volatile unsigned short *)0x10001810)
|
|
||||||
#define T3_COMP *((volatile unsigned short *)0x10001820)
|
|
||||||
|
|
||||||
/* IPU */
|
|
||||||
#define IPU_CMD *((volatile unsigned long *)0x10002000)
|
|
||||||
#define IPU_CTRL *((volatile unsigned int *)0x10002010)
|
|
||||||
#define IPU_BP *((volatile unsigned int *)0x10002020)
|
|
||||||
#define IPU_TOP *((volatile unsigned long *)0x10002030)
|
|
||||||
|
|
||||||
/* GIF */
|
|
||||||
#define GIF_CTRL *((volatile unsigned int *)0x10003000)
|
|
||||||
#define GIF_MODE *((volatile unsigned int *)0x10003010)
|
|
||||||
#define GIF_STAT *((volatile unsigned int *)0x10003020)
|
|
||||||
|
|
||||||
#define GIF_TAG0 *((volatile unsigned int *)0x10003040)
|
|
||||||
#define GIF_TAG1 *((volatile unsigned int *)0x10003050)
|
|
||||||
#define GIF_TAG2 *((volatile unsigned int *)0x10003060)
|
|
||||||
#define GIF_TAG3 *((volatile unsigned int *)0x10003070)
|
|
||||||
#define GIF_CNT *((volatile unsigned int *)0x10003080)
|
|
||||||
#define GIF_P3CNT *((volatile unsigned int *)0x10003090)
|
|
||||||
#define GIF_P3TAG *((volatile unsigned int *)0x100030a0)
|
|
||||||
|
|
||||||
/* VIF */
|
|
||||||
#define VIF0_STAT *((volatile unsigned int *)0x10003800)
|
|
||||||
#define VIF0_FBRST *((volatile unsigned int *)0x10003810)
|
|
||||||
#define VIF0_ERR *((volatile unsigned int *)0x10003820)
|
|
||||||
#define VIF0_MARK *((volatile unsigned int *)0x10003830)
|
|
||||||
#define VIF0_CYCLE *((volatile unsigned int *)0x10003840)
|
|
||||||
#define VIF0_MODE *((volatile unsigned int *)0x10003850)
|
|
||||||
#define VIF0_NUM *((volatile unsigned int *)0x10003860)
|
|
||||||
#define VIF0_MASK *((volatile unsigned int *)0x10003870)
|
|
||||||
#define VIF0_CODE *((volatile unsigned int *)0x10003880)
|
|
||||||
#define VIF0_ITOPS *((volatile unsigned int *)0x10003890)
|
|
||||||
|
|
||||||
#define VIF0_ITOP *((volatile unsigned int *)0x100038d0)
|
|
||||||
|
|
||||||
#define VIF0_R0 *((volatile unsigned int *)0x10003900)
|
|
||||||
#define VIF0_R1 *((volatile unsigned int *)0x10003910)
|
|
||||||
#define VIF0_R2 *((volatile unsigned int *)0x10003920)
|
|
||||||
#define VIF0_R3 *((volatile unsigned int *)0x10003930)
|
|
||||||
#define VIF0_C0 *((volatile unsigned int *)0x10003940)
|
|
||||||
#define VIF0_C1 *((volatile unsigned int *)0x10003950)
|
|
||||||
#define VIF0_C2 *((volatile unsigned int *)0x10003960)
|
|
||||||
#define VIF0_C3 *((volatile unsigned int *)0x10003970)
|
|
||||||
|
|
||||||
#define VIF1_STAT *((volatile unsigned int *)0x10003c00)
|
|
||||||
#define VIF1_FBRST *((volatile unsigned int *)0x10003c10)
|
|
||||||
#define VIF1_ERR *((volatile unsigned int *)0x10003c20)
|
|
||||||
#define VIF1_MARK *((volatile unsigned int *)0x10003c30)
|
|
||||||
#define VIF1_CYCLE *((volatile unsigned int *)0x10003c40)
|
|
||||||
#define VIF1_MODE *((volatile unsigned int *)0x10003c50)
|
|
||||||
#define VIF1_NUM *((volatile unsigned int *)0x10003c60)
|
|
||||||
#define VIF1_MASK *((volatile unsigned int *)0x10003c70)
|
|
||||||
#define VIF1_CODE *((volatile unsigned int *)0x10003c80)
|
|
||||||
#define VIF1_ITOPS *((volatile unsigned int *)0x10003c90)
|
|
||||||
#define VIF1_BASE *((volatile unsigned int *)0x10003ca0)
|
|
||||||
#define VIF1_OFST *((volatile unsigned int *)0x10003cb0)
|
|
||||||
#define VIF1_TOPS *((volatile unsigned int *)0x10003cc0)
|
|
||||||
#define VIF1_ITOP *((volatile unsigned int *)0x10003cd0)
|
|
||||||
#define VIF1_TOP *((volatile unsigned int *)0x10003ce0)
|
|
||||||
|
|
||||||
#define VIF1_R0 *((volatile unsigned int *)0x10003d00)
|
|
||||||
#define VIF1_R1 *((volatile unsigned int *)0x10003d10)
|
|
||||||
#define VIF1_R2 *((volatile unsigned int *)0x10003d20)
|
|
||||||
#define VIF1_R3 *((volatile unsigned int *)0x10003d30)
|
|
||||||
#define VIF1_C0 *((volatile unsigned int *)0x10003d40)
|
|
||||||
#define VIF1_C1 *((volatile unsigned int *)0x10003d50)
|
|
||||||
#define VIF1_C2 *((volatile unsigned int *)0x10003d60)
|
|
||||||
#define VIF1_C3 *((volatile unsigned int *)0x10003d70)
|
|
||||||
|
|
||||||
/* FIFO */
|
|
||||||
//#define VIF0_FIFO(write) *((volatile unsigned int128 *)0x10004000)
|
|
||||||
//#define VIF1_FIFO(read/write) *((volatile unsigned int128 *)0x10005000)
|
|
||||||
//#define GIF_FIFO(write) *((volatile unsigned int128 *)0x10006000)
|
|
||||||
//#define IPU_out_FIFO(read) *((volatile unsigned int128 *)0x10007000)
|
|
||||||
//#define IPU_in_FIFO(write) *((volatile unsigned int128 *)0x10007010)
|
|
||||||
|
|
||||||
/* DMAC */
|
|
||||||
#define CHCR 0x00
|
|
||||||
#define MADR 0x04
|
|
||||||
#define QWC 0x08
|
|
||||||
#define TADR 0x0C
|
|
||||||
#define ASR0 0x10
|
|
||||||
#define ASR1 0x14
|
|
||||||
|
|
||||||
#define DMA0 ((volatile unsigned int *)0x10008000)
|
|
||||||
#define DMA1 ((volatile unsigned int *)0x10009000)
|
|
||||||
#define DMA2 ((volatile unsigned int *)0x1000a000)
|
|
||||||
#define DMA3 ((volatile unsigned int *)0x1000b000)
|
|
||||||
#define DMA4 ((volatile unsigned int *)0x1000b400)
|
|
||||||
#define DMA5 ((volatile unsigned int *)0x1000c000)
|
|
||||||
#define DMA6 ((volatile unsigned int *)0x1000c400)
|
|
||||||
#define DMA7 ((volatile unsigned int *)0x1000c800)
|
|
||||||
#define DMA8 ((volatile unsigned int *)0x1000d000)
|
|
||||||
#define DMA9 ((volatile unsigned int *)0x1000d400)
|
|
||||||
|
|
||||||
#define D0_CHCR *((volatile unsigned int *)0x10008000)
|
|
||||||
#define D0_MADR *((volatile unsigned int *)0x10008010)
|
|
||||||
#define D0_QWC *((volatile unsigned int *)0x10008020)
|
|
||||||
#define D0_TADR *((volatile unsigned int *)0x10008030)
|
|
||||||
#define D0_ASR0 *((volatile unsigned int *)0x10008040)
|
|
||||||
#define D0_ASR1 *((volatile unsigned int *)0x10008050)
|
|
||||||
|
|
||||||
#define D1_CHCR *((volatile unsigned int *)0x10009000)
|
|
||||||
#define D1_MADR *((volatile unsigned int *)0x10009010)
|
|
||||||
#define D1_QWC *((volatile unsigned int *)0x10009020)
|
|
||||||
#define D1_TADR *((volatile unsigned int *)0x10009030)
|
|
||||||
#define D1_ASR0 *((volatile unsigned int *)0x10009040)
|
|
||||||
#define D1_ASR1 *((volatile unsigned int *)0x10009050)
|
|
||||||
|
|
||||||
#define D2_CHCR *((volatile unsigned int *)0x1000a000)
|
|
||||||
#define D2_MADR *((volatile unsigned int *)0x1000a010)
|
|
||||||
#define D2_QWC *((volatile unsigned int *)0x1000a020)
|
|
||||||
#define D2_TADR *((volatile unsigned int *)0x1000a030)
|
|
||||||
#define D2_ASR0 *((volatile unsigned int *)0x1000a040)
|
|
||||||
#define D2_ASR1 *((volatile unsigned int *)0x1000a050)
|
|
||||||
|
|
||||||
#define D3_CHCR *((volatile unsigned int *)0x1000b000)
|
|
||||||
#define D3_MADR *((volatile unsigned int *)0x1000b010)
|
|
||||||
#define D3_QWC *((volatile unsigned int *)0x1000b020)
|
|
||||||
|
|
||||||
#define D4_CHCR *((volatile unsigned int *)0x1000b400)
|
|
||||||
#define D4_MADR *((volatile unsigned int *)0x1000b410)
|
|
||||||
#define D4_QWC *((volatile unsigned int *)0x1000b420)
|
|
||||||
#define D4_TADR *((volatile unsigned int *)0x1000b430)
|
|
||||||
|
|
||||||
#define D5_CHCR *((volatile unsigned int *)0x1000c000)
|
|
||||||
#define D5_MADR *((volatile unsigned int *)0x1000c010)
|
|
||||||
#define D5_QWC *((volatile unsigned int *)0x1000c020)
|
|
||||||
|
|
||||||
#define D6_CHCR *((volatile unsigned int *)0x1000c400)
|
|
||||||
#define D6_MADR *((volatile unsigned int *)0x1000c410)
|
|
||||||
#define D6_QWC *((volatile unsigned int *)0x1000c420)
|
|
||||||
|
|
||||||
#define D7_CHCR *((volatile unsigned int *)0x1000c800)
|
|
||||||
#define D7_MADR *((volatile unsigned int *)0x1000c810)
|
|
||||||
#define D7_QWC *((volatile unsigned int *)0x1000c820)
|
|
||||||
|
|
||||||
#define D8_CHCR *((volatile unsigned int *)0x1000d000)
|
|
||||||
#define D8_MADR *((volatile unsigned int *)0x1000d010)
|
|
||||||
#define D8_QWC *((volatile unsigned int *)0x1000d020)
|
|
||||||
|
|
||||||
#define D8_SADR *((volatile unsigned int *)0x1000d080)
|
|
||||||
|
|
||||||
#define D9_CHCR *((volatile unsigned int *)0x1000d400)
|
|
||||||
#define D9_MADR *((volatile unsigned int *)0x1000d410)
|
|
||||||
#define D9_QWC *((volatile unsigned int *)0x1000d420)
|
|
||||||
#define D9_TADR *((volatile unsigned int *)0x1000d430)
|
|
||||||
|
|
||||||
#define D9_SADR *((volatile unsigned int *)0x1000d480)
|
|
||||||
|
|
||||||
/* DMAC */
|
|
||||||
#define D_CTRL *((volatile unsigned int *)0x1000e000)
|
|
||||||
#define D_STAT *((volatile unsigned int *)0x1000e010)
|
|
||||||
#define D_PCR *((volatile unsigned int *)0x1000e020)
|
|
||||||
#define D_SQWC *((volatile unsigned int *)0x1000e030)
|
|
||||||
#define D_RBSR *((volatile unsigned int *)0x1000e040)
|
|
||||||
#define D_RBOR *((volatile unsigned int *)0x1000e050)
|
|
||||||
#define D_STADR *((volatile unsigned int *)0x1000e060)
|
|
||||||
/* INTC */
|
|
||||||
//#define I_STAT 0x1000f000
|
|
||||||
//#define I_MASK 0x1000f010
|
|
||||||
|
|
||||||
/* TOOL putchar */
|
|
||||||
// .byte KPUTCHAR (0x1000f180)
|
|
||||||
/* SIF */
|
|
||||||
// #define SB_SMFLG (0x1000f230)
|
|
||||||
|
|
||||||
/* DMAC */
|
|
||||||
#define D_ENABLER *((volatile unsigned int *)0x1000f520)
|
|
||||||
#define D_ENABLEW *((volatile unsigned int *)0x1000f590)
|
|
||||||
|
|
||||||
/* VU Mem */
|
|
||||||
#define VUMicroMem0 *((volatile unsigned int *)0x11000000)
|
|
||||||
#define VUMem0 *((volatile unsigned int *)0x11004000)
|
|
||||||
#define VUMicroMem1 *((volatile unsigned int *)0x11008000)
|
|
||||||
#define VUMem1 *((volatile unsigned int *)0x1100c000)
|
|
||||||
|
|
||||||
/* GS Privileged */
|
|
||||||
#define GS_PMODE *((volatile unsigned long *)0x12000000)
|
|
||||||
#define GS_SMODE1 *((volatile unsigned long *)0x12000010)
|
|
||||||
#define GS_SMODE2 *((volatile unsigned long *)0x12000020)
|
|
||||||
#define GS_SRFSH *((volatile unsigned long *)0x12000030)
|
|
||||||
#define GS_SYNCH1 *((volatile unsigned long *)0x12000040)
|
|
||||||
#define GS_SYNCH2 *((volatile unsigned long *)0x12000050)
|
|
||||||
#define GS_SYNCV *((volatile unsigned long *)0x12000060)
|
|
||||||
#define GS_DISPFB1 *((volatile unsigned long *)0x12000070)
|
|
||||||
#define GS_DISPLAY1 *((volatile unsigned long *)0x12000080)
|
|
||||||
#define GS_DISPFB2 *((volatile unsigned long *)0x12000090)
|
|
||||||
#define GS_DISPLAY2 *((volatile unsigned long *)0x120000a0)
|
|
||||||
#define GS_EXTBUF *((volatile unsigned long *)0x120000b0)
|
|
||||||
#define GS_EXTDATA *((volatile unsigned long *)0x120000c0)
|
|
||||||
#define GS_EXTWRITE *((volatile unsigned long *)0x120000d0)
|
|
||||||
#define GS_BGCOLOR *((volatile unsigned long *)0x120000e0)
|
|
||||||
|
|
||||||
#define GS_CSR *((volatile unsigned long *)0x12001000)
|
|
||||||
#define GS_IMR *((volatile unsigned long *)0x12001010)
|
|
||||||
|
|
||||||
#define GS_BUSDIR *((volatile unsigned long *)0x12001040)
|
|
||||||
|
|
||||||
#define GS_SIGLBLID *((volatile unsigned long *)0x12001080)
|
|
||||||
|
|
||||||
/* GS General */
|
|
||||||
#define GS_PRIM 0x00
|
|
||||||
#define GS_RGBAQ 0x01
|
|
||||||
#define GS_ST 0x02
|
|
||||||
#define GS_UV 0x03
|
|
||||||
#define GS_XYZF2 0x04
|
|
||||||
#define GS_XYZ2 0x05
|
|
||||||
#define GS_TEX0_1 0x06
|
|
||||||
#define GS_TEX0_2 0x07
|
|
||||||
#define GS_CLAMP_1 0x08
|
|
||||||
#define GS_CLAMP_2 0x09
|
|
||||||
#define GS_FOG 0x0a
|
|
||||||
#define GS_XYZF3 0x0c
|
|
||||||
#define GS_XYZ3 0x0d
|
|
||||||
#define GS_AD 0x0e
|
|
||||||
#define GS_TEX1_1 0x14
|
|
||||||
#define GS_TEX1_2 0x15
|
|
||||||
#define GS_TEX2_1 0x16
|
|
||||||
#define GS_TEX2_2 0x17
|
|
||||||
#define GS_XYOFFSET_1 0x18
|
|
||||||
#define GS_XYOFFSET_2 0x19
|
|
||||||
#define GS_PRMODECONT 0x1a
|
|
||||||
#define GS_PRMODE 0x1b
|
|
||||||
#define GS_TEXCLUT 0x1c
|
|
||||||
#define GS_SCANMSK 0x22
|
|
||||||
#define GS_MIPTBP1_1 0x34
|
|
||||||
#define GS_MIPTBP1_2 0x35
|
|
||||||
#define GS_MIPTBP2_1 0x36
|
|
||||||
#define GS_MIPTBP2_2 0x37
|
|
||||||
#define GS_TEXA 0x3b
|
|
||||||
#define GS_FOGCOL 0x3d
|
|
||||||
#define GS_TEXFLUSH 0x3f
|
|
||||||
#define GS_SCISSOR_1 0x40
|
|
||||||
#define GS_SCISSOR_2 0x41
|
|
||||||
#define GS_ALPHA_1 0x42
|
|
||||||
#define GS_ALPHA_2 0x43
|
|
||||||
#define GS_DIMX 0x44
|
|
||||||
#define GS_DTHE 0x45
|
|
||||||
#define GS_COLCLAMP 0x46
|
|
||||||
#define GS_TEST_1 0x47
|
|
||||||
#define GS_TEST_2 0x48
|
|
||||||
#define GS_PABE 0x49
|
|
||||||
#define GS_FBA_1 0x4a
|
|
||||||
#define GS_FBA_2 0x4b
|
|
||||||
#define GS_FRAME_1 0x4c
|
|
||||||
#define GS_FRAME_2 0x4d
|
|
||||||
#define GS_ZBUF_1 0x4e
|
|
||||||
#define GS_ZBUF_2 0x4f
|
|
||||||
#define GS_BITBLTBUF 0x50
|
|
||||||
#define GS_TRXPOS 0x51
|
|
||||||
#define GS_TRXREG 0x52
|
|
||||||
#define GS_TRXDIR 0x53
|
|
||||||
#define GS_HWREG 0x54
|
|
||||||
#define GS_SIGNAL 0x60
|
|
||||||
#define GS_FINISH 0x61
|
|
||||||
#define GS_LABEL 0x62
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,73 +0,0 @@
|
||||||
//------------------------------------------------------------------------
|
|
||||||
// File: regs.h
|
|
||||||
// Author: Tony Saveski, t_saveski@yahoo.com
|
|
||||||
// Notes: Playstation 2 Register Definitions
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef R5900_REGS_H
|
|
||||||
#define R5900_REGS_H
|
|
||||||
|
|
||||||
// MIPS CPU Registsers
|
|
||||||
#define zero $0 // Always 0
|
|
||||||
#define at $1 // Assembler temporary
|
|
||||||
#define v0 $2 // Function return
|
|
||||||
#define v1 $3 //
|
|
||||||
#define a0 $4 // Function arguments
|
|
||||||
#define a1 $5
|
|
||||||
#define a2 $6
|
|
||||||
#define a3 $7
|
|
||||||
#define t0 $8 // Temporaries. No need
|
|
||||||
#define t1 $9 // to preserve in your
|
|
||||||
#define t2 $10 // functions.
|
|
||||||
#define t3 $11
|
|
||||||
#define t4 $12
|
|
||||||
#define t5 $13
|
|
||||||
#define t6 $14
|
|
||||||
#define t7 $15
|
|
||||||
#define s0 $16 // Saved Temporaries.
|
|
||||||
#define s1 $17 // Make sure to restore
|
|
||||||
#define s2 $18 // to original value
|
|
||||||
#define s3 $19 // if your function
|
|
||||||
#define s4 $20 // changes their value.
|
|
||||||
#define s5 $21
|
|
||||||
#define s6 $22
|
|
||||||
#define s7 $23
|
|
||||||
#define t8 $24 // More Temporaries.
|
|
||||||
#define t9 $25
|
|
||||||
#define k0 $26 // Reserved for Kernel
|
|
||||||
#define k1 $27
|
|
||||||
#define gp $28 // Global Pointer
|
|
||||||
#define sp $29 // Stack Pointer
|
|
||||||
#define fp $30 // Frame Pointer
|
|
||||||
#define ra $31 // Function Return Address
|
|
||||||
|
|
||||||
// COP0
|
|
||||||
#define Index $0 // Index into the TLB array
|
|
||||||
#define Random $1 // Randomly generated index into the TLB array
|
|
||||||
#define EntryLo0 $2 // Low-order portion of the TLB entry for..
|
|
||||||
#define EntryLo1 $3 // Low-order portion of the TLB entry for
|
|
||||||
#define Context $4 // Pointer to page table entry in memory
|
|
||||||
#define PageMask $5 // Control for variable page size in TLB entries
|
|
||||||
#define Wired $6 // Controls the number of fixed ("wired") TLB entries
|
|
||||||
#define BadVAddr $8 // Address for the most recent address-related exception
|
|
||||||
#define Count $9 // Processor cycle count
|
|
||||||
#define EntryHi $10 // High-order portion of the TLB entry
|
|
||||||
#define Compare $11 // Timer interrupt control
|
|
||||||
#define Status $12 // Processor status and control
|
|
||||||
#define Cause $13 // Cause of last general exception
|
|
||||||
#define EPC $14 // Program counter at last exception
|
|
||||||
#define PRId $15 // Processor identification and revision
|
|
||||||
#define Config $16 // Configuration register
|
|
||||||
#define LLAddr $17 // Load linked address
|
|
||||||
#define WatchLo $18 // Watchpoint address Section 6.25 on
|
|
||||||
#define WatchHi $19 // Watchpoint control
|
|
||||||
#define Debug $23 // EJTAG Debug register
|
|
||||||
#define DEPC $24 // Program counter at last EJTAG debug exception
|
|
||||||
#define PerfCnt $25 // Performance counter interface
|
|
||||||
#define ErrCtl $26 // Parity/ECC error control and status
|
|
||||||
#define CacheErr $27 // Cache parity error control and status
|
|
||||||
#define TagLo $28 // Low-order portion of cache tag interface
|
|
||||||
#define TagHi $29 // High-order portion of cache tag interface
|
|
||||||
#define ErrorPC $30 // Program counter at last error
|
|
||||||
#define DEASVE $31 // EJTAG debug exception save register
|
|
||||||
|
|
||||||
#endif // R5900_REGS_H
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BYTEORDER_H
|
|
||||||
#define BYTEORDER_H
|
|
||||||
|
|
||||||
#include <tamtypes.h>
|
|
||||||
|
|
||||||
#ifdef BIG_ENDIAN
|
|
||||||
inline unsigned int ntohl(x) { return x; }
|
|
||||||
inline unsigned short ntohs(x) { return x; }
|
|
||||||
inline unsigned int ntohl(x) { return x; }
|
|
||||||
inline unsigned short ntohs(x) { return x; }
|
|
||||||
#else
|
|
||||||
// LITTLE_ENDIAN
|
|
||||||
inline unsigned int
|
|
||||||
htonl(unsigned int x)
|
|
||||||
{
|
|
||||||
return ((x & 0xff) << 24 ) |
|
|
||||||
((x & 0xff00) << 8 ) |
|
|
||||||
((x & 0xff0000) >> 8 ) |
|
|
||||||
((x & 0xff000000) >> 24 );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline unsigned short
|
|
||||||
htons(unsigned short x)
|
|
||||||
{
|
|
||||||
return ((x & 0xff) << 8 ) | ((x & 0xff00) >> 8 );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ntohl htonl
|
|
||||||
#define ntohs htons
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->s_addr = htonl(((u32)(a & 0xff) << 24) | ((u32)(b & 0xff) << 16 ) | ((u32)(c & 0xff) << 8) | (u32)(d & 0xff))
|
|
||||||
|
|
||||||
#endif /* BYTEORDER_H */
|
|
|
@ -1,216 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PS2E_FIO_OPEN_CMD 0xcc2e0101
|
|
||||||
#define PS2E_FIO_CLOSE_CMD 0xcc2e0102
|
|
||||||
#define PS2E_FIO_READ_CMD 0xcc2e0103
|
|
||||||
#define PS2E_FIO_WRITE_CMD 0xcc2e0104
|
|
||||||
#define PS2E_FIO_LSEEK_CMD 0xcc2e0105
|
|
||||||
#define PS2E_FIO_OPENDIR_CMD 0xcc2e0106
|
|
||||||
#define PS2E_FIO_CLOSEDIR_CMD 0xcc2e0107
|
|
||||||
#define PS2E_FIO_READDIR_CMD 0xcc2e0108
|
|
||||||
#define PS2E_FIO_REMOVE_CMD 0xcc2e0109
|
|
||||||
#define PS2E_FIO_MKDIR_CMD 0xcc2e010a
|
|
||||||
#define PS2E_FIO_RMDIR_CMD 0xcc2e010b
|
|
||||||
#define PS2E_FIO_PRINTF_CMD 0xcc2e0201
|
|
||||||
|
|
||||||
#define PS2E_FIO_MAX_PATH 256
|
|
||||||
#define PKO_MAX_PATH 256
|
|
||||||
|
|
||||||
// old stuff
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
} __attribute__((packed)) pko_pkt_hdr;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
unsigned int retval;
|
|
||||||
} __attribute__((packed)) pko_pkt_file_rly;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int flags;
|
|
||||||
char path[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_open_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int fd;
|
|
||||||
} __attribute__((packed)) pko_pkt_close_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int fd;
|
|
||||||
int nbytes;
|
|
||||||
} __attribute__((packed)) pko_pkt_read_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int retval;
|
|
||||||
int nbytes;
|
|
||||||
} __attribute__((packed)) pko_pkt_read_rly;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int fd;
|
|
||||||
int nbytes;
|
|
||||||
} __attribute__((packed)) pko_pkt_write_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int fd;
|
|
||||||
int offset;
|
|
||||||
int whence;
|
|
||||||
} __attribute__((packed)) pko_pkt_lseek_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
char name[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_remove_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int mode;
|
|
||||||
char name[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_mkdir_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
char name[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_rmdir_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int fd;
|
|
||||||
} __attribute__((packed)) pko_pkt_dread_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int retval;
|
|
||||||
/* from io_common.h (fio_dirent_t) in ps2lib */
|
|
||||||
unsigned int mode;
|
|
||||||
unsigned int attr;
|
|
||||||
unsigned int size;
|
|
||||||
unsigned char ctime[8];
|
|
||||||
unsigned char atime[8];
|
|
||||||
unsigned char mtime[8];
|
|
||||||
unsigned int hisize;
|
|
||||||
char name[256];
|
|
||||||
} __attribute__((packed)) pko_pkt_dread_rly;
|
|
||||||
|
|
||||||
////
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
} __attribute__((packed)) pko_pkt_reset_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int argc;
|
|
||||||
char argv[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_execee_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int argc;
|
|
||||||
char argv[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_execiop_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
unsigned short size;
|
|
||||||
unsigned char file[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_gsexec_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
} __attribute__((packed)) pko_pkt_poweroff_req;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int vpu;
|
|
||||||
} __attribute__((packed)) pko_pkt_start_vu;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int vpu;
|
|
||||||
} __attribute__((packed)) pko_pkt_stop_vu;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
unsigned int offset;
|
|
||||||
unsigned int size;
|
|
||||||
char argv[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_mem_io;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
int regs;
|
|
||||||
char argv[PKO_MAX_PATH];
|
|
||||||
} __attribute__((packed)) pko_pkt_dump_regs;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
unsigned int regs[79];
|
|
||||||
} __attribute__((packed)) pko_pkt_send_regs;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int cmd;
|
|
||||||
unsigned short len;
|
|
||||||
unsigned int base;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
unsigned short psm;
|
|
||||||
} __attribute__((packed)) pko_pkt_screenshot;
|
|
||||||
|
|
||||||
#define PKO_MAX_WRITE_SEGMENT (1460 - sizeof(pko_pkt_write_req))
|
|
||||||
#define PKO_MAX_READ_SEGMENT (1460 - sizeof(pko_pkt_read_rly))
|
|
|
@ -1,43 +0,0 @@
|
||||||
# _____ ___ ____
|
|
||||||
# ____| | ____| PSX2 OpenSource Project
|
|
||||||
# | ___| |____ (C)2002, David Ryan ( Oobles@hotmail.com )
|
|
||||||
# ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Generated automatically from Makefile.in by configure.
|
|
||||||
#.SUFFIXES: .S .c .o .s .elf .irx
|
|
||||||
|
|
||||||
IOP_BIN = pcsx2hostfs.irx
|
|
||||||
IOP_OBJS = net_fsys.o net_fio.o ps2link.o tty.o nprintf.o excepHandler.o imports.o
|
|
||||||
|
|
||||||
IOP_INCS += -I../include
|
|
||||||
IOP_LIBS +=
|
|
||||||
IOP_LDFLAGS +=
|
|
||||||
IOP_CFLAGS += -Wall
|
|
||||||
|
|
||||||
# Enable zero-copy on fileio writes.
|
|
||||||
ifeq ($(ZEROCOPY),1)
|
|
||||||
IOP_CFLAGS += -DZEROCOPY
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Enable debug mode
|
|
||||||
ifeq ($(DEBUG),1)
|
|
||||||
IOP_CFLAGS += -DDEBUG
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PWOFFONRESET),1)
|
|
||||||
IOP_CFLAGS += -DPWOFFONRESET
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Enable screenshot functionality
|
|
||||||
ifeq ($(SCREENSHOTS),1)
|
|
||||||
IOP_CFLAGS += -DSCREENSHOTS
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
all: $(IOP_BIN)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f $(IOP_OBJS) $(IOP_BIN)
|
|
||||||
|
|
||||||
include $(PS2SDK)/Defs.make
|
|
||||||
include Rules.make
|
|
|
@ -1,54 +0,0 @@
|
||||||
# _____ ___ ____ ___ ____
|
|
||||||
# ____| | ____| | | |____|
|
|
||||||
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
|
|
||||||
#-----------------------------------------------------------------------
|
|
||||||
# Copyright 2001-2004.
|
|
||||||
# Licenced under Academic Free License version 2.0
|
|
||||||
# Review ps2sdk README & LICENSE files for further details.
|
|
||||||
|
|
||||||
|
|
||||||
IOP_CC_VERSION := $(shell $(IOP_CC) -v 2>&1 | sed -n 's/^.*version //p')
|
|
||||||
|
|
||||||
ASFLAGS_TARGET = -mcpu=r3000
|
|
||||||
|
|
||||||
ifeq ($(IOP_CC_VERSION),3.2.2)
|
|
||||||
CFLAGS_TARGET = -miop
|
|
||||||
ASFLAGS_TARGET = -march=r3000
|
|
||||||
LDFLAGS_TARGET = -miop
|
|
||||||
endif
|
|
||||||
|
|
||||||
IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include
|
|
||||||
|
|
||||||
IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -c $(IOP_INCS) $(IOP_CFLAGS)
|
|
||||||
IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS)
|
|
||||||
IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS)
|
|
||||||
|
|
||||||
# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB
|
|
||||||
|
|
||||||
%.o : %.c
|
|
||||||
$(IOP_CC) $(IOP_CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
%.o : %.s
|
|
||||||
$(IOP_AS) $(IOP_ASFLAGS) $< -o $@
|
|
||||||
|
|
||||||
# A rule to build imports.lst.
|
|
||||||
%.o : %.lst
|
|
||||||
echo "#include \"irx_imports.h\"" > build-imports.c
|
|
||||||
cat $< >> build-imports.c
|
|
||||||
$(IOP_CC) $(IOP_CFLAGS) build-imports.c -o $@
|
|
||||||
-rm -f build-imports.c
|
|
||||||
|
|
||||||
# A rule to build exports.tab.
|
|
||||||
%.o : %.tab
|
|
||||||
echo "#include \"irx.h\"" > build-exports.c
|
|
||||||
cat $< >> build-exports.c
|
|
||||||
$(IOP_CC) $(IOP_CFLAGS) build-exports.c -o $@
|
|
||||||
-rm -f build-exports.c
|
|
||||||
|
|
||||||
|
|
||||||
$(IOP_BIN) : $(IOP_OBJS)
|
|
||||||
$(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS)
|
|
||||||
|
|
||||||
$(IOP_LIB) : $(IOP_OBJS)
|
|
||||||
$(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS)
|
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2004 Lukasz Bruun (mail@lukasz.dk)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <tamtypes.h>
|
|
||||||
#include "irx_imports.h"
|
|
||||||
#include "hostlink.h"
|
|
||||||
|
|
||||||
#define BUFFER_SIZE sizeof(exception_frame_t)+4+4+128
|
|
||||||
|
|
||||||
u32 excep_buffer[BUFFER_SIZE/4] __attribute__ ((aligned(16)));
|
|
||||||
|
|
||||||
extern unsigned int pcsx2fioSendSifCmd(unsigned int cmd, void *src, unsigned int len); // lazy fix :)
|
|
||||||
extern int excepscrdump;
|
|
||||||
|
|
||||||
#define PKO_RPC_IOPEXCEP 12
|
|
||||||
|
|
||||||
// taken from smod by mrbrown, only use one function, didn't wanna include another irx.
|
|
||||||
|
|
||||||
/* Module info entry. */
|
|
||||||
typedef struct _smod_mod_info {
|
|
||||||
struct _smod_mod_info *next;
|
|
||||||
u8 *name;
|
|
||||||
u16 version;
|
|
||||||
u16 newflags; /* For modload shipped with games. */
|
|
||||||
u16 id;
|
|
||||||
u16 flags; /* I believe this is where flags are kept for BIOS versions. */
|
|
||||||
u32 entry; /* _start */
|
|
||||||
u32 gp;
|
|
||||||
u32 text_start;
|
|
||||||
u32 text_size;
|
|
||||||
u32 data_size;
|
|
||||||
u32 bss_size;
|
|
||||||
u32 unused1;
|
|
||||||
u32 unused2;
|
|
||||||
} smod_mod_info_t;
|
|
||||||
|
|
||||||
|
|
||||||
smod_mod_info_t *smod_get_next_mod(smod_mod_info_t *cur_mod)
|
|
||||||
{
|
|
||||||
/* If cur_mod is 0, return the head of the list (IOP address 0x800). */
|
|
||||||
if (!cur_mod) {
|
|
||||||
return (smod_mod_info_t *)0x800;
|
|
||||||
} else {
|
|
||||||
if (!cur_mod->next)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return cur_mod->next;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* ExceptionGetModuleName(u32 epc, u32* r_epc)
|
|
||||||
{
|
|
||||||
smod_mod_info_t *mod_info = 0;
|
|
||||||
|
|
||||||
while((mod_info = smod_get_next_mod(mod_info)) != 0)
|
|
||||||
{
|
|
||||||
if((epc >= mod_info->text_start) && (epc <= (mod_info->text_start+mod_info->text_size)))
|
|
||||||
{
|
|
||||||
if(r_epc)
|
|
||||||
*r_epc = epc - mod_info->text_start;
|
|
||||||
|
|
||||||
return mod_info->name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void excep_handler2(exception_frame_t *frame)
|
|
||||||
{
|
|
||||||
u32 r_epc; // relative epc
|
|
||||||
char *module_name;
|
|
||||||
u32 len;
|
|
||||||
u32* buffer = excep_buffer;
|
|
||||||
|
|
||||||
module_name = ExceptionGetModuleName(frame->epc, &r_epc);
|
|
||||||
|
|
||||||
len = strlen(module_name);
|
|
||||||
|
|
||||||
|
|
||||||
buffer[0] = 0x0d02beba; // reverse engineering..
|
|
||||||
buffer++;
|
|
||||||
|
|
||||||
memcpy(buffer, frame, BUFFER_SIZE);
|
|
||||||
buffer+= (sizeof(exception_frame_t)/4);
|
|
||||||
|
|
||||||
buffer[0] = r_epc;
|
|
||||||
buffer[1] = len;
|
|
||||||
buffer+=2;
|
|
||||||
memcpy(buffer, module_name, len+1);
|
|
||||||
|
|
||||||
//pcsx2fioSendSifCmd(PKO_RPC_IOPEXCEP, excep_buffer, BUFFER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void excep_handler(exception_type_t type, exception_frame_t *frame)
|
|
||||||
{
|
|
||||||
excep_handler2(frame); // Don't know why this works, but keeps iop alive.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Installs iop exception handlers for the 'usual' exceptions..
|
|
||||||
void installExceptionHandlers(void)
|
|
||||||
{
|
|
||||||
s32 i;
|
|
||||||
|
|
||||||
for(i=1; i < 8; i++)
|
|
||||||
set_exception_handler(i, excep_handler);
|
|
||||||
|
|
||||||
for(i=10; i < 13; i++)
|
|
||||||
set_exception_handler(i, excep_handler);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _EXCEPTION_H_
|
|
||||||
#define _EXCEPTION_H_
|
|
||||||
|
|
||||||
void installExceptionHandlers(void);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,63 +0,0 @@
|
||||||
|
|
||||||
stdio_IMPORTS_start
|
|
||||||
I_printf
|
|
||||||
stdio_IMPORTS_end
|
|
||||||
|
|
||||||
sysclib_IMPORTS_start
|
|
||||||
I_memset
|
|
||||||
I_memcpy
|
|
||||||
I_strlen
|
|
||||||
I_strncpy
|
|
||||||
I_strncmp
|
|
||||||
sysclib_IMPORTS_end
|
|
||||||
|
|
||||||
thsemap_IMPORTS_start
|
|
||||||
I_CreateSema
|
|
||||||
I_SignalSema
|
|
||||||
I_WaitSema
|
|
||||||
I_DeleteSema
|
|
||||||
thsemap_IMPORTS_end
|
|
||||||
|
|
||||||
thbase_IMPORTS_start
|
|
||||||
I_CreateThread
|
|
||||||
I_DeleteThread
|
|
||||||
I_StartThread
|
|
||||||
I_GetThreadId
|
|
||||||
I_ExitDeleteThread
|
|
||||||
thbase_IMPORTS_end
|
|
||||||
|
|
||||||
ioman_IMPORTS_start
|
|
||||||
I_open
|
|
||||||
I_close
|
|
||||||
I_AddDrv
|
|
||||||
I_DelDrv
|
|
||||||
ioman_IMPORTS_end
|
|
||||||
|
|
||||||
sifcmd_IMPORTS_start
|
|
||||||
I_sceSifInitRpc
|
|
||||||
I_sceSifSetRpcQueue
|
|
||||||
I_sceSifRegisterRpc
|
|
||||||
I_sceSifRpcLoop
|
|
||||||
sifcmd_IMPORTS_end
|
|
||||||
|
|
||||||
sifman_IMPORTS_start
|
|
||||||
I_sceSifSetDma
|
|
||||||
sifman_IMPORTS_end
|
|
||||||
|
|
||||||
intrman_IMPORTS_start
|
|
||||||
I_CpuEnableIntr
|
|
||||||
I_CpuSuspendIntr
|
|
||||||
I_CpuResumeIntr
|
|
||||||
intrman_IMPORTS_end
|
|
||||||
|
|
||||||
loadcore_IMPORTS_start
|
|
||||||
I_FlushDcache
|
|
||||||
loadcore_IMPORTS_end
|
|
||||||
|
|
||||||
modload_IMPORTS_start
|
|
||||||
I_LoadStartModule
|
|
||||||
modload_IMPORTS_end
|
|
||||||
|
|
||||||
ioptrap_IMPORTS_start
|
|
||||||
I_set_exception_handler
|
|
||||||
ioptrap_IMPORTS_end
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* irx_imports.h - Defines all IRX imports.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
|
|
||||||
*
|
|
||||||
* See the file LICENSE included with this distribution for licensing terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef IOP_IRX_IMPORTS_H
|
|
||||||
#define IOP_IRX_IMPORTS_H
|
|
||||||
|
|
||||||
#include "irx.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Please keep these in alphabetical order! */
|
|
||||||
#include "intrman.h"
|
|
||||||
#include "ioman.h"
|
|
||||||
#include "ioptrap.h"
|
|
||||||
#include "loadcore.h"
|
|
||||||
#include "modload.h"
|
|
||||||
#include "sifcmd.h"
|
|
||||||
#include "sifman.h"
|
|
||||||
#include "stdio.h"
|
|
||||||
#include "sysclib.h"
|
|
||||||
#include "thbase.h"
|
|
||||||
#include "thsemap.h"
|
|
||||||
|
|
||||||
#endif /* IOP_IRX_IMPORTS_H */
|
|
|
@ -1,80 +0,0 @@
|
||||||
/* Link script for PlayStation 2 IRXs
|
|
||||||
* Written by Douglas C. Knight <fsdck@uaf.edu>
|
|
||||||
*/
|
|
||||||
OUTPUT_FORMAT("elf32-littlemips")
|
|
||||||
SEARCH_DIR(/home/karmix/local/iop/lib);
|
|
||||||
ENTRY(_start)
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
/* This is the .iopmod section for the IRX, it contains
|
|
||||||
information that the IOP uses when loading the IRX.
|
|
||||||
This section is placed in its own segment. */
|
|
||||||
.iopmod : {
|
|
||||||
/* The linker will replace this first LONG with a pointer
|
|
||||||
to _irx_id if the symbol has been defined. */
|
|
||||||
LONG (0xffffffff) ;
|
|
||||||
LONG (_start) ;
|
|
||||||
LONG (_gp) ;
|
|
||||||
LONG (_text_size) ;
|
|
||||||
LONG (_data_size) ;
|
|
||||||
LONG (_bss_size) ;
|
|
||||||
/* The linker will put a SHORT here with the version of
|
|
||||||
the IRX (or zero if there is no version). */
|
|
||||||
/* The linker will put a null terminated string here
|
|
||||||
containing the name of the IRX (or an empty string if
|
|
||||||
the name is not known). */
|
|
||||||
}
|
|
||||||
. = 0x0 ;
|
|
||||||
_ftext = . ;
|
|
||||||
.text : {
|
|
||||||
CREATE_OBJECT_SYMBOLS
|
|
||||||
* ( .text )
|
|
||||||
* ( .text.* )
|
|
||||||
* ( .init )
|
|
||||||
* ( .fini )
|
|
||||||
} = 0
|
|
||||||
_etext = . ;
|
|
||||||
. = . ;
|
|
||||||
_fdata = . ;
|
|
||||||
.rodata : {
|
|
||||||
* ( .rdata )
|
|
||||||
* ( .rodata )
|
|
||||||
* ( .rodata1 )
|
|
||||||
* ( .rodata.* )
|
|
||||||
} = 0
|
|
||||||
.data : {
|
|
||||||
* ( .data )
|
|
||||||
* ( .data1 )
|
|
||||||
* ( .data.* )
|
|
||||||
CONSTRUCTORS
|
|
||||||
}
|
|
||||||
. = ALIGN(16) ;
|
|
||||||
_gp = . + 0x8000 ;
|
|
||||||
.sdata : {
|
|
||||||
* ( .lit8 )
|
|
||||||
* ( .lit4 )
|
|
||||||
* ( .sdata )
|
|
||||||
* ( .sdata.* )
|
|
||||||
}
|
|
||||||
_edata = . ;
|
|
||||||
. = ALIGN(4) ;
|
|
||||||
_fbss = . ;
|
|
||||||
.sbss : {
|
|
||||||
* ( .sbss )
|
|
||||||
* ( .scommon )
|
|
||||||
}
|
|
||||||
_bss_start = . ;
|
|
||||||
.bss : {
|
|
||||||
* ( .bss )
|
|
||||||
* ( COMMON )
|
|
||||||
. = ALIGN(4) ;
|
|
||||||
}
|
|
||||||
_end = . ;
|
|
||||||
_text_size = _etext - _ftext ;
|
|
||||||
_data_size = _edata - _fdata ;
|
|
||||||
_bss_size = _end - _fbss ;
|
|
||||||
/* This is the stuff that we don't want to be put in an IRX. */
|
|
||||||
/DISCARD/ : {
|
|
||||||
* ( .reginfo )
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,230 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* Copyright (C) 2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Fu*k knows why net_fio & net_fsys are separated..
|
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
#include <ioman.h>
|
|
||||||
#include <sysclib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <thbase.h>
|
|
||||||
|
|
||||||
#include <io_common.h>
|
|
||||||
|
|
||||||
#include "net_fio.h"
|
|
||||||
#include "hostlink.h"
|
|
||||||
|
|
||||||
#define PACKET_MAXSIZE 1024
|
|
||||||
static int send_packet[PACKET_MAXSIZE] __attribute__((aligned(16)));
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define dbgprintf(args...) printf(args)
|
|
||||||
#else
|
|
||||||
#define dbgprintf(args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
#define PCSX2_FIO_BASE ((volatile unsigned int*)0x1d000800)
|
|
||||||
#define PCSX2_FIO_RDID (PCSX2_FIO_BASE + 0) // [f0] on read: returns the FIO magic number 'E2SP'
|
|
||||||
#define PCSX2_FIO_WCMD (PCSX2_FIO_BASE + 0) // [f0] on write: executes a command (usually "call function")
|
|
||||||
#define PCSX2_FIO_DLEN (PCSX2_FIO_BASE + 1) // [f4] write only: length of params data
|
|
||||||
#define PCSX2_FIO_DPTR (PCSX2_FIO_BASE + 2) // [f8] write only: mem address of params data
|
|
||||||
#define PCSX2_FIO_WFID (PCSX2_FIO_BASE + 3) // [fc] on write: function ID
|
|
||||||
#define PCSX2_FIO_RRET (PCSX2_FIO_BASE + 3) // [fc] on read: return value of the function
|
|
||||||
|
|
||||||
#define PCSX2_FIO_CMD_CALL 1
|
|
||||||
|
|
||||||
int pcsx2fio_device_exists()
|
|
||||||
{
|
|
||||||
return (*PCSX2_FIO_RDID == 'E2SP'); // PS2E
|
|
||||||
}
|
|
||||||
|
|
||||||
int pcsx2fio_set_call(unsigned int func_id, void* params, int params_length)
|
|
||||||
{
|
|
||||||
*PCSX2_FIO_DLEN = params_length;
|
|
||||||
*PCSX2_FIO_DPTR = (int)params;
|
|
||||||
*PCSX2_FIO_WFID = func_id;
|
|
||||||
*PCSX2_FIO_WCMD = PCSX2_FIO_CMD_CALL;
|
|
||||||
return *PCSX2_FIO_RRET;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *strcpy(char *dest, const char *src)
|
|
||||||
{
|
|
||||||
while(*src)
|
|
||||||
{
|
|
||||||
*(dest++) = *(src++);
|
|
||||||
}
|
|
||||||
*(dest) = 0;
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
void
|
|
||||||
pcsx2fio_close_fsys(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_open_file(char *path, int flags)
|
|
||||||
{
|
|
||||||
send_packet[0] = flags;
|
|
||||||
strcpy((char*)(send_packet+1),path);
|
|
||||||
|
|
||||||
int length = strlen(path) + 4;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_OPEN_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_close_file(int fd)
|
|
||||||
{
|
|
||||||
send_packet[0] = fd;
|
|
||||||
|
|
||||||
int length = 4;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_CLOSE_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_lseek_file(int fd, unsigned int offset, int whence)
|
|
||||||
{
|
|
||||||
send_packet[0] = fd;
|
|
||||||
send_packet[1] = offset;
|
|
||||||
send_packet[2] = whence;
|
|
||||||
send_packet[3] = 0;
|
|
||||||
|
|
||||||
int length = 12;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_LSEEK_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_write_file(int fd, char *buf, int _length)
|
|
||||||
{
|
|
||||||
send_packet[0] = fd;
|
|
||||||
send_packet[1] = (int)buf;
|
|
||||||
send_packet[2] = _length;
|
|
||||||
send_packet[3] = 0;
|
|
||||||
|
|
||||||
int length = 12;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_WRITE_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_read_file(int fd, char *buf, int _length)
|
|
||||||
{
|
|
||||||
send_packet[0] = fd;
|
|
||||||
send_packet[1] = (int)buf;
|
|
||||||
send_packet[2] = _length;
|
|
||||||
send_packet[3] = 0;
|
|
||||||
|
|
||||||
int length = 12;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_READ_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_remove(char *name)
|
|
||||||
{
|
|
||||||
strcpy((char*)(send_packet+0),name);
|
|
||||||
|
|
||||||
int length = strlen(name);
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_REMOVE_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_mkdir(char *name, int mode)
|
|
||||||
{
|
|
||||||
send_packet[0] = mode;
|
|
||||||
strcpy((char*)(send_packet+1),name);
|
|
||||||
|
|
||||||
int length = strlen(name) + 4;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_MKDIR_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_rmdir(char *name)
|
|
||||||
{
|
|
||||||
strcpy((char*)(send_packet+0),name);
|
|
||||||
|
|
||||||
int length = strlen(name);
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_RMDIR_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_open_dir(char *path)
|
|
||||||
{
|
|
||||||
strcpy((char*)(send_packet+0),path);
|
|
||||||
|
|
||||||
int length = strlen(path);
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_OPENDIR_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_read_dir(int fd, void *buf)
|
|
||||||
{
|
|
||||||
send_packet[0] = fd;
|
|
||||||
send_packet[1] = (int)buf;
|
|
||||||
|
|
||||||
int length = 8;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_READDIR_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
int pcsx2fio_close_dir(int fd)
|
|
||||||
{
|
|
||||||
send_packet[0] = fd;
|
|
||||||
|
|
||||||
int length = 4;
|
|
||||||
|
|
||||||
int ret = pcsx2fio_set_call(PS2E_FIO_CLOSEDIR_CMD, send_packet, length);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* Copyright (C) 2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _NETFIO_H_
|
|
||||||
#define _NETFIO_H_
|
|
||||||
|
|
||||||
int pcsx2fio_device_exists();
|
|
||||||
|
|
||||||
int pcsx2fio_set_call(unsigned int func_id, void* params, int params_length);
|
|
||||||
|
|
||||||
int pcsx2fio_file_serv(void *arg);
|
|
||||||
int pcsx2fio_recv_bytes(int fd, char *buf, int bytes);
|
|
||||||
int pcsx2fio_accept_pkt(int fd, char *buf, int len, int pkt_type);
|
|
||||||
int pcsx2fio_open_file(char *path, int flags);
|
|
||||||
int pcsx2fio_close_file(int fd);
|
|
||||||
int pcsx2fio_read_file(int fd, char *buf, int length);
|
|
||||||
int pcsx2fio_write_file(int fd, char *buf, int length);
|
|
||||||
int pcsx2fio_lseek_file(int fd, unsigned int offset, int whence);
|
|
||||||
void pcsx2fio_close_socket(void);
|
|
||||||
void pcsx2fio_close_fsys(void);
|
|
||||||
int pcsx2fio_remove(char *name);
|
|
||||||
int pcsx2fio_mkdir(char *name, int mode);
|
|
||||||
int pcsx2fio_rmdir(char *name);
|
|
||||||
int pcsx2fio_open_dir(char *path);
|
|
||||||
int pcsx2fio_read_dir(int fd, void *buf);
|
|
||||||
int pcsx2fio_close_dir(int fd);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,306 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* Copyright (C) 2004 adresd (adresd_ps2dev@yahoo.com)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
#include <thbase.h>
|
|
||||||
#include <ioman.h>
|
|
||||||
#include <sysclib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <intrman.h>
|
|
||||||
#include <loadcore.h>
|
|
||||||
#include <thsemap.h>
|
|
||||||
|
|
||||||
#include "net_fio.h"
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define dbgprintf(args...) printf(args)
|
|
||||||
#else
|
|
||||||
#define dbgprintf(args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char fsname[] = "host";
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
//static iop_device_t fsys_driver;
|
|
||||||
|
|
||||||
/* File desc struct is probably larger than this, but we only
|
|
||||||
* need to access the word @ offset 0x0C (in which we put our identifier)
|
|
||||||
*/
|
|
||||||
struct filedesc_info
|
|
||||||
{
|
|
||||||
int unkn0;
|
|
||||||
int unkn4;
|
|
||||||
int device_id; // the X in hostX
|
|
||||||
int own_fd;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
/* We need(?) to protect the net access, so the server doesn't get
|
|
||||||
* confused if two processes calls a fsys func at the same time
|
|
||||||
*/
|
|
||||||
static int fsys_sema;
|
|
||||||
static int fsys_pid = 0;
|
|
||||||
//static iop_device_t fsys_driver;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int dummy5()
|
|
||||||
{
|
|
||||||
printf("dummy function called\n");
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static void fsysInit(iop_device_t *driver)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysDestroy(void)
|
|
||||||
{
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
pcsx2fio_close_fsys();
|
|
||||||
// ExitDeleteThread(fsys_pid);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
DeleteSema(fsys_sema);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysOpen( int fd, char *name, int mode)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int fsys_fd;
|
|
||||||
|
|
||||||
dbgprintf("fsysOpen..\n");
|
|
||||||
dbgprintf(" fd: %x, name: %s, mode: %d\n\n", fd, name, mode);
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
fsys_fd = pcsx2fio_open_file(name, mode);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
fd_info->own_fd = fsys_fd;
|
|
||||||
|
|
||||||
return fsys_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysClose( int fd)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
dbgprintf("fsys_close..\n"
|
|
||||||
" fd: %x\n\n", fd);
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_close_file(fd_info->own_fd);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysRead( int fd, char *buf, int size)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
|
|
||||||
dbgprintf("fsysRead..."
|
|
||||||
" fd: %x\n"
|
|
||||||
" bf: %x\n"
|
|
||||||
" sz: %d\n"
|
|
||||||
" ow: %d\n\n", fd, (int)buf, size, fd_info->own_fd);
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_read_file(fd_info->own_fd, buf, size);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysWrite( int fd, char *buf, int size)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
dbgprintf("fsysWrite..."
|
|
||||||
" fd: %x\n", fd);
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_write_file(fd_info->own_fd, buf, size);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysLseek( int fd, unsigned int offset, int whence)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
dbgprintf("fsysLseek..\n"
|
|
||||||
" fd: %x\n"
|
|
||||||
" of: %x\n"
|
|
||||||
" wh: %x\n\n", fd, offset, whence);
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_lseek_file(fd_info->own_fd, offset, whence);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysRemove(iop_file_t* file, char *name)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
dbgprintf("fsysRemove..\n");
|
|
||||||
dbgprintf(" name: %s\n\n", name);
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_remove(name);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysMkdir(iop_file_t* file, char *name, int mode)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
dbgprintf("fsysMkdir..\n");
|
|
||||||
dbgprintf(" name: '%s'\n\n", name);
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_mkdir(name, mode);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysRmdir(iop_file_t* file, char *name)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
dbgprintf("fsysRmdir..\n");
|
|
||||||
dbgprintf(" name: %s\n\n", name);
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_rmdir(name);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysDopen(int fd, char *name)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int fsys_fd;
|
|
||||||
|
|
||||||
dbgprintf("fsysDopen..\n");
|
|
||||||
dbgprintf(" fd: %x, name: %s\n\n", fd, name);
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
fsys_fd = pcsx2fio_open_dir(name);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
fd_info->own_fd = fsys_fd;
|
|
||||||
|
|
||||||
return fsys_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysDread(int fd, void *buf)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
|
|
||||||
dbgprintf("fsysDread..."
|
|
||||||
" fd: %x\n"
|
|
||||||
" bf: %x\n"
|
|
||||||
" ow: %d\n\n", fd, (int)buf, fd_info->own_fd);
|
|
||||||
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_read_dir(fd_info->own_fd, buf);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int fsysDclose(int fd)
|
|
||||||
{
|
|
||||||
struct filedesc_info *fd_info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
dbgprintf("fsys_dclose..\n"
|
|
||||||
" fd: %x\n\n", fd);
|
|
||||||
|
|
||||||
fd_info = (struct filedesc_info *)fd;
|
|
||||||
WaitSema(fsys_sema);
|
|
||||||
ret = pcsx2fio_close_dir(fd_info->own_fd);
|
|
||||||
SignalSema(fsys_sema);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
iop_device_ops_t fsys_functarray = { (void *)fsysInit, (void *)fsysDestroy, (void *)dummy5,
|
|
||||||
(void *)fsysOpen, (void *)fsysClose, (void *)fsysRead,
|
|
||||||
(void *)fsysWrite, (void *)fsysLseek, (void *)dummy5,
|
|
||||||
(void *)fsysRemove, (void *)fsysMkdir, (void *)fsysRmdir,
|
|
||||||
(void *)fsysDopen, (void *)fsysDclose, (void *)fsysDread,
|
|
||||||
(void *)dummy5, (void *)dummy5 };
|
|
||||||
|
|
||||||
iop_device_t fsys_driver = { fsname, 16, 1, "fsys driver",
|
|
||||||
&fsys_functarray };
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Entry point for mounting the file system
|
|
||||||
int fsysMount(void)
|
|
||||||
{
|
|
||||||
iop_sema_t sema_info;
|
|
||||||
|
|
||||||
sema_info.attr = 1;
|
|
||||||
sema_info.option = 0;
|
|
||||||
sema_info.initial = 1;
|
|
||||||
sema_info.max = 1;
|
|
||||||
fsys_sema = CreateSema(&sema_info);
|
|
||||||
|
|
||||||
DelDrv(fsname);
|
|
||||||
AddDrv(&fsys_driver);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fsysUnmount(void)
|
|
||||||
{
|
|
||||||
DelDrv(fsname);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
#include <thbase.h>
|
|
||||||
#include <sifcmd.h>
|
|
||||||
#include <sysclib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ioman.h>
|
|
||||||
#include <intrman.h>
|
|
||||||
#include <loadcore.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
#define NPM_PUTS 0x01
|
|
||||||
#define RPC_NPM_USER 0x014d704e
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static void *
|
|
||||||
naplinkRpcHandler(int cmd, void *buffer, int size)
|
|
||||||
{
|
|
||||||
// Only supports npmPrintf of course
|
|
||||||
switch(cmd) {
|
|
||||||
case NPM_PUTS:
|
|
||||||
printf(buffer);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("unknown npm rpc call\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static SifRpcServerData_t server __attribute((aligned(16)));
|
|
||||||
static SifRpcDataQueue_t queue __attribute((aligned(16)));
|
|
||||||
static unsigned char rpc_buffer[512] __attribute((aligned(16)));
|
|
||||||
|
|
||||||
static void
|
|
||||||
napThread(void *arg)
|
|
||||||
{
|
|
||||||
int pid;
|
|
||||||
|
|
||||||
SifInitRpc(0);
|
|
||||||
pid = GetThreadId();
|
|
||||||
SifSetRpcQueue(&queue, pid);
|
|
||||||
SifRegisterRpc(&server, RPC_NPM_USER, naplinkRpcHandler,
|
|
||||||
rpc_buffer, 0, 0, &queue);
|
|
||||||
SifRpcLoop(&queue); // Never exits
|
|
||||||
ExitDeleteThread();
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
int
|
|
||||||
naplinkRpcInit(void)
|
|
||||||
{
|
|
||||||
struct _iop_thread th_attr;
|
|
||||||
int ret;
|
|
||||||
int pid;
|
|
||||||
|
|
||||||
th_attr.attr = 0x02000000;
|
|
||||||
th_attr.option = 0;
|
|
||||||
th_attr.thread = napThread;
|
|
||||||
th_attr.stacksize = 0x800;
|
|
||||||
th_attr.priority = 79;
|
|
||||||
|
|
||||||
pid = CreateThread(&th_attr);
|
|
||||||
if (pid < 0) {
|
|
||||||
printf("IOP: napRpc createThread failed %d\n", pid);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = StartThread(pid, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
printf("IOP: napRpc startThread failed %d\n", ret);
|
|
||||||
DeleteThread(pid);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,55 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sysclib.h>
|
|
||||||
#include <loadcore.h>
|
|
||||||
#include <intrman.h>
|
|
||||||
#include <types.h>
|
|
||||||
#include <sifrpc.h>
|
|
||||||
#include <cdvdman.h>
|
|
||||||
#include "excepHandler.h"
|
|
||||||
|
|
||||||
// Entry points
|
|
||||||
extern int fsysMount(void);
|
|
||||||
extern int cmdHandlerInit(void);
|
|
||||||
extern int ttyMount(void);
|
|
||||||
extern int naplinkRpcInit(void);
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// main
|
|
||||||
// start threads & init rpc & filesys
|
|
||||||
int
|
|
||||||
_start( int argc, char **argv)
|
|
||||||
{
|
|
||||||
ttyWrite(NULL,"TEST",4);
|
|
||||||
|
|
||||||
FlushDcache();
|
|
||||||
CpuEnableIntr(0);
|
|
||||||
|
|
||||||
SifInitRpc(0);
|
|
||||||
|
|
||||||
pcsx2fio_device_exists();
|
|
||||||
|
|
||||||
if ((argc < 2) || (strncmp(argv[1], "-notty", 6))) {
|
|
||||||
ttyMount();
|
|
||||||
// Oh well.. There's a bug in either smapif or lwip's etharp
|
|
||||||
// that thrashes udp msgs which are queued while waiting for arp
|
|
||||||
// request
|
|
||||||
// alas, this msg will probably not be displayed
|
|
||||||
printf("tty mounted\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fsysMount();
|
|
||||||
printf("host: mounted\n");
|
|
||||||
naplinkRpcInit();
|
|
||||||
printf("Naplink thread started\n");
|
|
||||||
|
|
||||||
installExceptionHandlers();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
/*********************************************************************
|
|
||||||
* Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
|
|
||||||
* This file is subject to the terms and conditions of the PS2Link License.
|
|
||||||
* See the file LICENSE in the main directory of this distribution for more
|
|
||||||
* details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <types.h>
|
|
||||||
#include <thbase.h>
|
|
||||||
#include <thsemap.h>
|
|
||||||
#include <sysclib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ioman.h>
|
|
||||||
#include <intrman.h>
|
|
||||||
#include <loadcore.h>
|
|
||||||
|
|
||||||
#include "net_fio.h"
|
|
||||||
#include "hostlink.h"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static int tty_socket = 0;
|
|
||||||
static int tty_sema = -1;
|
|
||||||
|
|
||||||
static char ttyname[] = "tty";
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int dummy()
|
|
||||||
{
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int dummy0()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int ttyInit(iop_device_t *driver)
|
|
||||||
{
|
|
||||||
iop_sema_t sema_info;
|
|
||||||
|
|
||||||
sema_info.attr = 0;
|
|
||||||
sema_info.initial = 1; /* Unlocked. */
|
|
||||||
sema_info.max = 1;
|
|
||||||
if ((tty_sema = CreateSema(&sema_info)) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
if(!pcsx2fio_device_exists())
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int ttyOpen( int fd, char *name, int mode)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
static int ttyClose( int fd)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
int ttyWrite(iop_file_t *file, char *buf, int size)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
WaitSema(tty_sema);
|
|
||||||
|
|
||||||
res = pcsx2fio_set_call(PS2E_FIO_PRINTF_CMD,buf,size);
|
|
||||||
|
|
||||||
SignalSema(tty_sema);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
iop_device_ops_t tty_functarray = { ttyInit, dummy0, (void *)dummy,
|
|
||||||
(void *)ttyOpen, (void *)ttyClose, (void *)dummy,
|
|
||||||
(void *)ttyWrite, (void *)dummy, (void *)dummy,
|
|
||||||
(void *)dummy, (void *)dummy, (void *)dummy,
|
|
||||||
(void *)dummy, (void *)dummy, (void *)dummy,
|
|
||||||
(void *)dummy, (void *)dummy };
|
|
||||||
|
|
||||||
iop_device_t tty_driver = { ttyname, 3, 1, "Fast TTY for pcsx2",
|
|
||||||
&tty_functarray };
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Entry point for mounting the file system
|
|
||||||
int ttyMount(void)
|
|
||||||
{
|
|
||||||
close(0);
|
|
||||||
close(1);
|
|
||||||
DelDrv(ttyname);
|
|
||||||
AddDrv(&tty_driver);
|
|
||||||
if(open("tty00:", O_RDONLY) != 0) while(1);
|
|
||||||
if(open("tty00:", O_WRONLY) != 1) while(1);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
|
||||||
# Visual Studio 2008
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pcsx2hostfs", "pcsx2hostfs.vcproj", "{9728FF5E-4EC6-4D47-995A-05629DCDE23F}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{9728FF5E-4EC6-4D47-995A-05629DCDE23F}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{9728FF5E-4EC6-4D47-995A-05629DCDE23F}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{9728FF5E-4EC6-4D47-995A-05629DCDE23F}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{9728FF5E-4EC6-4D47-995A-05629DCDE23F}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
|
@ -1,269 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="9,00"
|
|
||||||
Name="pcsx2hostfs"
|
|
||||||
ProjectGUID="{9728FF5E-4EC6-4D47-995A-05629DCDE23F}"
|
|
||||||
RootNamespace="pcsx2hostfs"
|
|
||||||
Keyword="Win32Proj"
|
|
||||||
TargetFrameworkVersion="0"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="Debug"
|
|
||||||
IntermediateDirectory="Debug"
|
|
||||||
ConfigurationType="1"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;"
|
|
||||||
MinimalRebuild="true"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="4"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkIncremental="2"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="Release"
|
|
||||||
IntermediateDirectory="Release"
|
|
||||||
ConfigurationType="1"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="true"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkIncremental="2"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\byteorder.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\hostlink.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<Filter
|
|
||||||
Name="ee"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ee\excepHandler.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ee\r5900_regs.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="iop"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\excepHandler.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\irx_imports.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\net_fio.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ee\ps2regs.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
|
||||||
>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
|
||||||
>
|
|
||||||
<Filter
|
|
||||||
Name="ee"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ee\cmdHandler.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ee\excepHandler.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ee\ps2link.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="iop"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\excepHandler.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\net_fio.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\net_fsys.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\nprintf.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\ps2link.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\iop\tty.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
Loading…
Reference in New Issue