irx, nullptr, threading patch
This commit is contained in:
@@ -16,8 +16,23 @@
|
||||
#include <kernel.h>
|
||||
#include <sifrpc.h>
|
||||
#include <sbv_patches.h>
|
||||
#include <iopcontrol.h>
|
||||
#include "file/file_utils.hpp"
|
||||
|
||||
// external IRX modules
|
||||
|
||||
extern u8 sio2man_irx[];
|
||||
extern int size_sio2man_irx;
|
||||
|
||||
extern u8 padman_irx[];
|
||||
extern int size_padman_irx;
|
||||
|
||||
extern u8 audsrv_irx[];
|
||||
extern int size_audsrv_irx;
|
||||
|
||||
extern u8 libsd_irx[];
|
||||
extern int size_libsd_irx;
|
||||
|
||||
extern u8 bdm_irx[];
|
||||
extern int size_bdm_irx;
|
||||
|
||||
@@ -32,19 +47,41 @@ extern int size_usbmass_bd_irx;
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
bool IrxLoader::isLoaded = false;
|
||||
|
||||
IrxLoader::IrxLoader() {
|
||||
SifInitRpc(0);
|
||||
|
||||
while (!SifIopReset("", 0)) {
|
||||
};
|
||||
while (!SifIopSync()) {
|
||||
};
|
||||
|
||||
SifInitRpc(0);
|
||||
|
||||
this->applyRpcPatches();
|
||||
}
|
||||
|
||||
IrxLoader::~IrxLoader() {}
|
||||
|
||||
void IrxLoader::loadDefaultDrivers() {
|
||||
this->loadAudio();
|
||||
this->loadPad();
|
||||
}
|
||||
void IrxLoader::loadAll(const bool& withUsb, const bool& isLoggingToFile) {
|
||||
if (isLoaded) {
|
||||
TYRA_LOG("IRX modules already loaded!");
|
||||
return;
|
||||
}
|
||||
|
||||
void IrxLoader::loadUSBDriver() { this->loadUsb(); }
|
||||
loadSio2man(!isLoggingToFile);
|
||||
loadPadman(!isLoggingToFile);
|
||||
loadLibsd(!isLoggingToFile);
|
||||
|
||||
if (withUsb) {
|
||||
loadUsbModules(!isLoggingToFile);
|
||||
}
|
||||
|
||||
loadAudsrv(true);
|
||||
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Apply the SBV LMB patch to allow modules to be loaded from a buffer in
|
||||
@@ -53,7 +90,6 @@ void IrxLoader::loadUSBDriver() { this->loadUsb(); }
|
||||
*/
|
||||
int IrxLoader::applyRpcPatches() {
|
||||
int ret;
|
||||
TYRA_LOG("Applying SBV Patches");
|
||||
|
||||
ret = sbv_patch_enable_lmb();
|
||||
TYRA_ASSERT(ret >= 0,
|
||||
@@ -67,65 +103,69 @@ int IrxLoader::applyRpcPatches() {
|
||||
ret = sbv_patch_fileio();
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load Applying SBV Patches sbv_patch_fileio");
|
||||
|
||||
TYRA_LOG("SBV Patches applyed ");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int IrxLoader::loadUsb() {
|
||||
void IrxLoader::loadLibsd(const bool& verbose) {
|
||||
if (verbose) TYRA_LOG("IRX: Loading libsd...");
|
||||
|
||||
int ret;
|
||||
TYRA_LOG("Loading USB modules");
|
||||
SifExecModuleBuffer(&libsd_irx, size_libsd_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: libsd_irx");
|
||||
|
||||
// Load Block Device Manager (BDM)
|
||||
SifExecModuleBuffer(&bdm_irx, size_bdm_irx, 0, NULL, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: usbhdfsd");
|
||||
|
||||
// Load FATFS (mass:) driver
|
||||
SifExecModuleBuffer(&bdmfs_fatfs_irx, size_bdmfs_fatfs_irx, 0, NULL, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: usbd");
|
||||
|
||||
// Load USB Block Device drivers
|
||||
SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, NULL, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: usbd");
|
||||
|
||||
SifExecModuleBuffer(&usbmass_bd_irx, size_usbmass_bd_irx, 0, NULL, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: usbhdfsd");
|
||||
|
||||
this->waitUntilUsbDeviceIsReady();
|
||||
|
||||
TYRA_LOG("USB/MASS modules loaded!");
|
||||
|
||||
return ret;
|
||||
if (verbose) TYRA_LOG("IRX: Libsd loaded!");
|
||||
}
|
||||
|
||||
int IrxLoader::loadAudio() {
|
||||
void IrxLoader::loadUsbModules(const bool& verbose) {
|
||||
if (verbose) TYRA_LOG("IRX: Loading usb modules...");
|
||||
|
||||
int ret;
|
||||
|
||||
TYRA_LOG("Modules loading started (LIBSD, AUDSRV)");
|
||||
ret = SifLoadModule("rom0:LIBSD", 0, NULL);
|
||||
TYRA_ASSERT(ret != -203, "LIBSD loading failed!");
|
||||
SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: usbd_irx");
|
||||
|
||||
ret = SifLoadModule("host:audsrv.irx", 0, NULL);
|
||||
TYRA_ASSERT(ret != -203, "audsrv.irx loading failed!");
|
||||
TYRA_LOG("Audio modules loaded");
|
||||
SifExecModuleBuffer(&bdm_irx, size_bdm_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: bdm_irx");
|
||||
|
||||
return ret;
|
||||
SifExecModuleBuffer(&bdmfs_fatfs_irx, size_bdmfs_fatfs_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: bdmfs_fatfs");
|
||||
|
||||
SifExecModuleBuffer(&usbmass_bd_irx, size_usbmass_bd_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: usbmass");
|
||||
|
||||
waitUntilUsbDeviceIsReady();
|
||||
|
||||
if (verbose) TYRA_LOG("IRX: Usb modules loaded!");
|
||||
}
|
||||
|
||||
int IrxLoader::loadPad() {
|
||||
void IrxLoader::loadAudsrv(const bool& verbose) {
|
||||
if (verbose) TYRA_LOG("IRX: Loading audsrv...");
|
||||
|
||||
int ret;
|
||||
SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: audsrv_irx");
|
||||
|
||||
TYRA_LOG("PAD Modules loading started (SIO2MAN, PADMAN)");
|
||||
if (verbose) TYRA_LOG("IRX: Audsrv loaded!");
|
||||
}
|
||||
|
||||
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
||||
TYRA_ASSERT(ret >= 0,
|
||||
"SifLoadModule (SIO2MAN) failed! Returned value: ", ret);
|
||||
void IrxLoader::loadSio2man(const bool& verbose) {
|
||||
if (verbose) TYRA_LOG("IRX: Loading sio2man...");
|
||||
|
||||
ret = SifLoadModule("rom0:PADMAN", 0, NULL);
|
||||
TYRA_ASSERT(ret >= 0, "SifLoadModule (PADMAN) failed! Returned value: ", ret);
|
||||
int ret;
|
||||
SifExecModuleBuffer(&sio2man_irx, size_sio2man_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: sio2man_irx");
|
||||
|
||||
TYRA_LOG("Pad modules loaded!");
|
||||
if (verbose) TYRA_LOG("IRX: Sio2man loaded!");
|
||||
}
|
||||
|
||||
return ret;
|
||||
void IrxLoader::loadPadman(const bool& verbose) {
|
||||
if (verbose) TYRA_LOG("IRX: Loading padman...");
|
||||
|
||||
int ret;
|
||||
SifExecModuleBuffer(&padman_irx, size_padman_irx, 0, nullptr, &ret);
|
||||
TYRA_ASSERT(ret >= 0, "Failed to load module: padman_irx");
|
||||
|
||||
if (verbose) TYRA_LOG("IRX: Padman loaded!");
|
||||
}
|
||||
|
||||
void IrxLoader::delay(int count) {
|
||||
|
||||
Reference in New Issue
Block a user