Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!rutgers!cbmvax!jesup From: jesup@cbmvax.commodore.com (Randell Jesup) Newsgroups: comp.sys.amiga.programmer Subject: Re: Direct hardware drive access Message-ID: <20221@cbmvax.commodore.com> Date: 1 Apr 91 05:48:18 GMT References: <2147@pdxgate.UUCP> <20215@cbmvax.commodore.com> Reply-To: jesup@cbmvax.commodore.com (Randell Jesup) Organization: Commodore, West Chester, PA Lines: 93 In article mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes: >I check DSKRDY before reading/writing to the disk. I waited a little extra time >deliberatly to help ensure that drives that are up to 50% out of spec work. Better >safe than sorry. And to help other developers who use AmigaMail: The article >titled "Low Level Disk Access" by Bryce Nesbitt on page VIII-10/11 shows the following >routine: > >motor_wait btst.b #5,CIAA_PRA ; check READY line > bne.s motor_wait ; busy wait until drive is ready > rts > >When I tried this on an A500 at EA, it didn't work at ALL. Bug report??? It seems to work ok for us currently (2.0 trackdisk checks ready every .1 seconds up to .5, a compromise). What drives didn't that code work on? Did you tell bryce? >>>; Step toward track 80: >>>StepRight move.l #CIAB,a0 >>> move.b #%01000111,d0 >> ^ Interesting, that's DSKSEL3 >> Ever test this code with 4 drives? > >My mistake. One of us (you, Bryce, and myself) should have caught this >one. You saw these sources before we shipped. I had cut these routines >from a set of MS-DOS/Atari ST format drivers someone else had written. I never saw your routines, and Bryce is a busy person. Things like this are why we discourage the Abacus-style of programming (hard-coded constants, no includes), and prefer and encourage use of symbolic references. I would have written #(DSKSEL3!DSKSIDE!DSKDIREC!DSKSTEP), which makes it obvious that DSKSEL3 has been selected, without having to look up or memorize every bit in the hardware. If he was using hardcoded constants, you should have looked up the register definitions at least so you had some idea what he was doing. >> ^ Interesting, that's outwards (toward 0) > >Difference in terminology here, but Randall's usage is more correct. It should >be IN instead of RIGHT, and OUT instead of LEFT. I've never heard of left/right for disks. It's always in/out. >>> move.b #%01000100,d0 >> ^ Interesting, that's DSKSEL3 >> ^ Interesting, that's inwards (toward 80) >>The hardware manual says DSKDIREC MUST be set correctly BEFORE step is set to >>0. You must be lucky not to have hit a drive that actually requires it yet. >> > >PEOPLE NOTE THIS! There might not be a drive that requires it yet, but there >might be in the future. EA has had ZERO returns or reports of any problems >with these routines, but it is always a good idea to do it right. This sort of thing might not come to the attention of EA unless there were a lot of them out there. And as he says, there is no guarantee that the code above will work with the drives that leave the factory tomorrow or any other day. >>> move.b #%01000111,d0 >> ^ Interesting, that's DSKSEL3 >> ^ Interesting, that's outwards again >> This stuff of CIAB is not needed. > >Kinda picky about the lower 3 bits... is it WRONG? It doesn't hurt anything, but it's spurious. I thought you cared about efficiency... :-) >There is a routine called StepToTrack that calls these routines. When >it has stepped to the desired track, it waits 15ms. > >The original poster asked how to step the heads, not how to read/write >to the disk. Actually he seemed to be recalibrating the heads to track 0. >Another word of advice. Do not use the book "Amiga Disk Drives: Inside >and Out" by Abacus. I was told by Commodore when I was writing my routines >that the book is full of misinformation and was likely to cause people >to have disk driver problems. Absolutely. The code in the book doesn't even work with 1.3 roms, unless they've revised it recently. evil, evil, evil, IMHO. NOTE: this is my personal opinion, not an official opinion or statement of Commodore (of course). -- Randell Jesup, Keeper of AmigaDos, Commodore Engineering. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com BIX: rjesup Thus spake the Master Ninjei: "To program a million-line operating system is easy, to change a man's temperament is more difficult." (From "The Zen of Programming") ;-)