Re: [hatari-devel] Problem with SCSI initiator command register

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On 07/06/2012 18:53, Uwe Seimet wrote:
Hi,

Well, what did you expect? One loop iteration will take approximately 5
milliseconds (since you're basically waiting for the 200 Hz counter to
toggle its sign), and you're looping with d1 = 12000 times ...
that makes 12000 * 0.005 s = 60 s = 1 minute.

So unless you really expect something different here, I'd say Hatari
works here as designed ;-)

This is getting more and more interesting ;-).I have not checked how
long this loop might take for several years, probably because with a
real Atari it will always terminate early. (I will have to re-check the
arbitration timeout value again in any case, but I guess it is OK.)

Hello

just to confirm thomas' math and to clarify this subject, I ran your test loop under Hatari and everything looks fine regarding $fffa23 content and the whole loop is really supposed to take one minute.

Tos starts a 200 Hz timer by using ctrl reg = 6 (prediv = 64) and data reg = 192. This effectively gives 2.4576 MHz / 64 / 192 = 200 Hz

My previous mails were not correct on the values you read in data register on a real MFP (as well as on Hatari, because we correctly emulate those as some programs would lock otherwise).

When the timer is running, you will read values in the data reg between 1 and the starting value for the timer (192 in that case).

Forget my beq/bne test, there's only one special case when you read a "0" in data reg : if you stop the timer at the exact point where it would be looping (that is when its value is "1" and would be decremented to start again at 192 for example).

So in your case, your loop will read values between 1 and $7f (>0) and $80 and $c0 (<0).

"Luckily" for you, as the 200 Hz timer implies a data reg of $c0, your code is working and you can detect a timer's loop. But if TOS used some other values, it would not work at all (data reg = $50 for example) or could be very cpu sensitive (data reg = $82 for example).

With data reg = $c0, 33 % of the read are <0 and 66 % are >0, so this gives a large enough margin to account for possible interrupt of your loop and still be able to detect the bpl/bmi transition. But this would not be a correct method to detect a timer's loop in all the cases (testing interrupt pending bit or using your own interrupt handler to set a "loop flag" would be more accurate).


So the fact that with a real Atari the loop terminates early even when
no devices are connected means that the other (non-timer) register
values differ between Hatari and the TT/Falcon. They are checked in
order to quit the loop early, depending on the SCSI bus signals.

Some scsi related regs are certainly the cause of your loop exiting early, because this loop alone that only reads $fffa23 is correctly emulated.

But I never owned an SCSI disk on Atari and did not really checked the datasheets for this, so I can't really help on this point.


Nicolas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/