Skip to content

Commit

Permalink
Change definitions to use the ps2sdk definitions where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jun 26, 2021
1 parent 5f924f8 commit e2b5b61
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 451 deletions.
3 changes: 2 additions & 1 deletion modules/iopcore/cdvdfsv/cdvdfsv-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#include <thbase.h>
#include <thevent.h>
#include <thsemap.h>
#include <cdvdman.h>

#include "cdvdman.h"
#include "cdvdman_opl.h"
#include "smsutils.h"

extern void cdvdfsv_register_scmd_rpc(SifRpcDataQueue_t *rpc_DQ);
Expand Down
2 changes: 1 addition & 1 deletion modules/iopcore/cdvdfsv/irx_imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <irx.h>

#include "cdvdman.h"
#include <cdvdman.h>
#include <intrman.h>
#include <loadcore.h>
#include <sifcmd.h>
Expand Down
26 changes: 13 additions & 13 deletions modules/iopcore/cdvdfsv/ncmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef struct
u32 lsn;
u32 sectors;
void *buf;
cd_read_mode_t mode;
sceCdRMode mode;
void *eeaddr1;
void *eeaddr2;
} RpcCdvd_t;
Expand All @@ -22,7 +22,7 @@ typedef struct
u32 sectors;
void *buf;
int cmd;
cd_read_mode_t mode;
sceCdRMode mode;
u32 pad;
} RpcCdvdStream_t;

Expand Down Expand Up @@ -51,7 +51,7 @@ typedef struct
u8 buf2[64];
} cdvdfsv_readee_t;

static cd_read_mode_t cdvdfsv_Stmode;
static sceCdRMode cdvdfsv_Stmode;

static SifRpcServerData_t cdvdNcmds_rpcSD;
static u8 cdvdNcmds_rpcbuf[1024];
Expand Down Expand Up @@ -161,7 +161,7 @@ static inline void cdvd_readee(void *buf)

while (1) {
do {
if ((sectors_to_read == 0) || (sceCdGetError() == CDVD_ERR_ABRT)) {
if ((sectors_to_read == 0) || (sceCdGetError() == SCECdErABRT)) {
sysmemSendEE((void *)&readee, (void *)r->eeaddr1, sizeof(cdvdfsv_readee_t));

*((u32 *)&curlsn_buf[0]) = nbytes;
Expand All @@ -187,8 +187,8 @@ static inline void cdvd_readee(void *buf)
}

if (sceCdRead(r->lsn, temp, (void *)fsvRbuf, NULL) == 0) {
if (sceCdGetError() == CDVD_ERR_NO) {
fsverror = CDVD_ERR_READCF;
if (sceCdGetError() == SCECdErNO) {
fsverror = SCECdErREADCF;
sceCdSC(CDSC_SET_ERROR, &fsverror);
}

Expand Down Expand Up @@ -297,8 +297,8 @@ static inline void cdvd_readiopm(void *buf)
}

if (r == 0) {
if (sceCdGetError() == CDVD_ERR_NO) {
fsverror = CDVD_ERR_READCFR;
if (sceCdGetError() == SCECdErNO) {
fsverror = SCECdErREADCFR;
sceCdSC(CDSC_SET_ERROR, &fsverror);
}
}
Expand All @@ -323,8 +323,8 @@ static inline void cdvd_readchain(void *buf)

if ((u32)ch->buf & 1) { // IOP addr
if (sceCdRead(lsn, tsectors, (void *)addr, NULL) == 0) {
if (sceCdGetError() == CDVD_ERR_NO) {
fsverror = CDVD_ERR_READCFR;
if (sceCdGetError() == SCECdErNO) {
fsverror = SCECdErREADCFR;
sceCdSC(CDSC_SET_ERROR, &fsverror);
}

Expand All @@ -339,8 +339,8 @@ static inline void cdvd_readchain(void *buf)
nsectors = (tsectors > CDVDMAN_FS_SECTORS) ? CDVDMAN_FS_SECTORS : tsectors;

if (sceCdRead(lsn, nsectors, cdvdfsv_buf, NULL) == 0) {
if (sceCdGetError() == CDVD_ERR_NO) {
fsverror = CDVD_ERR_READCF;
if (sceCdGetError() == SCECdErNO) {
fsverror = SCECdErREADCF;
sceCdSC(CDSC_SET_ERROR, &fsverror);
}

Expand Down Expand Up @@ -368,7 +368,7 @@ static inline void rpcNCmd_cdreadDiskID(void *buf)
u8 *p = (u8 *)buf;

mips_memset(p, 0, 10);
*(int *)buf = sceCdReadDiskID(&p[4]);
*(int *)buf = sceCdReadDiskID((unsigned int *)&p[4]);
}

//-------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions modules/iopcore/cdvdfsv/scmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
typedef struct
{
int result;
cd_clock_t rtc;
sceCdCLOCK rtc;
} cdvdreadclock_res_t;

typedef struct
Expand Down Expand Up @@ -91,7 +91,7 @@ static inline void rpcSCmd_cdreadGUID(void *buf)

cdvdSCmd_res_t *r = (cdvdSCmd_res_t *)buf;

r->result = sceCdReadGUID(&r->param1);
r->result = sceCdReadGUID((u64 *)&r->param1);
}

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -151,7 +151,7 @@ static void *cbrpc_cdvdScmds(int fno, void *buf, int size)
*(int *)buf = 1;
break;
case CDVDFSV_SCMD_POWEROFF:
*(int *)buf = sceCdPowerOff((int *)buf);
*(int *)buf = sceCdPowerOff((u32 *)buf);
break;
case CDVDFSV_SCMD_MMODE:
*(int *)buf = sceCdMmode(*(int *)buf);
Expand Down
42 changes: 21 additions & 21 deletions modules/iopcore/cdvdfsv/searchfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
#include "cdvdfsv-internal.h"

typedef struct
{ // size =0x124
cd_file_t cdfile; // 0x000
char name[256]; // 0x020
void *dest; // 0x120
{ // size =0x124
sceCdlFILE cdfile; // 0x000
char name[256]; // 0x020
void *dest; // 0x120
} SearchFilePkt_t;

typedef struct
{ // size =0x128
cd_file_t cdfile; // 0x000
u32 flag; // 0x020
char name[256]; // 0x024
void *dest; // 0x124
{ // size =0x128
sceCdlFILE cdfile; // 0x000
u32 flag; // 0x020
char name[256]; // 0x024
void *dest; // 0x124
} SearchFilePkt2_t;

typedef struct
{ // size =0x12c
cd_file_t cdfile; // 0x000
u32 flag; // 0x020
char name[256]; // 0x024
void *dest; // 0x124
int layer; // 0x128
{ // size =0x12c
sceCdlFILE cdfile; // 0x000
u32 flag; // 0x020
char name[256]; // 0x024
void *dest; // 0x124
int layer; // 0x128
} SearchFilePktl_t;

static SifRpcServerData_t cdsearchfile_rpcSD;
Expand All @@ -50,21 +50,21 @@ static void *cbrpc_cdsearchfile(int fno, void *buf, int size)
if (size == sizeof(SearchFilePkt2_t)) {
ee_addr = (void *)pkt2->dest; // Search File: Called from Not Dual_layer Version
p = (void *)&pkt2->name[0];
pktsize = sizeof(cd_file_t) + sizeof(u32);
r = sceCdSearchFile((cd_file_t *)buf, p);
pktsize = sizeof(sceCdlFILE) + sizeof(u32);
r = sceCdSearchFile((sceCdlFILE *)buf, p);
pkt2->flag = 0;
} else {
if (size > sizeof(SearchFilePkt2_t)) { // Search File: Called from Dual_layer Version
ee_addr = (void *)pktl->dest;
p = (char *)&pktl->name[0];
pktsize = sizeof(cd_file_t) + sizeof(u32);
r = sceCdLayerSearchFile((cd_file_t *)buf, p, pktl->layer);
pktsize = sizeof(sceCdlFILE) + sizeof(u32);
r = sceCdLayerSearchFile((sceCdlFILE *)buf, p, pktl->layer);
pktl->flag = 0;
} else { // Search File: Called from Old Library
ee_addr = (void *)pkt->dest;
p = (char *)&pkt->name[0];
pktsize = sizeof(cd_file_t);
r = sceCdSearchFile((cd_file_t *)buf, p);
pktsize = sizeof(sceCdlFILE);
r = sceCdSearchFile((sceCdlFILE *)buf, p);
}
}

Expand Down
42 changes: 21 additions & 21 deletions modules/iopcore/cdvdman/cdvdman.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern struct irx_export_table _exp_dev9;

// internal functions prototypes
static void oplShutdown(int poff);
static int cdvdman_writeSCmd(u8 cmd, void *in, u32 in_size, void *out, u32 out_size);
static int cdvdman_writeSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 out_size);
static unsigned int event_alarm_cb(void *args);
static void cdvdman_signal_read_end(void);
static void cdvdman_signal_read_end_intr(void);
Expand Down Expand Up @@ -75,7 +75,7 @@ void oplRegisterShutdownCallback(oplShutdownCb_t cb)

static void oplShutdown(int poff)
{
int stat;
u32 stat;

DeviceLock();
if (vmcShutdownCb != NULL)
Expand Down Expand Up @@ -107,7 +107,7 @@ void cdvdman_init(void)
#endif

if (!cdvdman_cdinited) {
cdvdman_stat.err = CDVD_ERR_NO;
cdvdman_stat.err = SCECdErNO;

cdvdman_fs_init();

Expand Down Expand Up @@ -146,10 +146,10 @@ static int cdvdman_read_sectors(u32 lsn, unsigned int sectors, void *buf)

DPRINTF("cdvdman_read lsn=%lu sectors=%u buf=%p\n", lsn, sectors, buf);

cdvdman_stat.err = CDVD_ERR_NO;
cdvdman_stat.err = SCECdErNO;

for (ptr = buf, remaining = sectors; remaining > 0;) {
if (cdvdman_stat.err != CDVD_ERR_NO)
if (cdvdman_stat.err != SCECdErNO)
break;

SectorsToRead = remaining;
Expand All @@ -168,7 +168,7 @@ static int cdvdman_read_sectors(u32 lsn, unsigned int sectors, void *buf)
}

if (DeviceReadSectors(lsn, ptr, SectorsToRead) != 0) {
cdvdman_stat.err = CDVD_ERR_READ;
cdvdman_stat.err = SCECdErREAD;
if (cdvdman_settings.common.flags & IOPCORE_COMPAT_ACCU_READS)
CancelAlarm(&cdvdemu_read_end_cb, NULL);
break;
Expand Down Expand Up @@ -204,12 +204,12 @@ static int cdvdman_read_sectors(u32 lsn, unsigned int sectors, void *buf)
}
}

return (cdvdman_stat.err == CDVD_ERR_NO ? 0 : 1);
return (cdvdman_stat.err == SCECdErNO ? 0 : 1);
}

static int cdvdman_read(u32 lsn, u32 sectors, void *buf)
{
cdvdman_stat.status = CDVD_STAT_READ;
cdvdman_stat.status = SCECdStatRead;

buf = (void *)PHYSADDR(buf);
#ifdef HDD_DRIVER //As of now, only the ATA interface requires this. We do this here to share cdvdman_buf.
Expand Down Expand Up @@ -246,13 +246,13 @@ static int cdvdman_read(u32 lsn, u32 sectors, void *buf)

ReadPos = 0; /* Reset the buffer offset indicator. */

cdvdman_stat.status = CDVD_STAT_PAUSE;
cdvdman_stat.status = SCECdStatPause;

return 1;
}

//-------------------------------------------------------------------------
int sceCdGetReadPos(void)
u32 sceCdGetReadPos(void)
{
DPRINTF("sceCdGetReadPos\n");

Expand Down Expand Up @@ -331,16 +331,16 @@ int cdvdman_SyncRead(u32 lsn, u32 sectors, void *buf)
//-------------------------------------------------------------------------
static void cdvdman_initDiskType(void)
{
cdvdman_stat.err = CDVD_ERR_NO;
cdvdman_stat.err = SCECdErNO;

cdvdman_stat.disc_type_reg = (int)cdvdman_settings.common.media;
DPRINTF("DiskType=0x%x\n", cdvdman_settings.common.media);
}

//-------------------------------------------------------------------------
int sceCdPosToInt(cd_location_t *p)
u32 sceCdPosToInt(sceCdlLOCCD *p)
{
register int result;
register u32 result;

result = ((u32)p->minute >> 16) * 10 + ((u32)p->minute & 0xF);
result *= 60;
Expand All @@ -353,9 +353,9 @@ int sceCdPosToInt(cd_location_t *p)
}

//-------------------------------------------------------------------------
cd_location_t *sceCdIntToPos(int i, cd_location_t *p)
sceCdlLOCCD *sceCdIntToPos(u32 i, sceCdlLOCCD *p)
{
register int sc, se, mi;
register u32 sc, se, mi;

i += 150;
se = i / 75;
Expand All @@ -370,7 +370,7 @@ cd_location_t *sceCdIntToPos(int i, cd_location_t *p)
}

//-------------------------------------------------------------------------
int *sceCdCallback(void *func)
sceCdCBFunc sceCdCallback(sceCdCBFunc func)
{
int oldstate;
void *old_cb;
Expand All @@ -387,7 +387,7 @@ int *sceCdCallback(void *func)

CpuResumeIntr(oldstate);

return (int *)old_cb;
return old_cb;
}

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -431,7 +431,7 @@ int sceCdSC(int code, int *param)
}

//-------------------------------------------------------------------------
static int cdvdman_writeSCmd(u8 cmd, void *in, u32 in_size, void *out, u32 out_size)
static int cdvdman_writeSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 out_size)
{
int i;
u8 *p;
Expand Down Expand Up @@ -484,7 +484,7 @@ static int cdvdman_writeSCmd(u8 cmd, void *in, u32 in_size, void *out, u32 out_s
}

//--------------------------------------------------------------
int cdvdman_sendSCmd(u8 cmd, void *in, u32 in_size, void *out, u32 out_size)
int cdvdman_sendSCmd(u8 cmd, const void *in, u16 in_size, void *out, u16 out_size)
{
int r, retryCount = 0;

Expand Down Expand Up @@ -575,8 +575,8 @@ static void cdvdman_startThreads(void)
{
iop_thread_t thread_param;

cdvdman_stat.status = CDVD_STAT_PAUSE;
cdvdman_stat.err = CDVD_ERR_NO;
cdvdman_stat.status = SCECdStatPause;
cdvdman_stat.err = SCECdErNO;

thread_param.thread = &cdvdman_cdread_Thread;
thread_param.stacksize = 0x1000;
Expand Down
20 changes: 0 additions & 20 deletions modules/iopcore/cdvdman/device-bdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,9 @@
Review Open PS2 Loader README & LICENSE files for further details.
*/

#include "smsutils.h"
#include "atad.h"
#include "ioplib_util.h"
#include "cdvdman.h"
#include "internal.h"
#include "cdvd_config.h"

#include <bdm.h>
#include <loadcore.h>
#include <stdio.h>
#include <sysclib.h>
#include <sysmem.h>
#include <thbase.h>
#include <thevent.h>
#include <intrman.h>
#include <ioman.h>
#include <thsemap.h>
#include <usbd.h>
#include <errno.h>
#include <io_common.h>
#include "ioman_add.h"

#include <errno.h>

#include "device.h"

Expand Down
Loading

0 comments on commit e2b5b61

Please sign in to comment.