mirror of
https://github.com/libretro/RetroArch
synced 2025-03-16 07:21:03 +00:00
Merge pull request #8482 from fjtrujy/feature/CDFSSupport
[PS2] CDFS Support
This commit is contained in:
commit
2d838a7e76
4
.gitignore
vendored
4
.gitignore
vendored
@ -165,6 +165,10 @@ retroarch_switch.nacp
|
||||
retroarch_switch.nro
|
||||
retroarch_switch.nso
|
||||
|
||||
# PS2
|
||||
ps2/irx/*.c
|
||||
ps2/libcdvd/lib/
|
||||
|
||||
# Wayland
|
||||
gfx/common/wayland/idle-inhibit-unstable-v1.c
|
||||
gfx/common/wayland/idle-inhibit-unstable-v1.h
|
||||
|
46
Makefile.ps2
46
Makefile.ps2
@ -5,16 +5,19 @@ HAVE_LOGGER = 0
|
||||
HAVE_FILE_LOGGER = 0
|
||||
HAVE_THREADS = 0
|
||||
BIG_STACK = 0
|
||||
MUTE_WARNINGS = 0
|
||||
MUTE_WARNINGS = 1
|
||||
PS2_IP = 192.168.1.150
|
||||
|
||||
#Configuration for IRX
|
||||
EE_BIN2O = bin2o
|
||||
IRX_DIR = $(PS2SDK)/iop/irx
|
||||
|
||||
TARGET = retroarchps2.elf
|
||||
TARGET_RELEASE = retroarchps2-release.elf
|
||||
|
||||
# Lib CDVD
|
||||
CDVD_DIR = ps2/libcdvd
|
||||
|
||||
# Compile the IRXs first
|
||||
IRX_DIR = ps2/irx
|
||||
IRX_FILES = $(wildcard ps2/irx/*.c)
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
OPTIMIZE_LV := -O0 -g
|
||||
RARCH_DEFINES += -DDEBUG
|
||||
@ -27,7 +30,7 @@ ifeq ($(MUTE_WARNINGS), 1)
|
||||
DISABLE_WARNINGS := -Wno-sign-compare -Wno-unused -Wno-parentheses
|
||||
endif
|
||||
|
||||
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include
|
||||
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(CDVD_DIR)/ee
|
||||
INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include
|
||||
INCDIR += -Ideps -Ideps/stb -Ideps/libz -Ideps/7zip -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper
|
||||
GPVAL = -G0
|
||||
@ -38,14 +41,10 @@ RARCH_DEFINES += -DPS2 -DUSE_IOP_CTYPE_MACRO -D_MIPS_ARCH_R5900 -DHAVE_ZLIB -DHA
|
||||
RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L.
|
||||
LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lmf -lpad -lmc -lhdd -lsdl -lfileXio -lpatches -lpoweroff
|
||||
LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L$(CDVD_DIR)/lib -L.
|
||||
LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lmf -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio
|
||||
LIBS += -lcdvdfs -lpatches -lpoweroff
|
||||
|
||||
#IRX modules
|
||||
# IRX modules - modules have to be in IRX_DIR
|
||||
IRX = iomanX.irx fileXio.irx mcman.irx mcserv.irx usbd.irx usbhdfsd.irx freesd.irx audsrv.irx poweroff.irx ps2dev9.irx ps2atad.irx ps2hdd.irx ps2fs.irx
|
||||
IRX_OBJ = $(IRX:.irx=.o)
|
||||
EE_OBJS += $(IRX_OBJ)
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
RARCH_DEFINES += -DHAVE_THREADS
|
||||
@ -65,8 +64,15 @@ endif
|
||||
|
||||
CFLAGS += $(RARCH_DEFINES)
|
||||
|
||||
# All the IRX objects
|
||||
EE_OBJS += $(IRX_DIR)/freemtap_irx.o $(IRX_DIR)/freepad_irx.o $(IRX_DIR)/freesio2_irx.o $(IRX_DIR)/iomanX_irx.o
|
||||
EE_OBJS += $(IRX_DIR)/fileXio_irx.o $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o $(IRX_DIR)/usbd_irx.o
|
||||
EE_OBJS += $(IRX_DIR)/usbhdfsd_irx.o $(IRX_DIR)/freesd_irx.o $(IRX_DIR)/audsrv_irx.o $(IRX_DIR)/poweroff_irx.o
|
||||
EE_OBJS += $(IRX_DIR)/cdvd_irx.o
|
||||
|
||||
# Missing objecst on the PS2SDK
|
||||
EE_OBJS += ps2/compat_files/compat_ctype.o ps2/compat_files/time.o ps2/compat_files/ps2_devices.o
|
||||
EE_OBJS += ps2/compat_files/compat_ctype.o ps2/compat_files/time.o ps2/compat_files/ps2_devices.o
|
||||
EE_OBJS += ps2/compat_files/fileXio_cdvd.o ps2/compat_files/ps2_descriptor.o
|
||||
|
||||
#EE_OBJS = griffin/griffin.o bootstrap/ps2/kernel_functions.o
|
||||
EE_OBJS += griffin/griffin.o
|
||||
@ -77,14 +83,18 @@ EE_LDFLAGS = $(LDFLAGS)
|
||||
EE_LIBS = $(LIBS)
|
||||
EE_ASFLAGS = $(ASFLAGS)
|
||||
EE_INCS = $(INCDIR)
|
||||
EE_IRX_OBJ = $(IRX_OBJ)
|
||||
EE_BIN = $(TARGET)
|
||||
EE_GPVAL = $(GPVAL)
|
||||
|
||||
all: $(EE_IRX_OBJ) $(EE_BIN)
|
||||
|
||||
all: irxdir $(EE_BIN)
|
||||
|
||||
irxdir:
|
||||
$(MAKE) -C $(IRX_DIR)
|
||||
|
||||
clean:
|
||||
rm -f $(EE_BIN) $(EE_OBJS)
|
||||
$(MAKE) -C $(IRX_DIR) clean
|
||||
|
||||
prepare:
|
||||
ps2client -h $(PS2_IP) reset
|
||||
@ -100,10 +110,6 @@ package:
|
||||
|
||||
release: clean all package
|
||||
|
||||
#Specific file name and output per IRX Module
|
||||
$(EE_IRX_OBJ):
|
||||
$(EE_BIN2O) $(EE_GPVAL) $(IRX_DIR)/$(@:.o=.irx) $@ $(@:.o=_irx)
|
||||
|
||||
#Include preferences
|
||||
include $(PS2SDK)/samples/Makefile.pref
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
||||
|
@ -23,49 +23,15 @@
|
||||
#include <sifrpc.h>
|
||||
#include <iopcontrol.h>
|
||||
#include <libpwroff.h>
|
||||
#include <libmc.h>
|
||||
#include <libmtap.h>
|
||||
#include <audsrv.h>
|
||||
#include <libpad.h>
|
||||
#include <cdvd_rpc.h>
|
||||
#include <fileXio_cdvd.h>
|
||||
#include <ps2_devices.h>
|
||||
|
||||
|
||||
extern unsigned char poweroff_irx_start[];
|
||||
extern unsigned int poweroff_irx_size;
|
||||
|
||||
extern unsigned char ps2dev9_irx_start[];
|
||||
extern unsigned int ps2dev9_irx_size;
|
||||
|
||||
extern unsigned char ps2atad_irx_start[];
|
||||
extern unsigned int ps2atad_irx_size;
|
||||
|
||||
extern unsigned char ps2hdd_irx_start[];
|
||||
extern unsigned int ps2hdd_irx_size;
|
||||
|
||||
extern unsigned char ps2fs_irx_start[];
|
||||
extern unsigned int ps2fs_irx_size;
|
||||
|
||||
extern unsigned char iomanX_irx_start[];
|
||||
extern unsigned int iomanX_irx_size;
|
||||
|
||||
extern unsigned char fileXio_irx_start[];
|
||||
extern unsigned int fileXio_irx_size;
|
||||
|
||||
extern unsigned char freesd_irx_start[];
|
||||
extern unsigned int freesd_irx_size;
|
||||
|
||||
extern unsigned char audsrv_irx_start[];
|
||||
extern unsigned int audsrv_irx_size;
|
||||
|
||||
extern unsigned char usbd_irx_start[];
|
||||
extern unsigned int usbd_irx_size;
|
||||
|
||||
extern unsigned char usbhdfsd_irx_start[];
|
||||
extern unsigned int usbhdfsd_irx_size;
|
||||
|
||||
extern unsigned char mcman_irx_start[];
|
||||
extern unsigned int mcman_irx_size;
|
||||
|
||||
extern unsigned char mcserv_irx_start[];
|
||||
extern unsigned int mcserv_irx_size;
|
||||
#include <ps2_irx_variables.h>
|
||||
#include <ps2_descriptor.h>
|
||||
|
||||
char eboot_path[512];
|
||||
char user_path[512];
|
||||
@ -196,36 +162,60 @@ static void frontend_ps2_init(void *data)
|
||||
SifInitRpc(0);
|
||||
sbv_patch_enable_lmb();
|
||||
|
||||
/* Controllers */
|
||||
SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
||||
SifLoadModule("rom0:PADMAN", 0, NULL);
|
||||
|
||||
/* I/O Files */
|
||||
SifExecModuleBuffer(iomanX_irx_start, iomanX_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(fileXio_irx_start, fileXio_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&freesio2_irx, size_freesio2_irx, 0, NULL, NULL);
|
||||
|
||||
/* Memory Card */
|
||||
SifExecModuleBuffer(mcman_irx_start, mcman_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(mcserv_irx_start, mcserv_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&mcman_irx, size_mcman_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&mcserv_irx, size_mcserv_irx, 0, NULL, NULL);
|
||||
|
||||
/* Controllers */
|
||||
SifExecModuleBuffer(&freemtap_irx, size_freemtap_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&freepad_irx, size_freepad_irx, 0, NULL, NULL);
|
||||
|
||||
/* USB */
|
||||
SifExecModuleBuffer(usbd_irx_start, usbd_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(usbhdfsd_irx_start, usbhdfsd_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&usbd_irx, size_usbd_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&usbhdfsd_irx, size_usbhdfsd_irx, 0, NULL, NULL);
|
||||
|
||||
/* Audio */
|
||||
SifExecModuleBuffer(freesd_irx_start, freesd_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(audsrv_irx_start, audsrv_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL);
|
||||
|
||||
/* CDVD */
|
||||
SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL);
|
||||
|
||||
if (mcInit(MC_TYPE_XMC)) {
|
||||
RARCH_ERR("mcInit library not initalizated\n");
|
||||
}
|
||||
|
||||
/* Initializes audsrv library */
|
||||
if (audsrv_init()) {
|
||||
RARCH_ERR("audsrv library not initalizated\n");
|
||||
}
|
||||
|
||||
/* Initializes pad library
|
||||
/* Initializes pad libraries
|
||||
Must be init with 0 as parameter*/
|
||||
if (mtapInit() != 1) {
|
||||
RARCH_ERR("mtapInit library not initalizated\n");
|
||||
}
|
||||
if (padInit(0) != 1) {
|
||||
RARCH_ERR("padInit library not initalizated\n");
|
||||
}
|
||||
if (mtapPortOpen(0) != 1) {
|
||||
RARCH_ERR("mtapPortOpen library not initalizated\n");
|
||||
}
|
||||
|
||||
/* Initializes CDVD library */
|
||||
if (CDVD_Init() != 1) {
|
||||
RARCH_ERR("CDVD_Init library not initalizated\n");
|
||||
}
|
||||
if (cdInit(CDVD_INIT_INIT) != 1) {
|
||||
RARCH_ERR("cdInit library not initalizated\n");
|
||||
}
|
||||
|
||||
_init_ps2_io();
|
||||
|
||||
/* Prepare device */
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
@ -245,6 +235,9 @@ static void frontend_ps2_deinit(void *data)
|
||||
verbosity_disable();
|
||||
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
|
||||
#endif
|
||||
_free_ps2_io();
|
||||
cdInit(CDVD_INIT_EXIT);
|
||||
CDVD_Stop();
|
||||
padEnd();
|
||||
audsrv_quit();
|
||||
fileXioExit();
|
||||
@ -359,6 +352,11 @@ 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);
|
||||
menu_entries_append_enum(list,
|
||||
rootDevicePath(BOOT_DEVICE_CDFS),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
||||
enum_idx,
|
||||
FILE_TYPE_DIRECTORY, 0, 0);
|
||||
menu_entries_append_enum(list,
|
||||
rootDevicePath(BOOT_DEVICE_MASS),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
||||
|
@ -172,7 +172,7 @@ static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition,
|
||||
GS_TEXT);
|
||||
}
|
||||
|
||||
static void clearVRAMIfNeeded(ps2_video_t *ps2, void *frame, int width, int height)
|
||||
static void clearVRAMIfNeeded(ps2_video_t *ps2, const void *frame, int width, int height)
|
||||
{
|
||||
if (!ps2->clearVRAM) {
|
||||
if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID) {
|
||||
|
@ -68,6 +68,7 @@
|
||||
#if defined(PS2)
|
||||
#include <kernel.h>
|
||||
#include <timer.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(__PSL1GHT__)
|
||||
|
@ -100,7 +100,7 @@
|
||||
#define FIO_S_ISDIR SCE_S_ISDIR
|
||||
#endif
|
||||
|
||||
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP)
|
||||
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) || defined(PS2)
|
||||
#include <unistd.h> /* stat() is defined here */
|
||||
#endif
|
||||
|
||||
|
@ -166,7 +166,7 @@ typedef struct
|
||||
# endif
|
||||
# endif
|
||||
#elif PS2
|
||||
# define PRI_SIZET "lu"
|
||||
# define PRI_SIZET "u"
|
||||
#else
|
||||
# if (SIZE_MAX == 0xFFFF)
|
||||
# define PRI_SIZET "hu"
|
||||
|
@ -52,6 +52,7 @@
|
||||
# endif
|
||||
# if defined(PS2)
|
||||
# include <fileXio_rpc.h>
|
||||
# include <fileXio_cdvd.h>
|
||||
# endif
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
@ -1045,7 +1046,7 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool i
|
||||
#elif defined(VITA) || defined(PSP)
|
||||
rdir->directory = sceIoDopen(name);
|
||||
#elif defined(PS2)
|
||||
rdir->directory = fileXioDopen(name);
|
||||
rdir->directory = ps2fileXioDopen(name);
|
||||
#elif defined(_3DS)
|
||||
rdir->directory = !string_is_empty(name) ? opendir(name) : NULL;
|
||||
rdir->entry = NULL;
|
||||
@ -1088,7 +1089,7 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir)
|
||||
return (sceIoDread(rdir->directory, &rdir->entry) > 0);
|
||||
#elif defined(PS2)
|
||||
iox_dirent_t record;
|
||||
int ret = fileXioDread(rdir->directory, &record);
|
||||
int ret = ps2fileXioDread(rdir->directory, &record);
|
||||
rdir->entry = record;
|
||||
return ( ret > 0);
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
@ -1186,7 +1187,7 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir)
|
||||
#elif defined(VITA) || defined(PSP)
|
||||
sceIoDclose(rdir->directory);
|
||||
#elif defined(PS2)
|
||||
fileXioDclose(rdir->directory);
|
||||
ps2fileXioDclose(rdir->directory);
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
rdir->error = cellFsClosedir(rdir->directory);
|
||||
#elif defined(ORBIS)
|
||||
|
280
ps2/compat_files/fileXio_cdvd.c
Normal file
280
ps2/compat_files/fileXio_cdvd.c
Normal file
@ -0,0 +1,280 @@
|
||||
#include <stdio.h>
|
||||
#include <tamtypes.h>
|
||||
#include <kernel.h>
|
||||
#include <string.h>
|
||||
#include <sifrpc.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <cdvd_rpc.h>
|
||||
#include <fileXio_cdvd.h>
|
||||
#include "ps2_devices.h"
|
||||
#include "ps2_descriptor.h"
|
||||
|
||||
#define CD_SERVER_INIT 0x80000592
|
||||
#define CD_SERVER_SCMD 0x80000593
|
||||
#define CD_SCMD_GETDISCTYPE 0x03
|
||||
|
||||
static SifRpcClientData_t clientInit __attribute__ ((aligned(64)));
|
||||
static u32 initMode __attribute__ ((aligned(64)));
|
||||
static int cdThreadId = 0;
|
||||
static int bindSearchFile = -1;
|
||||
static int bindDiskReady = -1;
|
||||
static int bindInit = -1;
|
||||
static int bindNCmd = -1;
|
||||
static int bindSCmd = -1;
|
||||
static int nCmdSemaId = -1; // n-cmd semaphore id
|
||||
static int sCmdSemaId = -1; // s-cmd semaphore id
|
||||
static int callbackSemaId = -1; // callback semaphore id
|
||||
static int cdDebug = 0;
|
||||
static int sCmdNum = 0;
|
||||
static SifRpcClientData_t clientSCmd __attribute__ ((aligned(64)));
|
||||
static u8 sCmdRecvBuff[48] __attribute__ ((aligned(64)));
|
||||
static volatile int cbSema = 0;
|
||||
static ee_thread_status_t cdThreadParam;
|
||||
static int callbackThreadId = 0;
|
||||
volatile int cdCallbackNum __attribute__ ((aligned(64)));
|
||||
|
||||
static void cdSemaInit(void);
|
||||
static int cdCheckSCmd(int cur_cmd);
|
||||
static int cdSyncS(int mode);
|
||||
static void cdSemaExit(void);
|
||||
|
||||
static int first_file_index;
|
||||
|
||||
int cdInit(int mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (cdSyncS(1))
|
||||
return 0;
|
||||
SifInitRpc(0);
|
||||
cdThreadId = GetThreadId();
|
||||
bindSearchFile = -1;
|
||||
bindNCmd = -1;
|
||||
bindSCmd = -1;
|
||||
bindDiskReady = -1;
|
||||
bindInit = -1;
|
||||
|
||||
while (1) {
|
||||
if (SifBindRpc(&clientInit, CD_SERVER_INIT, 0) >= 0)
|
||||
if (clientInit.server != 0) break;
|
||||
i = 0x10000;
|
||||
while (i--);
|
||||
}
|
||||
|
||||
bindInit = 0;
|
||||
initMode = mode;
|
||||
SifWriteBackDCache(&initMode, 4);
|
||||
if (SifCallRpc(&clientInit, 0, 0, &initMode, 4, 0, 0, 0, 0) < 0)
|
||||
return 0;
|
||||
if (mode == CDVD_INIT_EXIT) {
|
||||
cdSemaExit();
|
||||
nCmdSemaId = -1;
|
||||
sCmdSemaId = -1;
|
||||
callbackSemaId = -1;
|
||||
} else {
|
||||
cdSemaInit();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void cdSemaExit(void)
|
||||
{
|
||||
if (callbackThreadId) {
|
||||
cdCallbackNum = -1;
|
||||
SignalSema(callbackSemaId);
|
||||
}
|
||||
DeleteSema(nCmdSemaId);
|
||||
DeleteSema(sCmdSemaId);
|
||||
DeleteSema(callbackSemaId);
|
||||
}
|
||||
|
||||
static void cdSemaInit(void)
|
||||
{
|
||||
struct t_ee_sema semaParam;
|
||||
|
||||
// return if both semaphores are already inited
|
||||
if (nCmdSemaId != -1 && sCmdSemaId != -1)
|
||||
return;
|
||||
|
||||
semaParam.init_count = 1;
|
||||
semaParam.max_count = 1;
|
||||
semaParam.option = 0;
|
||||
nCmdSemaId = CreateSema(&semaParam);
|
||||
sCmdSemaId = CreateSema(&semaParam);
|
||||
|
||||
semaParam.init_count = 0;
|
||||
callbackSemaId = CreateSema(&semaParam);
|
||||
|
||||
cbSema = 0;
|
||||
}
|
||||
|
||||
static int cdCheckSCmd(int cur_cmd)
|
||||
{
|
||||
int i;
|
||||
cdSemaInit();
|
||||
if (PollSema(sCmdSemaId) != sCmdSemaId) {
|
||||
if (cdDebug > 0)
|
||||
printf("Scmd fail sema cur_cmd:%d keep_cmd:%d\n", cur_cmd, sCmdNum);
|
||||
return 0;
|
||||
}
|
||||
sCmdNum = cur_cmd;
|
||||
ReferThreadStatus(cdThreadId, &cdThreadParam);
|
||||
if (cdSyncS(1)) {
|
||||
SignalSema(sCmdSemaId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SifInitRpc(0);
|
||||
if (bindSCmd >= 0)
|
||||
return 1;
|
||||
while (1) {
|
||||
if (SifBindRpc(&clientSCmd, CD_SERVER_SCMD, 0) < 0) {
|
||||
if (cdDebug > 0)
|
||||
printf("Libcdvd bind err S cmd\n");
|
||||
}
|
||||
if (clientSCmd.server != 0)
|
||||
break;
|
||||
|
||||
i = 0x10000;
|
||||
while (i--)
|
||||
;
|
||||
}
|
||||
|
||||
bindSCmd = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cdSyncS(int mode)
|
||||
{
|
||||
if (mode == 0) {
|
||||
if (cdDebug > 0)
|
||||
printf("S cmd wait\n");
|
||||
while (SifCheckStatRpc(&clientSCmd))
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
return SifCheckStatRpc(&clientSCmd);
|
||||
}
|
||||
|
||||
static int comp_entries_by_filename(const void *elem1, const void *elem2)
|
||||
{
|
||||
return strcmp(((entries*)elem1)->filename, ((entries*)elem2)->filename);
|
||||
}
|
||||
|
||||
static inline char* strzncpy(char *d, const char *s, size_t l)
|
||||
{
|
||||
d[0] = 0; return strncat(d, s, l);
|
||||
}
|
||||
|
||||
static int listcdvd(const char *path, entries *FileEntry)
|
||||
{
|
||||
static struct TocEntry TocEntryList[FILEENTRY_SIZE];
|
||||
char dir[1025];
|
||||
int i, n;
|
||||
int t = 0;
|
||||
|
||||
strcpy(dir, &path[5]);
|
||||
// Directories first...
|
||||
|
||||
CDVD_FlushCache();
|
||||
n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, TocEntryList, FILEENTRY_SIZE, dir);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (TocEntryList[i].fileProperties & 0x02 && (!strcmp(
|
||||
TocEntryList[i].filename, ".") || !strcmp(
|
||||
TocEntryList[i].filename, "..")))
|
||||
continue; // Skip pseudopaths "." and ".."
|
||||
|
||||
FileEntry[t].dircheck = 1;
|
||||
strcpy(FileEntry[t].filename, TocEntryList[i].filename);
|
||||
strzncpy(FileEntry[t].displayname, FileEntry[t].filename, 63);
|
||||
t++;
|
||||
|
||||
if (t >= FILEENTRY_SIZE - 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qsort(FileEntry, t, sizeof(entries), comp_entries_by_filename);
|
||||
first_file_index = t;
|
||||
|
||||
// Now files only
|
||||
|
||||
CDVD_FlushCache();
|
||||
n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_ONLY, TocEntryList, FILEENTRY_SIZE, dir);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (TocEntryList[i].fileProperties & 0x02 && (!strcmp(
|
||||
TocEntryList[i].filename, ".") || !strcmp(
|
||||
TocEntryList[i].filename, "..")))
|
||||
continue; // Skip pseudopaths "." and ".."
|
||||
|
||||
FileEntry[t].dircheck = 0;
|
||||
strcpy(FileEntry[t].filename, TocEntryList[i].filename);
|
||||
strzncpy(FileEntry[t].displayname, FileEntry[t].filename, 63);
|
||||
t++;
|
||||
|
||||
if (t >= FILEENTRY_SIZE - 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qsort(FileEntry + first_file_index, t - first_file_index, sizeof(entries), comp_entries_by_filename);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
static int fileXioCDDread(int fd, iox_dirent_t *dirent)
|
||||
{
|
||||
DescriptorTranslation *descriptor = __ps2_fd_grab(fd);
|
||||
if (descriptor->current_folder_position == -1) {
|
||||
descriptor->current_folder_position = 0;
|
||||
descriptor->items = listcdvd(descriptor->path, descriptor->FileEntry);
|
||||
}
|
||||
|
||||
if (descriptor->current_folder_position < descriptor->items) {
|
||||
strcpy(dirent->name, descriptor->FileEntry[descriptor->current_folder_position].filename);
|
||||
if (descriptor->FileEntry[descriptor->current_folder_position].dircheck) {
|
||||
dirent->stat.mode = FIO_S_IFDIR;
|
||||
}
|
||||
descriptor->current_folder_position++;
|
||||
} else {
|
||||
descriptor->current_folder_position = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ps2fileXioDopen(const char *name)
|
||||
{
|
||||
enum BootDeviceIDs deviceID = getBootDeviceID((char *)name);
|
||||
int fd;
|
||||
if (deviceID == BOOT_DEVICE_CDFS) {
|
||||
fd = __ps2_acquire_descriptor();
|
||||
DescriptorTranslation *descriptor = __ps2_fd_grab(fd);
|
||||
strcpy(descriptor->path, name);
|
||||
} else {
|
||||
fd = fileXioDopen(name);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int ps2fileXioDread(int fd, iox_dirent_t *dirent)
|
||||
{
|
||||
if (is_fd_valid(fd)) {
|
||||
return fileXioCDDread(fd, dirent);
|
||||
} else {
|
||||
return fileXioDread(fd, dirent);
|
||||
}
|
||||
}
|
||||
|
||||
int ps2fileXioDclose(int fd)
|
||||
{
|
||||
if (is_fd_valid(fd)) {
|
||||
return __ps2_release_descriptor(fd);
|
||||
} else {
|
||||
return fileXioDclose(fd);
|
||||
}
|
||||
}
|
150
ps2/compat_files/ps2_descriptor.c
Normal file
150
ps2/compat_files/ps2_descriptor.c
Normal file
@ -0,0 +1,150 @@
|
||||
/* 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_descriptor.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <kernel.h>
|
||||
#include <string.h>
|
||||
#include <fileXio_rpc.h>
|
||||
|
||||
static DescriptorTranslation *__ps2_fdmap[MAX_OPEN_FILES];
|
||||
static DescriptorTranslation __ps2_fdmap_pool[MAX_OPEN_FILES];
|
||||
static int _lock_sema_id = -1;
|
||||
|
||||
static inline int _lock(void)
|
||||
{
|
||||
return(WaitSema(_lock_sema_id));
|
||||
}
|
||||
|
||||
static inline int _unlock(void)
|
||||
{
|
||||
return(SignalSema(_lock_sema_id));
|
||||
}
|
||||
|
||||
static int __ps2_fd_drop(DescriptorTranslation *map)
|
||||
{
|
||||
_lock();
|
||||
|
||||
if (map->ref_count == 1)
|
||||
{
|
||||
map->ref_count--;
|
||||
free(map->FileEntry);
|
||||
memset(map, 0, sizeof(DescriptorTranslation));
|
||||
}
|
||||
else
|
||||
{
|
||||
map->ref_count--;
|
||||
}
|
||||
|
||||
_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_fd_valid(int fd)
|
||||
{
|
||||
/* Correct fd value */
|
||||
fd = MAX_OPEN_FILES - fd;
|
||||
|
||||
return (fd > 0) && (fd < MAX_OPEN_FILES) && (__ps2_fdmap[fd] != NULL);
|
||||
}
|
||||
|
||||
void _init_ps2_io(void) {
|
||||
int ret;
|
||||
ee_sema_t sp;
|
||||
|
||||
memset(__ps2_fdmap, 0, sizeof(__ps2_fdmap));
|
||||
memset(__ps2_fdmap_pool, 0, sizeof(__ps2_fdmap_pool));
|
||||
|
||||
sp.init_count = 1;
|
||||
sp.max_count = 1;
|
||||
sp.option = 0;
|
||||
_lock_sema_id = CreateSema(&sp);
|
||||
|
||||
}
|
||||
|
||||
void _free_ps2_io(void) {
|
||||
_lock();
|
||||
_unlock();
|
||||
if(_lock_sema_id >= 0) DeleteSema(_lock_sema_id);
|
||||
}
|
||||
|
||||
int __ps2_acquire_descriptor(void)
|
||||
{
|
||||
int fd = -1;
|
||||
int i = 0;
|
||||
_lock();
|
||||
|
||||
/* get free descriptor */
|
||||
for (fd = 0; fd < MAX_OPEN_FILES; ++fd)
|
||||
{
|
||||
if (__ps2_fdmap[fd] == NULL)
|
||||
{
|
||||
/* get free pool */
|
||||
for (i = 0; i < MAX_OPEN_FILES; ++i)
|
||||
{
|
||||
if (__ps2_fdmap_pool[i].ref_count == 0)
|
||||
{
|
||||
__ps2_fdmap[fd] = &__ps2_fdmap_pool[i];
|
||||
__ps2_fdmap[fd]->ref_count = 1;
|
||||
__ps2_fdmap[fd]->current_folder_position = -1;
|
||||
__ps2_fdmap[fd]->FileEntry = calloc(sizeof(entries), FILEENTRY_SIZE);
|
||||
_unlock();
|
||||
return MAX_OPEN_FILES - fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no mores descriptors available... */
|
||||
_unlock();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int __ps2_release_descriptor(int fd)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
if (is_fd_valid(fd) && __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0)
|
||||
{
|
||||
_lock();
|
||||
/* Correct fd value */
|
||||
fd = MAX_OPEN_FILES - fd;
|
||||
__ps2_fdmap[fd] = NULL;
|
||||
res = 0;
|
||||
_unlock();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
DescriptorTranslation *__ps2_fd_grab(int fd)
|
||||
{
|
||||
DescriptorTranslation *map = NULL;
|
||||
|
||||
_lock();
|
||||
|
||||
if (is_fd_valid(fd))
|
||||
{
|
||||
/* Correct fd value */
|
||||
fd = MAX_OPEN_FILES - fd;
|
||||
map = __ps2_fdmap[fd];
|
||||
|
||||
if (map)
|
||||
map->ref_count++;
|
||||
}
|
||||
|
||||
_unlock();
|
||||
return map;
|
||||
}
|
@ -16,12 +16,15 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <kernel.h>
|
||||
#include <string.h>
|
||||
#include <fileXio_rpc.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:"
|
||||
@ -40,6 +43,7 @@
|
||||
|
||||
#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
|
||||
@ -67,6 +71,8 @@ char *rootDevicePath(enum BootDeviceIDs device_id)
|
||||
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:
|
||||
@ -110,6 +116,8 @@ enum BootDeviceIDs getBootDeviceID(char *path)
|
||||
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))
|
||||
|
37
ps2/include/fileXio_cdvd.h
Normal file
37
ps2/include/fileXio_cdvd.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef PS2_CD_H
|
||||
#define PS2_CD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <fileXio_rpc.h>
|
||||
#include <fileXio.h>
|
||||
|
||||
#define CDVD_INIT_INIT 0x00
|
||||
#define CDVD_INIT_NOCHECK 0x01
|
||||
#define CDVD_INIT_EXIT 0x05
|
||||
|
||||
typedef enum {
|
||||
CDVD_TYPE_NODISK = 0x00, /* No Disc inserted */
|
||||
CDVD_TYPE_DETECT, /* Detecting disc type */
|
||||
CDVD_TYPE_DETECT_CD,
|
||||
CDVD_TYPE_DETECT_DVDSINGLE,
|
||||
CDVD_TYPE_DETECT_DVDDUAL,
|
||||
CDVD_TYPE_UNKNOWN, /* Unknown disc type */
|
||||
|
||||
CDVD_TYPE_PS1CD = 0x10, /* PS1 CD with no CDDA tracks */
|
||||
CDVD_TYPE_PS1CDDA, /* PS1 CD with CDDA tracks */
|
||||
CDVD_TYPE_PS2CD, /* PS2 CD with no CDDA tracks */
|
||||
CDVD_TYPE_PS2CDDA, /* PS2 CD with CDDA tracks */
|
||||
CDVD_TYPE_PS2DVD, /* PS2 DVD */
|
||||
|
||||
CDVD_TYPE_CDDA = 0xFD, /* CDDA */
|
||||
CDVD_TYPE_DVDVIDEO, /* DVD Video */
|
||||
CDVD_TYPE_ILLEGAL, /* Illegal disk type */
|
||||
} CdvdDiscType_t;
|
||||
|
||||
int cdInit(int);
|
||||
|
||||
int ps2fileXioDopen(const char *name);
|
||||
int ps2fileXioDread(int fd, iox_dirent_t *dirent);
|
||||
int ps2fileXioDclose(int fd);
|
||||
|
||||
#endif /* PS2_CD_H */
|
@ -19,4 +19,4 @@
|
||||
#define PRIu64 "lu"
|
||||
#define PRIuPTR "lu"
|
||||
|
||||
#endif //INTTYPES_H
|
||||
#endif /* INTTYPES_H */
|
||||
|
48
ps2/include/ps2_descriptor.h
Normal file
48
ps2/include/ps2_descriptor.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* 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_DESCRIPTOR_H
|
||||
#define PS2_DESCRIPTOR_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <fileXio_cdvd.h>
|
||||
|
||||
#define MAX_OPEN_FILES 256
|
||||
#define FILEENTRY_SIZE 2048
|
||||
|
||||
typedef struct {
|
||||
char displayname[64];
|
||||
int dircheck;
|
||||
char filename[256];
|
||||
} entries;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char path[256];
|
||||
int ref_count;
|
||||
int items;
|
||||
int current_folder_position;
|
||||
entries *FileEntry;
|
||||
} DescriptorTranslation;
|
||||
|
||||
extern DescriptorTranslation *__ps2_fdmap[];
|
||||
|
||||
void _init_ps2_io(void);
|
||||
void _free_ps2_io(void);
|
||||
int is_fd_valid(int fd);
|
||||
int __ps2_acquire_descriptor(void);
|
||||
int __ps2_release_descriptor(int fd);
|
||||
DescriptorTranslation *__ps2_fd_grab(int fd);
|
||||
|
||||
#endif /* PS2_DESCRIPTOR_H */
|
@ -22,6 +22,7 @@ enum BootDeviceIDs{
|
||||
BOOT_DEVICE_MC0 = 0,
|
||||
BOOT_DEVICE_MC1,
|
||||
BOOT_DEVICE_CDROM,
|
||||
BOOT_DEVICE_CDFS,
|
||||
BOOT_DEVICE_MASS,
|
||||
BOOT_DEVICE_MASS0,
|
||||
BOOT_DEVICE_HDD,
|
||||
|
69
ps2/include/ps2_irx_variables.h
Normal file
69
ps2/include/ps2_irx_variables.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* 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 freesio2_irx;
|
||||
extern unsigned int size_freesio2_irx;
|
||||
|
||||
extern unsigned char mcman_irx;
|
||||
extern unsigned int size_mcman_irx;
|
||||
|
||||
extern unsigned char mcserv_irx;
|
||||
extern unsigned int size_mcserv_irx;
|
||||
|
||||
extern unsigned char freemtap_irx;
|
||||
extern unsigned int size_freemtap_irx;
|
||||
|
||||
extern unsigned char freepad_irx;
|
||||
extern unsigned int size_freepad_irx;
|
||||
|
||||
extern unsigned char poweroff_irx;
|
||||
extern unsigned int size_poweroff_irx;
|
||||
|
||||
extern unsigned char iomanX_irx;
|
||||
extern unsigned int size_iomanX_irx;
|
||||
|
||||
extern unsigned char fileXio_irx;
|
||||
extern unsigned int size_fileXio_irx;
|
||||
|
||||
extern unsigned char ps2dev9_irx;
|
||||
extern unsigned int size_ps2dev9_irx;
|
||||
|
||||
extern unsigned char ps2atad_irx;
|
||||
extern unsigned int size_ps2atad_irx;
|
||||
|
||||
extern unsigned char ps2hdd_irx;
|
||||
extern unsigned int size_ps2hdd_irx;
|
||||
|
||||
extern unsigned char ps2fs_irx;
|
||||
extern unsigned int size_ps2fs_irx;
|
||||
|
||||
extern unsigned char usbd_irx;
|
||||
extern unsigned int size_usbd_irx;
|
||||
|
||||
extern unsigned char usbhdfsd_irx;
|
||||
extern unsigned int size_usbhdfsd_irx;
|
||||
|
||||
extern unsigned char cdvd_irx;
|
||||
extern unsigned int size_cdvd_irx;
|
||||
|
||||
extern unsigned char audsrv_irx;
|
||||
extern unsigned int size_audsrv_irx;
|
||||
|
||||
extern unsigned char freesd_irx;
|
||||
extern unsigned int size_freesd_irx;
|
||||
|
||||
#endif /* PS2_IRX_VARIABLES_H */
|
32
ps2/irx/Makefile
Normal file
32
ps2/irx/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
#Configuration for IRX
|
||||
EE_BIN2C = bin2c
|
||||
IRX_DIR = $(PS2SDK)/iop/irx
|
||||
|
||||
#Specific folder for cdvd.irx
|
||||
LIBCDVD_DIR = ../libcdvd
|
||||
LIBCDVD_IRX_DIR = $(LIBCDVD_DIR)/lib
|
||||
|
||||
#IRX modules
|
||||
# IRX modules - modules have to be in IRX_DIR
|
||||
IRX_FILES += freemtap.irx freepad.irx freesio2.irx iomanX.irx fileXio.irx mcman.irx mcserv.irx usbd.irx usbhdfsd.irx
|
||||
IRX_FILES += freesd.irx audsrv.irx poweroff.irx cdvd.irx
|
||||
IRX_C_FILES = $(IRX_FILES:.irx=_irx.c)
|
||||
|
||||
# Specific file name and output per IRX Module
|
||||
%.irx:
|
||||
if [[ "$(@)" == "cdvd.irx" ]]; then \
|
||||
$(MAKE) -C $(LIBCDVD_DIR); \
|
||||
$(EE_BIN2C) $(LIBCDVD_IRX_DIR)/$@ $(@:.irx=_irx.c) $(@:.irx=_irx); \
|
||||
else \
|
||||
$(EE_BIN2C) $(IRX_DIR)/$@ $(@:.irx=_irx.c) $(@:.irx=_irx); \
|
||||
fi
|
||||
|
||||
all: $(IRX_FILES)
|
||||
|
||||
clean:
|
||||
rm -f $(IRX_C_FILES)
|
||||
$(MAKE) -C $(LIBCDVD_DIR) clean
|
||||
|
||||
#Include preferences
|
||||
include $(PS2SDK)/samples/Makefile.pref
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
19
ps2/libcdvd/Makefile
Normal file
19
ps2/libcdvd/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
# Remove the line below, if you want to disable silent mode
|
||||
#.SILENT:
|
||||
|
||||
all: lib/libcdvdfs.a lib/cdvd.irx
|
||||
|
||||
lib:
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
$(MAKE) -C ee clean
|
||||
$(MAKE) -C iop clean
|
||||
|
||||
lib/cdvd.irx: iop | lib
|
||||
@echo Building IRX
|
||||
$(MAKE) -C $<
|
||||
|
||||
lib/libcdvdfs.a: ee | lib
|
||||
@echo Building EE client
|
||||
$(MAKE) -C $<
|
45
ps2/libcdvd/common/cdvd.h
Normal file
45
ps2/libcdvd/common/cdvd.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef _CDVD_H
|
||||
#define _CDVD_H
|
||||
|
||||
// This header contains the common definitions for libcdvd
|
||||
// that are used by both IOP and EE sides
|
||||
|
||||
#define CDVD_IRX 0xB001337
|
||||
#define CDVD_FINDFILE 0x01
|
||||
#define CDVD_GETDIR 0x02
|
||||
#define CDVD_STOP 0x04
|
||||
#define CDVD_TRAYREQ 0x05
|
||||
#define CDVD_DISKREADY 0x06
|
||||
#define CDVD_FLUSHCACHE 0x07
|
||||
#define CDVD_GETSIZE 0x08
|
||||
|
||||
|
||||
struct TocEntry
|
||||
{
|
||||
u32 fileLBA;
|
||||
u32 fileSize;
|
||||
u8 fileProperties;
|
||||
u8 padding1[3];
|
||||
char filename[128 + 1];
|
||||
u8 padding2[3];
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
enum CDVD_getMode {
|
||||
CDVD_GET_FILES_ONLY = 1,
|
||||
CDVD_GET_DIRS_ONLY = 2,
|
||||
CDVD_GET_FILES_AND_DIRS = 3
|
||||
};
|
||||
|
||||
// Macros for TrayReq
|
||||
#define CdTrayOpen 0
|
||||
#define CdTrayClose 1
|
||||
#define CdTrayCheck 2
|
||||
|
||||
// Macros for DiskReady
|
||||
#define CdComplete 0x02
|
||||
#define CdNotReady 0x06
|
||||
#define CdBlock 0x00
|
||||
#define CdNonBlock 0x01
|
||||
|
||||
#endif // _CDVD_H
|
10
ps2/libcdvd/ee/Makefile
Normal file
10
ps2/libcdvd/ee/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
EE_LIB = ../lib/libcdvdfs.a
|
||||
EE_OBJS = cdvd_rpc.o
|
||||
|
||||
all: $(EE_LIB)
|
||||
|
||||
clean:
|
||||
rm -f $(EE_LIB) $(EE_OBJS)
|
||||
|
||||
include $(PS2SDK)/samples/Makefile.pref
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
135
ps2/libcdvd/ee/cdvd_rpc.c
Normal file
135
ps2/libcdvd/ee/cdvd_rpc.c
Normal file
@ -0,0 +1,135 @@
|
||||
#include <tamtypes.h>
|
||||
#include <kernel.h>
|
||||
#include <sifrpc.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cdvd_rpc.h"
|
||||
|
||||
int k_sceSifDmaStat(unsigned int id);
|
||||
static unsigned sbuff[0x1300] __attribute__((aligned(64)));
|
||||
static SifRpcClientData_t cd0;
|
||||
|
||||
int cdvd_inited = 0;
|
||||
|
||||
int CDVD_Init()
|
||||
{
|
||||
int i;
|
||||
|
||||
while (1) {
|
||||
if (SifBindRpc(&cd0, CDVD_IRX, 0) < 0)
|
||||
return -1; // bind error
|
||||
if (cd0.server != 0)
|
||||
break;
|
||||
i = 0x10000;
|
||||
while (i--)
|
||||
;
|
||||
}
|
||||
|
||||
cdvd_inited = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CDVD_DiskReady(int mode)
|
||||
{
|
||||
if (!cdvd_inited)
|
||||
return -1;
|
||||
|
||||
sbuff[0] = mode;
|
||||
|
||||
SifCallRpc(&cd0, CDVD_DISKREADY, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0);
|
||||
|
||||
return sbuff[0];
|
||||
}
|
||||
|
||||
int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry)
|
||||
{
|
||||
if (!cdvd_inited)
|
||||
return -1;
|
||||
|
||||
strncpy((char *)&sbuff, fname, 1024);
|
||||
|
||||
SifCallRpc(&cd0, CDVD_FINDFILE, 0, (void *)(&sbuff[0]), 1024, (void *)(&sbuff[0]), sizeof(struct TocEntry) + 1024, 0, 0);
|
||||
|
||||
memcpy(tocEntry, &sbuff[256], sizeof(struct TocEntry));
|
||||
|
||||
return sbuff[0];
|
||||
}
|
||||
|
||||
void CDVD_Stop()
|
||||
{
|
||||
if (!cdvd_inited)
|
||||
return;
|
||||
|
||||
SifCallRpc(&cd0, CDVD_STOP, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int CDVD_TrayReq(int mode)
|
||||
{
|
||||
if (!cdvd_inited)
|
||||
return -1;
|
||||
|
||||
SifCallRpc(&cd0, CDVD_TRAYREQ, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0);
|
||||
|
||||
return sbuff[0];
|
||||
}
|
||||
|
||||
int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname)
|
||||
{
|
||||
unsigned int num_entries;
|
||||
|
||||
if (!cdvd_inited)
|
||||
return -1;
|
||||
|
||||
// copy the requested pathname to the rpc buffer
|
||||
strncpy((char *)sbuff, pathname, 1023);
|
||||
|
||||
// copy in the extension list to the rpc buffer
|
||||
if (extensions == NULL) {
|
||||
// Can't copy in the extension list since there isnt one, so just null the string in the rpc buffer
|
||||
sbuff[1024 / 4] = 0;
|
||||
} else {
|
||||
strncpy((char *)&sbuff[1024 / 4], extensions, 127);
|
||||
}
|
||||
|
||||
sbuff[1152 / 4] = getMode;
|
||||
|
||||
sbuff[1156 / 4] = (int)tocEntry;
|
||||
|
||||
sbuff[1160 / 4] = req_entries;
|
||||
|
||||
SifWriteBackDCache(tocEntry, req_entries * sizeof(struct TocEntry));
|
||||
|
||||
// This will get the directory contents, and fill tocEntry via DMA
|
||||
SifCallRpc(&cd0, CDVD_GETDIR, 0, (void *)(&sbuff[0]), 1024 + 128 + 4 + 4 + 4, (void *)(&sbuff[0]), 4 + 1024, 0, 0);
|
||||
|
||||
num_entries = sbuff[0];
|
||||
|
||||
if (new_pathname != NULL)
|
||||
strncpy(new_pathname, (char *)&sbuff[1], 1023);
|
||||
|
||||
return (num_entries);
|
||||
}
|
||||
|
||||
void CDVD_FlushCache()
|
||||
{
|
||||
if (!cdvd_inited)
|
||||
return;
|
||||
|
||||
SifCallRpc(&cd0, CDVD_FLUSHCACHE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int CDVD_GetSize()
|
||||
{
|
||||
if (!cdvd_inited)
|
||||
return -1;
|
||||
|
||||
SifCallRpc(&cd0, CDVD_GETSIZE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 4, 0, 0);
|
||||
|
||||
return sbuff[0];
|
||||
}
|
28
ps2/libcdvd/ee/cdvd_rpc.h
Normal file
28
ps2/libcdvd/ee/cdvd_rpc.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef _CDVD_RPC_H
|
||||
#define _CDVD_RPC_H
|
||||
|
||||
// include the common definitions
|
||||
#include "../common/cdvd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int CDVD_Init();
|
||||
int CDVD_DiskReady(int mode);
|
||||
int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry);
|
||||
void CDVD_Stop();
|
||||
int CDVD_TrayReq(int mode);
|
||||
int CDVD_DiskReady(int mode);
|
||||
int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname);
|
||||
void CDVD_FlushCache();
|
||||
unsigned int CDVD_GetSize();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _CDVD_H
|
12
ps2/libcdvd/iop/Makefile
Normal file
12
ps2/libcdvd/iop/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
IOP_BIN = ../lib/cdvd.irx
|
||||
|
||||
IOP_OBJS = cdvd_iop.o imports.o
|
||||
|
||||
|
||||
all: $(IOP_BIN)
|
||||
|
||||
clean:
|
||||
rm -f $(IOP_BIN) $(IOP_OBJS)
|
||||
|
||||
include $(PS2SDK)/Defs.make
|
||||
include Rules.make
|
54
ps2/libcdvd/iop/Rules.make
Normal file
54
ps2/libcdvd/iop/Rules.make
Normal file
@ -0,0 +1,54 @@
|
||||
# _____ ___ ____ ___ ____
|
||||
# ____| | ____| | | |____|
|
||||
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2001-2004.
|
||||
# Licenced under Academic Free License version 2.0
|
||||
# Review ps2sdk README & LICENSE files for further details.
|
||||
|
||||
|
||||
IOP_CC_VERSION := $(shell $(IOP_CC) -v 2>&1 | sed -n 's/^.*version //p')
|
||||
|
||||
ASFLAGS_TARGET = -mcpu=r3000
|
||||
|
||||
ifeq ($(IOP_CC_VERSION),3.2.2)
|
||||
CFLAGS_TARGET = -miop
|
||||
ASFLAGS_TARGET = -march=r3000
|
||||
LDFLAGS_TARGET = -miop
|
||||
endif
|
||||
|
||||
IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include
|
||||
|
||||
IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -D_IOP -c $(IOP_INCS) $(IOP_CFLAGS)
|
||||
IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS)
|
||||
IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS)
|
||||
|
||||
# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB
|
||||
|
||||
%.o : %.c
|
||||
$(IOP_CC) $(IOP_CFLAGS) $< -o $@
|
||||
|
||||
%.o : %.s
|
||||
$(IOP_AS) $(IOP_ASFLAGS) $< -o $@
|
||||
|
||||
# A rule to build imports.lst.
|
||||
%.o : %.lst
|
||||
echo "#include \"irx_imports.h\"" > build-imports.c
|
||||
cat $< >> build-imports.c
|
||||
$(IOP_CC) $(IOP_CFLAGS) build-imports.c -o $@
|
||||
-rm -f build-imports.c
|
||||
|
||||
# A rule to build exports.tab.
|
||||
%.o : %.tab
|
||||
echo "#include \"irx.h\"" > build-exports.c
|
||||
cat $< >> build-exports.c
|
||||
$(IOP_CC) $(IOP_CFLAGS) build-exports.c -o $@
|
||||
-rm -f build-exports.c
|
||||
|
||||
|
||||
$(IOP_BIN) : $(IOP_OBJS)
|
||||
$(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS)
|
||||
|
||||
$(IOP_LIB) : $(IOP_OBJS)
|
||||
$(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS)
|
||||
|
1852
ps2/libcdvd/iop/cdvd_iop.c
Normal file
1852
ps2/libcdvd/iop/cdvd_iop.c
Normal file
File diff suppressed because it is too large
Load Diff
84
ps2/libcdvd/iop/cdvd_iop.h
Normal file
84
ps2/libcdvd/iop/cdvd_iop.h
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef _CDVD_IOP_H
|
||||
#define _CDVD_IOP_H
|
||||
|
||||
#include "../common/cdvd.h"
|
||||
|
||||
// Macros for READ Data pattan
|
||||
#define CdSecS2048 0 // sector size 2048
|
||||
#define CdSecS2328 1 // sector size 2328
|
||||
#define CdSecS2340 2 // sector size 2340
|
||||
|
||||
// Macros for Spindle control
|
||||
#define CdSpinMax 0
|
||||
#define CdSpinNom 1 // Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced.
|
||||
#define CdSpinStm 0 // Recommended stream rotation speed.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 stat; // 0: normal. Any other: error
|
||||
u8 second; // second (BCD value)
|
||||
u8 minute; // minute (BCD value)
|
||||
u8 hour; // hour (BCD value)
|
||||
u8 week; // week (BCD value)
|
||||
u8 day; // day (BCD value)
|
||||
u8 month; // month (BCD value)
|
||||
u8 year; // year (BCD value)
|
||||
} CdCLOCK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 lsn; // Logical sector number of file
|
||||
u32 size; // File size (in bytes)
|
||||
char name[16]; // Filename
|
||||
u8 date[8]; // 1th: Seconds
|
||||
// 2th: Minutes
|
||||
// 3th: Hours
|
||||
// 4th: Date
|
||||
// 5th: Month
|
||||
// 6th 7th: Year (4 digits)
|
||||
} CdlFILE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 minute; // Minutes
|
||||
u8 second; // Seconds
|
||||
u8 sector; // Sector
|
||||
u8 track; // Track number
|
||||
} CdlLOCCD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 trycount; // Read try count (No. of error retries + 1) (0 - 255)
|
||||
u8 spindlctrl; // SCECdSpinStm: Recommended stream rotation speed.
|
||||
// SCECdSpinNom: Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced.
|
||||
u8 datapattern; // SCECdSecS2048: Data size 2048 bytes
|
||||
// SCECdSecS2328: 2328 bytes
|
||||
// SCECdSecS2340: 2340 bytes
|
||||
u8 pad; // Padding data produced by alignment.
|
||||
} CdRMode;
|
||||
|
||||
|
||||
int CdBreak(void);
|
||||
int CdCallback(void (*func)());
|
||||
int CdDiskReady(int mode);
|
||||
int CdGetDiskType(void);
|
||||
int CdGetError(void);
|
||||
u32 CdGetReadPos(void);
|
||||
int CdGetToc(u8 *toc);
|
||||
int CdInit(int init_mode);
|
||||
CdlLOCCD *CdIntToPos(int i, CdlLOCCD *p);
|
||||
int CdPause(void);
|
||||
int CdPosToInt(CdlLOCCD *p);
|
||||
int CdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode);
|
||||
int CdReadClock(CdCLOCK *rtc);
|
||||
int CdSearchFile(CdlFILE *fp, const char *name);
|
||||
int CdSeek(u32 lsn);
|
||||
int CdStandby(void);
|
||||
int CdStatus(void);
|
||||
int CdStop(void);
|
||||
int CdSync(int mode);
|
||||
int CdTrayReq(int mode, u32 *traycnt);
|
||||
int CdFlushCache(void);
|
||||
unsigned int CdGetSize(void);
|
||||
|
||||
#endif // _CDVD_H
|
62
ps2/libcdvd/iop/imports.lst
Normal file
62
ps2/libcdvd/iop/imports.lst
Normal file
@ -0,0 +1,62 @@
|
||||
cdvdman_IMPORTS_start
|
||||
I_sceCdInit
|
||||
I_sceCdGetError
|
||||
I_sceCdRead
|
||||
I_sceCdStop
|
||||
I_sceCdSync
|
||||
I_sceCdDiskReady
|
||||
I_sceCdGetDiskType
|
||||
I_sceCdTrayReq
|
||||
cdvdman_IMPORTS_end
|
||||
|
||||
intrman_IMPORTS_start
|
||||
I_CpuSuspendIntr
|
||||
I_CpuResumeIntr
|
||||
intrman_IMPORTS_end
|
||||
|
||||
ioman_IMPORTS_start
|
||||
I_AddDrv
|
||||
I_DelDrv
|
||||
ioman_IMPORTS_end
|
||||
|
||||
sifcmd_IMPORTS_start
|
||||
I_sceSifInitRpc
|
||||
I_sceSifSetRpcQueue
|
||||
I_sceSifRegisterRpc
|
||||
I_sceSifRpcLoop
|
||||
sifcmd_IMPORTS_end
|
||||
|
||||
sifman_IMPORTS_start
|
||||
I_sceSifSetDma
|
||||
I_sceSifDmaStat
|
||||
sifman_IMPORTS_end
|
||||
|
||||
stdio_IMPORTS_start
|
||||
I_printf
|
||||
I_puts
|
||||
stdio_IMPORTS_end
|
||||
|
||||
sysclib_IMPORTS_start
|
||||
I_tolower
|
||||
I_strcpy
|
||||
I_strncpy
|
||||
I_strncmp
|
||||
I_strtok
|
||||
I_strrchr
|
||||
I_strcat
|
||||
I_strlen
|
||||
I_memset
|
||||
I_memcpy
|
||||
I_memcmp
|
||||
sysclib_IMPORTS_end
|
||||
|
||||
sysmem_IMPORTS_start
|
||||
I_AllocSysMemory
|
||||
sysmem_IMPORTS_end
|
||||
|
||||
thbase_IMPORTS_start
|
||||
I_GetThreadId
|
||||
I_CreateThread
|
||||
I_StartThread
|
||||
I_SleepThread
|
||||
thbase_IMPORTS_end
|
9
ps2/libcdvd/iop/irx_imports.h
Normal file
9
ps2/libcdvd/iop/irx_imports.h
Normal file
@ -0,0 +1,9 @@
|
||||
#include <cdvdman.h>
|
||||
#include <intrman.h>
|
||||
#include <ioman.h>
|
||||
#include <sifcmd.h>
|
||||
#include <sifman.h>
|
||||
#include <stdio.h>
|
||||
#include <sysclib.h>
|
||||
#include <sysmem.h>
|
||||
#include <thbase.h>
|
45
ps2/libcdvd/license.txt
Normal file
45
ps2/libcdvd/license.txt
Normal file
@ -0,0 +1,45 @@
|
||||
Copyright (c) 2002, A.Lee & Nicholas Van Veen
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software, in source and binary forms, with or
|
||||
without modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. You are granted a license to use this software for academic, research and
|
||||
non-commercial purposes only.
|
||||
|
||||
4. The copyright holder imposes no restrictions on any code developed using
|
||||
this software. However, the copyright holder retains a non-exclusive
|
||||
royalty-free license to any modifications to the distribution made by the
|
||||
licensee.
|
||||
|
||||
5. Any licensee wishing to make commercial use of this software should contact
|
||||
the copyright holder to execute the appropriate license for such commercial
|
||||
use. Commercial use includes:
|
||||
|
||||
- Integration of all or part of the source code into a product for sale
|
||||
or commercial license by or on behalf of Licensee to third parties, or
|
||||
|
||||
- Distribution of the binary code or source code to third parties that
|
||||
need it to utilize a commercial product sold or licensed by or on
|
||||
behalf of Licensee.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
|
Loading…
x
Reference in New Issue
Block a user