1010
1111#include "acata_internal.h"
1212
13+ #include "atahw.h"
14+
1315static int atapi_dma_xfer (acDmaT dma , int intr , acDmaOp op );
1416static void atapi_dma_done (acDmaT dma );
1517static 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 {
0 commit comments