diff --git a/common/include/atahw.h b/common/include/atahw.h index 9b2dc5fc02ff..045737cd213e 100644 --- a/common/include/atahw.h +++ b/common/include/atahw.h @@ -48,14 +48,14 @@ typedef struct _ata_hwport (ata_hwport_t *)ATA_AIF_HDD_BASE /* r_error bits. */ -#define ATA_ERR_MARK 0x01 -#define ATA_ERR_TRACK0 0x02 -#define ATA_ERR_ABORT 0x04 -#define ATA_ERR_MCR 0x08 -#define ATA_ERR_ID 0x10 -#define ATA_ERR_MC 0x20 -#define ATA_ERR_ECC 0x40 -#define ATA_ERR_ICRC 0x80 +#define ATA_ERR_MARK 0x01 // bit 0 [AMNF] Address mark not found. +#define ATA_ERR_TRACK0 0x02 // bit 1 [TKZNF] Track zero not found. +#define ATA_ERR_ABORT 0x04 // bit 2 [ABRT] Aborted command. +#define ATA_ERR_MCR 0x08 // bit 3 [MCR] Media change request. +#define ATA_ERR_ID 0x10 // bit 4 [IDNF] ID not found. +#define ATA_ERR_MC 0x20 // bit 5 [MC] Media changed. +#define ATA_ERR_ECC 0x40 // bit 6 [UNC] Uncorrectable data error. +#define ATA_ERR_ICRC 0x80 // bit 7 [BBK] Bad Block detected. /* r_status bits. */ #define ATA_STAT_ERR 0x01 @@ -68,7 +68,10 @@ typedef struct _ata_hwport #define ATA_STAT_BUSY 0x80 /* r_select bits. */ -#define ATA_SEL_LBA 0x40 +/// In CHS addressing, bits 0 to 3 of the head. In LBA addressing, bits 24 to 27 of the block number. +/// bits 5 and 7 are supposed to be always set +#define ATA_SEL_DRV 0x10 // bit 4 [DRV] Selects the drive number. +#define ATA_SEL_LBA 0x40 // bit 6 [LBA] Uses CHS addressing if clear or LBA addressing if set. /** ATA command codes. */ enum ATA_C_CODES { diff --git a/iop/arcade/acata/src/acata_internal.h b/iop/arcade/acata/src/acata_internal.h index 202288cbb9e3..0d4bce05aa31 100644 --- a/iop/arcade/acata/src/acata_internal.h +++ b/iop/arcade/acata/src/acata_internal.h @@ -14,6 +14,22 @@ #include #include +#define ACATA_A_DATA 0xB6000000 // Read/Write PIO data bytes + +#define ACATA_R_DATA *((acAtaReg)0xB6000000) // Read/Write PIO data bytes +#define ACATA_R_FEATURE *((acAtaReg)0xB6010000) // [W] Used to control command specific interface features. +#define ACATA_R_ERROR ACATA_R_FEATURE // [R] Used to retrieve any error generated by the last ATA command executed. +#define ACATA_R_NSECTOR *((acAtaReg)0xB6020000) // Number of sectors to read/write (0 is a special value). +#define ACATA_R_SECTOR *((acAtaReg)0xB6030000) // This is CHS / LBA28 / LBA48 specific. +#define ACATA_R_LCYL *((acAtaReg)0xB6040000) // Partial Disk Sector address. +#define ACATA_R_HCYL *((acAtaReg)0xB6050000) // Partial Disk Sector address. +#define ACATA_R_SELECT *((acAtaReg)0xB6060000) // Used to select a drive and/or head. Supports extra address/flag bits. [`ACATA_UNIT0`, `ACATA_UNIT1`] +#define ACATA_R_STATUS *((acAtaReg)0xB6070000) // [R] Used to read the current status. +#define ACATA_R_COMMAND ACATA_R_STATUS // [W] Used to send ATA commands to the device. +#define ACATA_R_STATUS_ALT *((acAtaReg)0xB6160000) // [R] A duplicate of the Status Register which does not affect interrupts. +#define ACATA_R_CONTROL ACATA_R_STATUS_ALT // [W] Used to reset the bus or enable/disable interrupts. + + struct ata_softc { acQueueHeadData requestq; diff --git a/iop/arcade/acata/src/ata.c b/iop/arcade/acata/src/ata.c index 7d3105a05638..41d68bc1e60b 100644 --- a/iop/arcade/acata/src/ata.c +++ b/iop/arcade/acata/src/ata.c @@ -188,30 +188,30 @@ int ata_probe(acAtaReg atareg) int count; (void)atareg; - while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 ) + while ( (ACATA_R_STATUS & ATA_STAT_BUSY) != 0 ) ; - *((volatile acUint16 *)0xB6020000) = 4660; + ACATA_R_NSECTOR = 4660; // cppcheck-suppress knownConditionTrueFalse - if ( *((volatile acUint16 *)0xB6020000) != 52 ) + if ( ACATA_R_NSECTOR != 52 ) return 0; - *((volatile acUint16 *)0xB6030000) = 18; + ACATA_R_SECTOR = 18; // cppcheck-suppress knownConditionTrueFalse - if ( *((volatile acUint16 *)0xB6030000) != 18 ) + if ( ACATA_R_SECTOR != 18 ) return 0; active = 0; unit = 0; - *((volatile acUint16 *)0xB6160000) = 2; - *((volatile acUint16 *)0xB6010000) = 0; + ACATA_R_CONTROL = 2; + ACATA_R_FEATURE = 0; count = 0; while ( unit < 2 ) { - *((volatile acUint16 *)0xB6060000) = 16 * (unit != 0); - *((volatile acUint16 *)0xB6070000) = 0; - *((volatile acUint16 *)0xB6070000) = 0; + ACATA_R_SELECT = 16 * (unit != 0); + ACATA_R_COMMAND = 0; + ACATA_R_COMMAND = 0; while ( count <= 1999999 ) { // cppcheck-suppress knownConditionTrueFalse - if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 ) + if ( (ACATA_R_STATUS & ATA_STAT_BUSY) == 0 ) break; ++count; } @@ -304,7 +304,7 @@ int acAtaModuleStart(int argc, char **argv) Atac.requestq.q_next = 0; DelayThread(delay); ChangeThreadPriority(0, 123); - index_v12 = ata_probe((acAtaReg)0xB6000000); + index_v12 = ata_probe((acAtaReg)ACATA_A_DATA); Atac.active = index_v12; if ( index_v12 == 0 ) { diff --git a/iop/arcade/acata/src/atacmd.c b/iop/arcade/acata/src/atacmd.c index 6d743e187a2e..510ca89bae34 100644 --- a/iop/arcade/acata/src/atacmd.c +++ b/iop/arcade/acata/src/atacmd.c @@ -29,7 +29,7 @@ static int ata_dma_xfer(acDmaT dma, int intr, acDmaOp op) if ( dmatmp->ad_state == 31 ) { dmatmp->ad_result = dmatmp->ad_ata->ac_h.a_size; - return op(dma, (void *)0xB6000000, dmatmp->ad_ata->ac_h.a_buf, dmatmp->ad_ata->ac_h.a_size); + return op(dma, (void *)ACATA_A_DATA, dmatmp->ad_ata->ac_h.a_buf, dmatmp->ad_ata->ac_h.a_size); } thid = dmatmp->ad_thid; dmatmp->ad_state = 3; @@ -143,15 +143,15 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) cmd = ata->ac_command; count = 5; flag_v8 = atah->a_flag; - *((volatile acUint16 *)0xB6060000) = flag_v8 & 0x10; - *((volatile acUint16 *)0xB6160000) = (flag_v8 & 2) ^ 2; - *((volatile acUint16 *)0xB6010000) = 0; + ACATA_R_SELECT = flag_v8 & 0x10; + ACATA_R_CONTROL = (flag_v8 & 2) ^ 2; + ACATA_R_FEATURE = 0; while ( count >= 0 ) { int data; data = *cmd++; - *(acUint16 *)(((2 * ((data >> 8) & 8) + ((data >> 8) & 7)) << 16) + 0xB6000000) = data & 0xFF; + *(acUint16 *)(((2 * ((data >> 8) & 8) + ((data >> 8) & 7)) << 16) + ACATA_A_DATA) = data & 0xFF; --count; if ( ((data >> 8) & 0xF) == 7 ) { @@ -183,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) & ATA_STAT_BUSY) != 0 ) + while ( (ACATA_R_STATUS & ATA_STAT_BUSY) != 0 ) ; while ( a_size > 0 ) { @@ -199,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) & ATA_STAT_DRQ) != 0 ) + while ( (ACATA_R_STATUS & ATA_STAT_DRQ) != 0 ) { int ret_v17; @@ -209,27 +209,27 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) ret_v17 = *a_buf; a_buf++; } - *((volatile acUint16 *)0xB6000000) = ret_v17; + ACATA_R_DATA = ret_v17; --xlen_v16; } if ( (flag_v8 & 2) != 0 ) { - sr = *((volatile acUint16 *)0xB6160000); + sr = ACATA_R_STATUS_ALT; ret_v20 = sr & 0xFF; - while ( (ret_v20 & 0x80) != 0 ) + while ( (ret_v20 & ATA_STAT_BUSY) != 0 ) { ret_v20 = -116; if ( SleepThread() != 0 ) break; - ret_v20 = *((volatile acUint16 *)0xB6160000); + ret_v20 = ACATA_R_STATUS_ALT; } } else { - ret_v20 = *((volatile acUint16 *)0xB6070000); + ret_v20 = ACATA_R_STATUS; while ( (ret_v20 & ATA_STAT_BUSY) != 0 ) { - sr = *((volatile acUint16 *)0xB6070000); + sr = ACATA_R_STATUS; ret_v20 = sr & 0xFF; } } @@ -256,22 +256,22 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) if ( (flag_v8 & 2) != 0 ) { - sr_v25 = *((volatile acUint16 *)0xB6160000); + sr_v25 = ACATA_R_STATUS_ALT; sr_v25 = sr_v25 & 0xFF; while ( (sr_v25 & 0x80) != 0 ) { sr_v25 = -116; if ( SleepThread() ) break; - sr_v25 = *((volatile acUint16 *)0xB6160000); + sr_v25 = ACATA_R_STATUS_ALT; } } else { - sr_v25 = *((volatile acUint16 *)0xB6070000); + sr_v25 = ACATA_R_STATUS; while ( (sr_v25 & ATA_STAT_BUSY) != 0 ) { - sr_v25 = *((volatile acUint16 *)0xB6070000); + sr_v25 = ACATA_R_STATUS; sr_v25 = sr_v25 & 0xFF; } } @@ -284,18 +284,18 @@ 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) & ATA_STAT_BUSY); + (void)(ACATA_R_STATUS & ATA_STAT_BUSY); xlen_v30 = xlen_v28 - 1; - while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) + while ( (ACATA_R_STATUS & ATA_STAT_DRQ) != 0 ) { if ( xlen_v30 >= 0 ) { - *buf_v23 = *((volatile acUint16 *)0xB6000000); + *buf_v23 = ACATA_R_DATA; buf_v23++; } --xlen_v30; } - ret_v29 = *((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY; + ret_v29 = ACATA_R_STATUS & ATA_STAT_BUSY; if ( !ret_v29 ) break; } @@ -313,14 +313,14 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) { int v38; - v38 = *((volatile acUint16 *)0xB6160000) & 1; + v38 = ACATA_R_STATUS_ALT & ATA_STAT_ERR; if ( v38 || state >= 511 ) { printf( "acata:A:dma_iowait: TIMEDOUT %04x:%02x:%02x\n", state, - *((volatile acUint16 *)0xB6160000), - *((volatile acUint16 *)0xB6010000)); + ACATA_R_STATUS_ALT, + ACATA_R_ERROR); if ( state < 1023 ) acDmaCancel(&dma_data.ad_dma, -116); ret = 0; @@ -329,7 +329,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) break; } state = dma_data.ad_state; - if ( (*((volatile acUint16 *)0xB6160000) & 0x80) == 0 && (int)dma_data.ad_state >= 64 ) + if ( (ACATA_R_STATUS_ALT & ATA_STAT_BUSY) == 0 && (int)dma_data.ad_state >= 64 ) { ret = dma_data.ad_result; break; @@ -347,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) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) + while ( (ACATA_R_STATUS_ALT & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( SleepThread() ) { @@ -361,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) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) + while ( (ACATA_R_STATUS & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( tmout < 0 ) { @@ -380,9 +380,9 @@ 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) & ATA_STAT_ERR) != 0 ) - return -((sr_v34 << 8) + *((volatile acUint16 *)0xB6010000)); + sr_v34 = ACATA_R_STATUS; + if ( (ACATA_R_STATUS & ATA_STAT_ERR) != 0 ) + return -((sr_v34 << 8) + ACATA_R_ERROR); if ( atah->a_state < 0x1FFu ) { atah->a_state = 127; @@ -395,7 +395,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) cmd_v36 = ata->ac_command; if ( ret_v35 < 0 ) { - return -((sr_v34 << 8) + *((volatile acUint16 *)0xB6010000)); + return -((sr_v34 << 8) + ACATA_R_ERROR); } for ( rest_v37 = 6; rest_v37 > 0; --rest_v37 ) { @@ -403,7 +403,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) break; *cmd_v36 = ((((int)*cmd_v36 >> 12) & 0xF) << 12) - | ((*(acUint16 *)(((2 * (((int)*cmd_v36 >> 12) & 8) + (((int)*cmd_v36 >> 12) & 7)) << 16) + 0xB6000000)) & 0xFF); + | ((*(acUint16 *)(((2 * (((int)*cmd_v36 >> 12) & 8) + (((int)*cmd_v36 >> 12) & 7)) << 16) + ACATA_A_DATA)) & 0xFF); ++cmd_v36; } return 6 - rest_v37; diff --git a/iop/arcade/acata/src/atapicmd.c b/iop/arcade/acata/src/atapicmd.c index 7fefe2c3e331..99eaf6b9f583 100644 --- a/iop/arcade/acata/src/atapicmd.c +++ b/iop/arcade/acata/src/atapicmd.c @@ -31,7 +31,7 @@ static int atapi_dma_xfer(acDmaT dma, int intr, acDmaOp op) if ( dmatmp->ad_state == 31 ) { dmatmp->ad_result = dmatmp->ad_atapi->ap_h.a_size; - return op(dma, (void *)0xB6000000, dmatmp->ad_atapi->ap_h.a_buf, dmatmp->ad_atapi->ap_h.a_size); + return op(dma, (void *)ACATA_A_DATA, dmatmp->ad_atapi->ap_h.a_buf, dmatmp->ad_atapi->ap_h.a_size); } thid = dmatmp->ad_thid; dmatmp->ad_state = 3; @@ -81,16 +81,16 @@ static int atapi_packet_send(acAtaReg atareg, acAtapiPacketData *pkt, int flag) (void)atareg; count = 6; - *((volatile acUint16 *)0xB6050000) = 0; - *((volatile acUint16 *)0xB6040000) = 64; - *((volatile acUint16 *)0xB6060000) = flag & 0x10; - *((volatile acUint16 *)0xB6160000) = (flag & 2) ^ 2; - *((volatile acUint16 *)0xB6010000) = flag & 1; - *((volatile acUint16 *)0xB6070000) = 160; // ATA_STAT_BUSY|ATA_STAT_READY? + ACATA_R_HCYL = 0; + ACATA_R_LCYL = 64; + ACATA_R_SELECT = flag & 0x10; + ACATA_R_CONTROL = (flag & 2) ^ 2; + ACATA_R_FEATURE = flag & 1; + ACATA_R_COMMAND = ATA_C_PACKET; // ATA_STAT_BUSY|ATA_STAT_READY? tmout = 999; v6 = 1000; // cppcheck-suppress knownConditionTrueFalse - while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) != 0 ) + while ( (ACATA_R_STATUS & ATA_STAT_BUSY) != 0 ) { if ( tmout < 0 ) { @@ -107,12 +107,12 @@ static int atapi_packet_send(acAtaReg atareg, acAtapiPacketData *pkt, int flag) return -116; } // cppcheck-suppress knownConditionTrueFalse - while ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_DRQ) != 0 ) + while ( (ACATA_R_STATUS & ATA_STAT_DRQ) != 0 ) { --count; if ( count < 0 ) break; - *((volatile acUint16 *)0xB6000000) = pkt->u_h[0]; + ACATA_R_DATA = pkt->u_h[0]; pkt = (acAtapiPacketData *)((char *)pkt + 2); } return 0; @@ -140,30 +140,30 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag) if ( !sr ) { - sr_v5 = *((volatile acUint16 *)0xB6070000); + sr_v5 = ACATA_R_STATUS; while ( (sr_v5 & ATA_STAT_BUSY) != 0 ) { - xlen = *((volatile acUint16 *)0xB6070000); + xlen = ACATA_R_STATUS; sr_v5 = xlen & 0xFF; } } else { - xlen = *((volatile acUint16 *)0xB6160000); + xlen = ACATA_R_STATUS_ALT; sr_v5 = xlen & 0xFF; while ( (sr_v5 & 0x80) != 0 ) { sr_v5 = -116; if ( SleepThread() != 0 ) break; - sr_v5 = *((volatile acUint16 *)0xB6160000); + sr_v5 = ACATA_R_STATUS_ALT; } } if ( sr_v5 < 0 ) return sr_v5; if ( (sr_v5 & 8) == 0 ) break; - xlen_v6 = (*((volatile acUint16 *)0xB6050000) << 8) + *((volatile acUint16 *)0xB6040000); + xlen_v6 = (ACATA_R_HCYL << 8) + ACATA_R_LCYL; drop = xlen_v6 - rest; if ( rest >= xlen_v6 ) drop = 0; @@ -174,13 +174,13 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag) while ( xlen_v8 >= 0 ) { --xlen_v8; - *buf++ = *((volatile acUint16 *)0xB6000000); + *buf++ = ACATA_R_DATA; } sr_v9 = drop + 1; for ( drop_v10 = sr_v9 / 2 - 1; drop_v10 >= 0; --drop_v10 ) ; sr = v6 & 2; - if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 ) + if ( (ACATA_R_STATUS & ATA_STAT_BUSY) == 0 ) { break; } @@ -257,7 +257,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) if ( ret_v5 < 0 ) return ret_v5; ChangeThreadPriority(0, cmdpri); - ret_v5 = atapi_packet_send((acAtaReg)0xB6000000, &atapi->ap_packet, flag); + ret_v5 = atapi_packet_send((acAtaReg)ACATA_A_DATA, &atapi->ap_packet, flag); if ( ret_v5 >= 0 ) { int v12; @@ -294,7 +294,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) v15 = (acUint16 *)atah->a_buf; if ( (flag & 4) == 0 ) { - ret_v5 = atapi_pio_read((acAtaReg)0xB6000000, a_buf, atah->a_size, flag); + ret_v5 = atapi_pio_read((acAtaReg)ACATA_A_DATA, a_buf, atah->a_size, flag); } else { @@ -315,22 +315,22 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) if ( sr ) { - xlen = *((volatile acUint16 *)0xB6160000); + xlen = ACATA_R_STATUS_ALT; sr_v14 = xlen & 0xFF; while ( (sr_v14 & 0x80) != 0 ) { sr_v14 = -116; if ( SleepThread() != 0 ) break; - sr_v14 = *((volatile acUint16 *)0xB6160000); + sr_v14 = ACATA_R_STATUS_ALT; } } else { - sr_v14 = *((volatile acUint16 *)0xB6070000); + sr_v14 = ACATA_R_STATUS; while ( (sr_v14 & ATA_STAT_BUSY) != 0 ) { - xlen = *((volatile acUint16 *)0xB6070000); + xlen = ACATA_R_STATUS; sr_v14 = xlen & 0xFF; } } @@ -342,7 +342,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) ret_v5 = size - a_size; break; } - xlen_v15 = (*((volatile acUint16 *)0xB6050000) << 8) + *((volatile acUint16 *)0xB6040000); + xlen_v15 = (ACATA_R_HCYL << 8) + ACATA_R_LCYL; drop = xlen_v15 - a_size; if ( a_size >= xlen_v15 ) drop = 0; @@ -352,14 +352,14 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) xlen_v17 = (xlen_v15 + 1) / 2 - 1; for ( sr_v18 = drop + 1; xlen_v17 >= 0; sr_v18 = drop + 1 ) { - *((volatile acUint16 *)0xB6000000) = *v15; + ACATA_R_DATA = *v15; v15++; --xlen_v17; } for ( drop_v20 = sr_v18 / 2 - 1; drop_v20 >= 0; --drop_v20 ) - *((volatile acUint16 *)0xB6000000) = 0; + ACATA_R_DATA = 0; sr = flag & 2; - if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_BUSY) == 0 ) + if ( (ACATA_R_STATUS & ATA_STAT_BUSY) == 0 ) { ret_v5 = size - a_size; break; @@ -390,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) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) + while ( (ACATA_R_STATUS_ALT & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( SleepThread() ) { @@ -404,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) & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) + while ( (ACATA_R_STATUS & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( tmout < 0 ) { @@ -430,14 +430,14 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) { int v30; - v30 = *((volatile acUint16 *)0xB6160000) & 1; + v30 = ACATA_R_STATUS_ALT & ATA_STAT_ERR; if ( v30 || ret_v23 >= 511 ) { printf( "acata:P:dma_iowait: TIMEDOUT %04x:%02x:%02x\n", ret_v23, - *((volatile acUint16 *)0xB6160000), - *((volatile acUint16 *)0xB6010000)); + ACATA_R_STATUS_ALT, + ACATA_R_ERROR); if ( ret_v23 < 1023 ) acDmaCancel(&dma_data.ad_dma, -116); ad_result = 0; @@ -446,7 +446,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri) break; } ret_v23 = dma_data.ad_state; - if ( (*((volatile acUint16 *)0xB6160000) & 0x80) == 0 && (int)dma_data.ad_state >= 64 ) + if ( (ACATA_R_STATUS_ALT & ATA_STAT_BUSY) == 0 && (int)dma_data.ad_state >= 64 ) { ad_result = dma_data.ad_result; break; @@ -462,8 +462,8 @@ 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) & ATA_STAT_ERR) != 0 ) - return -((*((volatile acUint16 *)0xB6070000) << 8) + *((volatile acUint16 *)0xB6010000)); + if ( (ACATA_R_STATUS & ATA_STAT_ERR) != 0 ) + return -((ACATA_R_STATUS << 8) + ACATA_R_ERROR); if ( atah->a_state >= 0x1FFu ) { return -116; @@ -505,7 +505,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) acAtapiT atapi; atapi = (acAtapiT)atah; - if ( (*((volatile acUint16 *)0xB6070000) & ATA_STAT_ERR) == 0 ) + if ( (ACATA_R_STATUS & ATA_STAT_ERR) == 0 ) return ret; memset(&sense, 0, sizeof(sense)); memset(&u, 0, sizeof(u)); @@ -513,9 +513,9 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) u.opcode = 0x03; u.len = 0x12; u.lun = atapi->ap_packet.u_b[1]; - *((volatile acUint16 *)0xB6160000) = (flag & 2) ^ 2; - *((volatile acUint16 *)0xB6010000) = 0; - v3 = atapi_packet_send((acAtaReg)0xB6000000, &u.pkt, flag); + ACATA_R_CONTROL = (flag & 2) ^ 2; + ACATA_R_FEATURE = 0; + v3 = atapi_packet_send((acAtaReg)ACATA_A_DATA, &u.pkt, flag); if ( v3 < 0 ) { ret = v3; @@ -525,7 +525,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) int v4; int v5; - v4 = atapi_pio_read((acAtaReg)0xB6000000, (acUint16 *)&sense, sizeof(sense), flag); + v4 = atapi_pio_read((acAtaReg)ACATA_A_DATA, (acUint16 *)&sense, sizeof(sense), flag); v5 = v4; if ( v4 > 0 ) { @@ -534,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) == ATA_STAT_BUSY ) + while ( (*(volatile acUint16 *)0xB6160000) & (ATA_STAT_BUSY|ATA_STAT_ERR) == ATA_STAT_BUSY ) { if ( SleepThread() ) { @@ -548,7 +548,7 @@ static int atapi_ops_error(struct ac_ata_h *atah, int ret) int tmout; tmout = 99999; - while ( (*((volatile acUint16 *)0xB6070000) & 0x81) == ATA_STAT_BUSY ) + while ( (ACATA_R_STATUS & (ATA_STAT_BUSY|ATA_STAT_ERR)) == ATA_STAT_BUSY ) { if ( tmout < 0 ) { diff --git a/iop/arcade/acatad/src/acatad.c b/iop/arcade/acatad/src/acatad.c index 5b92c107cefd..e4186c4fda0a 100644 --- a/iop/arcade/acatad/src/acatad.c +++ b/iop/arcade/acatad/src/acatad.c @@ -203,7 +203,7 @@ ata_devinfo_t *sceAtaInit(int device) int ident_err; u32 total_sectors[2]; - probe_res = ata_probe((acAtaReg)0xB6000000); + probe_res = ata_probe((acAtaReg)ACATA_A_DATA); g_devinfo.has_packet = 0; g_devinfo.exists = device == probe_res - 1; if ( device != probe_res - 1 ) diff --git a/iop/arcade/accore/src/dma.c b/iop/arcade/accore/src/dma.c index f56263f0b6c0..eaee800d0d87 100644 --- a/iop/arcade/accore/src/dma.c +++ b/iop/arcade/accore/src/dma.c @@ -88,7 +88,7 @@ static int dma_xfer(acDmaT dma, void *ioptr, void *buf, int count) attr = dma->d_attr; v12 = GetAcIoDelayReg() & 0x80FFDFFF; v13 = 0x62000000; - if ( ioptr == (void *)0xB6000000 ) + if ( ioptr == (void *)ACATA_A_DATA ) v13 = 0x24000000; SetAcIoDelayReg(v12 | v13); dmac_ch_set_dpcr(8u, (unsigned int)attr >> 5); diff --git a/iop/arcade/acmeme/src/meme.c b/iop/arcade/acmeme/src/meme.c index df3bd9431e5f..7b26472e921e 100644 --- a/iop/arcade/acmeme/src/meme.c +++ b/iop/arcade/acmeme/src/meme.c @@ -528,11 +528,11 @@ int acMemeModuleStart(int argc, char **argv) while ( index < argc ) { opt = *v8; - if ( **v8 == 45 ) + if ( **v8 == '-' ) { v10 = opt[1]; opt_v7 = opt + 2; - if ( v10 == 112 ) + if ( v10 == 'p' ) { value = strtol(opt_v7, &next, 0); if ( next != opt_v7 ) diff --git a/iop/arcade/acuart/README.md b/iop/arcade/acuart/README.md index 017bf3002e6a..db504cffb41e 100644 --- a/iop/arcade/acuart/README.md +++ b/iop/arcade/acuart/README.md @@ -22,3 +22,18 @@ The UART is easily accesible through the white JST 3 pin connector located on th From left to right, the pins are: RX, TX, GND. An USB to RS232 (usually with DB9 connector) is recommended + +## Parameters + +param | parameter | description +----- | ----------- | --------- +`-x` | number | size of output buffer +`-r` | number | size of input buffer +`-l` | none | enables loopback +`-b` | number | sets baud +`-f` | number | fifo + +example +```c +const char* args = "-x" "\0" "2048" "\0" "-b" "\0" "115200"; +```