[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple ][ plus 13 sector! Problems...



I wrote about the Disk II self-sync pattern:
> The controller doesn't care if there are a few extra zero bits between
> the end of one nibble and the beginning of the next one.  This is used
> for the self-sync method.
> 
> In 13-sector format, the self-sync pattern consists of a series of
> self-sync nibbles that each have eight 1 bits followed by a single 0 bit
> (total of nine bits each).  If the controller starts attempting to read
> at an arbitrary point in the sequence, the first byte it reads will
> probably contain at least one 0 bit, rather than being the desired all
> 1s pattern (hex FF).  Because the zero bits can NEVER be interpreted as
> the high bit of a nibble, as it reads each succeeding byte from the
> controller, it will "catch up" to the point where it reads synchronized
> FF bytes.
> 
> In 16-sector format, the self-sync uses eight 1 bits followed by two 0
> bits (total of ten bits each).  This allows the controller and software
> to get in sync faster.

Here is an example of the 9-bit self sync pattern, showing what happens
if the controller starts reading at three of the nine possible positions:


disk:    1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0

case 1:  1 1 1 1 1 1 1 1
         \             /
                FF     - in sync at outset

case 2:    1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1
           \             / \             /
                 FE              FF    - in sync after first nibble

case 3:      1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1
             \             / \             / \             /
                  FD                FE             FF      
                                             -- in sync after second nibble

For the remaining cases, it just takes more repetitions of the self-sync
pattern.  I'll only show them in hexadecimal:

case 4:  FB FD FE FF
case 5:  F7 FB FD FE FF
case 6:  7F F7 FB FD FE FF
case 7:  DF 7F F7 FB FD FE FF
case 8:  BF DF 7F F7 FB FD FE FF
case 9:  (leading 0 bit discarded) FF

The final case occurs if the the start of the read is at the 0 bit.  Because
the controller detects that it has read a full nibble by the most significant
bit of the shift register being 1, a leading 0 will simply get shifted out
and ignored.  Thus synchronization is effectively already achieved as in
case 1, but with about ~4 us delay.

The result is that after reading at least seven nibbles of a self-sync area,
synchronization is guaranteed.

The 10-bit nibbles work similarly, but can guarantee sync after reading
at least four nibbles.

case 1:   FF  - in sync at outset
case 2:   FE FF
case 3:   FC FF
case 4:   F9 FE FF
case 5:   F3 FC FF
case 6:   E7 F9 FE FF
case 7:   CF F3 FC FF
case 8:   9F E7 F9 FE FF
case 9:   (leading 00 bits discarded) FF  - in sync
case 10:  (leading 0 bits discarded) FF

Of course, the disk controller may start reading at any point, not just
in a self-sync area.  But it is only interested in finding an address mark
(D5 AA 96).  The self-sync area immediately precedes the address
mark.  The software just reads and discards nibbles until it sees the
correct sequence of address mark nibbles; if it starts at some random point
out of sync (which is likely), the self-sync area will force it into correct
sync by the start of the address mark.

Of course, if it starts reading in the middle of the address mark, or near
the end of the self-sync area, it will fail to read that address mark
correctly.  But it will continue trying, and in the absence of disk errors
will be able to read all of the subsequent address marks.

As each address field is read, the track and sector number in the address
field are compared with those in the I/O request.  If they do not match,
the software will go back to searching for the next address mark.

If it was searching for the sector for which the address mark was
initially read incorrectly, it will find it when it comes around again
after slightly less than one full revolution.

The software will time out if the desired address field is not found within
some period of time.

Reading a data mark works similarly.  The data mark pattern for 16-sector
ormat is D5 AA AD.  There is a self-sync pattern before the data mark.
The software (RWTS or equivalent) doesn't attempt to find the data mark
until immediately after it has decoded the desired address mark, so it
doesn't try for nearly as long.  It would not be acceptable for it to
read the data field of the wrong sector.