diff --git a/iop/arcade/acata/src/ata.c b/iop/arcade/acata/src/ata.c index ccc8e4b89bc..7d3105a0563 100644 --- a/iop/arcade/acata/src/ata.c +++ b/iop/arcade/acata/src/ata.c @@ -9,6 +9,7 @@ */ #include "acata_internal.h" +#include "atahw.h" static struct ata_softc Atac; @@ -187,7 +188,7 @@ int ata_probe(acAtaReg atareg) int count; (void)atareg; - while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 ) + while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 ) ; *((volatile acUint16 *)0xB6020000) = 4660; // cppcheck-suppress knownConditionTrueFalse @@ -210,7 +211,7 @@ int ata_probe(acAtaReg atareg) while ( count <= 1999999 ) { // cppcheck-suppress knownConditionTrueFalse - if ( (*((volatile acUint16 *)0xB6070000) & 0x80) == 0 ) + if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 ) break; ++count; } diff --git a/iop/arcade/acata/src/atacmd.c b/iop/arcade/acata/src/atacmd.c index e6f21a2224c..6d743e187a2 100644 --- a/iop/arcade/acata/src/atacmd.c +++ b/iop/arcade/acata/src/atacmd.c @@ -9,6 +9,7 @@ */ #include "acata_internal.h" +#include "atahw.h" static int ata_dma_xfer(acDmaT dma, int intr, acDmaOp op); 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) int a_size; a_size = atah->a_size; - while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 ) + while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 ) ; while ( a_size > 0 ) { @@ -198,7 +199,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) a_size -= xlen; xlen_v15 = (unsigned int)xlen >> 1; xlen_v16 = xlen_v15 - 1; - while ( (*((volatile acUint16 *)0xB6070000) & 8) != 0 ) + while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) { int ret_v17; @@ -226,7 +227,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) else { ret_v20 = *((volatile acUint16 *)0xB6070000); - while ( (ret_v20 & 0x80) != 0 ) + while ( (ret_v20 & ATA_STAT_BUSY) != 0 ) { sr = *((volatile acUint16 *)0xB6070000); ret_v20 = sr & 0xFF; @@ -268,7 +269,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) else { sr_v25 = *((volatile acUint16 *)0xB6070000); - while ( (sr_v25 & 0x80) != 0 ) + while ( (sr_v25 & ATA_STAT_BUSY) != 0 ) { sr_v25 = *((volatile acUint16 *)0xB6070000); sr_v25 = sr_v25 & 0xFF; @@ -283,9 +284,9 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) xlen_v28 = (unsigned int)xlen_v27 >> 1; if ( (sr_v25 & 1) != 0 ) xlen_v28 = 0; - (void)(*((volatile acUint16 *)0xB6070000) & 0x80); + (void)(*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY); xlen_v30 = xlen_v28 - 1; - while ( (*((volatile acUint16 *)0xB6070000) & 8) != 0 ) + while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) { if ( xlen_v30 >= 0 ) { @@ -294,7 +295,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) } --xlen_v30; } - ret_v29 = *((volatile acUint16 *)0xB6070000) & 0x80; + ret_v29 = *((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY; if ( !ret_v29 ) break; } @@ -346,7 +347,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) ret = 0; if ( v16 ) { - while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == 128 ) + while ( (*((volatile acUint16 *)0xB6160000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( SleepThread() ) { @@ -360,7 +361,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) int tmout; tmout = 99999; - while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == 128 ) + while ( (*((volatile acUint16 *)0xB6070000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( tmout < 0 ) { @@ -380,7 +381,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) return ret; } sr_v34 = *((volatile acUint16 *)0xB6070000); - if ( (*((volatile acUint16 *)0xB6070000) & 1) != 0 ) + if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) != 0 ) return -((sr_v34 << 8) + *((volatile acUint16 *)0xB6010000)); if ( atah->a_state < 0x1FFu ) { diff --git a/iop/arcade/acata/src/atapicmd.c b/iop/arcade/acata/src/atapicmd.c index eef34a98f16..7fefe2c3e33 100644 --- a/iop/arcade/acata/src/atapicmd.c +++ b/iop/arcade/acata/src/atapicmd.c @@ -10,6 +10,8 @@ #include "acata_internal.h" +#include "atahw.h" + static int atapi_dma_xfer(acDmaT dma, int intr, acDmaOp op); static void atapi_dma_done(acDmaT dma); 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) *((volatile acUint16 *)0xB6060000) = flag & 0x10; *((volatile acUint16 *)0xB6160000) = (flag & 2) ^ 2; *((volatile acUint16 *)0xB6010000) = flag & 1; - *((volatile acUint16 *)0xB6070000) = 160; + *((volatile acUint16 *)0xB6070000) = 160; // ATA_STAT_BUSY|ATA_STAT_READY? tmout = 999; v6 = 1000; // cppcheck-suppress knownConditionTrueFalse - while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 ) + while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 ) { if ( tmout < 0 ) { @@ -105,7 +107,7 @@ static int atapi_packet_send(acAtaReg atareg, acAtapiPacketData *pkt, int flag) return -116; } // cppcheck-suppress knownConditionTrueFalse - while ( (*((volatile acUint16 *)0xB6070000) & 8) != 0 ) + while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) { --count; if ( count < 0 ) @@ -139,7 +141,7 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag) if ( !sr ) { sr_v5 = *((volatile acUint16 *)0xB6070000); - while ( (sr_v5 & 0x80) != 0 ) + while ( (sr_v5 & ATA_STAT_BUSY) != 0 ) { xlen = *((volatile acUint16 *)0xB6070000); sr_v5 = xlen & 0xFF; @@ -178,7 +180,7 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag) for ( drop_v10 = sr_v9 / 2 - 1; drop_v10 >= 0; --drop_v10 ) ; sr = v6 & 2; - if ( (*((volatile acUint16 *)0xB6070000) & 0x80) == 0 ) + if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 ) { break; } @@ -326,7 +328,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) else { sr_v14 = *((volatile acUint16 *)0xB6070000); - while ( (sr_v14 & 0x80) != 0 ) + while ( (sr_v14 & ATA_STAT_BUSY) != 0 ) { xlen = *((volatile acUint16 *)0xB6070000); sr_v14 = xlen & 0xFF; @@ -357,7 +359,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) for ( drop_v20 = sr_v18 / 2 - 1; drop_v20 >= 0; --drop_v20 ) *((volatile acUint16 *)0xB6000000) = 0; sr = flag & 2; - if ( (*((volatile acUint16 *)0xB6070000) & 0x80) == 0 ) + if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 ) { ret_v5 = size - a_size; break; @@ -388,7 +390,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) v32 = 0; if ( (flag & 2) != 0 ) { - while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == 128 ) + while ( (*((volatile acUint16 *)0xB6160000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( SleepThread() ) { @@ -402,7 +404,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) int tmout; tmout = 99999; - while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == 128 ) + while ( (*((volatile acUint16 *)0xB6070000) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( tmout < 0 ) { @@ -460,7 +462,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) } if ( ret_v5 < 0 ) return ret_v5; - if ( (*((volatile acUint16 *)0xB6070000) & 1) != 0 ) + if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) != 0 ) return -((*((volatile acUint16 *)0xB6070000) << 8) + *((volatile acUint16 *)0xB6010000)); if ( atah->a_state >= 0x1FFu ) { @@ -503,7 +505,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) acAtapiT atapi; atapi = (acAtapiT)atah; - if ( (*((volatile acUint16 *)0xB6070000) & 1) == 0 ) + if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) == 0 ) return ret; memset(&sense, 0, sizeof(sense)); memset(&u, 0, sizeof(u)); @@ -532,7 +534,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) v6 = 0; if ( (flag & 2) != 0 ) { - while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == 128 ) + while ( (*((volatile acUint16 *)0xB6160000) & 0x81) == ATA_STAT_BUSY ) { if ( SleepThread() ) { @@ -546,7 +548,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) int tmout; tmout = 99999; - while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == 128 ) + while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == ATA_STAT_BUSY ) { if ( tmout < 0 ) { diff --git a/iop/arcade/accdvd/src/acd.c b/iop/arcade/accdvd/src/acd.c index 5b6850f2bd9..44972e83a36 100644 --- a/iop/arcade/accdvd/src/acd.c +++ b/iop/arcade/accdvd/src/acd.c @@ -8,6 +8,7 @@ # Review ps2sdk README & LICENSE files for further details. */ +#include #include "accdvd_internal.h" static struct acd_softc Acdc; @@ -739,7 +740,7 @@ int acd_getstatus() { acAtaCommandData v1[4]; - v1[1] = 2021; + v1[1] = ATA_C_CHECK_POWER_MODE | 0x700; v1[0] = (Acdc.drive & 0xFF) | 0x2600; return acd_ata_request(Acdc.drive | 2, v1, 2, acd_getstatus_done, "getstatus"); } @@ -833,7 +834,7 @@ static int acd_identify(int drive) flag = 16 * (drive != 0); cmd[0] = flag | 0x600; - cmd[1] = 1953; + cmd[1] = ATA_C_IDENTIFY_PACKET_DEVICE | 0x700; acAtaSetup(&acdata.a_ata, acd_ata_done, 0, 0x4C4B40u); // cppcheck-suppress unreadVariable acdata.a_thid = GetThreadId(); diff --git a/iop/arcade/accore/src/intr.c b/iop/arcade/accore/src/intr.c index 4b73d1ad392..63eb2453210 100644 --- a/iop/arcade/accore/src/intr.c +++ b/iop/arcade/accore/src/intr.c @@ -11,7 +11,7 @@ #include "accore_internal.h" static acUint8 masks_8[3] = {128u, 2u, 64u}; -static struct intr_softc Intrc; +static struct intr_softc Intrc ={0,1}; static int intr_intr(void *arg) {