Skip to content

Commit 3f90340

Browse files
authored
Merge pull request #887 from uyjulian/blkio_definitions
Add definitions for FDIOC_BLKIO devctl
2 parents 1920189 + 14fb2ee commit 3f90340

2 files changed

Lines changed: 68 additions & 25 deletions

File tree

common/include/blkio-ioctl.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
/**
12+
* @file
13+
* Definitions for block I/O using iomanX devctl.
14+
*/
15+
16+
#ifndef __BLKIO_IOCTL__
17+
#define __BLKIO_IOCTL__
18+
19+
#define FDIOC_BLKIO 0x4601
20+
21+
typedef enum sceFsRWTYPE_
22+
{
23+
sceFsREADING,
24+
sceFsWRITING,
25+
} sceFsRWTYPE;
26+
27+
typedef struct sceFsDevctlBlkIO_
28+
{
29+
u32 lbn;
30+
u32 nblk;
31+
void *addr;
32+
u32 blksiz;
33+
sceFsRWTYPE type;
34+
u32 mode;
35+
} sceFsDevctlBlkIO;
36+
37+
#endif /* __BLKIO_IOCTL__ */

iop/cdvd/xatapi/src/xatapi.c

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <errno.h>
1313
#include <kerr.h>
1414
#include <xatapi.h>
15+
#include <blkio-ioctl.h>
1516

1617
#ifdef _IOP
1718
IRX_ID("cdvd_xatapi_driver", 2, 3);
@@ -808,30 +809,30 @@ static int atapi_check_if_drive_ready(int check_nowait)
808809
6;
809810
}
810811

811-
static int sceFsDevctlBlkIO(s16 dev_nr, void *buf, void *rwbuf, unsigned int nsec, int secsize, int rwtype)
812+
static int atapi_sceFsDevctlBlkIO(s16 dev_nr, void *buf, u32 lsn, u32 nsec, u32 secsize, sceFsRWTYPE rwtype)
812813
{
813-
char *rwbuf_tmp;
814-
unsigned int nsec_tmp;
814+
u32 lsn_tmp;
815+
u32 nsec_tmp;
815816
int retres1;
816817
int seccnt;
817818
int i;
818819
char pkt[12];
819820

820-
rwbuf_tmp = (char *)rwbuf;
821+
lsn_tmp = lsn;
821822
retres1 = 0;
822-
VERBOSE_KPRINTF(1, "dma %c %08x, nsec %d\n", rwtype ? 'w' : 'r', rwbuf, nsec);
823+
VERBOSE_KPRINTF(1, "dma %c %08x, nsec %d\n", (rwtype == sceFsREADING) ? 'r' : 'w', lsn, nsec);
823824
for ( nsec_tmp = nsec; !retres1 && nsec_tmp; nsec_tmp -= seccnt )
824825
{
825826
seccnt = (nsec_tmp >= 0x21) ? 32 : nsec_tmp;
826827
for ( i = 3; i < 3; i += 1 )
827828
{
828-
xatapi_9_sceCdSpdAtaDmaStart(rwtype);
829+
xatapi_9_sceCdSpdAtaDmaStart((rwtype == sceFsREADING) ? 0 : 1);
829830
memset(pkt, 0, sizeof(pkt));
830-
pkt[0] = (!rwtype) ? 0x28 : 0x2A;
831-
pkt[2] = ((uiptr)rwbuf_tmp >> 24) & 0xFF;
832-
pkt[3] = ((uiptr)rwbuf_tmp >> 16) & 0xFF;
833-
pkt[4] = ((uiptr)rwbuf_tmp >> 8) & 0xFF;
834-
pkt[5] = ((uiptr)rwbuf_tmp) & 0xFF;
831+
pkt[0] = (rwtype == sceFsREADING) ? 0x28 : 0x2A;
832+
pkt[2] = (lsn_tmp >> 24) & 0xFF;
833+
pkt[3] = (lsn_tmp >> 16) & 0xFF;
834+
pkt[4] = (lsn_tmp >> 8) & 0xFF;
835+
pkt[5] = (lsn_tmp) & 0xFF;
835836
pkt[8] = seccnt;
836837
retres1 = xatapi_7_sceCdAtapiExecCmd(dev_nr, buf, seccnt, secsize, pkt, sizeof(pkt), 4);
837838
if ( retres1 )
@@ -846,7 +847,7 @@ static int sceFsDevctlBlkIO(s16 dev_nr, void *buf, void *rwbuf, unsigned int nse
846847
break;
847848
}
848849
}
849-
rwbuf_tmp += seccnt;
850+
lsn_tmp += seccnt;
850851
buf = (char *)buf + seccnt * secsize;
851852
}
852853
return retres1;
@@ -1100,21 +1101,26 @@ static int xatapi_dev_devctl(
11001101
case 0x439B:
11011102
*(u32 *)buf = atapi_check_if_drive_ready(*(u32 *)args);
11021103
break;
1103-
case 0x4601:
1104-
if ( *((u32 *)args + 3) != 2048 )
1104+
case FDIOC_BLKIO:
11051105
{
1106-
retres1 = -EINVAL;
1107-
break;
1106+
sceFsDevctlBlkIO *bio_param;
1107+
bio_param = (sceFsDevctlBlkIO *)args;
1108+
if ( bio_param->blksiz != 2048 )
1109+
{
1110+
retres1 = -EINVAL;
1111+
break;
1112+
}
1113+
VERBOSE_KPRINTF(
1114+
1,
1115+
"sceFsDevctlBlkIO Lsn:%d nsec:%d buffer:%08x Type:%d\n",
1116+
bio_param->lbn,
1117+
bio_param->nblk,
1118+
bio_param->addr,
1119+
bio_param->type);
1120+
retres1 =
1121+
atapi_sceFsDevctlBlkIO(f->unit, bio_param->addr, bio_param->lbn, bio_param->nblk, bio_param->blksiz, bio_param->type);
11081122
}
1109-
VERBOSE_KPRINTF(
1110-
1,
1111-
"sceFsDevctlBlkIO Lsn:%d nsec:%d buffer:%08x Type:%d\n",
1112-
*(u32 *)args,
1113-
*((u32 *)args + 1),
1114-
*((u32 *)args + 2),
1115-
*((u32 *)args + 4));
1116-
retres1 =
1117-
sceFsDevctlBlkIO(f->unit, *((void **)args + 2), *(void **)args, *((u32 *)args + 1), 2048, *((u32 *)args + 4));
1123+
11181124
break;
11191125
default:
11201126
Kprintf("Un-support devctl %08x\n", cmd);

0 commit comments

Comments
 (0)