@@ -83,7 +83,7 @@ static const ata_cmd_info_t smart_cmd_table[] = {
83
83
{ATA_S_SMART_ENABLE_OPERATIONS , 0x01 }};
84
84
#define SMART_CMD_TABLE_SIZE (sizeof smart_cmd_table / sizeof(ata_cmd_info_t))
85
85
86
- /* This is the state info tracked between ata_io_start () and ata_io_finish (). */
86
+ /* This is the state info tracked between sceAtaExecCmd () and sceAtaWaitResult (). */
87
87
typedef struct _ata_cmd_state
88
88
{
89
89
s32 type ; /* The ata_cmd_info_t type field. */
@@ -157,14 +157,14 @@ int atad_start(void)
157
157
}
158
158
159
159
/* In v1.04, PIO mode 0 was set here. In late versions, it is set in ata_init_devices(). */
160
- dev9RegisterIntrCb (1 , & ata_intr_cb );
161
- dev9RegisterIntrCb (0 , & ata_intr_cb );
160
+ SpdRegisterIntrHandler (1 , & ata_intr_cb );
161
+ SpdRegisterIntrHandler (0 , & ata_intr_cb );
162
162
if (!ata_gamestar_workaround ) {
163
163
dev9RegisterPreDmaCb (0 , & ata_pre_dma_cb );
164
164
dev9RegisterPostDmaCb (0 , & ata_post_dma_cb );
165
165
}
166
166
/* Register this at the last position, as it should be the last thing done before shutdown. */
167
- dev9RegisterShutdownCb (15 , & ata_shutdown_cb );
167
+ Dev9RegisterPowerOffHandler (15 , & ata_shutdown_cb );
168
168
169
169
iop_sema_t smp ;
170
170
smp .initial = 1 ;
@@ -182,7 +182,7 @@ int atad_start(void)
182
182
static int ata_intr_cb (int flag )
183
183
{
184
184
if (flag != 1 ) { /* New card, invalidate device info. */
185
- dev9IntrDisable (SPD_INTR_ATA );
185
+ SpdIntrDisable (SPD_INTR_ATA );
186
186
iSetEventFlag (ata_evflg , ATA_EV_COMPLETE );
187
187
}
188
188
@@ -196,7 +196,7 @@ static unsigned int ata_alarm_cb(void *unused)
196
196
}
197
197
198
198
/* Export 8 */
199
- int ata_get_error (void )
199
+ int sceAtaGetError (void )
200
200
{
201
201
USE_ATA_REGS ;
202
202
return ata_hwport -> r_error & 0xff ;
@@ -276,7 +276,7 @@ static int ata_device_select(int device)
276
276
277
277
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.
278
278
*/
279
- int ata_io_start (void * buf , u32 blkcount , u16 feature , u16 nsector , u16 sector , u16 lcyl , u16 hcyl , u16 select , u16 command )
279
+ int sceAtaExecCmd (void * buf , u32 blkcount , u16 feature , u16 nsector , u16 sector , u16 lcyl , u16 hcyl , u16 select , u16 command )
280
280
{
281
281
USE_ATA_REGS ;
282
282
iop_sys_clock_t cmd_timeout ;
@@ -354,7 +354,7 @@ int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector,
354
354
355
355
/* Enable the command completion interrupt. */
356
356
if ((type & 0x7F ) == 1 )
357
- dev9IntrEnable (SPD_INTR_ATA0 );
357
+ SpdIntrEnable (SPD_INTR_ATA0 );
358
358
359
359
/* Finally! We send off the ATA command with arguments. */
360
360
ata_hwport -> r_control = (using_timeout == 0 ) << 1 ;
@@ -376,11 +376,11 @@ int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector,
376
376
ata_hwport -> r_sector = sector & 0xff ;
377
377
ata_hwport -> r_lcyl = lcyl & 0xff ;
378
378
ata_hwport -> r_hcyl = hcyl & 0xff ;
379
- ata_hwport -> r_select = (select | ATA_SEL_LBA ) & 0xff ; //In v1.04, LBA was enabled in the ata_device_sector_io function.
379
+ ata_hwport -> r_select = (select | ATA_SEL_LBA ) & 0xff ; //In v1.04, LBA was enabled in the sceAtaDmaTransfer function.
380
380
ata_hwport -> r_command = command & 0xff ;
381
381
382
382
/* Turn on the LED. */
383
- dev9LEDCtl (1 );
383
+ SpdSetLED (1 );
384
384
385
385
return 0 ;
386
386
}
@@ -399,7 +399,7 @@ static inline int ata_pio_transfer(ata_cmd_state_t *cmd_state)
399
399
u16 status = ata_hwport -> r_status & 0xff ;
400
400
401
401
if (status & ATA_STAT_ERR ) {
402
- M_PRINTF ("Error: Command error: status 0x%02x, error 0x%02x.\n" , status , ata_get_error ());
402
+ M_PRINTF ("Error: Command error: status 0x%02x, error 0x%02x.\n" , status , sceAtaGetError ());
403
403
return ATA_RES_ERR_IO ;
404
404
}
405
405
@@ -453,7 +453,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
453
453
if (dma_stat )
454
454
goto next_transfer ;
455
455
456
- dev9IntrEnable (SPD_INTR_ATA );
456
+ SpdIntrEnable (SPD_INTR_ATA );
457
457
/* Wait for the previous transfer to complete or a timeout. */
458
458
WaitEventFlag (ata_evflg , ATA_EV_TIMEOUT | ATA_EV_COMPLETE , WEF_CLEAR | WEF_OR , & bits );
459
459
@@ -465,12 +465,12 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
465
465
if (!(SPD_REG16 (SPD_R_INTR_STAT ) & 0x02 )) {
466
466
if (ata_hwport -> r_control & 0x01 ) {
467
467
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 , ata_get_error ());
468
+ M_PRINTF ("Error: Command error status 0x%02x, error 0x%02x.\n" , ata_hwport -> r_status , sceAtaGetError ());
469
469
#ifdef NETLOG_DEBUG
470
- pNetlogSend ("Error: Command error status 0x%02x, error 0x%02x.\n" , ata_hwport -> r_status , ata_get_error ());
470
+ pNetlogSend ("Error: Command error status 0x%02x, error 0x%02x.\n" , ata_hwport -> r_status , sceAtaGetError ());
471
471
#endif
472
472
/* In v1.04, there was no check for ICRC. */
473
- return ((ata_get_error () & ATA_ERR_ICRC ) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO );
473
+ return ((sceAtaGetError () & ATA_ERR_ICRC ) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO );
474
474
} else {
475
475
M_PRINTF ("Warning: Got command interrupt, but not an error.\n" );
476
476
continue ;
@@ -482,7 +482,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
482
482
next_transfer :
483
483
count = (blkcount < dma_stat ) ? blkcount : dma_stat ;
484
484
nbytes = count * 512 ;
485
- if ((res = dev9DmaTransfer (0 , buf , (nbytes << 9 ) | 32 , dir )) < 0 )
485
+ if ((res = SpdDmaTransfer (0 , buf , (nbytes << 9 ) | 32 , dir )) < 0 )
486
486
return res ;
487
487
488
488
buf = (void * )((u8 * )buf + nbytes );
@@ -493,7 +493,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir)
493
493
}
494
494
495
495
/* Export 7 */
496
- int ata_io_finish (void )
496
+ int sceAtaWaitResult (void )
497
497
{
498
498
USE_SPD_REGS ;
499
499
USE_ATA_REGS ;
@@ -517,7 +517,7 @@ int ata_io_finish(void)
517
517
if ((stat = SPD_REG16 (SPD_R_INTR_STAT ) & 0x01 ))
518
518
break ;
519
519
if (!stat ) {
520
- dev9IntrEnable (SPD_INTR_ATA0 );
520
+ SpdIntrEnable (SPD_INTR_ATA0 );
521
521
WaitEventFlag (ata_evflg , ATA_EV_TIMEOUT | ATA_EV_COMPLETE , WEF_CLEAR | WEF_OR , & bits );
522
522
if (bits & ATA_EV_TIMEOUT ) {
523
523
M_PRINTF ("Error: ATA timeout on DMA completion.\n" );
@@ -545,16 +545,16 @@ int ata_io_finish(void)
545
545
if (ata_hwport -> r_status & ATA_STAT_BUSY )
546
546
res = ata_wait_busy ();
547
547
if ((stat = ata_hwport -> r_status ) & ATA_STAT_ERR ) {
548
- M_PRINTF ("Error: Command error: status 0x%02x, error 0x%02x.\n" , stat , ata_get_error ());
548
+ M_PRINTF ("Error: Command error: status 0x%02x, error 0x%02x.\n" , stat , sceAtaGetError ());
549
549
/* In v1.04, there was no check for ICRC. */
550
- res = (ata_get_error () & ATA_ERR_ICRC ) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO ;
550
+ res = (sceAtaGetError () & ATA_ERR_ICRC ) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO ;
551
551
}
552
552
553
553
finish :
554
554
/* The command has completed (with an error or not), so clean things up. */
555
555
CancelAlarm (& ata_alarm_cb , NULL );
556
556
/* Turn off the LED. */
557
- dev9LEDCtl (0 );
557
+ SpdSetLED (0 );
558
558
559
559
if (res )
560
560
M_PRINTF ("error: ATA failed, %d\n" , res );
@@ -563,19 +563,19 @@ int ata_io_finish(void)
563
563
}
564
564
565
565
/* Export 17 */
566
- int ata_device_flush_cache (int device )
566
+ int sceAtaFlushCache (int device )
567
567
{
568
568
int res ;
569
569
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 ();
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 ();
572
572
573
573
return res ;
574
574
}
575
575
576
576
/* Export 9 */
577
577
/* Note: this can only support DMA modes, due to the commands issued. */
578
- int ata_device_sector_io (int device , void * buf , u32 lba , u32 nsectors , int dir )
578
+ int sceAtaDmaTransfer (int device , void * buf , u32 lba , u32 nsectors , int dir )
579
579
{
580
580
USE_SPD_REGS ;
581
581
int res = 0 , retries ;
@@ -611,14 +611,14 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir)
611
611
if (ata_gamestar_workaround )
612
612
ata_set_dir (dir );
613
613
614
- if ((res = ata_io_start (buf , len , 0 , len , sector , lcyl , hcyl , select , command )) != 0 )
614
+ if ((res = sceAtaExecCmd (buf , len , 0 , len , sector , lcyl , hcyl , select , command )) != 0 )
615
615
break ;
616
616
617
617
/* Set up (part of) the transfer here. In v1.04, this was called at the top of the outer loop. */
618
618
if (!ata_gamestar_workaround )
619
619
ata_set_dir (dir );
620
620
621
- res = ata_io_finish ();
621
+ res = sceAtaWaitResult ();
622
622
623
623
/* In v1.04, this was not done. Neither was there a mechanism to retry if a non-permanent error occurs. */
624
624
SPD_REG16 (SPD_R_IF_CTRL ) &= ~SPD_IF_DMA_ENABLE ;
@@ -638,7 +638,7 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir)
638
638
}
639
639
640
640
/* Export 4 */
641
- ata_devinfo_t * ata_get_devinfo (int device )
641
+ ata_devinfo_t * sceAtaInit (int device )
642
642
{
643
643
return & atad_devinfo ;
644
644
}
@@ -659,8 +659,8 @@ static int ata_device_standby_immediate(int device)
659
659
{
660
660
int res ;
661
661
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 ();
662
+ if (!(res = sceAtaExecCmd (NULL , 1 , 0 , 0 , 0 , 0 , 0 , (device << 4 ) & 0xFFFF , ATA_C_STANDBY_IMMEDIATE )))
663
+ res = sceAtaWaitResult ();
664
664
665
665
return res ;
666
666
}
0 commit comments