Skip to content

Commit 88485de

Browse files
authored
Merge pull request #820 from israpps/arcade-tweaks
tweaks to arcade modules
2 parents 023b678 + 7ae92c8 commit 88485de

5 files changed

Lines changed: 33 additions & 28 deletions

File tree

iop/arcade/acata/src/ata.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include "acata_internal.h"
12+
#include "atahw.h"
1213

1314
static struct ata_softc Atac;
1415

@@ -187,7 +188,7 @@ int ata_probe(acAtaReg atareg)
187188
int count;
188189

189190
(void)atareg;
190-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
191+
while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 )
191192
;
192193
*((volatile acUint16 *)0xB6020000) = 4660;
193194
// cppcheck-suppress knownConditionTrueFalse
@@ -210,7 +211,7 @@ int ata_probe(acAtaReg atareg)
210211
while ( count <= 1999999 )
211212
{
212213
// cppcheck-suppress knownConditionTrueFalse
213-
if ( (*((volatile acUint16 *)0xB6070000) & 0x80) == 0 )
214+
if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 )
214215
break;
215216
++count;
216217
}

iop/arcade/acata/src/atacmd.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include "acata_internal.h"
12+
#include "atahw.h"
1213

1314
static int ata_dma_xfer(acDmaT dma, int intr, acDmaOp op);
1415
static void ata_dma_done(acDmaT dma);
@@ -182,7 +183,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
182183
int a_size;
183184

184185
a_size = atah->a_size;
185-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
186+
while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 )
186187
;
187188
while ( a_size > 0 )
188189
{
@@ -198,7 +199,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
198199
a_size -= xlen;
199200
xlen_v15 = (unsigned int)xlen >> 1;
200201
xlen_v16 = xlen_v15 - 1;
201-
while ( (*((volatile acUint16 *)0xB6070000) & 8) != 0 )
202+
while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 )
202203
{
203204
int ret_v17;
204205

@@ -226,7 +227,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
226227
else
227228
{
228229
ret_v20 = *((volatile acUint16 *)0xB6070000);
229-
while ( (ret_v20 & 0x80) != 0 )
230+
while ( (ret_v20 & ATA_STAT_BUSY) != 0 )
230231
{
231232
sr = *((volatile acUint16 *)0xB6070000);
232233
ret_v20 = sr & 0xFF;
@@ -268,7 +269,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
268269
else
269270
{
270271
sr_v25 = *((volatile acUint16 *)0xB6070000);
271-
while ( (sr_v25 & 0x80) != 0 )
272+
while ( (sr_v25 & ATA_STAT_BUSY) != 0 )
272273
{
273274
sr_v25 = *((volatile acUint16 *)0xB6070000);
274275
sr_v25 = sr_v25 & 0xFF;
@@ -283,9 +284,9 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
283284
xlen_v28 = (unsigned int)xlen_v27 >> 1;
284285
if ( (sr_v25 & 1) != 0 )
285286
xlen_v28 = 0;
286-
(void)(*((volatile acUint16 *)0xB6070000) & 0x80);
287+
(void)(*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY);
287288
xlen_v30 = xlen_v28 - 1;
288-
while ( (*((volatile acUint16 *)0xB6070000) & 8) != 0 )
289+
while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 )
289290
{
290291
if ( xlen_v30 >= 0 )
291292
{
@@ -294,7 +295,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
294295
}
295296
--xlen_v30;
296297
}
297-
ret_v29 = *((volatile acUint16 *)0xB6070000) & 0x80;
298+
ret_v29 = *((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY;
298299
if ( !ret_v29 )
299300
break;
300301
}
@@ -346,7 +347,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
346347
ret = 0;
347348
if ( v16 )
348349
{
349-
while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == 128 )
350+
while ( (*((volatile acUint16 *)0xB6160000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY )
350351
{
351352
if ( SleepThread() )
352353
{
@@ -360,7 +361,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
360361
int tmout;
361362

362363
tmout = 99999;
363-
while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == 128 )
364+
while ( (*((volatile acUint16 *)0xB6070000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY )
364365
{
365366
if ( tmout < 0 )
366367
{
@@ -380,7 +381,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
380381
return ret;
381382
}
382383
sr_v34 = *((volatile acUint16 *)0xB6070000);
383-
if ( (*((volatile acUint16 *)0xB6070000) & 1) != 0 )
384+
if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) != 0 )
384385
return -((sr_v34 << 8) + *((volatile acUint16 *)0xB6010000));
385386
if ( atah->a_state < 0x1FFu )
386387
{

iop/arcade/acata/src/atapicmd.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include "acata_internal.h"
1212

13+
#include "atahw.h"
14+
1315
static int atapi_dma_xfer(acDmaT dma, int intr, acDmaOp op);
1416
static void atapi_dma_done(acDmaT dma);
1517
static void atapi_dma_error(acDmaT dma, int intr, acDmaState state, int result);
@@ -84,11 +86,11 @@ static int atapi_packet_send(acAtaReg atareg, acAtapiPacketData *pkt, int flag)
8486
*((volatile acUint16 *)0xB6060000) = flag & 0x10;
8587
*((volatile acUint16 *)0xB6160000) = (flag & 2) ^ 2;
8688
*((volatile acUint16 *)0xB6010000) = flag & 1;
87-
*((volatile acUint16 *)0xB6070000) = 160;
89+
*((volatile acUint16 *)0xB6070000) = 160; // ATA_STAT_BUSY|ATA_STAT_READY?
8890
tmout = 999;
8991
v6 = 1000;
9092
// cppcheck-suppress knownConditionTrueFalse
91-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
93+
while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 )
9294
{
9395
if ( tmout < 0 )
9496
{
@@ -105,7 +107,7 @@ static int atapi_packet_send(acAtaReg atareg, acAtapiPacketData *pkt, int flag)
105107
return -116;
106108
}
107109
// cppcheck-suppress knownConditionTrueFalse
108-
while ( (*((volatile acUint16 *)0xB6070000) & 8) != 0 )
110+
while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 )
109111
{
110112
--count;
111113
if ( count < 0 )
@@ -139,7 +141,7 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag)
139141
if ( !sr )
140142
{
141143
sr_v5 = *((volatile acUint16 *)0xB6070000);
142-
while ( (sr_v5 & 0x80) != 0 )
144+
while ( (sr_v5 & ATA_STAT_BUSY) != 0 )
143145
{
144146
xlen = *((volatile acUint16 *)0xB6070000);
145147
sr_v5 = xlen & 0xFF;
@@ -178,7 +180,7 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag)
178180
for ( drop_v10 = sr_v9 / 2 - 1; drop_v10 >= 0; --drop_v10 )
179181
;
180182
sr = v6 & 2;
181-
if ( (*((volatile acUint16 *)0xB6070000) & 0x80) == 0 )
183+
if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 )
182184
{
183185
break;
184186
}
@@ -326,7 +328,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
326328
else
327329
{
328330
sr_v14 = *((volatile acUint16 *)0xB6070000);
329-
while ( (sr_v14 & 0x80) != 0 )
331+
while ( (sr_v14 & ATA_STAT_BUSY) != 0 )
330332
{
331333
xlen = *((volatile acUint16 *)0xB6070000);
332334
sr_v14 = xlen & 0xFF;
@@ -357,7 +359,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
357359
for ( drop_v20 = sr_v18 / 2 - 1; drop_v20 >= 0; --drop_v20 )
358360
*((volatile acUint16 *)0xB6000000) = 0;
359361
sr = flag & 2;
360-
if ( (*((volatile acUint16 *)0xB6070000) & 0x80) == 0 )
362+
if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 )
361363
{
362364
ret_v5 = size - a_size;
363365
break;
@@ -388,7 +390,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
388390
v32 = 0;
389391
if ( (flag & 2) != 0 )
390392
{
391-
while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == 128 )
393+
while ( (*((volatile acUint16 *)0xB6160000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY )
392394
{
393395
if ( SleepThread() )
394396
{
@@ -402,7 +404,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
402404
int tmout;
403405

404406
tmout = 99999;
405-
while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == 128 )
407+
while ( (*((volatile acUint16 *)0xB6070000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY )
406408
{
407409
if ( tmout < 0 )
408410
{
@@ -460,7 +462,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
460462
}
461463
if ( ret_v5 < 0 )
462464
return ret_v5;
463-
if ( (*((volatile acUint16 *)0xB6070000) & 1) != 0 )
465+
if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) != 0 )
464466
return -((*((volatile acUint16 *)0xB6070000) << 8) + *((volatile acUint16 *)0xB6010000));
465467
if ( atah->a_state >= 0x1FFu )
466468
{
@@ -503,7 +505,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret)
503505
acAtapiT atapi;
504506

505507
atapi = (acAtapiT)atah;
506-
if ( (*((volatile acUint16 *)0xB6070000) & 1) == 0 )
508+
if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) == 0 )
507509
return ret;
508510
memset(&sense, 0, sizeof(sense));
509511
memset(&u, 0, sizeof(u));
@@ -532,7 +534,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret)
532534
v6 = 0;
533535
if ( (flag & 2) != 0 )
534536
{
535-
while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == 128 )
537+
while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == ATA_STAT_BUSY )
536538
{
537539
if ( SleepThread() )
538540
{
@@ -546,7 +548,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret)
546548
int tmout;
547549

548550
tmout = 99999;
549-
while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == 128 )
551+
while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == ATA_STAT_BUSY )
550552
{
551553
if ( tmout < 0 )
552554
{

iop/arcade/accdvd/src/acd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Review ps2sdk README & LICENSE files for further details.
99
*/
1010

11+
#include <atahw.h>
1112
#include "accdvd_internal.h"
1213

1314
static struct acd_softc Acdc;
@@ -739,7 +740,7 @@ int acd_getstatus()
739740
{
740741
acAtaCommandData v1[4];
741742

742-
v1[1] = 2021;
743+
v1[1] = ATA_C_CHECK_POWER_MODE | 0x700;
743744
v1[0] = (Acdc.drive & 0xFF) | 0x2600;
744745
return acd_ata_request(Acdc.drive | 2, v1, 2, acd_getstatus_done, "getstatus");
745746
}
@@ -833,7 +834,7 @@ static int acd_identify(int drive)
833834

834835
flag = 16 * (drive != 0);
835836
cmd[0] = flag | 0x600;
836-
cmd[1] = 1953;
837+
cmd[1] = ATA_C_IDENTIFY_PACKET_DEVICE | 0x700;
837838
acAtaSetup(&acdata.a_ata, acd_ata_done, 0, 0x4C4B40u);
838839
// cppcheck-suppress unreadVariable
839840
acdata.a_thid = GetThreadId();

iop/arcade/accore/src/intr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "accore_internal.h"
1212

1313
static acUint8 masks_8[3] = {128u, 2u, 64u};
14-
static struct intr_softc Intrc;
14+
static struct intr_softc Intrc ={0,1};
1515

1616
static int intr_intr(void *arg)
1717
{

0 commit comments

Comments
 (0)