Skip to content

Commit 37099fc

Browse files
authored
Merge pull request #798 from uyjulian/acata_fix_mmio
Handle volatile MMIO correctly in acata
2 parents 8c8b9f2 + 5974005 commit 37099fc

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

iop/arcade/acata/src/ata.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ int ata_probe(acAtaReg atareg)
190190
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
191191
;
192192
*((volatile acUint16 *)0xB6020000) = 4660;
193+
// cppcheck-suppress knownConditionTrueFalse
194+
if ( *((volatile acUint16 *)0xB6020000) != 52 )
195+
return 0;
193196
*((volatile acUint16 *)0xB6030000) = 18;
197+
// cppcheck-suppress knownConditionTrueFalse
198+
if ( *((volatile acUint16 *)0xB6030000) != 18 )
199+
return 0;
194200
active = 0;
195201
unit = 0;
196202
*((volatile acUint16 *)0xB6160000) = 2;
@@ -200,6 +206,7 @@ int ata_probe(acAtaReg atareg)
200206
{
201207
*((volatile acUint16 *)0xB6060000) = 16 * (unit != 0);
202208
*((volatile acUint16 *)0xB6070000) = 0;
209+
*((volatile acUint16 *)0xB6070000) = 0;
203210
while ( count <= 1999999 )
204211
{
205212
// cppcheck-suppress knownConditionTrueFalse

iop/arcade/acata/src/atacmd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
215215
{
216216
sr = *((volatile acUint16 *)0xB6160000);
217217
ret_v20 = sr & 0xFF;
218-
while ( (*((volatile acUint16 *)0xB6160000) & 0x80) != 0 )
218+
while ( (ret_v20 & 0x80) != 0 )
219219
{
220220
ret_v20 = -116;
221221
if ( SleepThread() != 0 )
@@ -226,7 +226,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
226226
else
227227
{
228228
ret_v20 = *((volatile acUint16 *)0xB6070000);
229-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
229+
while ( (ret_v20 & 0x80) != 0 )
230230
{
231231
sr = *((volatile acUint16 *)0xB6070000);
232232
ret_v20 = sr & 0xFF;
@@ -257,7 +257,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
257257
{
258258
sr_v25 = *((volatile acUint16 *)0xB6160000);
259259
sr_v25 = sr_v25 & 0xFF;
260-
while ( (*((volatile acUint16 *)0xB6160000) & 0x80) != 0 )
260+
while ( (sr_v25 & 0x80) != 0 )
261261
{
262262
sr_v25 = -116;
263263
if ( SleepThread() )
@@ -268,7 +268,7 @@ static int ata_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
268268
else
269269
{
270270
sr_v25 = *((volatile acUint16 *)0xB6070000);
271-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
271+
while ( (sr_v25 & 0x80) != 0 )
272272
{
273273
sr_v25 = *((volatile acUint16 *)0xB6070000);
274274
sr_v25 = sr_v25 & 0xFF;

iop/arcade/acata/src/atapicmd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static int atapi_packet_send(acAtaReg atareg, acAtapiPacketData *pkt, int flag)
8686
*((volatile acUint16 *)0xB6010000) = flag & 1;
8787
*((volatile acUint16 *)0xB6070000) = 160;
8888
tmout = 999;
89+
v6 = 1000;
8990
// cppcheck-suppress knownConditionTrueFalse
9091
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
9192
{
@@ -138,7 +139,7 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag)
138139
if ( !sr )
139140
{
140141
sr_v5 = *((volatile acUint16 *)0xB6070000);
141-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
142+
while ( (sr_v5 & 0x80) != 0 )
142143
{
143144
xlen = *((volatile acUint16 *)0xB6070000);
144145
sr_v5 = xlen & 0xFF;
@@ -148,7 +149,7 @@ static int atapi_pio_read(acAtaReg atareg, acUint16 *buf, int count, int flag)
148149
{
149150
xlen = *((volatile acUint16 *)0xB6160000);
150151
sr_v5 = xlen & 0xFF;
151-
while ( (*((volatile acUint16 *)0xB6160000) & 0x80) != 0 )
152+
while ( (sr_v5 & 0x80) != 0 )
152153
{
153154
sr_v5 = -116;
154155
if ( SleepThread() != 0 )
@@ -314,7 +315,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
314315
{
315316
xlen = *((volatile acUint16 *)0xB6160000);
316317
sr_v14 = xlen & 0xFF;
317-
while ( (*((volatile acUint16 *)0xB6160000) & 0x80) != 0 )
318+
while ( (sr_v14 & 0x80) != 0 )
318319
{
319320
sr_v14 = -116;
320321
if ( SleepThread() != 0 )
@@ -325,7 +326,7 @@ static int atapi_ops_command(struct ac_ata_h *atah, int cmdpri, int pri)
325326
else
326327
{
327328
sr_v14 = *((volatile acUint16 *)0xB6070000);
328-
while ( (*((volatile acUint16 *)0xB6070000) & 0x80) != 0 )
329+
while ( (sr_v14 & 0x80) != 0 )
329330
{
330331
xlen = *((volatile acUint16 *)0xB6070000);
331332
sr_v14 = xlen & 0xFF;

0 commit comments

Comments
 (0)