[PS2] Use ps2_drivers library for simplify frontend (#14724)

* Use ps2_drivers

* improvements in frontend driver

* Resetting IOP drivers before load elf
This commit is contained in:
Francisco Javier Trujillo Mata 2022-12-12 05:52:57 +01:00 committed by GitHub
parent b2d73c9bf2
commit b207ddbe84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 538 deletions

View file

@ -84,29 +84,15 @@ $(error "Please set PS2SDK in your environment. export PS2SDK=<path to>ps2sdk")
endif
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include
INCDIR += -Ips2/include -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip
INCDIR += -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip
LDFLAGS += -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -L.
# Lib cdvd is needed to get proper time
LIBS += -lpatches -lgskit -ldmakit -laudsrv -lmtap -lpadx -lz -lcdvd -lelf-loader -lfileXio -lpoweroff
LIBS += -lpatches -lgskit -ldmakit -lps2_drivers -lz -lelf-loader
CFLAGS = $(OPTIMIZE_LV) $(DISABLE_WARNINGS) $(DEFINES) -DPS2 -ffast-math -fsingle-precision-constant
ASFLAGS = $(CFLAGS)
# IRX libs
IRX_FILES += sio2man.irx iomanX.irx fileXio.irx
IRX_FILES += mcman.irx mcserv.irx
IRX_FILES += usbd.irx bdm.irx bdmfs_vfat.irx usbmass_bd.irx
IRX_FILES += libsd.irx audsrv.irx
IRX_FILES += cdfs.irx
IRX_FILES += ps2dev9.irx ps2atad.irx ps2hdd.irx ps2fs.irx poweroff.irx
IRX_FILES += mtapman.irx padman.irx
EE_OBJS += $(IRX_FILES:.irx=_irx.o)
# Missing objecst on the PS2SDK
EE_OBJS += ps2/compat_files/ps2_devices.o
EE_OBJS += $(OBJ)
EE_CFLAGS = $(CFLAGS)
@ -118,7 +104,6 @@ EE_INCS = $(INCDIR)
EE_BIN = $(TARGET).elf
EE_GPVAL = $(GPVAL)
all: $(EE_BIN)
clean:
@ -139,10 +124,6 @@ debug: clean all run
release: all
ps2-packer $(EE_BIN) $(TARGET_RELEASE)
# IRX files
%_irx.c:
$(PS2SDK)/bin/bin2c $(PS2SDK)/iop/irx/$*.irx $@ $*_irx
#Include preferences
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal_cpp

View file

@ -20,15 +20,15 @@ ifeq ($(MUTE_WARNINGS), 1)
endif
INCDIR = -Ilibretro-common/include
INCDIR += -Ips2/include
INCDIR += -I$(PS2SDK)/ports/include
CFLAGS = $(OPTIMIZE_LV) $(DISABLE_WARNINGS) -ffast-math -fsingle-precision-constant
ASFLAGS = $(CFLAGS)
RARCH_DEFINES += -DPS2 -DIS_SALAMANDER -DRARCH_CONSOLE
LIBDIR =
LDFLAGS =
LIBS = -lelf-loader -lpatches -lfileXio -lpoweroff
LDFLAGS += -L$(PS2SDK)/ports/lib
LIBS = -lelf-loader -lps2_drivers -lpatches
ifeq ($(SCREEN_DEBUG), 1)
LIBS += -ldebug
@ -60,16 +60,7 @@ EE_OBJS = frontend/frontend_salamander.o \
libretro-common/vfs/vfs_implementation.o \
libretro-common/hash/lrc_hash.o \
libretro-common/time/rtime.o \
verbosity.o \
ps2/compat_files/ps2_devices.o
# IRX libs
IRX_FILES += sio2man.irx iomanX.irx fileXio.irx
IRX_FILES += mcman.irx mcserv.irx
IRX_FILES += usbd.irx bdm.irx bdmfs_vfat.irx usbmass_bd.irx
IRX_FILES += cdfs.irx
IRX_FILES += ps2dev9.irx ps2atad.irx ps2hdd.irx ps2fs.irx poweroff.irx
EE_OBJS += $(IRX_FILES:.irx=_irx.o)
verbosity.o
EE_CFLAGS = $(CFLAGS)
EE_CXXFLAGS = $(CFLAGS)
@ -93,10 +84,6 @@ run:
release: all
ps2-packer $(EE_BIN) $(TARGET_RELEASE)
# IRX files
%_irx.c:
$(PS2SDK)/bin/bin2c $(PS2SDK)/iop/irx/$*.irx $@ $*_irx
#Include preferences
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal_cpp

View file

@ -16,24 +16,14 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <kernel.h>
#include <sbv_patches.h>
#include <sifrpc.h>
#include <iopcontrol.h>
#include <ps2_devices.h>
#include <ps2_irx_variables.h>
#include <loadfile.h>
#include <elf-loader.h>
#include <ps2_all_drivers.h>
#include <libpwroff.h>
#include <audsrv.h>
#include <libmtap.h>
#include <libpad.h>
#define NEWLIB_PORT_AWARE
#include <fileXio_rpc.h>
#include <fileio.h>
#include <hdd-ioctl.h>
#include <ps2sdkapi.h>
#if defined(SCREEN_DEBUG)
#include <debug.h>
@ -60,12 +50,15 @@
#define DEFAULT_PARTITION "hdd0:__common:pfs"
#endif
static enum frontend_fork ps2_fork_mode = FRONTEND_FORK_NONE;
static char cwd[FILENAME_MAX] = {0};
static char mountString[10] = {0};
static char mountPoint[50] = {0};
static int hdd_mounted = 0;
static int pfsModuleLoaded = 0;
// Disable pthread functionality
PS2_DISABLE_AUTOSTART_PTHREAD();
static enum frontend_fork ps2_fork_mode = FRONTEND_FORK_NONE;
static char cwd[FILENAME_MAX] = {0};
static char mountString[10] = {0};
static char mountPoint[50] = {0};
static enum HDD_MOUNT_STATUS hddMountStatus = HDD_MOUNT_INIT_STATUS_NOT_READY;
static enum HDD_INIT_STATUS hddStatus = HDD_INIT_STATUS_UNKNOWN;
static void create_path_names(void)
{
@ -141,101 +134,63 @@ static void reset_IOP()
sbv_patch_disable_prefix_check();
}
static int hddCheck(void)
/* This method returns true if it can extract needed info from path, otherwise false.
* In case of true, it also updates mountString, mountPoint and newCWD parameters
* It splits path by ":", and requires a minimum of 3 elements
* Example: if path = hdd0:__common:pfs:/retroarch/ then
* mountString = "pfs:"
* mountPoint = "hdd0:__common"
* newCWD = pfs:/retroarch/
* return true
*/
bool getMountInfo(char *path, char *mountString, char *mountPoint, char *newCWD)
{
int ret = fileXioDevctl("hdd0:", HDIOC_STATUS, NULL, 0, NULL, 0);
/* 0 = HDD connected and formatted, 1 = not formatted, 2 = HDD not usable, 3 = HDD not connected. */
if ((ret >= 3) || (ret < 0))
return -1;
return ret;
struct string_list *str_list = string_split(path, ":");
if (str_list->size < 3 )
{
return false;
}
sprintf(mountPoint, "%s:%s", str_list->elems[0].data, str_list->elems[1].data);
sprintf(mountString, "%s:", str_list->elems[2].data);
sprintf(newCWD, "%s%s", mountString, str_list->size == 4 ? str_list->elems[3].data : "");
return true;
}
static void load_hdd_modules()
static void init_drivers(bool extra_drivers)
{
pfsModuleLoaded = 0;
int ret;
char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
ret = SifExecModuleBuffer(&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, NULL);
ret = SifExecModuleBuffer(&ps2atad_irx, size_ps2atad_irx, 0, NULL, NULL);
if (ret < 0)
{
RARCH_WARN("HDD: No HardDisk Drive detected.\n");
return;
}
ret = SifExecModuleBuffer(&ps2hdd_irx, size_ps2hdd_irx, sizeof(hddarg), hddarg, NULL);
if (ret < 0)
{
RARCH_WARN("HDD: No HardDisk Drive detected.\n");
return;
}
/* Check if a HDD unit is connected */
if (hddCheck() < 0)
{
RARCH_WARN("HDD: No HardDisk Drive detected.\n");
return;
}
ret = SifExecModuleBuffer(&ps2fs_irx, size_ps2fs_irx, 0, NULL, NULL);
if (ret < 0)
{
RARCH_WARN("HDD: HardDisk Drive not formatted (PFS).\n");
return;
}
RARCH_LOG("HDDSUPPORT modules loaded\n");
pfsModuleLoaded = 1;
}
static void load_modules()
{
/* I/O Files */
SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, NULL, NULL);
SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, NULL, NULL);
SifExecModuleBuffer(&sio2man_irx, size_sio2man_irx, 0, NULL, NULL);
fileXioInitSkipOverride();
/* Memory Card */
SifExecModuleBuffer(&mcman_irx, size_mcman_irx, 0, NULL, NULL);
SifExecModuleBuffer(&mcserv_irx, size_mcserv_irx, 0, NULL, NULL);
/* USB */
SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, NULL, NULL);
SifExecModuleBuffer(&bdm_irx, size_bdm_irx, 0, NULL, NULL);
SifExecModuleBuffer(&bdmfs_vfat_irx, size_bdmfs_vfat_irx, 0, NULL, NULL);
SifExecModuleBuffer(&usbmass_bd_irx, size_usbmass_bd_irx, 0, NULL, NULL);
/* Power off */
SifExecModuleBuffer(&poweroff_irx, size_poweroff_irx, 0, NULL, NULL);
/* HDD */
load_hdd_modules();
#if !defined(DEBUG)
/* CDFS */
SifExecModuleBuffer(&cdfs_irx, size_cdfs_irx, 0, NULL, NULL);
init_fileXio_driver();
init_memcard_driver(true);
init_usb_driver();
init_cdfs_driver();
bool only_if_booted_from_hdd = true;
#if defined(DEBUG) && !defined(BUILD_FOR_PCSX2)
only_if_booted_from_hdd = false;
#else
init_poweroff_driver();
#endif
hddStatus = init_hdd_driver(false, only_if_booted_from_hdd);
#ifndef IS_SALAMANDER
/* Controllers */
SifExecModuleBuffer(&mtapman_irx, size_mtapman_irx, 0, NULL, NULL);
SifExecModuleBuffer(&padman_irx, size_padman_irx, 0, NULL, NULL);
/* Audio */
SifExecModuleBuffer(&libsd_irx, size_libsd_irx, 0, NULL, NULL);
SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL);
if (extra_drivers)
{
init_audio_driver();
init_joystick_driver(true);
}
#endif
}
static int mount_hdd_partition(void)
static void mount_partition(void)
{
char mount_path[FILENAME_MAX];
char new_cwd[FILENAME_MAX];
int should_mount = 0;
int bootDeviceID = getBootDeviceID(cwd);
if (hddStatus != HDD_INIT_STATUS_IRX_OK)
return;
/* Try to mount HDD partition, either from cwd or default one */
if (bootDeviceID == BOOT_DEVICE_HDD || bootDeviceID == BOOT_DEVICE_HDD0)
{
@ -252,18 +207,19 @@ static int mount_hdd_partition(void)
#endif
if (!should_mount)
return 0;
return;
if (getMountInfo(mount_path, mountString, mountPoint, new_cwd) != 1)
{
RARCH_WARN("Partition info not readed\n");
return 0;
return;
}
if (fileXioMount(mountString, mountPoint, FIO_MT_RDWR) < 0)
hddMountStatus = mount_hdd_partition(mountString, mountPoint);
if (hddMountStatus != HDD_MOUNT_STATUS_OK)
{
RARCH_WARN("Error mount mounting partition %s, %s\n", mountString, mountPoint);
return 0;
return;
}
if (bootDeviceID == BOOT_DEVICE_HDD || bootDeviceID == BOOT_DEVICE_HDD0)
@ -278,26 +234,34 @@ static int mount_hdd_partition(void)
with LoadELFFromFileWithPartition */
strlcpy(mountPoint, "", sizeof(mountPoint));
}
return 1;
}
static void prepare_for_exit(void)
static void deinit_drivers(bool deinit_filesystem, bool deinit_powerOff)
{
if (hdd_mounted)
{
fileXioUmount(mountString);
fileXioDevctl(mountString, PDIOC_CLOSEALL, NULL, 0, NULL, 0);
fileXioDevctl("hdd0:", HDIOC_IDLEIMM, NULL, 0, NULL, 0);
#ifndef IS_SALAMANDER
deinit_audio_driver();
deinit_joystick_driver(false);
#endif
if (deinit_filesystem) {
umount_hdd_partition(mountString);
deinit_hdd_driver(false);
deinit_usb_driver();
deinit_memcard_driver(true);
deinit_fileXio_driver();
hddMountStatus = HDD_MOUNT_INIT_STATUS_NOT_READY;
hddStatus = HDD_INIT_STATUS_UNKNOWN;
}
if (pfsModuleLoaded)
fileXioDevctl("dev9x:", DDIOC_OFF, NULL, 0, NULL, 0);
if (deinit_powerOff)
deinit_poweroff_driver();
}
static void poweroffHandler(void *arg)
{
prepare_for_exit();
deinit_drivers(true, false);
poweroffShutdown();
}
@ -339,79 +303,64 @@ static void frontend_ps2_get_env(int *argc, char *argv[],
#endif
}
static void frontend_ps2_init(void *data)
static void common_init_drivers(bool extra_drivers)
{
reset_IOP();
#if defined(SCREEN_DEBUG)
init_scr();
scr_printf("\n\nStarting RetroArch...\n");
#endif
load_modules();
init_drivers(true);
poweroffInit();
poweroffSetCallback(&poweroffHandler, NULL);
#ifndef IS_SALAMANDER
/* Initializes audsrv library */
if (audsrv_init())
{
RARCH_ERR("audsrv library not initalizated\n");
}
/* Initializes pad un multitap libraries */
if (mtapInit() != 1)
{
RARCH_ERR("mtapInit library not initalizated\n");
}
if (padInit(0) != 1)
{
RARCH_ERR("padInit library not initalizated\n");
}
#endif
getcwd(cwd, sizeof(cwd));
#if !defined(IS_SALAMANDER) && !defined(DEBUG)
/* If it is not Salamander, we need to go one level
* up for setting the CWD. */
path_parent_dir(cwd, strlen(cwd));
#endif
if (pfsModuleLoaded)
hdd_mounted = mount_hdd_partition();
mount_partition();
#if !defined(DEBUG)
waitUntilDeviceIsReady(cwd);
}
static void frontend_ps2_init(void *data)
{
reset_IOP();
#if defined(SCREEN_DEBUG)
init_scr();
scr_printf("\n\nStarting RetroArch...\n");
#endif
common_init_drivers(true);
}
static void frontend_ps2_deinit(void *data)
{
bool deinit_filesystem = false;
#ifndef IS_SALAMANDER
if (ps2_fork_mode == FRONTEND_FORK_NONE)
prepare_for_exit();
if (audsrv_quit())
{
RARCH_ERR("audsrv library not deinitalizated\n");
}
if (padEnd() != 1)
{
RARCH_ERR("padEnd library not deinitalizated\n");
}
deinit_filesystem = true;
#endif
deinit_drivers(deinit_filesystem, true);
}
static void frontend_ps2_exec(const char *path, bool should_load_game)
{
int args = 0;
static char *argv[1];
char *argv[1];
RARCH_LOG("Attempt to load executable: [%s], partition [%s].\n", path, mountPoint);
/* Reload IOP drivers for saving IOP ram */
reset_IOP();
common_init_drivers(false);
waitUntilDeviceIsReady(path);
#ifndef IS_SALAMANDER
char game_path[FILENAME_MAX];
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT))
{
args++;
argv[0] = (char *)path_get(RARCH_PATH_CONTENT);
const char *content = path_get(RARCH_PATH_CONTENT);
strlcpy(game_path, content, sizeof(game_path));
argv[0] = game_path;
RARCH_LOG("Attempt to load executable: [%s], partition [%s] with game [%s]\n", path, mountPoint, game_path);
}
#endif
LoadELFFromFileWithPartition(path, mountPoint, args, argv);
@ -469,7 +418,7 @@ static int frontend_ps2_get_rating(void) { return 10; }
enum frontend_architecture frontend_ps2_get_arch(void)
{
return FRONTEND_ARCH_MIPS;
return FRONTEND_ARCH_MIPS;
}
static int frontend_ps2_parse_drive_list(void *data, bool load_content)
@ -501,7 +450,7 @@ static int frontend_ps2_parse_drive_list(void *data, bool load_content)
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
enum_idx,
FILE_TYPE_DIRECTORY, 0, 0, NULL);
if (hdd_mounted)
if (hddMountStatus == HDD_MOUNT_STATUS_OK)
{
size_t _len = strlcpy(hdd, mountString, sizeof(hdd));
hdd[_len ] = '/';

View file

@ -1,204 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <ps2_devices.h>
#include <stdio.h>
#include <stdlib.h>
#include <kernel.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <lists/string_list.h>
#define DEVICE_SLASH "/"
#define DEVICE_MC0 "mc0:"
#define DEVICE_MC1 "mc1:"
#define DEVICE_CDROM "cdrom0:"
#define DEVICE_CDFS "cdfs:"
#define DEVICE_MASS "mass:"
#define DEVICE_MASS0 "mass0:"
#define DEVICE_HDD "hdd:"
#define DEVICE_HDD0 "hdd0:"
#define DEVICE_HOST "host:"
#define DEVICE_HOST0 "host0:"
#define DEVICE_HOST1 "host1:"
#define DEVICE_HOST2 "host2:"
#define DEVICE_HOST3 "host3:"
#define DEVICE_HOST4 "host4:"
#define DEVICE_HOST5 "host5:"
#define DEVICE_HOST6 "host6:"
#define DEVICE_HOST7 "host7:"
#define DEVICE_HOST8 "host8:"
#define DEVICE_HOST9 "host9:"
#define DEVICE_MC0_PATH DEVICE_MC0 DEVICE_SLASH
#define DEVICE_MC1_PATH DEVICE_MC1 DEVICE_SLASH
#define DEVICE_CDFS_PATH DEVICE_CDFS DEVICE_SLASH
#define DEVICE_CDROM_PATH DEVICE_CDROM DEVICE_SLASH
#define DEVICE_MASS_PATH DEVICE_MASS DEVICE_SLASH
#define DEVICE_MASS0_PATH DEVICE_MASS0 DEVICE_SLASH
#define DEVICE_HDD_PATH DEVICE_HDD DEVICE_SLASH
#define DEVICE_HDD0_PATH DEVICE_HDD0 DEVICE_SLASH
#define DEVICE_HOST_PATH DEVICE_HOST DEVICE_SLASH
#define DEVICE_HOST0_PATH DEVICE_HOST0 DEVICE_SLASH
#define DEVICE_HOST1_PATH DEVICE_HOST1 DEVICE_SLASH
#define DEVICE_HOST2_PATH DEVICE_HOST2 DEVICE_SLASH
#define DEVICE_HOST3_PATH DEVICE_HOST3 DEVICE_SLASH
#define DEVICE_HOST4_PATH DEVICE_HOST4 DEVICE_SLASH
#define DEVICE_HOST5_PATH DEVICE_HOST5 DEVICE_SLASH
#define DEVICE_HOST6_PATH DEVICE_HOST6 DEVICE_SLASH
#define DEVICE_HOST7_PATH DEVICE_HOST7 DEVICE_SLASH
#define DEVICE_HOST8_PATH DEVICE_HOST8 DEVICE_SLASH
#define DEVICE_HOST9_PATH DEVICE_HOST9 DEVICE_SLASH
char *rootDevicePath(enum BootDeviceIDs device_id)
{
switch (device_id)
{
case BOOT_DEVICE_MC0:
return DEVICE_MC0_PATH;
case BOOT_DEVICE_MC1:
return DEVICE_MC1_PATH;
case BOOT_DEVICE_CDROM:
return DEVICE_CDROM_PATH;
case BOOT_DEVICE_CDFS:
return DEVICE_CDFS_PATH;
case BOOT_DEVICE_MASS:
return DEVICE_MASS_PATH;
case BOOT_DEVICE_MASS0:
return DEVICE_MASS_PATH;
case BOOT_DEVICE_HDD:
return DEVICE_HDD_PATH;
case BOOT_DEVICE_HDD0:
return DEVICE_HDD0_PATH;
case BOOT_DEVICE_HOST:
return DEVICE_HOST_PATH;
case BOOT_DEVICE_HOST0:
return DEVICE_HOST0_PATH;
case BOOT_DEVICE_HOST1:
return DEVICE_HOST1_PATH;
case BOOT_DEVICE_HOST2:
return DEVICE_HOST2_PATH;
case BOOT_DEVICE_HOST3:
return DEVICE_HOST3_PATH;
case BOOT_DEVICE_HOST4:
return DEVICE_HOST4_PATH;
case BOOT_DEVICE_HOST5:
return DEVICE_HOST5_PATH;
case BOOT_DEVICE_HOST6:
return DEVICE_HOST6_PATH;
case BOOT_DEVICE_HOST7:
return DEVICE_HOST7_PATH;
case BOOT_DEVICE_HOST8:
return DEVICE_HOST8_PATH;
case BOOT_DEVICE_HOST9:
return DEVICE_HOST9_PATH;
default:
return "";
}
}
enum BootDeviceIDs getBootDeviceID(char *path)
{
if (!strncmp(path, DEVICE_MC0, 4))
return BOOT_DEVICE_MC0;
else if (!strncmp(path, DEVICE_MC1, 4))
return BOOT_DEVICE_MC1;
else if (!strncmp(path, DEVICE_CDROM, 7))
return BOOT_DEVICE_CDROM;
else if (!strncmp(path, DEVICE_CDFS, 5))
return BOOT_DEVICE_CDFS;
else if (!strncmp(path, DEVICE_MASS, 5))
return BOOT_DEVICE_MASS;
else if (!strncmp(path, DEVICE_MASS0, 6))
return BOOT_DEVICE_MASS0;
else if (!strncmp(path, DEVICE_HDD, 4))
return BOOT_DEVICE_HDD;
else if (!strncmp(path, DEVICE_HDD0, 5))
return BOOT_DEVICE_HDD0;
else if (!strncmp(path, DEVICE_HOST, 5))
return BOOT_DEVICE_HOST;
else if (!strncmp(path, DEVICE_HOST0, 6))
return BOOT_DEVICE_HOST0;
else if (!strncmp(path, DEVICE_HOST1, 6))
return BOOT_DEVICE_HOST1;
else if (!strncmp(path, DEVICE_HOST2, 6))
return BOOT_DEVICE_HOST2;
else if (!strncmp(path, DEVICE_HOST3, 6))
return BOOT_DEVICE_HOST3;
else if (!strncmp(path, DEVICE_HOST4, 6))
return BOOT_DEVICE_HOST4;
else if (!strncmp(path, DEVICE_HOST5, 6))
return BOOT_DEVICE_HOST5;
else if (!strncmp(path, DEVICE_HOST6, 6))
return BOOT_DEVICE_HOST6;
else if (!strncmp(path, DEVICE_HOST7, 6))
return BOOT_DEVICE_HOST7;
else if (!strncmp(path, DEVICE_HOST8, 6))
return BOOT_DEVICE_HOST8;
else if (!strncmp(path, DEVICE_HOST9, 6))
return BOOT_DEVICE_HOST9;
else
return BOOT_DEVICE_UNKNOWN;
}
/* This method returns true if it can extract needed info from path, otherwise false.
* In case of true, it also updates mountString, mountPoint and newCWD parameters
* It splits path by ":", and requires a minimum of 3 elements
* Example: if path = hdd0:__common:pfs:/retroarch/ then
* mountString = "pfs:"
* mountPoint = "hdd0:__common"
* newCWD = pfs:/retroarch/
* return true
*/
bool getMountInfo(char *path, char *mountString, char *mountPoint, char *newCWD)
{
struct string_list *str_list = string_split(path, ":");
if (str_list->size < 3 )
{
return false;
}
sprintf(mountPoint, "%s:%s", str_list->elems[0].data, str_list->elems[1].data);
sprintf(mountString, "%s:", str_list->elems[2].data);
sprintf(newCWD, "%s%s", mountString, str_list->size == 4 ? str_list->elems[3].data : "");
return true;
}
/* HACK! If booting from a USB device, keep trying to
* open this program again until it succeeds.
*
* This will ensure that the emulator will be able to load its files.
*/
bool waitUntilDeviceIsReady(char *path)
{
struct stat buffer;
int ret = -1;
int retries = 50;
while(ret != 0 && retries > 0)
{
ret = stat(path, &buffer);
/* Wait untill the device is ready */
nopdelay();
retries--;
}
return ret == 0;
}

View file

@ -1,52 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PS2_DEVICES_H
#define PS2_DEVICES_H
#include <stdbool.h>
enum BootDeviceIDs{
BOOT_DEVICE_UNKNOWN = -1,
BOOT_DEVICE_MC0 = 0,
BOOT_DEVICE_MC1,
BOOT_DEVICE_CDROM,
BOOT_DEVICE_CDFS,
BOOT_DEVICE_MASS,
BOOT_DEVICE_MASS0,
BOOT_DEVICE_HDD,
BOOT_DEVICE_HDD0,
BOOT_DEVICE_HOST,
BOOT_DEVICE_HOST0,
BOOT_DEVICE_HOST1,
BOOT_DEVICE_HOST2,
BOOT_DEVICE_HOST3,
BOOT_DEVICE_HOST4,
BOOT_DEVICE_HOST5,
BOOT_DEVICE_HOST6,
BOOT_DEVICE_HOST7,
BOOT_DEVICE_HOST8,
BOOT_DEVICE_HOST9,
BOOT_DEVICE_COUNT,
};
char *rootDevicePath(enum BootDeviceIDs device_id);
enum BootDeviceIDs getBootDeviceID(char *path);
bool getMountInfo(char *path, char *mountString, char *mountPoint, char *newCWD);
bool waitUntilDeviceIsReady(char *path);
#endif

View file

@ -1,87 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PS2_IRX_VARIABLES_H
#define PS2_IRX_VARIABLES_H
extern unsigned char sio2man_irx[] __attribute__((aligned(16)));
extern unsigned int size_sio2man_irx;
extern unsigned char mcman_irx[] __attribute__((aligned(16)));
extern unsigned int size_mcman_irx;
extern unsigned char mcserv_irx[] __attribute__((aligned(16)));
extern unsigned int size_mcserv_irx;
extern unsigned char mtapman_irx[] __attribute__((aligned(16)));
extern unsigned int size_mtapman_irx;
extern unsigned char padman_irx[] __attribute__((aligned(16)));
extern unsigned int size_padman_irx;
extern unsigned char iomanX_irx[] __attribute__((aligned(16)));
extern unsigned int size_iomanX_irx;
extern unsigned char fileXio_irx[] __attribute__((aligned(16)));
extern unsigned int size_fileXio_irx;
extern unsigned char ps2dev9_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2dev9_irx;
extern unsigned char ps2atad_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2atad_irx;
extern unsigned char ps2hdd_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2hdd_irx;
extern unsigned char ps2fs_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2fs_irx;
extern unsigned char usbd_irx[] __attribute__((aligned(16)));
extern unsigned int size_usbd_irx;
extern unsigned char bdm_irx[] __attribute__((aligned(16)));
extern unsigned int size_bdm_irx;
extern unsigned char bdmfs_vfat_irx[] __attribute__((aligned(16)));
extern unsigned int size_bdmfs_vfat_irx;
extern unsigned char usbmass_bd_irx[] __attribute__((aligned(16)));
extern unsigned int size_usbmass_bd_irx;
extern unsigned char cdfs_irx[] __attribute__((aligned(16)));
extern unsigned int size_cdfs_irx;
extern unsigned char libsd_irx[] __attribute__((aligned(16)));
extern unsigned int size_libsd_irx;
extern unsigned char audsrv_irx[] __attribute__((aligned(16)));
extern unsigned int size_audsrv_irx;
extern unsigned char ps2dev9_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2dev9_irx;
extern unsigned char ps2atad_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2atad_irx;
extern unsigned char ps2hdd_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2hdd_irx;
extern unsigned char ps2fs_irx[] __attribute__((aligned(16)));
extern unsigned int size_ps2fs_irx;
extern unsigned char poweroff_irx[] __attribute__((aligned(16)));
extern unsigned int size_poweroff_irx;
#endif /* PS2_IRX_VARIABLES_H */