Skip to content

Commit 4a3dfac

Browse files
authored
Revert changes partially
1 parent 2dc3e54 commit 4a3dfac

File tree

11 files changed

+92
-92
lines changed

11 files changed

+92
-92
lines changed

modules/iopcore/cdvdfsv/scmd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,4 @@ static void *cbrpc_cdvdScmds(int fno, void *buf, int size)
183183
void cdvdfsv_register_scmd_rpc(SifRpcDataQueue_t *rpc_DQ)
184184
{
185185
sceSifRegisterRpc(&cdvdScmds_rpcSD, 0x80000593, &cbrpc_cdvdScmds, cdvdScmds_rpcbuf, NULL, NULL, rpc_DQ);
186-
}
186+
}

modules/iopcore/cdvdman/atad.c

+30-30
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static const ata_cmd_info_t smart_cmd_table[] = {
8383
{ATA_S_SMART_ENABLE_OPERATIONS, 0x01}};
8484
#define SMART_CMD_TABLE_SIZE (sizeof smart_cmd_table / sizeof(ata_cmd_info_t))
8585

86-
/* This is the state info tracked between sceAtaExecCmd() and sceAtaWaitResult(). */
86+
/* This is the state info tracked between ata_io_start() and ata_io_finish(). */
8787
typedef struct _ata_cmd_state
8888
{
8989
s32 type; /* The ata_cmd_info_t type field. */
@@ -157,14 +157,14 @@ int atad_start(void)
157157
}
158158

159159
/* In v1.04, PIO mode 0 was set here. In late versions, it is set in ata_init_devices(). */
160-
SpdRegisterIntrHandler(1, &ata_intr_cb);
161-
SpdRegisterIntrHandler(0, &ata_intr_cb);
160+
dev9RegisterIntrCb(1, &ata_intr_cb);
161+
dev9RegisterIntrCb(0, &ata_intr_cb);
162162
if (!ata_gamestar_workaround) {
163163
dev9RegisterPreDmaCb(0, &ata_pre_dma_cb);
164164
dev9RegisterPostDmaCb(0, &ata_post_dma_cb);
165165
}
166166
/* Register this at the last position, as it should be the last thing done before shutdown. */
167-
Dev9RegisterPowerOffHandler(15, &ata_shutdown_cb);
167+
dev9RegisterShutdownCb(15, &ata_shutdown_cb);
168168

169169
iop_sema_t smp;
170170
smp.initial = 1;
@@ -182,7 +182,7 @@ int atad_start(void)
182182
static int ata_intr_cb(int flag)
183183
{
184184
if (flag != 1) { /* New card, invalidate device info. */
185-
SpdIntrDisable(SPD_INTR_ATA);
185+
dev9IntrDisable(SPD_INTR_ATA);
186186
iSetEventFlag(ata_evflg, ATA_EV_COMPLETE);
187187
}
188188

@@ -196,7 +196,7 @@ static unsigned int ata_alarm_cb(void *unused)
196196
}
197197

198198
/* Export 8 */
199-
int sceAtaGetError(void)
199+
int ata_get_error(void)
200200
{
201201
USE_ATA_REGS;
202202
return ata_hwport->r_error & 0xff;
@@ -276,7 +276,7 @@ static int ata_device_select(int device)
276276
277277
48-bit LBA just involves writing the upper 24 bits in the format above into each respective register on the first write pass, before writing the lower 24 bits in the 2nd write pass. The LBA bits within the device field are not used in either write pass.
278278
*/
279-
int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command)
279+
int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command)
280280
{
281281
USE_ATA_REGS;
282282
iop_sys_clock_t cmd_timeout;
@@ -354,7 +354,7 @@ int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector,
354354

355355
/* Enable the command completion interrupt. */
356356
if ((type & 0x7F) == 1)
357-
SpdIntrEnable(SPD_INTR_ATA0);
357+
dev9IntrEnable(SPD_INTR_ATA0);
358358

359359
/* Finally! We send off the ATA command with arguments. */
360360
ata_hwport->r_control = (using_timeout == 0) << 1;
@@ -376,11 +376,11 @@ int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector,
376376
ata_hwport->r_sector = sector & 0xff;
377377
ata_hwport->r_lcyl = lcyl & 0xff;
378378
ata_hwport->r_hcyl = hcyl & 0xff;
379-
ata_hwport->r_select = (select | ATA_SEL_LBA) & 0xff; //In v1.04, LBA was enabled in the sceAtaDmaTransfer function.
379+
ata_hwport->r_select = (select | ATA_SEL_LBA) & 0xff; //In v1.04, LBA was enabled in the ata_device_sector_io function.
380380
ata_hwport->r_command = command & 0xff;
381381

382382
/* Turn on the LED. */
383-
SpdSetLED(1);
383+
dev9LEDCtl(1);
384384

385385
return 0;
386386
}
@@ -399,7 +399,7 @@ static inline int ata_pio_transfer(ata_cmd_state_t *cmd_state)
399399
u16 status = ata_hwport->r_status & 0xff;
400400

401401
if (status & ATA_STAT_ERR) {
402-
M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", status, sceAtaGetError());
402+
M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", status, ata_get_error());
403403
return ATA_RES_ERR_IO;
404404
}
405405

@@ -453,7 +453,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
453453
if (dma_stat)
454454
goto next_transfer;
455455

456-
SpdIntrEnable(SPD_INTR_ATA);
456+
dev9IntrEnable(SPD_INTR_ATA);
457457
/* Wait for the previous transfer to complete or a timeout. */
458458
WaitEventFlag(ata_evflg, ATA_EV_TIMEOUT | ATA_EV_COMPLETE, WEF_CLEAR | WEF_OR, &bits);
459459

@@ -465,12 +465,12 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
465465
if (!(SPD_REG16(SPD_R_INTR_STAT) & 0x02)) {
466466
if (ata_hwport->r_control & 0x01) {
467467
M_PRINTF("Error: Command error while doing DMA.\n");
468-
M_PRINTF("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, sceAtaGetError());
468+
M_PRINTF("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, ata_get_error());
469469
#ifdef NETLOG_DEBUG
470-
pNetlogSend("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, sceAtaGetError());
470+
pNetlogSend("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, ata_get_error());
471471
#endif
472472
/* In v1.04, there was no check for ICRC. */
473-
return ((sceAtaGetError() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO);
473+
return ((ata_get_error() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO);
474474
} else {
475475
M_PRINTF("Warning: Got command interrupt, but not an error.\n");
476476
continue;
@@ -482,7 +482,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
482482
next_transfer:
483483
count = (blkcount < dma_stat) ? blkcount : dma_stat;
484484
nbytes = count * 512;
485-
if ((res = SpdDmaTransfer(0, buf, (nbytes << 9) | 32, dir)) < 0)
485+
if ((res = dev9DmaTransfer(0, buf, (nbytes << 9) | 32, dir)) < 0)
486486
return res;
487487

488488
buf = (void *)((u8 *)buf + nbytes);
@@ -493,7 +493,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
493493
}
494494

495495
/* Export 7 */
496-
int sceAtaWaitResult(void)
496+
int ata_io_finish(void)
497497
{
498498
USE_SPD_REGS;
499499
USE_ATA_REGS;
@@ -517,7 +517,7 @@ int sceAtaWaitResult(void)
517517
if ((stat = SPD_REG16(SPD_R_INTR_STAT) & 0x01))
518518
break;
519519
if (!stat) {
520-
SpdIntrEnable(SPD_INTR_ATA0);
520+
dev9IntrEnable(SPD_INTR_ATA0);
521521
WaitEventFlag(ata_evflg, ATA_EV_TIMEOUT | ATA_EV_COMPLETE, WEF_CLEAR | WEF_OR, &bits);
522522
if (bits & ATA_EV_TIMEOUT) {
523523
M_PRINTF("Error: ATA timeout on DMA completion.\n");
@@ -545,16 +545,16 @@ int sceAtaWaitResult(void)
545545
if (ata_hwport->r_status & ATA_STAT_BUSY)
546546
res = ata_wait_busy();
547547
if ((stat = ata_hwport->r_status) & ATA_STAT_ERR) {
548-
M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", stat, sceAtaGetError());
548+
M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", stat, ata_get_error());
549549
/* In v1.04, there was no check for ICRC. */
550-
res = (sceAtaGetError() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO;
550+
res = (ata_get_error() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO;
551551
}
552552

553553
finish:
554554
/* The command has completed (with an error or not), so clean things up. */
555555
CancelAlarm(&ata_alarm_cb, NULL);
556556
/* Turn off the LED. */
557-
SpdSetLED(0);
557+
dev9LEDCtl(0);
558558

559559
if (res)
560560
M_PRINTF("error: ATA failed, %d\n", res);
@@ -563,19 +563,19 @@ int sceAtaWaitResult(void)
563563
}
564564

565565
/* Export 17 */
566-
int sceAtaFlushCache(int device)
566+
int ata_device_flush_cache(int device)
567567
{
568568
int res;
569569

570-
if (!(res = sceAtaExecCmd(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, lba_48bit ? ATA_C_FLUSH_CACHE_EXT : ATA_C_FLUSH_CACHE)))
571-
res = sceAtaWaitResult();
570+
if (!(res = ata_io_start(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, lba_48bit ? ATA_C_FLUSH_CACHE_EXT : ATA_C_FLUSH_CACHE)))
571+
res = ata_io_finish();
572572

573573
return res;
574574
}
575575

576576
/* Export 9 */
577577
/* Note: this can only support DMA modes, due to the commands issued. */
578-
int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir)
578+
int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir)
579579
{
580580
USE_SPD_REGS;
581581
int res = 0, retries;
@@ -611,14 +611,14 @@ int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir)
611611
if (ata_gamestar_workaround)
612612
ata_set_dir(dir);
613613

614-
if ((res = sceAtaExecCmd(buf, len, 0, len, sector, lcyl, hcyl, select, command)) != 0)
614+
if ((res = ata_io_start(buf, len, 0, len, sector, lcyl, hcyl, select, command)) != 0)
615615
break;
616616

617617
/* Set up (part of) the transfer here. In v1.04, this was called at the top of the outer loop. */
618618
if (!ata_gamestar_workaround)
619619
ata_set_dir(dir);
620620

621-
res = sceAtaWaitResult();
621+
res = ata_io_finish();
622622

623623
/* In v1.04, this was not done. Neither was there a mechanism to retry if a non-permanent error occurs. */
624624
SPD_REG16(SPD_R_IF_CTRL) &= ~SPD_IF_DMA_ENABLE;
@@ -638,7 +638,7 @@ int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir)
638638
}
639639

640640
/* Export 4 */
641-
ata_devinfo_t *sceAtaInit(int device)
641+
ata_devinfo_t *ata_get_devinfo(int device)
642642
{
643643
return &atad_devinfo;
644644
}
@@ -659,8 +659,8 @@ static int ata_device_standby_immediate(int device)
659659
{
660660
int res;
661661

662-
if (!(res = sceAtaExecCmd(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xFFFF, ATA_C_STANDBY_IMMEDIATE)))
663-
res = sceAtaWaitResult();
662+
if (!(res = ata_io_start(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xFFFF, ATA_C_STANDBY_IMMEDIATE)))
663+
res = ata_io_finish();
664664

665665
return res;
666666
}

modules/iopcore/cdvdman/atad.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <types.h>
1818
#include <irx.h>
1919

20-
/* These are used with the dir parameter of sceAtaDmaTransfer(). */
20+
/* These are used with the dir parameter of ata_device_sector_io(). */
2121
#define ATA_DIR_READ 0
2222
#define ATA_DIR_WRITE 1
2323

@@ -48,12 +48,12 @@ typedef struct _ata_devinfo
4848
#define ATA_RES_ERR_ICRC -510
4949

5050
int atad_start(void);
51-
ata_devinfo_t *sceAtaInit(int device);
52-
int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command);
53-
int sceAtaWaitResult(void);
54-
int sceAtaGetError(void);
55-
int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir);
56-
int sceAtaFlushCache(int device);
51+
ata_devinfo_t *ata_get_devinfo(int device);
52+
int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command);
53+
int ata_io_finish(void);
54+
int ata_get_error(void);
55+
int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir);
56+
int ata_device_flush_cache(int device);
5757

5858
// APA Partition
5959
#define APA_MAGIC 0x00415041 // 'APA\0'

modules/iopcore/cdvdman/cdvdman.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -871,4 +871,4 @@ int _shutdown(void)
871871
DeviceDeinit();
872872

873873
return 0;
874-
}
874+
}

modules/iopcore/cdvdman/dev9.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static int dev9x_devctl(iop_file_t *f, const char *name, int cmd, void *args, in
8989
return dev9type;
9090
case DDIOC_OFF:
9191
//Do not let the DEV9 interface to be switched off by other software.
92-
//Dev9CardStop();
92+
//dev9Shutdown();
9393
return 0;
9494
default:
9595
return 0;
@@ -161,7 +161,7 @@ int dev9d_init(void)
161161
}
162162

163163
/* Export 4 */
164-
void SpdRegisterIntrHandler(int intr, dev9_intr_cb_t cb)
164+
void dev9RegisterIntrCb(int intr, dev9_intr_cb_t cb)
165165
{
166166
#ifdef HDD_DRIVER
167167
//Don't let anything else change the HDD interrupt handlers.
@@ -221,7 +221,7 @@ static void dev9_set_stat(int stat)
221221
}
222222

223223
/* Export 6 */
224-
void Dev9CardStop(void)
224+
void dev9Shutdown(void)
225225
{
226226
int idx;
227227
USE_DEV9_REGS;
@@ -244,7 +244,7 @@ void Dev9CardStop(void)
244244
}
245245

246246
/* Export 7 */
247-
void SpdIntrEnable(int mask)
247+
void dev9IntrEnable(int mask)
248248
{
249249
USE_SPD_REGS;
250250
int flags;
@@ -255,7 +255,7 @@ void SpdIntrEnable(int mask)
255255
}
256256

257257
/* Export 8 */
258-
void SpdIntrDisable(int mask)
258+
void dev9IntrDisable(int mask)
259259
{
260260
USE_SPD_REGS;
261261
int flags;
@@ -266,7 +266,7 @@ void SpdIntrDisable(int mask)
266266
}
267267

268268
/* Export 5 */
269-
int SpdDmaTransfer(int ctrl, void *buf, int bcr, int dir)
269+
int dev9DmaTransfer(int ctrl, void *buf, int bcr, int dir)
270270
{
271271
USE_SPD_REGS;
272272
volatile iop_dmac_chan_t *dev9_chan = (iop_dmac_chan_t *)DEV9_DMAC_BASE;
@@ -383,7 +383,7 @@ static int read_eeprom_data(void)
383383
}
384384

385385
/* Export 9 */
386-
int SpdGetEthernetID(u16 *buf)
386+
int dev9GetEEPROM(u16 *buf)
387387
{
388388
int i;
389389

@@ -400,14 +400,14 @@ int SpdGetEthernetID(u16 *buf)
400400
}
401401

402402
/* Export 10 */
403-
void SpdSetLED(int ctl)
403+
void dev9LEDCtl(int ctl)
404404
{
405405
USE_SPD_REGS;
406406
SPD_REG8(SPD_R_PIO_DATA) = (ctl == 0);
407407
}
408408

409409
/* Export 11 */
410-
int Dev9RegisterPowerOffHandler(int idx, dev9_shutdown_cb_t cb)
410+
int dev9RegisterShutdownCb(int idx, dev9_shutdown_cb_t cb)
411411
{
412412
if (idx < 16) {
413413
dev9_shutdown_cbs[idx] = cb;
@@ -436,7 +436,7 @@ static int dev9_init(void)
436436
dev9_set_stat(0x103);
437437

438438
/* Disable all device interrupts. */
439-
SpdIntrDisable(0xffff);
439+
dev9IntrDisable(0xffff);
440440

441441
/* Register interrupt dispatch callback handler. */
442442
p_dev9_intr_cb = (void *)dev9_intr_dispatch;
@@ -453,7 +453,7 @@ static int dev9_init(void)
453453
/* Read in the MAC address. */
454454
read_eeprom_data();
455455
/* Turn the LED off. */
456-
SpdSetLED(0);
456+
dev9LEDCtl(0);
457457
return 0;
458458
}
459459

modules/iopcore/cdvdman/dev9.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ typedef void (*dev9_shutdown_cb_t)(void);
2424
typedef void (*dev9_dma_cb_t)(int bcr, int dir);
2525

2626
int dev9d_init(void);
27-
void SpdRegisterIntrHandler(int intr, dev9_intr_cb_t cb); // #4
28-
int SpdDmaTransfer(int ctrl, void *buf, int bcr, int dir); // #5
29-
void Dev9CardStop(void); // #6
30-
void SpdIntrEnable(int mask); // #7
31-
void SpdIntrDisable(int mask); // #8
32-
int SpdGetEthernetID(u16 *buf); // #9
33-
void SpdSetLED(int ctl); // #10
34-
int Dev9RegisterPowerOffHandler(int idx, dev9_shutdown_cb_t cb); // #11
35-
void dev9RegisterPreDmaCb(int ctrl, dev9_dma_cb_t cb); // #12
36-
void dev9RegisterPostDmaCb(int ctrl, dev9_dma_cb_t cb); // #13
27+
void dev9RegisterIntrCb(int intr, dev9_intr_cb_t cb); // #4
28+
int dev9DmaTransfer(int ctrl, void *buf, int bcr, int dir); // #5
29+
void dev9Shutdown(void); // #6
30+
void dev9IntrEnable(int mask); // #7
31+
void dev9IntrDisable(int mask); // #8
32+
int dev9GetEEPROM(u16 *buf); // #9
33+
void dev9LEDCtl(int ctl); // #10
34+
int dev9RegisterShutdownCb(int idx, dev9_shutdown_cb_t cb); // #11
35+
void dev9RegisterPreDmaCb(int ctrl, dev9_dma_cb_t cb); // #12
36+
void dev9RegisterPostDmaCb(int ctrl, dev9_dma_cb_t cb); // #13
3737

3838
#endif /* IOP_PS2DEV9_H */

0 commit comments

Comments
 (0)