On 12/22/2005 at 10:24 PM ard at p850ug1.demon.co.uk wrote:
But to read the IDs, it appears you _have_ to
submit the next command as
soon as you get the results from the current one, or risk missing a
sector. And as far as I can see there's no way to be sure of doing that
on a multitasking system.
Okay, I'll drop another hint (geez, you guys really need to read the data
sheets). Let's assume that the disk contains something other than format
I will remind you of the comment in parentheses next time you need
something explained. As I said last night, I've read the Intel and NEC
data sheets, and this was not obvious to me.
pattern in all sectors; i.e., assume that the contents
sector-to-sector
differ. If you're not sure about the latter bit, you could always read
the sectors up and save them, write your own pattern, do your ordering
determination, then write the original data back.
No way would I recomend writing to an alien-format disk when trying to
archive it. Too much could go wrong.
Read a bunch of ID's repeatedly so that you're relatively sure that you've
got them all. Based on the number of different sector ID's you have,
figure out how many sectors are on the track.
Now, issue a Read Track for the appropriate sector count--stash the data
away for a bit.
Now, read each sector individually and hang onto the data.
Using a good checksum or hash, compute a sum for each sector in each of the
two buffers. Use the Read Track buffer to tell you what the order of
sectors is on the track.
Here's the thing about Read Track--it starts at the index and reads sectors
without regard to what's in the IDAMs--so you get the sector data in the
order that it occurs on the track--and so you can figure out how things are
ordered.
It's a pity that the Read Track command doesn't also give you the
contents of the headers (or at least give you the option of getting the
contents of the headers). That would make this whole job totally trivial....
This is the sort of thing which makes me think everything about the PC is
broken somehow...
It's not perfect, but it will work pretty well.
Probably good enough, a fair bit of work (and the first part, getting all
the IDs, is time-critical enough not to be possible from userland under a
multi-tasking OS).
-tony