Skip to content
Open
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
24 changes: 24 additions & 0 deletions common/include/libcdvd-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,30 @@ extern int sceCdReadRegionParams(u32 *arg1, u32 *result);
*/
extern int sceCdWriteRegionParams(u8 arg1, u32 *arg2, u8 *arg3, u32 *result);

/** Gets temperature of the temperature sensor connected to Mechacon in Celsius
* Minimum Mechacon firmware version: 50400
* SUPPORTED IN XCDVDMAN INCLUDED WITHIN NEWER BOOT ROMS ONLY
*
* @return 1 on success, 0 on failure
*/
extern int cdvdman_152_get_temperature(u32 *param, u32 *status);

/** Stores some sort of buffer from ATAPI drive to PS2 drive.
* Minimum Mechacon firmware version: 50400
* SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
*
* @return 1 on success, 0 on failure
*/
extern int cdvdman_167_atapi2dragon(u8 *inbuf, u32 *status);

/** Stores some sort of buffer from PS2 drive to ATAPI drive.
* Minimum Mechacon firmware version: 50400
* SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES
*
* @return 1 on success, 0 on failure
*/
extern int cdvdman_169_dragon2atapi(u8 *outbuf, u32 *status);

// Compatibility names for older ps2sdk versions.

// sceCdlFILE renames
Expand Down
2 changes: 1 addition & 1 deletion common/include/libcdvd-rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ typedef struct cdvdfsv_rpc3_3B_outpacket_
{
int m_retres;
u32 m_arg2;
u32 m_arg1;
u8 m_arg1[16];
} cdvdfsv_rpc3_3B_outpacket_t;

typedef struct cdvdfsv_rpc3_3C_outpacket_
Expand Down
1 change: 1 addition & 0 deletions iop/cdvd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SUBDIRS = \
cdvdman \
cdvdstm \
poffsim \
xatapi \
xesdrv

include $(PS2SDKSRC)/Defs.make
Expand Down
34 changes: 9 additions & 25 deletions iop/cdvd/cdvdfsv/src/cdvdfsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2360,7 +2360,7 @@ cdvdfsv_rpc3_2B_setfanprofile(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen,
#endif

#ifdef CDVD_VARIANT_OSD
static void cdvdfsv_rpc3_2C_i_152(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvdfsv_rpc3_outpacket_t *outbuf)
static void cdvdfsv_rpc3_2C_i_152_gettemperature(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvdfsv_rpc3_outpacket_t *outbuf)
{
int i;
u32 efbits;
Expand All @@ -2371,12 +2371,7 @@ static void cdvdfsv_rpc3_2C_i_152(const cdvdfsv_rpc3_inpacket_t *inbuf, int bufl
for ( i = 0; i < 3 && !outbuf->m_retres; i += 1 )
{
WaitEventFlag(g_scmd_evfid, 1, WEF_AND, &efbits);
#if 0
// TODO FIXME IMPORT
outbuf->m_retres = cdvdman_152(&outbuf->m_pkt_2C.m_arg1, &outbuf->m_pkt_2C.m_arg2);
#else
outbuf->m_retres = 1;
#endif
outbuf->m_retres = cdvdman_152_get_temperature(&outbuf->m_pkt_2C.m_arg1, &outbuf->m_pkt_2C.m_arg2);
}
}
#endif
Expand Down Expand Up @@ -2570,7 +2565,7 @@ cdvdfsv_rpc3_39_buzzerctl(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvd

#ifdef CDVD_VARIANT_XOSD
static void
cdvdfsv_rpc3_3A_resetwakeupreason(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvdfsv_rpc3_outpacket_t *outbuf)
cdvdfsv_rpc3_3A_i_167_atapi2dragon(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvdfsv_rpc3_outpacket_t *outbuf)
{
int i;
u32 efbits;
Expand All @@ -2580,19 +2575,13 @@ cdvdfsv_rpc3_3A_resetwakeupreason(const cdvdfsv_rpc3_inpacket_t *inbuf, int bufl
for ( i = 0; i < 3 && !outbuf->m_retres; i += 1 )
{
WaitEventFlag(g_scmd_evfid, 1, WEF_AND, &efbits);
#if 0
// TODO FIXME IMPORT
outbuf->m_retres = sceCdResetWakeupReason((u32 *)inbuf, &outbuf->m_pkt_3A.m_arg2);
#else
(void)inbuf;
outbuf->m_retres = 1;
#endif
outbuf->m_retres = cdvdman_167_atapi2dragon((char *)inbuf, &outbuf->m_pkt_3A.m_arg2);
}
}
#endif

#ifdef CDVD_VARIANT_XOSD
static void cdvdfsv_rpc3_3B_i_169(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvdfsv_rpc3_outpacket_t *outbuf)
static void cdvdfsv_rpc3_3B_i_169_dragon2atapi(const cdvdfsv_rpc3_inpacket_t *inbuf, int buflen, cdvdfsv_rpc3_outpacket_t *outbuf)
{
int i;
u32 efbits;
Expand All @@ -2603,12 +2592,7 @@ static void cdvdfsv_rpc3_3B_i_169(const cdvdfsv_rpc3_inpacket_t *inbuf, int bufl
for ( i = 0; i < 3 && !outbuf->m_retres; i += 1 )
{
WaitEventFlag(g_scmd_evfid, 1, WEF_AND, &efbits);
#if 0
// TODO FIXME IMPORT
outbuf->m_retres = cdvdman_169(&outbuf->m_pkt_3B.m_arg1, &outbuf->m_pkt_3B.m_arg2);
#else
outbuf->m_retres = 1;
#endif
outbuf->m_retres = cdvdman_169_dragon2atapi(outbuf->m_pkt_3B.m_arg1, &outbuf->m_pkt_3B.m_arg2);
}
}
#endif
Expand Down Expand Up @@ -3157,7 +3141,7 @@ static void *cbrpc_rpc3_cdvdscmds(int fno, void *buffer, int length)
cdvdfsv_rpc3_2B_setfanprofile(buffer, length, &g_outbuf);
break;
case 44:
cdvdfsv_rpc3_2C_i_152(buffer, length, &g_outbuf);
cdvdfsv_rpc3_2C_i_152_gettemperature(buffer, length, &g_outbuf);
break;
#endif
#ifdef CDVD_VARIANT_XOSD
Expand Down Expand Up @@ -3193,10 +3177,10 @@ static void *cbrpc_rpc3_cdvdscmds(int fno, void *buffer, int length)
cdvdfsv_rpc3_39_buzzerctl(buffer, length, &g_outbuf);
break;
case 58:
cdvdfsv_rpc3_3A_resetwakeupreason(buffer, length, &g_outbuf);
cdvdfsv_rpc3_3A_i_167_atapi2dragon(buffer, length, &g_outbuf);
break;
case 59:
cdvdfsv_rpc3_3B_i_169(buffer, length, &g_outbuf);
cdvdfsv_rpc3_3B_i_169_dragon2atapi(buffer, length, &g_outbuf);
break;
case 60:
cdvdfsv_rpc3_3C_xbspowerctl(buffer, length, &g_outbuf);
Expand Down
3 changes: 3 additions & 0 deletions iop/cdvd/cdvdman/include/cdvdman.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,14 @@ extern int sceCdDeobfuscateUsingUniqueKey(u8 *buffer, unsigned int shiftval, int
#define I_sceRemote2_7Get DECLARE_IMPORT(128, sceRemote2_7Get)
#define I_sceCdReadPS1BootParam DECLARE_IMPORT(148, sceCdReadPS1BootParam)
#define I_sceCdSetFanProfile DECLARE_IMPORT(150, sceCdSetFanProfile)
#define I_cdvdman_152_get_temperature DECLARE_IMPORT(152, cdvdman_152_get_temperature)
#define I_sceCdChgSys DECLARE_IMPORT(154, sceCdChgSys)
#define I_sceCdNoticeGameStart DECLARE_IMPORT(156, sceCdNoticeGameStart)
#define I_sceCdDeobfuscateUsingUniqueKey DECLARE_IMPORT(161, sceCdDeobfuscateUsingUniqueKey)
#define I_sceCdXLEDCtl DECLARE_IMPORT(163, sceCdXLEDCtl)
#define I_sceCdBuzzerCtl DECLARE_IMPORT(165, sceCdBuzzerCtl)
#define I_cdvdman_167_atapi2dragon DECLARE_IMPORT(167, cdvdman_167_atapi2dragon)
#define I_cdvdman_169_dragon2atapi DECLARE_IMPORT(169, cdvdman_169_dragon2atapi)
#define I_sceCdXBSPowerCtl DECLARE_IMPORT(171, sceCdXBSPowerCtl)
#define I_sceCdSetAtapiEjectCallback DECLARE_IMPORT(173, sceCdSetAtapiEjectCallback)
#define I_sceCdSetMediumRemoval DECLARE_IMPORT(175, sceCdSetMediumRemoval)
Expand Down
12 changes: 6 additions & 6 deletions iop/cdvd/cdvdman/src/cdvdman.c
Original file line number Diff line number Diff line change
Expand Up @@ -7808,7 +7808,7 @@ int sceCdSetFanProfile(u8 param, u32 *status)
return retval;
}

int cdvdman_152(u32 *param, u32 *status)
int cdvdman_152_get_temperature(u32 *param, u32 *status)
{
int retval;
char rdata[3];
Expand Down Expand Up @@ -8667,20 +8667,20 @@ int sceCdBuzzerCtl(u32 *status)
#endif

#ifdef CDVD_VARIANT_XOSD
int sceCdResetWakeupReason(u32 *inbuf, u32 *status)
int cdvdman_167_atapi2dragon(u8 *inbuf, u32 *status)
{
if ( !g_cdvdman_minver_50600 )
{
*status = 256;
return 1;
}
*status = SCECdErNO;
return cdvdman_write_scmd_swap_dev5(0x2F, (char *)inbuf, 16, (char *)status, 1, 1);
return cdvdman_write_scmd_swap_dev5(0x2F, inbuf, 16, (char *)status, 1, 1);
}
#endif

#ifdef CDVD_VARIANT_XOSD
int cdvdman_169(u32 *arg1, u32 *status)
int cdvdman_169_dragon2atapi(u8 *outbuf, u32 *status)
{
int i;
int retval;
Expand All @@ -8698,7 +8698,7 @@ int cdvdman_169(u32 *arg1, u32 *status)
{
return 0;
}
memset(arg1, 0, 16);
memset(outbuf, 0, 16);
if ( *status )
{
vSetEventFlag(g_scmd_evfid, 1);
Expand All @@ -8713,7 +8713,7 @@ int cdvdman_169(u32 *arg1, u32 *status)
{
DelayThread(2000);
retval = cdvdman_write_scmd_swap_dev5(0x30, wdata, sizeof(wdata), rdata, sizeof(rdata), 0);
memcpy(&arg1[i * 2], &rdata[1], sizeof(rdata) - 1);
memcpy(&outbuf[i * 8], &rdata[1], sizeof(rdata) - 1);
*status = rdata[0];
}
}
Expand Down
29 changes: 29 additions & 0 deletions iop/cdvd/xatapi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

IOP_BIN ?= xatapi.irx

IOP_CFLAGS += -DBUILDING_CDVD_MODULE

IOP_IMPORT_INCS += \
cdvd/cdvdman \
system/dmacman \
system/intrman \
system/iomanx \
system/loadcore \
system/stdio \
system/sysclib \
system/sysmem \
system/threadman

IOP_OBJS = xatapi.o imports.o exports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
include $(PS2SDKSRC)/iop/Rules.make
include $(PS2SDKSRC)/iop/Rules.release
62 changes: 62 additions & 0 deletions iop/cdvd/xatapi/include/xatapi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

/**
* @file
* SPEED ATAPI device driver definitions and imports.
*/

#ifndef _XATAPI_H
#define _XATAPI_H

#include <tamtypes.h>

extern int xatapi_2_terminate(int with_quit);
extern int xatapi_4_sceAtaSoftReset(void);
extern int xatapi_5_sceAtaExecCmd(
void *buf,
u32 blkcount,
u16 feature,
u16 nsector,
u16 sector,
u16 lcyl,
u16 hcyl,
u16 select,
u16 command,
u32 unk10);
extern int xatapi_6_sceAtaWaitResult(void);
extern int xatapi_7_sceCdAtapiExecCmd(s16 n, void *buf, int nsec, int secsize, void *pkt, int pkt_len, int proto);
extern int xatapi_8_sceCdAtapiWaitResult(void);
extern void xatapi_9_sceCdSpdAtaDmaStart(int dir);
extern void xatapi_10_sceCdSpdAtaDmaEnd(void);
extern int xatapi_11_sceAtaGetError(void);
extern int xatapi_12_get_ata_control(void);
extern int xatapi_13_get_speed_reg(int regaddr);
extern int xatapi_14_set_speed_reg(int regaddr, u16 regval);
extern int xatapi_15_exec_f6_f9_scsi(void);

#define xatapi_IMPORTS_start DECLARE_IMPORT_TABLE(xatapi, 1, 1)
#define xatapi_IMPORTS_end END_IMPORT_TABLE

#define I_xatapi_2_terminate DECLARE_IMPORT(2, xatapi_2_terminate)
#define I_xatapi_4_sceAtaSoftReset DECLARE_IMPORT(4, xatapi_4_sceAtaSoftReset)
#define I_xatapi_5_sceAtaExecCmd DECLARE_IMPORT(5, xatapi_5_sceAtaExecCmd)
#define I_xatapi_6_sceAtaWaitResult DECLARE_IMPORT(6, xatapi_6_sceAtaWaitResult)
#define I_xatapi_7_sceCdAtapiExecCmd DECLARE_IMPORT(7, xatapi_7_sceCdAtapiExecCmd)
#define I_xatapi_8_sceCdAtapiWaitResult DECLARE_IMPORT(8, xatapi_8_sceCdAtapiWaitResult)
#define I_xatapi_9_sceCdSpdAtaDmaStart DECLARE_IMPORT(9, xatapi_9_sceCdSpdAtaDmaStart)
#define I_xatapi_10_sceCdSpdAtaDmaEnd DECLARE_IMPORT(10, xatapi_10_sceCdSpdAtaDmaEnd)
#define I_xatapi_11_sceAtaGetError DECLARE_IMPORT(11, xatapi_11_sceAtaGetError)
#define I_xatapi_12_get_ata_control DECLARE_IMPORT(12, xatapi_12_get_ata_control)
#define I_xatapi_13_get_speed_reg DECLARE_IMPORT(13, xatapi_13_get_speed_reg)
#define I_xatapi_14_set_speed_reg DECLARE_IMPORT(14, xatapi_14_set_speed_reg)
#define I_xatapi_15_exec_f6_f9_scsi DECLARE_IMPORT(15, xatapi_15_exec_f6_f9_scsi)

#endif
21 changes: 21 additions & 0 deletions iop/cdvd/xatapi/src/exports.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

DECLARE_EXPORT_TABLE(xatapi, 1, 1)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(xatapi_2_terminate)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(xatapi_4_sceAtaSoftReset)
DECLARE_EXPORT(xatapi_5_sceAtaExecCmd)
DECLARE_EXPORT(xatapi_6_sceAtaWaitResult)
DECLARE_EXPORT(xatapi_7_sceCdAtapiExecCmd)
DECLARE_EXPORT(xatapi_8_sceCdAtapiWaitResult)
DECLARE_EXPORT(xatapi_9_sceCdSpdAtaDmaStart)
DECLARE_EXPORT(xatapi_10_sceCdSpdAtaDmaEnd)
DECLARE_EXPORT(xatapi_11_sceAtaGetError)
DECLARE_EXPORT(xatapi_12_get_ata_control)
DECLARE_EXPORT(xatapi_13_get_speed_reg)
DECLARE_EXPORT(xatapi_14_set_speed_reg)
DECLARE_EXPORT(xatapi_15_exec_f6_f9_scsi)
END_EXPORT_TABLE

void _retonly() {}
75 changes: 75 additions & 0 deletions iop/cdvd/xatapi/src/imports.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

sysmem_IMPORTS_start
I_Kprintf
sysmem_IMPORTS_end

loadcore_IMPORTS_start
I_RegisterLibraryEntries
loadcore_IMPORTS_end

intrman_IMPORTS_start
I_CpuSuspendIntr
I_CpuResumeIntr
I_QueryIntrContext
intrman_IMPORTS_end

stdio_IMPORTS_start
I_printf
stdio_IMPORTS_end

dmacman_IMPORTS_start
I_dmac_ch_set_madr
I_dmac_ch_get_madr
I_dmac_ch_set_bcr
I_dmac_ch_get_bcr
I_dmac_ch_set_chcr
I_dmac_ch_get_chcr
dmacman_IMPORTS_end

thbase_IMPORTS_start
I_DelayThread
I_SetAlarm
I_CancelAlarm
I_USec2SysClock
thbase_IMPORTS_end

thevent_IMPORTS_start
I_CreateEventFlag
I_DeleteEventFlag
I_SetEventFlag
I_iSetEventFlag
I_ClearEventFlag
I_WaitEventFlag
I_PollEventFlag
I_ReferEventFlagStatus
I_iReferEventFlagStatus
thevent_IMPORTS_end

thsemap_IMPORTS_start
I_CreateSema
I_SignalSema
I_WaitSema
thsemap_IMPORTS_end

sysclib_IMPORTS_start
I_look_ctype_table
I_memcpy
I_memset
I_strncmp
sysclib_IMPORTS_end

iomanX_IMPORTS_start
I_AddDrv
I_DelDrv
iomanX_IMPORTS_end

cdvdman_IMPORTS_start
I_sceCdSC
I_sceCdChgSys
I_sceCdBuzzerCtl
I_cdvdman_167_atapi2dragon
I_cdvdman_169_dragon2atapi
I_sceCdSetAtapiEjectCallback
I_sceCdSetMediumRemoval
I_sceCdGetMediumRemoval
cdvdman_IMPORTS_end
Loading