2009-05-03 20:53:31 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
|
|
|
|
/* Constants */
|
2010-09-19 01:16:05 +02:00
|
|
|
#define IOCTL_DI_READID 0x70
|
|
|
|
#define IOCTL_DI_READ 0x71
|
|
|
|
#define IOCTL_DI_WAITCVRCLOSE 0x79
|
|
|
|
#define IOCTL_DI_GETCOVER 0x88
|
|
|
|
#define IOCTL_DI_RESET 0x8A
|
|
|
|
#define IOCTL_DI_OPENPART 0x8B
|
|
|
|
#define IOCTL_DI_CLOSEPART 0x8C
|
|
|
|
#define IOCTL_DI_UNENCREAD 0x8D
|
|
|
|
#define IOCTL_DI_SEEK 0xAB
|
|
|
|
#define IOCTL_DI_STOPLASER 0xD2
|
|
|
|
#define IOCTL_DI_OFFSET 0xD9
|
|
|
|
#define IOCTL_DI_DISC_BCA 0xDA
|
|
|
|
#define IOCTL_DI_STOPMOTOR 0xE3
|
|
|
|
#define IOCTL_DI_SETUSBMODE 0xF4
|
|
|
|
#define IOCTL_DI_DISABLERESET 0xF6
|
2009-07-30 07:41:12 +02:00
|
|
|
|
|
|
|
/** Hermes IOS222 **/
|
2010-09-19 01:16:05 +02:00
|
|
|
#define DI_SETWBFSMODE 0xfe
|
2009-07-30 07:41:12 +02:00
|
|
|
#define DI_SETOFFSETBASE 0xf1
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
/* Variables */
|
2010-09-19 01:16:05 +02:00
|
|
|
static u32 inbuf[8] ATTRIBUTE_ALIGN( 32 );
|
|
|
|
static u32 outbuf[8] ATTRIBUTE_ALIGN( 32 );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
static const char di_fs[] ATTRIBUTE_ALIGN( 32 ) = "/dev/di";
|
2009-05-03 20:53:31 +02:00
|
|
|
static s32 di_fd = -1;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Init( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Open "/dev/di" */
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( di_fd < 0 )
|
|
|
|
{
|
|
|
|
di_fd = IOS_Open( di_fs, 0 );
|
|
|
|
if ( di_fd < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return di_fd;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
return 0;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Close( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Close "/dev/di" */
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( di_fd >= 0 )
|
|
|
|
{
|
|
|
|
IOS_Close( di_fd );
|
2009-07-30 07:41:12 +02:00
|
|
|
di_fd = -1;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
return 0;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_GetHandle( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Return di handle */
|
|
|
|
return di_fd;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Reset( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Reset drive */
|
|
|
|
inbuf[0] = IOCTL_DI_RESET << 24;
|
|
|
|
inbuf[1] = 1;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_RESET, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_ReadDiskId( void *id )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Read disc ID */
|
|
|
|
inbuf[0] = IOCTL_DI_READID << 24;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_READID, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret == 1 )
|
|
|
|
{
|
|
|
|
memcpy( id, outbuf, sizeof( dvddiskid ) );
|
2009-07-30 07:41:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
return -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Seek( u64 offset )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Drive seek */
|
|
|
|
inbuf[0] = IOCTL_DI_SEEK << 24;
|
2010-09-19 01:16:05 +02:00
|
|
|
inbuf[1] = ( u32 )( offset >> 2 );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_SEEK, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret != 1 )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
// Try old cIOS 222
|
|
|
|
/* Drive seek */
|
|
|
|
inbuf[0] = DI_SETOFFSETBASE << 24;
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, DI_SETOFFSETBASE, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
2009-07-30 07:41:12 +02:00
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Offset( u64 offset )
|
|
|
|
{
|
2009-10-14 23:59:13 +02:00
|
|
|
//u32 *off = (u32 *)((void *)&offset);
|
2010-09-19 01:16:05 +02:00
|
|
|
union { u64 off64; u32 off32[2]; } off; off.off64 = offset;
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Set offset */
|
|
|
|
inbuf[0] = IOCTL_DI_OFFSET << 24;
|
2010-09-19 01:16:05 +02:00
|
|
|
inbuf[1] = ( off.off32[0] ) ? 1 : 0;
|
|
|
|
inbuf[2] = ( off.off32[1] >> 2 );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_OFFSET, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_StopLaser( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Stop laser */
|
|
|
|
inbuf[0] = IOCTL_DI_STOPLASER << 24;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_STOPLASER, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_StopMotor( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Stop motor */
|
|
|
|
inbuf[0] = IOCTL_DI_STOPMOTOR << 24;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_STOPMOTOR, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-07-30 07:41:12 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_OpenPartition( u64 offset )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
u8 *vector = NULL;
|
|
|
|
|
|
|
|
u32 *buffer = NULL;
|
|
|
|
s32 ret;
|
|
|
|
|
|
|
|
/* Allocate memory */
|
2010-09-19 01:16:05 +02:00
|
|
|
buffer = ( u32 * )memalign( 32, 0x5000 );
|
|
|
|
if ( !buffer )
|
2009-07-30 07:41:12 +02:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Set vector pointer */
|
2010-09-19 01:16:05 +02:00
|
|
|
vector = ( u8 * )buffer;
|
2009-07-30 07:41:12 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( buffer, 0, 0x5000 );
|
2009-07-30 07:41:12 +02:00
|
|
|
|
|
|
|
/* Open partition */
|
2010-09-19 01:16:05 +02:00
|
|
|
buffer[0] = ( u32 )( buffer + 0x10 );
|
2009-07-30 07:41:12 +02:00
|
|
|
buffer[1] = 0x20;
|
|
|
|
buffer[3] = 0x024A;
|
2010-09-19 01:16:05 +02:00
|
|
|
buffer[6] = ( u32 )( buffer + 0x380 );
|
2009-07-30 07:41:12 +02:00
|
|
|
buffer[7] = 0x49E4;
|
2010-09-19 01:16:05 +02:00
|
|
|
buffer[8] = ( u32 )( buffer + 0x360 );
|
2009-07-30 07:41:12 +02:00
|
|
|
buffer[9] = 0x20;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
buffer[( 0x40 >> 2 )] = IOCTL_DI_OPENPART << 24;
|
|
|
|
buffer[( 0x40 >> 2 ) + 1] = offset >> 2;
|
2009-07-30 07:41:12 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctlv( di_fd, IOCTL_DI_OPENPART, 3, 2, ( ioctlv * )vector );
|
2009-07-30 07:41:12 +02:00
|
|
|
|
|
|
|
/* Free memory */
|
2010-09-19 01:16:05 +02:00
|
|
|
free( buffer );
|
2009-07-30 07:41:12 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_ClosePartition( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Close partition */
|
|
|
|
inbuf[0] = IOCTL_DI_CLOSEPART << 24;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_CLOSEPART, inbuf, sizeof( inbuf ), NULL, 0 );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_UnencryptedRead( void *buf, u32 len, u64 offset )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Unencrypted read */
|
|
|
|
inbuf[0] = IOCTL_DI_UNENCREAD << 24;
|
|
|
|
inbuf[1] = len;
|
2010-09-19 01:16:05 +02:00
|
|
|
inbuf[2] = ( u32 )( offset >> 2 );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_UNENCREAD, inbuf, sizeof( inbuf ), buf, len );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Read( void *buf, u32 len, u64 offset )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Disc read */
|
|
|
|
inbuf[0] = IOCTL_DI_READ << 24;
|
|
|
|
inbuf[1] = len;
|
2010-09-19 01:16:05 +02:00
|
|
|
inbuf[2] = ( u32 )( offset >> 2 );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_READ, inbuf, sizeof( inbuf ), buf, len );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_WaitForDisc( void )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Wait for disc */
|
|
|
|
inbuf[0] = IOCTL_DI_WAITCVRCLOSE << 24;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_WAITCVRCLOSE, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_GetCoverStatus( u32 *status )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Get cover status */
|
|
|
|
inbuf[0] = IOCTL_DI_GETCOVER << 24;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_GETCOVER, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret == 1 )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Copy cover status */
|
2010-09-19 01:16:05 +02:00
|
|
|
memcpy( status, outbuf, sizeof( u32 ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
return -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_DisableReset( u8 val )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-07-30 07:41:12 +02:00
|
|
|
/* Disable/Enable reset */
|
|
|
|
inbuf[0] = IOCTL_DI_DISABLERESET << 24;
|
|
|
|
inbuf[1] = val;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_DISABLERESET, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-05-03 20:53:31 +02:00
|
|
|
}
|
2009-07-30 07:41:12 +02:00
|
|
|
|
2009-06-12 01:02:05 +02:00
|
|
|
/** Hermes **/
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_SetUSBMode( const u8 *id, s32 partition )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
s32 ret;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-07-30 07:41:12 +02:00
|
|
|
|
|
|
|
/* Set USB mode */
|
|
|
|
inbuf[0] = IOCTL_DI_SETUSBMODE << 24;
|
2010-09-19 01:16:05 +02:00
|
|
|
inbuf[1] = ( id ) ? 1 : 0;
|
2009-07-30 07:41:12 +02:00
|
|
|
|
|
|
|
/* Copy ID */
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( id )
|
|
|
|
{
|
|
|
|
memcpy( &inbuf[2], id, 6 );
|
|
|
|
if ( IOS_GetVersion() != 249 )
|
|
|
|
{
|
|
|
|
inbuf[5] = partition;
|
|
|
|
}
|
2009-07-30 07:41:12 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_SETUSBMODE, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
|
|
|
if ( ret != 1 )
|
|
|
|
{
|
2009-07-30 07:41:12 +02:00
|
|
|
// Try old cIOS 222
|
|
|
|
/* Set USB mode */
|
|
|
|
inbuf[0] = DI_SETWBFSMODE << 24;
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, DI_SETWBFSMODE, inbuf, sizeof( inbuf ), outbuf, sizeof( outbuf ) );
|
2009-07-30 07:41:12 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( ret < 0 )
|
2009-07-30 07:41:12 +02:00
|
|
|
return ret;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-07-30 07:41:12 +02:00
|
|
|
}
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 WDVD_Read_Disc_BCA( void *buf )
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
s32 ret;
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
memset( inbuf, 0, sizeof( inbuf ) );
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
/* Disc read */
|
|
|
|
inbuf[0] = IOCTL_DI_DISC_BCA << 24;
|
|
|
|
//inbuf[1] = 64;
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret = IOS_Ioctl( di_fd, IOCTL_DI_DISC_BCA, inbuf, sizeof( inbuf ), buf, 64 );
|
|
|
|
if ( ret < 0 )
|
|
|
|
return ret;
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
return ( ret == 1 ) ? 0 : -ret;
|
2009-12-04 16:05:20 +01:00
|
|
|
}
|