Skip to content

Commit 9f497c8

Browse files
committed
[irx loader] fix irx load error check and use the error description
1 parent 8480c35 commit 9f497c8

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

engine/inc/irx/irx_loader.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#pragma once
1212

1313
#include <tamtypes.h>
14+
#include <map>
1415

1516
namespace Tyra {
1617

@@ -34,6 +35,8 @@ class IrxLoader {
3435
int applyRpcPatches();
3536
void waitUntilUsbDeviceIsReady();
3637
void delay(int count);
38+
std::string GetIrxErrorDescription(const int ID, const int RET);
39+
std::map<int, std::string>IOPErrors;
3740
};
3841

3942
} // namespace Tyra

engine/src/irx/irx_loader.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ std::map<int, std::string>IrxLoader::IOPErrors = {
137137
*/
138138
std::string IrxLoader::GetIrxErrorDescription(const int ID, const int RET = 0) {
139139
if (RET == 1) return "Module willingly requested to be unloaded from IOP";
140-
return IOPErrors[ID]
140+
return IrxLoader::IOPErrors[ID]
141141
}
142142

143143
void IrxLoader::loadAll(const bool& withUsb, const bool& isLoggingToFile) {
@@ -186,26 +186,26 @@ int IrxLoader::applyRpcPatches() {
186186
void IrxLoader::loadLibsd(const bool& verbose) {
187187
if (verbose) TYRA_LOG("IRX: Loading libsd...");
188188

189-
int ret;
190-
SifExecModuleBuffer(&libsd_irx, size_libsd_irx, 0, nullptr, &ret);
191-
TYRA_ASSERT(ret >= 0, "Failed to load module: libsd_irx");
189+
int ret, id;
190+
id = SifExecModuleBuffer(&libsd_irx, size_libsd_irx, 0, nullptr, &ret);
191+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: libsd_irx", IrxLoader::GetIrxErrorDescription(id, ret));
192192

193193
if (verbose) TYRA_LOG("IRX: Libsd loaded!");
194194
}
195195

196196
void IrxLoader::loadIO(const bool& verbose) {
197-
int ret;
197+
int ret, id;
198198
if (verbose) TYRA_LOG("IRX: Loading iomanX...");
199199

200-
SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, nullptr, &ret);
201-
TYRA_ASSERT(ret >= 0, "Failed to load module: iomanX_irx");
200+
id = SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, nullptr, &ret);
201+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: iomanX_irx", IrxLoader::GetIrxErrorDescription(id, ret));
202202

203203
if (verbose) TYRA_LOG("IRX: iomanX loaded!");
204204

205205
if (verbose) TYRA_LOG("IRX: Loading fileXio...");
206206

207207
SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, nullptr, &ret);
208-
TYRA_ASSERT(ret >= 0, "Failed to load module: fileXio_irx");
208+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: fileXio_irx", IrxLoader::GetIrxErrorDescription(id, ret));
209209

210210
if (verbose) TYRA_LOG("IRX: fileXio_irx loaded!");
211211

@@ -214,19 +214,19 @@ void IrxLoader::loadIO(const bool& verbose) {
214214
void IrxLoader::loadUsbModules(const bool& verbose) {
215215
if (verbose) TYRA_LOG("IRX: Loading usb modules...");
216216

217-
int ret;
217+
int ret, id;
218218

219219
SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, nullptr, &ret);
220-
TYRA_ASSERT(ret >= 0, "Failed to load module: usbd_irx");
220+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: usbd_irx", IrxLoader::GetIrxErrorDescription(id, ret));
221221

222222
SifExecModuleBuffer(&bdm_irx, size_bdm_irx, 0, nullptr, &ret);
223-
TYRA_ASSERT(ret >= 0, "Failed to load module: bdm_irx");
223+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: bdm_irx", IrxLoader::GetIrxErrorDescription(id, ret));
224224

225225
SifExecModuleBuffer(&bdmfs_fatfs_irx, size_bdmfs_fatfs_irx, 0, nullptr, &ret);
226-
TYRA_ASSERT(ret >= 0, "Failed to load module: bdmfs_fatfs");
226+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: bdmfs_fatfs_irx", IrxLoader::GetIrxErrorDescription(id, ret));
227227

228228
SifExecModuleBuffer(&usbmass_bd_irx, size_usbmass_bd_irx, 0, nullptr, &ret);
229-
TYRA_ASSERT(ret >= 0, "Failed to load module: usbmass");
229+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: usbmass_bd_irx", IrxLoader::GetIrxErrorDescription(id, ret));
230230

231231
waitUntilUsbDeviceIsReady();
232232

@@ -236,29 +236,29 @@ void IrxLoader::loadUsbModules(const bool& verbose) {
236236
void IrxLoader::loadAudsrv(const bool& verbose) {
237237
if (verbose) TYRA_LOG("IRX: Loading audsrv...");
238238

239-
int ret;
239+
int ret, id;
240240
SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, nullptr, &ret);
241-
TYRA_ASSERT(ret >= 0, "Failed to load module: audsrv_irx");
241+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: audsrv_irx", IrxLoader::GetIrxErrorDescription(id, ret));
242242

243243
if (verbose) TYRA_LOG("IRX: Audsrv loaded!");
244244
}
245245

246246
void IrxLoader::loadSio2man(const bool& verbose) {
247247
if (verbose) TYRA_LOG("IRX: Loading sio2man...");
248248

249-
int ret;
249+
int ret, id;
250250
SifExecModuleBuffer(&sio2man_irx, size_sio2man_irx, 0, nullptr, &ret);
251-
TYRA_ASSERT(ret >= 0, "Failed to load module: sio2man_irx");
251+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: sio2man_irx", IrxLoader::GetIrxErrorDescription(id, ret));
252252

253253
if (verbose) TYRA_LOG("IRX: Sio2man loaded!");
254254
}
255255

256256
void IrxLoader::loadPadman(const bool& verbose) {
257257
if (verbose) TYRA_LOG("IRX: Loading padman...");
258258

259-
int ret;
259+
int ret, id;
260260
SifExecModuleBuffer(&padman_irx, size_padman_irx, 0, nullptr, &ret);
261-
TYRA_ASSERT(ret >= 0, "Failed to load module: padman_irx");
261+
TYRA_ASSERT(ret == 1 || id < 0, "Failed to load module: padman_irx", IrxLoader::GetIrxErrorDescription(id, ret));
262262

263263
if (verbose) TYRA_LOG("IRX: Padman loaded!");
264264
}

0 commit comments

Comments
 (0)