Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion ee/rpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ SUBDIRS += remote
SUBDIRS += secr
SUBDIRS += sior
SUBDIRS += tcpips
SUBDIRS += xcdvd

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/Rules.make
8 changes: 7 additions & 1 deletion ee/rpc/cdvd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ NCMD_OBJS += _ncmd_internals.o _CdAlignReadBuffer.o sceCdRead.o sceCdReadDVDV.o
sceCdApplyNCmd.o sceCdReadIOPMem.o sceCdNCmdDiskReady.o \
sceCdGetReadPos.o sceCdStStart.o sceCdStRead.o sceCdStStop.o sceCdStSeek.o sceCdStInit.o \
sceCdStStat.o sceCdStPause.o sceCdStResume.o sceCdStream.o sceCdCddaStream.o sceCdSync.o \
_CdCheckNCmd.o sceCdReadKey.o
_CdCheckNCmd.o sceCdReadKey.o \
sceCdReadChain.o

SCMD_OBJS += _scmd_internals.o sceCdReadClock.o ps2time.o sceCdWriteClock.o sceCdGetDiskType.o \
sceCdGetError.o sceCdTrayReq.o sceCdApplySCmd.o sceCdStatus.o sceCdBreak.o \
Expand All @@ -24,8 +25,13 @@ SCMD_OBJS += _scmd_internals.o sceCdReadClock.o ps2time.o sceCdWriteClock.o sceC
sceCdReadConfig.o sceCdWriteConfig.o \
sceCdReadNVM.o sceCdWriteNVM.o sceCdRI.o sceCdWI.o sceCdReadConsoleID.o sceCdWriteConsoleID.o \
sceCdNoticeGameStart.o \
sceCdCancelPOffRdy.o sceCdBlueLedCtrl.o sceCdPowerOff.o sceCdMmode.o \
sceCdForbidRead.o sceCdSpinCtrlEE.o sceCdBootCertify.o sceCdRM.o sceCdWM.o \
sceCdChangeThreadPriority.o \
_CdSyncS.o

EE_LIB_ALTNAMES ?= libxcdvd.a

EE_OBJS = $(LIBCDVD_OBJS) $(NCMD_OBJS) $(SCMD_OBJS) erl-support.o

include $(PS2SDKSRC)/Defs.make
Expand Down
22 changes: 21 additions & 1 deletion ee/rpc/cdvd/src/libcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ extern void *_gp;
// prototypes
void _CdSemaExit(void);

typedef struct
{
int m_init_result;
/* The rest of the values in this struct are only set in SDK >= 2.0.0. */
/* Otherwise they are zero. */
int m_cdvdfsv_version;
int m_cdvdman_version;
int m_cdvdfsv_isverbose;
} CdInitPkt;

/** searchfile structure */
typedef struct
{
Expand All @@ -56,6 +66,9 @@ typedef struct
int bindInit = -1;
int bindDiskReady = -1;
int bindSearchFile = -1;
// version variables
int initVersionCdvdfsv;
int initVersionCdvdman;
// rpc binded client data
/** for sceCdInit() */
SifRpcClientData_t clientInit __attribute__((aligned(64)));
Expand Down Expand Up @@ -89,6 +102,8 @@ s32 diskReadyMode __attribute__((aligned(64)));
s32 trayReqData __attribute__((aligned(64)));
u32 initMode __attribute__((aligned(64)));

// init stuff
CdInitPkt cdInitRecvBuff __attribute__((aligned(64)));
// searchfile stuff
SearchFilePkt searchFileSendBuff __attribute__((aligned(64)));
u32 searchFileRecvBuff __attribute__((aligned(64)));
Expand All @@ -98,6 +113,8 @@ u32 searchFileRecvBuff __attribute__((aligned(64)));
extern int bindInit;
extern int bindDiskReady;
extern int bindSearchFile;
extern int initVersionCdvdfsv;
extern int initVersionCdvdman;
extern SifRpcClientData_t clientInit;
extern SifRpcClientData_t clientDiskReady;
extern SifRpcClientData_t clientSearchFile;
Expand All @@ -113,6 +130,7 @@ extern ee_thread_t callbackThreadParam;
extern s32 diskReadyMode;
extern s32 trayReqData;
extern u32 initMode;
extern CdInitPkt cdInitRecvBuff;
extern SearchFilePkt searchFileSendBuff;
extern u32 searchFileRecvBuff;

Expand Down Expand Up @@ -143,8 +161,10 @@ s32 sceCdInit(s32 mode)

bindInit = 0;
initMode = mode;
if (sceSifCallRpc(&clientInit, 0, 0, &initMode, 4, 0, 0, 0, 0) < 0)
if (sceSifCallRpc(&clientInit, 0, 0, &initMode, sizeof(initMode), &cdInitRecvBuff, sizeof(cdInitRecvBuff), 0, 0) < 0)
return 0;
initVersionCdvdfsv = cdInitRecvBuff.m_cdvdfsv_version;
initVersionCdvdman = cdInitRecvBuff.m_cdvdman_version;
if (mode == SCECdEXIT) {
if (CdDebug > 0)
printf("Libcdvd Exit\n");
Expand Down
72 changes: 61 additions & 11 deletions ee/rpc/cdvd/src/ncmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ u32 seekSector __attribute__((aligned(64)));
u32 cdda_st_buf[64 / sizeof(u32)] ALIGNED(64);
#endif

extern int initVersionCdvdfsv;
extern int bindNcmd;
extern SifRpcClientData_t clientNCmd;
extern int nCmdSemaId;
Expand All @@ -125,8 +126,7 @@ int sceCdNCmdDiskReady(void);

/* N-Command Functions */

#ifdef _XCDVD
struct _cdvd_read_data
struct _cdvd_read_data_1400
{
u32 size1;
u32 size2;
Expand All @@ -135,8 +135,7 @@ struct _cdvd_read_data
u8 src1[64];
u8 src2[64];
};
#else
struct _cdvd_read_data
struct _cdvd_read_data_1300
{
u32 size1;
u32 size2;
Expand All @@ -145,27 +144,42 @@ struct _cdvd_read_data
u8 src1[16];
u8 src2[16];
};
#endif

void _CdAlignReadBuffer(void *data);
extern void _CdAlignReadBuffer(void *data);
/** this gets called when the sceCdRead function finishes
* to copy the data read in to unaligned buffers
*/
#ifdef F__CdAlignReadBuffer
void _CdAlignReadBuffer(void *data)
{
struct _cdvd_read_data *uncached = UNCACHED_SEG(data);
if (initVersionCdvdfsv > 0x104)
{
struct _cdvd_read_data_1400 *uncached = UNCACHED_SEG(data);

if (uncached->size1 && uncached->dest1) {
memcpy(uncached->dest1, &uncached->src1, uncached->size1);
}

if (uncached->size1 && uncached->dest1) {
memcpy(uncached->dest1, &uncached->src1, uncached->size1);
if (uncached->size2 && uncached->dest2) {
memcpy(uncached->dest2, &uncached->src2, uncached->size2);
}
}
else
{
struct _cdvd_read_data_1300 *uncached = UNCACHED_SEG(data);

if (uncached->size2 && uncached->dest2) {
memcpy(uncached->dest2, &uncached->src2, uncached->size2);
if (uncached->size1 && uncached->dest1) {
memcpy(uncached->dest1, &uncached->src1, uncached->size1);
}

if (uncached->size2 && uncached->dest2) {
memcpy(uncached->dest2, &uncached->src2, uncached->size2);
}
}

_CdGenericCallbackFunction((void *)&CdCallbackNum);
}

#endif

#ifdef F_sceCdRead
Expand Down Expand Up @@ -815,6 +829,42 @@ int _CdCheckNCmd(int cmd)

nopdelay();
}
if (!initVersionCdvdfsv)
{
struct _cdvd_read_data_1400 tmpbuf;
int i;
int eq_count;
struct _cdvd_read_data_1400 *uncached;

uncached = UNCACHED_SEG(_rd_intr_data);
// Attempt to determine the size of the CDVD read unaligned buffer
readData[0] = 0;
readData[1] = 0;
readData[2] = (u32)NULL;
readData[3] = 0;
readData[4] = (u32)_rd_intr_data;

if (sceSifCallRpc(&clientNCmd, CD_NCMD_CDDAREAD, 0, readData, sizeof(readData), NULL, 0, 0, 0) < 0)
return 0;

// Nothing is read, so ensure that is the case
if (uncached->size1 || uncached->dest1 || uncached->size2 || uncached->dest2)
return 0;
tmpbuf = *uncached;
for (i = 0; i < sizeof(*uncached); i += 1)
((u8 *)uncached)[i] ^= 0xFF;

if (sceSifCallRpc(&clientNCmd, CD_NCMD_CDDAREAD, 0, readData, sizeof(readData), NULL, 0, 0, 0) < 0)
return 0;
// Nothing is read, so ensure that is the case
if (uncached->size1 || uncached->dest1 || uncached->size2 || uncached->dest2)
return 0;

eq_count = 0;
for (i = 0; i < sizeof(*uncached); i += 1)
eq_count += (((u8 *)uncached)[i] == ((u8 *)&tmpbuf)[i]) ? 1 : 0;
initVersionCdvdfsv = (eq_count > sizeof(struct _cdvd_read_data_1300)) ? 0x200 : 0x104;
}

bindNCmd = 0;
return 1;
Expand Down
7 changes: 2 additions & 5 deletions ee/rpc/cdvd/src/scmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ int sCmdNum = 0;
int CdConfigRdWrNumBlocks;
#endif

extern int initVersionCdvdman;
extern int bindSCmd;
extern SifRpcClientData_t clientSCmd;
extern int sCmdSemaId;
Expand Down Expand Up @@ -875,11 +876,7 @@ int sceCdMV(unsigned char *buffer, u32 *result)

if (sceSifCallRpc(&clientSCmd, CD_SCMD_READ_MECHACON_VERSION, 0, NULL, 0, sCmdRecvBuff, 16, NULL, NULL) >= 0) {

#ifdef _XCDVD
memcpy(buffer, UNCACHED_SEG(&sCmdRecvBuff[8]), 4);
#else
memcpy(buffer, UNCACHED_SEG(&sCmdRecvBuff[8]), 3);
#endif
memcpy(buffer, UNCACHED_SEG(&sCmdRecvBuff[8]), (initVersionCdvdman >= 0x200) ? 4 : 3);
*result = *(u32 *)UNCACHED_SEG(&sCmdRecvBuff[4]);
status = *(int *)UNCACHED_SEG(sCmdRecvBuff);
} else {
Expand Down
20 changes: 0 additions & 20 deletions ee/rpc/xcdvd/Makefile

This file was deleted.

Loading