; Dec 03 1991 v5.00'
;------------------------------------------------------------------------
; :
; AHDI Hard Disk Driver for the Atari ST, TT and ST Book :
; Copyright 1985-1991 Atari Corp. :
; All Rights Reserved :
; :
;------------------------------------------------------------------------
;
;+
; Edit History
;
;
; 22-May-1989 ml Started this from ahdi 3.00
; Files created for this driver:
; ACSI.S Low-level driver for ACSI.
; CMDBLK.S Builds packets for command blocks.
; DOIT.S Sends packets out to SCSI or ACSI.
; DRIVER.S This file.
; SCSI.S Low-level driver for SCSI.
;
; 25-May-1989 ml Eliminated pread(), use _ahdi_rw() in physical mode
; instead.
;
; 06-Jun-1989 ml Created INSTALL.S for driver installation.
;
; 11-Jul-1989 ml Rwabs() now handles DMA to fast RAM on ACSI side
; also. If no extra RAM was reserved for fast RAM
; transferred, _dskbufp is used for the transfer.
; (This is going to be really slow!!!)
;
; 19-Jul-1989 ml If there is cache on CPU, Rwabs() reads will
; flush both the I and D cache.
;
; 06-Sep-1989 ml Use _FRB (in the cookie jar) for fast RAM transfer,
; assuming _FRB WILL be there if there is fast RAM on
; the machine.
;
; 20-Feb-1990 ml 3.64 Fixed bug in return code when doing ACSI odd transfer.
; When successful, 0 should be returned.
;
; 02-Mar-1990 ml 3.65 Took out wait loop for SCSI 0 to be ready.
; (modified file: install.s)
;
; 05-Mar-1990 ml 3.66 Added more checks for I/O to ACSI and SCSI non-
; accessible memory. _FRB will be used if it exists.
; If _FRB doesn't exist, _dskbuf will used (which
; means I/O could be "really" slow). (_do_rw())
;
; _FRB is being looked for when it's needed for the
; first time, not at boot time. (Applications can
; add the _FRB when they are executed.)
;
; 08-Mar-1990 ml Added SCFRDMA flag in defs.h to make SCSI DMA to
; fast RAM conditional assembly.
; (modified file: driver.s)
;
; 15-Mar-1990 ml Added DEBUG flag in defs.h to make debugging code
; conditional assembly.
;
; 09-Apr-1990 ml 3.67 Added a "read" from WDL after toggling the ACSI DMA
; chip to point the MMU to the correct direction.
; (modified file: acsi.s)
;
; 10-Apr-1990 ml Put up banner at beginning and end of loading driver
; (requested by jwt), instead of just at the end.
; (Printing of banner moved to install.s)
;
; 17-Apr-1990 ml Added ODMA flag in defs.h to make the klutch of
; making byte counter bigger than # bytes requested
; when receiving data from SCSI conditional assembly.
; (modified file: scsi.s)
;
; 20-Apr-1990 ml Added RDWDL flag in defs.h to make the "extra read"
; added on 09-Apr-1990 conditional assembly. (When
; writing to ACSI, first 32 bytes are always FF's!!
; Wondering why...)
; (modified file: acsi.s)
;
; 30-Jul-1990 ml 4.00 Final for TT release.
; (Vectored-interrupts code not included)
;
; 31-Jul-1990 ml Vectored-interrupt code included as conditional
; assembly.
;
; 29-Oct-1990 ml 4.01 BUG!!! Getcookie() module provided by AKP has a
; variable declared in the bss. This bss will be
; clobbered when the driver adds GEMDOS buffers and
; OS pool. When getcookie() was called, and access
; the bss, it clobbered whatever was using its space
; at the time.
; Fixed in cookie.s by changing moving the variable
; from the bss to the text segment.
; (modified file: cookie.s)
;
; 26-Nov-1990 ml 4.02 BUG!! From 3.00 through 4.01, when Rwabs() is called
; in raw mode, it ignored media change completely.
; This created problems with cartridge swapping on the
; removable drives. If Getbpb(), on a logical drive
; that has not been accessed on the previous cartridge,
; is called right after a cartridge swap, Getbpb() will
; call Rwabs() in raw mode to read the partition map of
; the physical unit concerned. This Rwabs() call will
; get the media change error from the controller and
; ignores it without setting any mcflg of the physical
; unit. Now when Mediach(), on a logical drive that was
; accessed on the previous cartridge, is called, the
; driver will return media not change!
; In version 4.02, Rwabs() still does not return media
; change error when called in raw mode, but will
; remember it by setting the mcflgs of the physical
; unit concerned to maybe changed.
;
; 02-Apr-1991 ml 4.03 BUG!! At boot time,
; move.l #(i_sasi1-i_sasi),tokeep
; is used to find number of bytes of code to keep.
; In pre-4.00 AHDI, this works just fine because both
; i_sasi1 and i_sasi are in the same file. But, since
; 3.00, i_sasi1 has been moved to the file INSTALL.S,
; thus external. Madmac did not complain that the
; expression #(i_sasi1-i_sasi) is not valid anymore.
; Instead it assembles the code as
; move.l #i_sasi1,tokeep
; This is bad, because it depends of where the driver
; is being loaded, the driver may end up hogging large
; amount of memory that it is not using. This is now
; fixed by calculating the amount at run time.
; move.l #i_sasi1,tokeep
; subi.l #i_sasi,tokeep
; (modified file: driver.s)
;
; 04-Apr-1991 ml Some SCSI drives will recalibrate every so often.
; While recalibrating, the drive still accepts the
; command block, but delays the transfer of data to
; after the recalibration. So, timeout for the data
; transfer should include the amount of time spent
; on recalibration. The worst case we know of is
; the Fujisu drives which takes 4 seconds. So, the
; default for recalibration time is set to 4 seconds.
; (modified files: driver.s, scsi.s)
;
; 08-Aug-1991 ml BUG!! When the eject button on the MEGAFILE 44 is
; pressed without actually changing the cartridge, the
; driver still thinks there is a media change. The
; driver complains that the FAT checksum is different
; from what's been recorded.
;
; The cause:
; When _ahdi_rw() is called in physical mode, the
; variable sizr should not be set. First, it is not
; necessary to set it, because the variable is not
; used at all when in physical mode. Secondly, the
; setting of the variable overwrites its value which
; may have been set by the logical mode _ahdi_rw() that
; calls _ahdi_rw() recursively in physical mode!
; (modified file: driver.s)
;
; 14-Aug-1991 ml 4.60 Folded v4.59, which handles the IDE drives, into
; v4.03.
; (added files: ide.s, ide.h, blitter.h)
; (modified files: driver.s, install.s, defs.h)
;
; 19-Aug-1991 ml Modified errcode() so that it returns a BIOS
; error code instead of the controller error code.
; It now handles error for ACSI, SCSI and IDE drives.
;
; 20-Aug-1991 ml Optimized code by eliminating as many mulu's
; and divu's as possible.
; (modified files: driver.s install.s, acsi.s)
;
; 21-Aug-1991 ml Modified the ACSI-accessible RAM boundary check
; in _do_rw(). The boundary is at 4Mb for STs,
; at 10Mb for TTs.
; (modified files: driver.s, install.s, defs.h)
;
; 30-Aug-1991 ml Eliminated the requirement that physical units
; connected to the system must have consecutive
; physical unit numbers. The flag how2scan tells
; the driver how to scan the physical units. If set,
; the driver will scan the physical units as specified
; by the flags to be explained later. If how2scan is
; not set, the driver will do the scanning the default
; way, which is, consecutively. Acsi2scan, scsi2scan
; and ide2scan are flags introduced to tell the driver
; which physical units to scan at boot time. Each bit
; in the flags corresponds to one physical unit.
; acsi2scan: bit 0..7 corresponds to ACSI unit 0..7
; scsi2scan: bit 0..7 corresponds to SCSI unit 0..7
; ide2scan: bit 0..1 corresponds to IDE unit 0..1
; Acsi2scan, scsi2scan and ide2scan are defaulted to
; 0xff, which tells the driver to scan all units.
; (modified files: driver.s install.s)
;
; 06-Sep-1991 ml Added boot-time-messages to show information of the
; device being scanned.
; (modified files: install.s)
;
; 13-Sep-1991 ml Decision has been made that there will only be ONE
; IDE drive connected to the controller at the current
; IDE bus address. So, code that was written to take
; care of IDE unit 1 was eliminated.
; (modified files: driver.s install.s)
;
; 16-Sep-1991 ml Check if driver is running on ST Book. If so, do
; NOT use BLiTTER for IDE hard disk data transfer.
; (modified files: driver.s install.s)
;
; 17-Sep-1991 ml Added a flag, called ideinit, for programs (e.g.
; Slavik's POWER.PRG) to set to let the driver know
; that it needs to reinitialize the IDE drive.
; Initializing the drive involves doing an identify(),
; an initparm(), and reset of the drive's internal
; spin down counter.
; (modified files: driver.s)
;
; 18-Sep-1991 ml Assuming that an IDE drive will boot up in a mode as
; specified by the parameters returned by the Identify
; command, there is no need to do the Initparm command
; at boot time. It is also not necessary for the
; to reinitialize the drive after a shut down. So
; changes added yesterday are deleted.
; (modified files: driver.s install.s)
;
; 24-Sep-1991 ml 5.00a Wrapped up driver for ST Book and STE+. To show
; info of ACSI devices at boot time, delay must be
; added to take care of the slow ones (e.g. laser
; printer.)
; (modified files: acsi.s driver.s install.s)
;
; 01-Oct-1991 ml 5.00 First preliminary release for ST Book.
;
; 07-Oct-1991 ml Changes made to _rcvacsi() in calculating # of
; times to send the command. Refer to comments in
; acsi.s.
; (modified file: acsi.s)
;
; 11-Oct-1991 ml Special-cased Conner CP2024 in finding current
; drive parameters of IDE drives.
; (modified files: ide.s install.s)
;
; 22-Oct-1991 ml Added in check for command line arguements. If
; there is any, do NOT print any messages on the
; screen.
; (modified files: driver.s install.s)
;
; 03-Dec-1991 ml Fixed a bug in _qdone. Refer to comments in acsi.s
; for details.
; (modified file: acsi.s)
;-