Subject: Floppy driver

From: [email-masked] (Brad Pepers)

Here is more status info on the floppy driver. It now works well
enough for adosfs to work on it. I can mount my amiga floppies
and copy files from them. Here is what I haven't done:

1. Really test things with multiple tasks making requests

2. Make code robust to handle disk changes and write errors

3. Test out write code fully (need a writeable filesystem)

4. Handle disk labels enough to get newfs to work

I have been cleaning the code up and its not too bad right now. The
track writing code is still being worked on but it does work in some
simple cases I tried.

My plan now is to finish cleaning up the write code and implement
disk labels. Then I can try newfs on it and get a read/write fs.

I would also like to look at handling msdos disks. Maybe someone
could send me info on msdos disks or after the code is released
they can add in msdos disk handling.

+----------------------------Ren & Stimpy--------------------------------+
| "Psst. Hey Guido. It's all so clear to me now. I'm the keeper of the   |
| cheese. And you're the lemon merchant. Get it? And he knows it. That's |
| why he's gonna kill us. So we gotta beat it. Yeah. Before he lets      |
| loose the marmosets on us! Don't worry, little missy! I'll save you!"  |
+------------------ Brad Pepers -- [email-masked] -------------------+

---

From: [email-masked] (Ron Roskens)

>From the reaches of cyberspace, Brad Pepers wrote:
> 
> stuff on adosfs deleted.
>

If I'm not mistaken there already is support for the msdos file system
in the form of a gnu msdos file system. Maybe it would be better to
try to work the code to be able to handle that instead of trying to
totally rewrite the msdos fs.

Ron Roskens

---

From: [email-masked] (Brad Pepers)

> totally rewrite the msdos fs.

I was talking about a lower level than the filesystem. MSDOS disks are
formatted in a different way and all the track/sector information is
different. The low level disk reading code has to be changed first
so that it can even find any data on MSDOS disks. Once that is working
the msdos filesystem that comes with netbsd can be used.

---

From: [email-masked] (Ty Sarna)

> totally rewrite the msdos fs.

Yes, NetBSD has a msdos filesystem (not GNU copyrighted). What Brad is
talking about though is supporting the MSDOS raw disk layout in his
driver. Otherwise, you'll only be able to read msdos disks formatted for
Amiga 880K format, which is pretty useless.

-- 
Ty Sarna                 "As you know, Joel, children have always looked
[email-masked]        up to cowboys as role models. And vice versa."

---

From: [email-masked] (Mike Schwartz)

>totally rewrite the msdos fs.

Handling MS-DOS disks doesn't mean the filesystem.  The IBM PCs have a Western
Digital floppy controller chip that writes sectors to floppy disk differently
than the amiga OS does.  Fortunately, the Amiga hardware is capable of
reading and writing data compatible with the Western Digital controller,
but it's a
radically different program to do so.  In other words, take that amigaOS
compatible floppy driver sources and you can only use the motor on/off and
head stepping code.  The entire rest of the driver needs brand new and
custom code to read the WD controller format.

I actually had code to read/write the WD controller format, as well as code to
read write trackdisk.device format.  I have found the trackdisk format code
and even translated it to C and sent it to mtk.  I'm not much interested in
hacking kernels as other people are - my hopes were that either mtk or
someone mtk found might be willing to work with the code.  I offer to send
anyone the assembly version of the trackdisk format code - it uses the
blitter for mfm encoding and
decoding and has some non-traditional (but superior) features to
traditional trackdisk devices (unix or amigados).  For example, my routines
search the drives for a specific disk instead of requiring that specific
disk to be in a specific drive.  In other words, you can do a dir on the
floppy, eject it and put it in another drive and do dir again and the
software finds the floppy in the new drive...

I'd offer the MS-DOS (actually Atari ST, but same difference) format
routines in assembly, but I haven't been able to find them :(

---

From: Olaf Seibert <[email-masked]>

> routines in assembly, but I haven't been able to find them :(

Drat! They removed my MSH stuff from aminet! Anyway, again I offer
my MSH code (in assembly) for use; even the faster version that has
never been published in source code before.

-Olaf.
--
___ Olaf 'Rhialto' Seibert       D787B44DFC896063 4CBB95A5BD1DAA96
\X/ There are no lemurs in this post	      [email-masked]

---

From: [email-masked] (Niklas Hallqvist)

>>>>> "Brad" == Brad Pepers <[email-masked]> writes:

Brad> Here is more status info on the floppy driver. It now works well
Brad> enough for adosfs to work on it. I can mount my amiga floppies
Brad> and copy files from them. Here is what I haven't done:

Nice to hear that!

Brad> 4. Handle disk labels enough to get newfs to work

Don't forget, You still need to recognize ADOS disks without real disklabels.
It's easy, but don't forget it.

Brad> My plan now is to finish cleaning up the write code and
Brad> implement disk labels. Then I can try newfs on it and get a
Brad> read/write fs.

Fun!

Great work!

Niklas

---

From: [email-masked]

> custom code to read the WD controller format.
	The AMIX floppy driver used tables of some sort and the same
	low level routines to write Amiga vs IBM format, both low and
	high, 1.44M, density. That might be an angle to look at...
	It also used a user mode process to do stuff that looks alot like what
	trackdisk does and had a weird ioctl interface that only that user
	mode daemon used. It appears the user mode daemon was used for
	writes only.

		-Rob

---

From: [email-masked] (Brad Pepers)

<lots of stuff deleted>
> Just as an aside - have you thought about looking at the PC0: driver
> to see how Amiga resolved those differences?
> 
>  - Eric

I think I know how to do it. There will be a bit or two in the minor #
which tells the driver what type of disk it is. Then the code that does
the track decoding can be different. What I'm not sure of though is if
the MSDOS disk ca be handled in the same way as the amiga (on a track
basis - not by sector).

---

From: David Jones <[email-masked]>

> the MSDOS disk ca be handled in the same way as the amiga (on a track

Best to do the following with minor device #:

	DPUU

	D = density: 0=low (720/880) 1=high (1.44/1.76)
	P = PC? 0=amiga (880/1.76) 1=pc (720/1.44)
	U = unit (0-3)

PC and Amiga formats both use MFM with 0x4489 as the sync pattern.  The
track I/O code can be shared.  The sector decode code cannot.

-- 
David Jones, M.A.Sc student, Electronics Group (VLSI), University of Toronto
email: [email-masked], finger for more info/PGP public key

---

From: [email-masked] (Brad Pepers)

> It's easy, but don't forget it.

I have it working both ways now. I have a newfs formatted floppy in
drive 0 and mounted. I also have an amiga formatted floppy in drive
1 mounted using adosfs (works great!).

---

From: David L Miller <[email-masked]>

> 	P = PC? 0=amiga (880/1.76) 1=pc (720/1.44)

Is it possible to leave expansion room for 2.88/3.52MB floppies?

--DLM

|\ |  |\/|  David L. Miller    [email-masked]  (206) 685-6240
|/ |_ |  |  Software Engineer, Pine Development Team   (206) 685-4045 (FAX)
University of Washington, Networks & Distributed Computing
4545 15th Ave NE, Seattle WA 98105, USA

---

From: [email-masked] (Brad Pepers)

> 	P = PC? 0=amiga (880/1.76) 1=pc (720/1.44)

The density bit is not needed since the drive can be probed to find that
out. Also the PC/amiga could be probed as well (read a track and try to
decode using both methods - whichever one works is the proper type). But
I think I'll use a bit for this since the track format probe would take
a while.

> track I/O code can be shared.  The sector decode code cannot.

Yes I think I will be able to do this by only writing two new routines
which handle sector <-> raw track for msdos type tracks.

---

From: [email-masked] (Brad Pepers)

<stuff on minor #'s deleted>
> Is it possible to leave expansion room for 2.88/3.52MB floppies?

Can you get 2.88/3.52 MB floppies for the amiga? How do they work?

---

From: [email-masked] (Mike Schwartz)

>Brad> implement disk labels. Then I can try newfs on it and get a

I have a bit of advise here.  When I wrote MS-DOS or AmigaOS formatted
floppies with my own drivers, I wrote two sectors on track 40 of the floppy
to fool amigaos into thinking that the disk was indeed an AmigaOS disk but
that it was 100% full.  My reasoning was that when someone sticks a disk in
the drive and sees a bad volume reported by amigaos, they'd consider
formatting it to use it :-)  With the 100% full (fill BAM sector with
0xffff), they saw the disk was valid and could not use DOS or some other
program to write on the disk.

What was involved was to use ADos to format a blank floppy then use a
sector editor to dump track 40 sectors 0 and 1 and see for yourself what
the format is.  To add an ADOS disk label, there was an offset into sector
0 for a count+string
(not null terminated) and a checksum.  Sector 1 is the bam and should be all
0xffff.  My floppy disk drivers would automatically skip writing or reading
data from these two "magic" sectors.

You also have to deal with track 0, where the boot sector goes.  Otherwise
ADOS will not see it is a valid dos disk.

---

From: [email-masked] (Mike Schwartz)

>the MSDOS disk ca be handled in the same way as the amiga (on a track

No you can't treat an MS-DOS disk as you would an ADOS disk.  If my memory
serves correct - and forgive me if it doesn't - we're going back at least 3
years :-)  What I remember having to do was to turn on DMA on a sector by
sector basis.  And I think that the WD chip writes a magic MFM word (DSKSYN
byte) before each sector.  And I think that ADOS writes out even and odd
bits to separate memory chunks (after you read in a track) but the WD chip
does not -
hence your blitter MFM encode/decode are radically different.  I also remember
that I had to determine wheter the DMA to be started was indeed for the
sector I wanted.  It would obviously help to get a DOS formatted floppy and
examine it.

---

From: "hamish (h.i.) macdonald" <[email-masked]>

>> PC and Amiga formats both use MFM with 0x4489 as the sync pattern.
>> The track I/O code can be shared.  The sector decode code cannot.

>>>>> Brad wrote:

pepersb> Yes I think I will be able to do this by only writing two new
pepersb> routines which handle sector <-> raw track for msdos type
pepersb> tracks.

I think that MSDOS tracks have to be written aligned to the index sync
pulse.

The MSH code triggers write DMA start on the occurence of an index
sync interrupt (Flag interrupt on CIA B, interrupt level 6).

---

From: David Jones <[email-masked]>

> sector I wanted.  It would obviously help to get a DOS formatted floppy and

Paula has a signal called DSKSYNC.  When this is set, Paula will wait for
the 0x4489 sync word (common to MS-DOS and Amiga floppies) before starting
DMA.  Both Amiga and MS-DOS formats start each sector with a sync word.

In both cases, it is best to enable DSKSYNC and do DMA for a full track
(actually, a little more).  Then use software-based functions to pick the
data apart.  For writing MS-DOS floppies, I'd take the trackdisk approach:
buffer a whole track and rewrite all sectors at once.  Block-level writing
is too CPU-intensive on the Amiga.

---

From: Alan Bair <[email-masked]>

> ADOS will not see it is a valid dos disk.

If bad blocks are supported for floppies under NetBSD, the special ADOS
blocks could be marked as bad to avoid requiring special code to skip them.
This could be setup when the disk is formated under NetBSD, though then the
foramting program would need the special processing code, which could be an
option. Also, it may be nice to put an ADOS name like "NetBSD_floppy" to
make it easy to know what kind of disk this is on the ADOS side.

-- 
Alan Bair             		MCTG AMCU DSCS
Motorola, Inc.            	    (Design Software &
Mail Stop OE-320		     Computer Services)
6501 William Cannon Dr. West	(512) 891-2336
Austin, TX  78735-8598          [email-masked]

---

From: [email-masked] (Mike Schwartz)

>make it easy to know what kind of disk this is on the ADOS side.

Sounds like the hard way to do things...  However, to label the disk, there's
an offset as I mentioned in sector 0 of track 40 where you can put any label
you want.  You need to checksum the track and store it in the right offset as
well.