Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File xio improvements #21

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions ee/loader/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ _off64_t lseek64 (int __filedes, _off64_t __offset, int __whence); // should be
#include <loadfile.h>
#include <iopcontrol.h>
#include <libcdvd-common.h>
#include <file-advanced.h>

// Other
#include "elf.h"
Expand All @@ -36,6 +37,9 @@ _off64_t lseek64 (int __filedes, _off64_t __offset, int __whence); // should be
DISABLE_PATCHED_FUNCTIONS(); // Disable the patched functionalities
DISABLE_EXTRA_TIMERS_FUNCTIONS(); // Disable the extra functionalities for timers
PS2_DISABLE_AUTOSTART_PTHREAD(); // Disable pthread functionality
void _libcglue_timezone_update() {}; // Disable timezone update

FILE_SWAP_PS2SDK_FUNCTIONS(); // Swap PS2SDK functions from fileIO to fileXio once the IOP modules are loaded

#define OPL_MOD_STORAGE 0x00097000 //(default) Address of the module storage region
/*
Expand Down Expand Up @@ -759,11 +763,14 @@ void *modlist_get_settings(struct SModList *ml, const char *name)

int fhi_bdm_add_file_by_fd(struct fhi_bdm *bdm, int fhi_fid, int fd)
{
int i;
int i, iop_fd;
off_t size;
unsigned int frag_start = 0;
struct fhi_bdm_fragfile *frag = &bdm->fragfile[fhi_fid];

// Get actual IOP fd
iop_fd = ps2sdk_get_iop_fd(fd);

// Get file size
size = lseek64(fd, 0, SEEK_END);

Expand All @@ -773,7 +780,7 @@ int fhi_bdm_add_file_by_fd(struct fhi_bdm *bdm, int fhi_fid, int fd)

// Set fragment file
frag->frag_start = frag_start;
frag->frag_count = fileXioIoctl2(fd, USBMASS_IOCTL_GET_FRAGLIST, NULL, 0, (void *)&bdm->frags[frag->frag_start], sizeof(bd_fragment_t) * (BDM_MAX_FRAGS - frag->frag_start));
frag->frag_count = fileXioIoctl2(iop_fd, USBMASS_IOCTL_GET_FRAGLIST, NULL, 0, (void *)&bdm->frags[frag->frag_start], sizeof(bd_fragment_t) * (BDM_MAX_FRAGS - frag->frag_start));
frag->size = size;

// Check for max fragments
Expand All @@ -789,8 +796,8 @@ int fhi_bdm_add_file_by_fd(struct fhi_bdm *bdm, int fhi_fid, int fd)

// Set BDM driver name and number
// NOTE: can be set only once! Check?
bdm->drvName = (uint32_t)fileXioIoctl2(fd, USBMASS_IOCTL_GET_DRIVERNAME, NULL, 0, NULL, 0);
fileXioIoctl2(fd, USBMASS_IOCTL_GET_DEVICE_NUMBER, NULL, 0, &bdm->devNr, 4);
bdm->drvName = (uint32_t)fileXioIoctl2(iop_fd, USBMASS_IOCTL_GET_DRIVERNAME, NULL, 0, NULL, 0);
fileXioIoctl2(iop_fd, USBMASS_IOCTL_GET_DEVICE_NUMBER, NULL, 0, &bdm->devNr, 4);
char *drvName = (char *)&bdm->drvName;
printf("Using BDM device: %s%d\n", drvName, (int)bdm->devNr);

Expand Down Expand Up @@ -1032,7 +1039,7 @@ int main(int argc, char *argv[])
*/
printf("Reboot IOP into Load Environment (LE)\n");
#if 1
//fileXioExit();
//swapToFileIO();
SifExitIopHeap();
SifLoadFileExit();
SifExitRpc();
Expand All @@ -1053,7 +1060,7 @@ int main(int argc, char *argv[])
if (modlist_start(&drv.mod_all_env) < 0)
return -1;
if (modlist_get_by_name(&drv.mod_l_env, "fileXio.irx") != NULL)
fileXioInit();
swapToFileXio();

// FAKEMOD optional module
// Only loaded when modules need to be faked
Expand Down