"Pete Rittwage" <
pe...@rittwage.com> writes:
> I see that there was discussion years ago about this, and it seemed to be
> implemented, but never became official?
There is a "minor" problem: I don't think it is possible to implement
fast serial on the existing hardware without opening the possibility for
data corruption or throwing out major pieces of functionality.
Background:
CP/M for the C128 assumes that a drive that is not fast-serial-capable
is always a 1541. I'm currently not sure if it will still read
double-sided 1571 disks in this mode, but at least for the 1581 the CP/M
disk format differs enough from the 1541 format that the computer will
read and/or write to completely wrong locations when it accesses the
directory, resulting in a corruption on writes if the drive misses a
fast serial capability check.
The check for this capability is built into the standard protocol:
Before starting the normal serial protocol to select a specific drive on
the bus, a single byte is sent over the fast serial connection - that
means the drive must always be able to receive this byte without any
prior warning. This is easy to do with a hardware shift register, but
there is none available for this job on any hardware that runs
sd2iec.
If the shift register is emulated in software, the data from the
bus must be read at most three microseconds after the clock edge to
ensure it is still valid. This is possible on the current hardware only
if the CPU is fully dedicated to the job with no other interrupts
interfering. As noted above, from the drive's point of view the fast
serial detection happens without warning, so the CPU would need to poll
for the fast serial data in the place where it is currently just
idling.
Disabling all interrupts at this point would also disable the regular
timer interrupt which is responsible for things like the LED blinking on
errors and checking the buttons used for disk swaps. Not disabling the
timer interrupt could result in a missed fast serial check from the
computer, which in turn would result in CP/M detecting the drive as a
1541 and possibly corrupting a D81 image file. I really do not want
features in the code that come with an unavoidable chance of corrupting
data - IIRC I calculated the probability of missing the fast serial
check at about 0.5% of all drive accesses.
Things would be much easier with either some external hardware that
implements the shift register and signals a received byte to the CPU
which can then read it with much more relaxed real-time
constraints. Another possibility would be to use a CPU with multiple
interrupt priorities, e.g. a Cortex M3. On that CPU the fast serial
clock line could be connected to an interrupt-capable input and the
priority of this interrupt can be set to the highest level so it would
run even when the timer interrupt is currently active.
On the AVR simulating the second approach by re-enabling interrupts at
the beginning of the timer interrupt still wouldn't work because at 8MHz
the additional worst-case latency for the second interrupt would still
be too much. It might be possible at 16MHz, but this wouldn't help
existing users either and part of the code base is cycle-counted
assembly built for 8MHz. That's a large effort for a feature that only a
very small number of people would ever use.
TL,DR: Unavoidable data corruption if enabled, few people need it
Oh, and quite a few sd2iec-based devices don't even bother to connect
the SRQ line to the AVR (two I remember off-hand: C64SD infinity, 1564).
-ik