-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now uses wLE loader, wLE settings can be saved
- Loading branch information
Showing
6 changed files
with
125 additions
and
701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,40 @@ | ||
/* | ||
# _____ ___ ____ ___ ____ | ||
# ____| | ____| | | |____| | ||
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. | ||
#----------------------------------------------------------------------- | ||
# (c) 2020 Francisco Javier Trujillo Mata <[email protected]> | ||
# Licenced under Academic Free License version 2.0 | ||
# Review ps2sdk README & LICENSE files for further details. | ||
*/ | ||
|
||
//-------------------------------------------------------------- | ||
//File name: loader.c | ||
//-------------------------------------------------------------- | ||
//dlanor: This subprogram has been modified to minimize the code | ||
//dlanor: size of the resident loader portion. Some of the parts | ||
//dlanor: that were moved into the main program include loading | ||
//dlanor: of all IRXs and mounting pfs0: for ELFs on hdd. | ||
//dlanor: Another change was to skip threading in favor of ExecPS2 | ||
/*================================================================== | ||
== == | ||
== Copyright(c)2004 Adam Metcalf([email protected]) == | ||
== Copyright(c)2004 Thomas Hawcroft([email protected]) == | ||
== This file is subject to terms and conditions shown in the == | ||
== file LICENSE which should be kept in the top folder of == | ||
== this distribution. == | ||
== == | ||
== Portions of this code taken from PS2Link: == | ||
== pkoLoadElf == | ||
== wipeUserMemory == | ||
== (C) 2003 Tord Lindstrom ([email protected]) == | ||
== (C) 2003 adresd ([email protected]) == | ||
== Portions of this code taken from Independence MC exploit == | ||
== tLoadElf == | ||
== LoadAndRunHDDElf == | ||
== (C) 2003 Marcus Brown <[email protected]> == | ||
== == | ||
==================================================================*/ | ||
#include <kernel.h> | ||
#include <loadfile.h> | ||
#include <sifrpc.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <iopcontrol.h> | ||
//-------------------------------------------------------------- | ||
|
||
//-------------------------------------------------------------- | ||
//End of data declarations | ||
//-------------------------------------------------------------- | ||
//Start of function code: | ||
//-------------------------------------------------------------- | ||
|
@@ -25,10 +47,10 @@ static void wipeUserMem(void) | |
int i; | ||
for (i = 0x100000; i < GetMemorySize(); i += 64) { | ||
asm volatile( | ||
"\tsq $0, 0(%0) \n" | ||
"\tsq $0, 16(%0) \n" | ||
"\tsq $0, 32(%0) \n" | ||
"\tsq $0, 48(%0) \n" ::"r"(i)); | ||
"\tsq $0, 0(%0) \n" | ||
"\tsq $0, 16(%0) \n" | ||
"\tsq $0, 32(%0) \n" | ||
"\tsq $0, 48(%0) \n" ::"r"(i)); | ||
} | ||
} | ||
|
||
|
@@ -40,32 +62,53 @@ static void wipeUserMem(void) | |
int main(int argc, char *argv[]) | ||
{ | ||
static t_ExecData elfdata; | ||
char *target, *path; | ||
char *args[1]; | ||
int ret; | ||
|
||
if (argc < 1) { // arg1=path to ELF | ||
return -EINVAL; | ||
} | ||
|
||
// Initialize | ||
SifInitRpc(0); | ||
wipeUserMem(); | ||
|
||
if (argc != 2) { // arg1=path to ELF, arg2=partition to mount | ||
SifExitRpc(); | ||
return -EINVAL; | ||
} | ||
|
||
target = argv[0]; | ||
path = argv[1]; | ||
|
||
//Writeback data cache before loading ELF. | ||
FlushCache(0); | ||
ret = SifLoadElf(argv[0], &elfdata); | ||
ret = SifLoadElf(target, &elfdata); | ||
if (ret == 0) { | ||
args[0] = path; | ||
|
||
if (strncmp(path, "hdd", 3) == 0 && (path[3] >= '0' && path[3] <= ':')) { /* Final IOP reset, to fill the IOP with the default modules. | ||
It appears that it was once a thing for the booting software to leave the IOP with the required IOP modules. | ||
This can be seen in OSDSYS v1.0x (no IOP reboot) and the mechanism to boot DVD player updates (OSDSYS will get LoadExecPS2 to load SIO2 modules). | ||
However, it changed with the introduction of the HDD unit, as the software booted may be built with a different SDK revision. | ||
Reboot the IOP, to leave it in a clean & consistent state. | ||
But do not do that for boot targets on other devices, for backward-compatibility with older (homebrew) software. */ | ||
while (!SifIopReset("", 0)) { | ||
}; | ||
while (!SifIopSync()) { | ||
}; | ||
} | ||
|
||
SifExitRpc(); | ||
|
||
FlushCache(0); | ||
FlushCache(2); | ||
|
||
// Following the standard the first parameter of a argv is the executable itself | ||
return ExecPS2((void *)elfdata.epc, (void *)elfdata.gp, argc, argv); | ||
ExecPS2((void *)elfdata.epc, (void *)elfdata.gp, 1, args); | ||
return 0; | ||
} else { | ||
SifExitRpc(); | ||
return -ENOENT; | ||
} | ||
} | ||
|
||
//-------------------------------------------------------------- | ||
//End of func: int main(int argc, char *argv[]) | ||
//-------------------------------------------------------------- | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.