(FILECREATED "20-Apr-86 13:17:43" {ERIS}<LISPCORE>SOURCES>DOVEFLOPPY.;19 54435  

      changes to:  (FNS \DOVEFLOPPY.INITDCB)

      previous date: "23-Mar-86 14:48:07" {ERIS}<LISPCORE>SOURCES>DOVEFLOPPY.;18)


(* Copyright (c) 1985, 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT DOVEFLOPPYCOMS)

(RPAQQ DOVEFLOPPYCOMS 
       ((DECLARE: EVAL@COMPILE DONTCOPY (FILES MESATYPES (SOURCE)
                                               DOVEDECLS)
               (COMS * DOVEFLOPPYDECLS))
        (VARS \DOVEFLOPPY.HARDFDCCOMMANDS \DOVEFLOPPY.#COMMANDBYTES \DOVEFLOPPY.#RESULTBYTES 
              \DOVEFLOPPY.COMMANDS \DOVEFLOPPY.DATATRANSFEROPS \DOVEFLOPPY.DEBUG 
              \DOVEFLOPPY.FDCBYTEONEMASKS \DOVEFLOPPY.FDCBYTETWOMASKS \DOVEFLOPPY.FORMATINFO 
              \DOVEFLOPPY.IMPLIEDSEEKOPS \DOVEFLOPPY.ST0MASKS \DOVEFLOPPY.ST1MASKS 
              \DOVEFLOPPY.ST2MASKS \DOVEFLOPPY.SECTORLENGTHS \DOVEFLOPPY.WAITFORINTERRUPTCMDS 
              \DOVEFLOPPY.CURRENTCONTEXT)
        (FNS \DOVEFLOPPY.RESET \DOVEFLOPPY.SETCONTEXT \DOVEFLOPPY.XFERDISK \DOVEFLOPPY.BYTESWAPIOCB 
             \DOVEFLOPPY.CLEARDISKCHANGED \DOVEFLOPPY.DISKCHANGED \DOVEFLOPPY.DOOROPEN 
             \DOVEFLOPPY.GETERRORSTATUS \DOVEFLOPPY.INIT \DOVEFLOPPY.INITDCB \DOVEFLOPPY.INITIOCB 
             \DOVEFLOPPY.INITIATE \DOVEFLOPPY.SETUPDMAINFO \DOVEFLOPPY.SETUPPRIMITIVEFDCOP 
             \DOVEFLOPPY.STOPHANDLER \DOVEFLOPPY.TRANSFER \DOVEFLOPPY.VALIDATEIOCB 
             \DOVEFLOPPY.WRITEPROTECTED)
        (INITVARS \DOVEFLOPPY.IOCB \DOVEFLOPPY.CURRENTCONTEXT (\DoveFloppy.FCBPointer))
        (GLOBALVARS \DOVEFLOPPY.IOCB \DOVEFLOPPY.CURRENTCONTEXT \DOVEFLOPPY.HARDFDCCOMMANDS 
               \DoveFloppy.FCBPointer)))
(DECLARE: EVAL@COMPILE DONTCOPY 
(FILESLOAD MESATYPES (SOURCE)
       DOVEDECLS)


(RPAQQ DOVEFLOPPYDECLS ((CONSTANTS (\DOVEFLOPPY.STOPDMA 516)
                               (\DOVEFLOPPY.STARTDMAWRITE 5798)
                               (\DOVEFLOPPY.STOPCOUNTER 16384)
                               (\DOVEFLOPPY.STARTDMAREAD 41574)
                               (\DOVEFLOPPY.STARTCOUNTER 49159)
                               (\DOVEFLOPPY.BYTETRUE 1)
                               (\DOVEFLOPPY.BYTEFALSE 0))
                        (CONSTANTS (\DOVEFLOPPY.HARDDOUBLEDENSITY 64)
                               (\DOVEFLOPPY.HARDHEADONE 4)
                               (\DOVEFLOPPY.HARDMULTITRACKMODE 128)
                               (\DOVEFLOPPY.HARDSKIPDELETEDSECTOR 32))
                        (CONSTANTS (\DOVEFLOPPY.DMAINTERRUPTWHENDONE 256)
                               (\DOVEFLOPPY.FDCCMDLENGTH 13))
                        (CONSTANTS (\DOVEFLOPPY.WRITEPROTECT 64)
                               (\DOVEFLOPPY.WAITING 3)
                               (\DOVEFLOPPY.READ 1)
                               (\DOVEFLOPPY.WRITE 2)
                               (\DOVEFLOPPY.NONE 0)
                               (\DOVEFLOPPY.OPERATIONCOMPLETED 6)
                               (\DOVEFLOPPY.INPROGRESS 4)
                               (\DOVEFLOPPY.OPERATIONFAILED 7)
                               (\DOVEFLOPPY.OPERATIONBUILT 2))
                        (RECORDS DOVEFLOPPYCMDBYTES DOVEFLOPPYCONTEXT DOVEFLOPPYDCB DOVEFLOPPYFCB 
                               DOVEFLOPPYFDCCOMMAND DOVEFLOPPYFORMATINFO DOVEFLOPPYIOCB 
                               DOVEFLOPPYSECTORHEADER DOVEQUEUEBLOCK)))
(DECLARE: EVAL@COMPILE 

(RPAQQ \DOVEFLOPPY.STOPDMA 516)

(RPAQQ \DOVEFLOPPY.STARTDMAWRITE 5798)

(RPAQQ \DOVEFLOPPY.STOPCOUNTER 16384)

(RPAQQ \DOVEFLOPPY.STARTDMAREAD 41574)

(RPAQQ \DOVEFLOPPY.STARTCOUNTER 49159)

(RPAQQ \DOVEFLOPPY.BYTETRUE 1)

(RPAQQ \DOVEFLOPPY.BYTEFALSE 0)

(CONSTANTS (\DOVEFLOPPY.STOPDMA 516)
       (\DOVEFLOPPY.STARTDMAWRITE 5798)
       (\DOVEFLOPPY.STOPCOUNTER 16384)
       (\DOVEFLOPPY.STARTDMAREAD 41574)
       (\DOVEFLOPPY.STARTCOUNTER 49159)
       (\DOVEFLOPPY.BYTETRUE 1)
       (\DOVEFLOPPY.BYTEFALSE 0))
)
(DECLARE: EVAL@COMPILE 

(RPAQQ \DOVEFLOPPY.HARDDOUBLEDENSITY 64)

(RPAQQ \DOVEFLOPPY.HARDHEADONE 4)

(RPAQQ \DOVEFLOPPY.HARDMULTITRACKMODE 128)

(RPAQQ \DOVEFLOPPY.HARDSKIPDELETEDSECTOR 32)

(CONSTANTS (\DOVEFLOPPY.HARDDOUBLEDENSITY 64)
       (\DOVEFLOPPY.HARDHEADONE 4)
       (\DOVEFLOPPY.HARDMULTITRACKMODE 128)
       (\DOVEFLOPPY.HARDSKIPDELETEDSECTOR 32))
)
(DECLARE: EVAL@COMPILE 

(RPAQQ \DOVEFLOPPY.DMAINTERRUPTWHENDONE 256)

(RPAQQ \DOVEFLOPPY.FDCCMDLENGTH 13)

(CONSTANTS (\DOVEFLOPPY.DMAINTERRUPTWHENDONE 256)
       (\DOVEFLOPPY.FDCCMDLENGTH 13))
)
(DECLARE: EVAL@COMPILE 

(RPAQQ \DOVEFLOPPY.WRITEPROTECT 64)

(RPAQQ \DOVEFLOPPY.WAITING 3)

(RPAQQ \DOVEFLOPPY.READ 1)

(RPAQQ \DOVEFLOPPY.WRITE 2)

(RPAQQ \DOVEFLOPPY.NONE 0)

(RPAQQ \DOVEFLOPPY.OPERATIONCOMPLETED 6)

(RPAQQ \DOVEFLOPPY.INPROGRESS 4)

(RPAQQ \DOVEFLOPPY.OPERATIONFAILED 7)

(RPAQQ \DOVEFLOPPY.OPERATIONBUILT 2)

(CONSTANTS (\DOVEFLOPPY.WRITEPROTECT 64)
       (\DOVEFLOPPY.WAITING 3)
       (\DOVEFLOPPY.READ 1)
       (\DOVEFLOPPY.WRITE 2)
       (\DOVEFLOPPY.NONE 0)
       (\DOVEFLOPPY.OPERATIONCOMPLETED 6)
       (\DOVEFLOPPY.INPROGRESS 4)
       (\DOVEFLOPPY.OPERATIONFAILED 7)
       (\DOVEFLOPPY.OPERATIONBUILT 2))
)
[DECLARE: EVAL@COMPILE 

(BLOCKRECORD DOVEFLOPPYCMDBYTES ((CB1 BYTE)
                                 (CB2 BYTE)
                                 (CB3 BYTE)
                                 (CB4 BYTE)
                                 (CB5 BYTE)
                                 (CB6 BYTE)
                                 (CB7 BYTE)
                                 (CB8 BYTE)
                                 (CB9 BYTE)))

(TYPERECORD DOVEFLOPPYCONTEXT (DRIVETYPE SECTORSPERTRACK NUMBEROFHEADS NUMBEROFCYLINDERS DENSITY 
                                     DISKCHANGED SECTORLENGTH))

(MESARECORD DOVEFLOPPYDCB ((DEVICEATTRIBUTES 5 WORD)
                           (DRIVEACQUIREDBYPCE BYTE)
                           (DRIVEBUSY BYTE)
                           (DIAGNOSTICDISKCHANGED WORD)
                           (PILOTDISKCHANGED WORD)
                           (DIAGNOSTICCONTEXT WORD)
                           (PILOTCONTEXT WORD)
                           (DOOROPEN WORD)
                           (DRIVESTATUSHEAD0 BYTE)
                           (DRIVESTATUSHEAD1 BYTE)
                           (Port80ControlWord WORD)
                           (StepRateTimePlusHeadUnloadTime BYTE)
                           (HeadLoadTimePlusNotInDMAmode BYTE))
                          (BLOCKRECORD DOVEFLOPPYDCB ((NIL 12 WORD)
                                                      (EnableMainMemory FLAG)
                                                      (EnableTimerZero FLAG)
                                                      (FDDMotorOn FLAG)
                                                      (FDDInUse FLAG)
                                                      (AllowTimerTC FLAG)
                                                      (FDDLowSpeed FLAG)
                                                      (SelectChAIntClk FLAG)
                                                      (EnableDCEClk FLAG)
                                                      (DriveSelect3 FLAG)
                                                      (DriveSelect2 FLAG)
                                                      (DriveSelect1 FLAG)
                                                      (DriveSelect0 FLAG)
                                                      (Select250KbDataRate FLAG)
                                                      (PreCompensation BITS 3))))

(MESARECORD DOVEFLOPPYFCB ((FLOPPYTASK DoveIO.TaskContextBlock)
                           (FLOPPYDMATASK DoveIO.TaskContextBlock)
                           (FLOPPYSTOPHANDLER BYTE)
                           (FLOPPYRESETFDC BYTE)
                           (FLOPPYHANDLERISSTOPPED BYTE)
                           (FLOPPYFDCHUNG BYTE)
                           (FLOPPYWAITINGFORDMA BYTE)
                           (FLOPPYFIRSTDMAINTERRUPT BYTE)
                           (FLOPPYDRIVEMOTORCONTROLCOUNT BYTE)
                           (FLOPPYNUMBEROFDRIVES BYTE)
                           (FLOPPYBADDMAINTERRUPTCOUNT BYTE)
                           (FLOPPYBADFDCINTERRUPTCOUNT BYTE)
                           (NIL WORD)
                           (FLOPPYFILLERFORFORMATTING BYTE)
                           (FLOPPYDIAGNOSTICSON BYTE)
                           (FLOPPYENCODEDDEVICETYPES WORD)
                           (FLOPPYWORKMASK WORD)
                           (FLOPPYWORKNOTIFY WORD)
                           (FLOPPYLOCKMASK WORD)
                           (FLOPPYCURRENTIOCB Dove.OpieAddress)
                           (FLOPPYDIAGNOSTICQUEUE Dove.QueueBlock)
                           (FLOPPYPILOTQUEUE Dove.QueueBlock)
                           (FLOPPYIOPQUEUE Dove.QueueBlock)
                           (FLOPPYDCB0BASE DOVEFLOPPYDCB)
                           (FLOPPYDCB1BASE DOVEFLOPPYDCB)
                           (FLOPPYDCB2BASE DOVEFLOPPYDCB)
                           (FLOPPYDCB3BASE DOVEFLOPPYDCB)))

(BLOCKRECORD DOVEFLOPPYFDCCOMMAND ((FDCCODE BYTE)
                                   (DATATRANSFERCODE BYTE)
                                   (NIL BYTE)
                                   (MUSTWAITFORINTERRUPT BYTE)
                                   (NUMBEROFCOMMANDBYTES BYTE)
                                   (NUMBEROFCOMMANDBYTESWRITTEN BYTE)
                                   (COMMANDBYTES 10 BYTE)
                                   (NUMBEROFRESULTBYTES BYTE)
                                   (NUMBEROFRESULTBYTESREAD BYTE)
                                   (RESULTBYTES 8 BYTE)))

(RECORD DOVEFLOPPYFORMATINFO (VALIDFORMAT SECTORSPERTRACK READWRITEGAPLENGTH FORMATGAPLENGTH))

(BLOCKRECORD DOVEFLOPPYIOCB ((CYLINDER BYTE)
                             (HEAD BYTE)
                             (SECTOR BYTE)
                             (DENSITY BYTE)
                             (NIL WORD)
                             (RECALIBRATEFIRST? FLAG)
                             (RESETFIRST? FLAG)
                             (NIL BITS 6)
                             (DATATRANSFERCODE BYTE)
                             (BUFFER POINTER)
                             (OPERATION POINTER)
                             (FDCOPERATION BYTE)
                             (NIL BYTE)
                             (FLOPPYCONTEXT WORD)
                             (ALTERNATESECTORS FLAG)
                             (MULTITRACKMODE FLAG)
                             (SKIPDELETEDSECTOR FLAG)
                             (NIL BITS 5)
                             (CURRENTRETRYCOUNT BYTE)
                             (ISQUEUED BYTE)
                             (OPERATIONSTATE BYTE)
                             (NEXTIOCB 2 WORD)
                             (DATAADDRESS 2 WORD)
                             (CLIENTCONDITION 3 WORD)
                             (FinalStateOfFDC BYTE)
                             (SpecifyBeforeProcessing BYTE)
                             (PCEResetFDCFlag BYTE)
                             (PCEStartMotorFlags BYTE)
                             (RESETFDCBEFOREPROCESSING BYTE)
                             (RECALIBRATEBEFOREPROCESSING BYTE)
                             (DRIVENUMBER BYTE)
                             (FDCHUNG BYTE)
                             (BYTESTOTRANSFER WORD)
                             (BYTESTRANSFERRED WORD)
                             (COUNTERCONTROLREG WORD)
                             (FIRSTDMATRANSFERCOUNT WORD)
                             (FIRSTDMACONTROLWORD WORD)
                             (NUMBEROFMIDDLEDMATRANSFERS WORD)
                             (MIDDLEDMATRANSFERCOUNT WORD)
                             (MIDDLEDMACONTROLWORD WORD)
                             (LASTDMATRANSFERCOUNT WORD)
                             (LASTDMACONTROLWORD WORD)
                             (FINALDMACOUNT WORD)
                             (INCREMENTDATAPTR BYTE)
                             (TimeoutOccurred BYTE)
                             (NUMBEROFFDCCOMMANDS WORD)
                             (CURRENTFDCCOMMAND WORD)
                             (FDCCOMMANDS 39 WORD)))

(BLOCKRECORD DOVEFLOPPYSECTORHEADER ((CYLINDER BYTE)
                                     (HEAD BYTE)
                                     (SECTOR BYTE)
                                     (ENCODEDSECTORLENGTH BYTE)))

(BLOCKRECORD DOVEQUEUEBLOCK ((QUEUEHEAD 2 WORD)
                             (QUEUETAIL 2 WORD)
                             (QUEUENEXT 2 WORD)))
]
)

(RPAQQ \DOVEFLOPPY.HARDFDCCOMMANDS ((NOP . 0)
                                    (FORMATTRACK . 13)
                                    (READDATA . 6)
                                    (READDELETEDDATA . 12)
                                    (READID . 10)
                                    (READTRACK . 2)
                                    (RECALIBRATE . 7)
                                    (SCANEQUAL . 17)
                                    (SCANHIGHOREQUAL . 29)
                                    (SCANLOWOREQUAL . 25)
                                    (SEEK . 15)
                                    (SENSEDRIVESTATUS . 4)
                                    (SENSEINTERRUPTSTATUS . 8)
                                    (SPECIFY . 3)
                                    (WRITEDATA . 5)
                                    (WRITEDELETEDDATA . 9)))

(RPAQQ \DOVEFLOPPY.#COMMANDBYTES ((NOP . 0)
                                  (FORMATTRACK . 6)
                                  (READDATA . 9)
                                  (READDELETEDDATA . 9)
                                  (READID . 2)
                                  (READTRACK . 9)
                                  (RECALIBRATE . 2)
                                  (SCANEQUAL . 9)
                                  (SCANHIGHOREQUAL . 9)
                                  (SCANLOWOREQUAL . 9)
                                  (SEEK . 3)
                                  (SENSEDRIVESTATUS . 2)
                                  (SENSEINTERRUPTSTATUS . 1)
                                  (SPECIFY . 3)
                                  (WRITEDATA . 9)
                                  (WRITEDELETEDDATA . 9)))

(RPAQQ \DOVEFLOPPY.#RESULTBYTES ((NOP . 0)
                                 (FORMATTRACK . 7)
                                 (READDATA . 7)
                                 (READDELETEDDATA . 7)
                                 (READID . 7)
                                 (READTRACK . 7)
                                 (RECALIBRATE . 0)
                                 (SCANEQUAL . 7)
                                 (SCANHIGHOREQUAL . 7)
                                 (SCANLOWOREQUAL . 7)
                                 (SEEK . 0)
                                 (SENSEDRIVESTATUS . 1)
                                 (SENSEINTERRUPTSTATUS . 2)
                                 (SPECIFY . 0)
                                 (WRITEDATA . 7)))

(RPAQQ \DOVEFLOPPY.COMMANDS ((NOP . 0)
                             (FORMATTRACK . 1)
                             (READDATA . 2)
                             (READDELETEDDATA . 3)
                             (READID . 4)
                             (READTRACK . 5)
                             (RECALIBRATE . 6)
                             (SCANEQUAL . 7)
                             (SCANHIGHOREQUAL . 8)
                             (SCANLOWOREQUAL . 9)
                             (SEEK . 10)
                             (SENSEDRIVESTATUS . 11)
                             (SENSEINTERRUPTSTATUS . 12)
                             (SPECIFY . 13)
                             (WRITEDATA . 14)
                             (WRITEDELETEDDATA . 15)))

(RPAQQ \DOVEFLOPPY.DATATRANSFEROPS ((NOP . 0)
                                    (FORMATTRACK . 2)
                                    (READDATA . 1)
                                    (READDELETEDDATA . 1)
                                    (READID . 0)
                                    (READTRACK . 1)
                                    (RECALIBRATE . 0)
                                    (SCANEQUAL . 2)
                                    (SCANHIGHOREQUAL . 2)
                                    (SCANLOWOREQUAL . 2)
                                    (SEEK . 0)
                                    (SENSEDRIVESTATUS . 0)
                                    (SENSEINTERRUPTSTATUS . 0)
                                    (SPECIFY . 0)
                                    (WRITEDATA . 2)
                                    (WRITEDELETEDDATA . 2)))

(RPAQQ \DOVEFLOPPY.DEBUG T)

(RPAQQ \DOVEFLOPPY.FDCBYTEONEMASKS ((NOP . 0)
                                    (FORMATTRACK . 95)
                                    (READDATA . 255)
                                    (READDELETEDDATA . 255)
                                    (READID . 95)
                                    (READTRACK . 127)
                                    (RECALIBRATE . 31)
                                    (SCANEQUAL . 255)
                                    (SCANHIGHOREQUAL . 255)
                                    (SCANLOWOREQUAL . 255)
                                    (SEEK . 31)
                                    (SENSEDRIVESTATUS . 31)
                                    (SENSEINTERRUPTSTATUS . 31)
                                    (SPECIFY . 31)
                                    (WRITEDATA . 223)
                                    (WRITEDELETEDDATA . 223)))

(RPAQQ \DOVEFLOPPY.FDCBYTETWOMASKS ((NOP . 0)
                                    (FORMATTRACK . 7)
                                    (READDATA . 7)
                                    (READDELETEDDATA . 7)
                                    (READID . 7)
                                    (READTRACK . 7)
                                    (RECALIBRATE . 3)
                                    (SCANEQUAL . 7)
                                    (SCANHIGHOREQUAL . 7)
                                    (SCANLOWOREQUAL . 7)
                                    (SEEK . 7)
                                    (SENSEDRIVESTATUS . 7)
                                    (SENSEINTERRUPTSTATUS . 0)
                                    (SPECIFY . 255)
                                    (WRITEDATA . 7)
                                    (WRITEDELETEDDATA . 7)))

(RPAQQ \DOVEFLOPPY.FORMATINFO [(128 ((SINGLE T 16 16 25)
                                     (DOUBLE NIL 0 0 0)))
                               (256 ((SINGLE T 8 24 48)
                                     (DOUBLE T 16 32 50)))
                               (512 ((SINGLE T 4 70 135)
                                     (DOUBLE T 9 42 80)))
                               (1024 ((SINGLE NIL 2 200 255)
                                      (DOUBLE NIL 4 200 240)))
                               (2048 ((SINGLE NIL 1 200 255)
                                      (DOUBLE NIL 2 200 255)))
                               (4096 ((SINGLE NIL 0 0 0)
                                      (DOUBLE NIL 1 200 255])

(RPAQQ \DOVEFLOPPY.IMPLIEDSEEKOPS (FORMATTRACK READDATA READDELETEDDATA READID READTRACK SCANEQUAL 
                                         SCANHIGHOREQUAL SCANLOWOREQUAL SEEK WRITEDATA 
                                         WRITEDELETEDDATA))

(RPAQQ \DOVEFLOPPY.ST0MASKS ((8 . NOTREADY)))

(RPAQQ \DOVEFLOPPY.ST1MASKS ((128 . ENDOFTRACK)
                             (32 . DATAERROR)
                             (16 . OVERRUNERROR)
                             (4 . SECTORNOTFOUND)
                             (2 . WRITEPROTECTED)
                             (1 . MISSINGADDRESSMARK)))

(RPAQQ \DOVEFLOPPY.ST2MASKS ((16 . WRONGCYLINDER)
                             (8 . SCANEQUALHIT)
                             (4 . SCANNOTSATISFIED)
                             (2 . BADCYLINDER)))

(RPAQQ \DOVEFLOPPY.SECTORLENGTHS ((128 . 0)
                                  (256 . 1)
                                  (512 . 2)
                                  (1024 . 3)
                                  (2048 . 4)
                                  (4096 . 5)))

(RPAQQ \DOVEFLOPPY.WAITFORINTERRUPTCMDS (FORMATTRACK READDATA READDELETEDDATA READID READTRACK 
                                               RECALIBRATE SCANEQUAL SCANHIGHOREQUAL SCANLOWOREQUAL 
                                               SEEK WRITEDATA WRITEDELETEDDATA))

(RPAQQ \DOVEFLOPPY.CURRENTCONTEXT (DOVEFLOPPYCONTEXT SA455 9 2 40 DOUBLE NIL 512))
(DEFINEQ

(\DOVEFLOPPY.RESET
  (LAMBDA NIL                                                (* mpl " 7-Aug-85 15:17")
    (\DOVEFLOPPY.INIT)))

(\DOVEFLOPPY.SETCONTEXT
  (LAMBDA (DENSITY SECTORLENGTH)                             (* mpl " 7-Aug-85 15:20")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.SECTORLENGTHS \DOVEFLOPPY.CURRENTCONTEXT))
    (COND
      ((NOT (LISTP \DOVEFLOPPY.CURRENTCONTEXT))
	(\DOVEFLOPPY.INIT)))
    (COND
      ((FMEMB DENSITY (QUOTE (SINGLE DOUBLE)))
	(replace (DOVEFLOPPYCONTEXT DENSITY) of \DOVEFLOPPY.CURRENTCONTEXT with DENSITY))
      (T (HELP "Invalid density " DENSITY)))
    (COND
      ((FASSOC SECTORLENGTH \DOVEFLOPPY.SECTORLENGTHS)
	(replace (DOVEFLOPPYCONTEXT SECTORLENGTH) of \DOVEFLOPPY.CURRENTCONTEXT with 
										     SECTORLENGTH))
      (T (HELP "Invalid sector length " SECTORLENGTH)))))

(\DOVEFLOPPY.XFERDISK
  [LAMBDA (CYL HD SEC BUFF MODE RECAL? RESET?)               (* edited: "23-Mar-86 14:40")
    (PROG (STATUS)
	    (SETQ STATUS (\DOVEFLOPPY.TRANSFER CYL HD SEC BUFF MODE RESET? RECAL?))
	    [for I from 1 to 50
	       do 

          (* * kbr: " 8-Nov-85 12:19" Repeat a few times because of spurious OVERRUN errors. I've also seen a few spurious 
	  DATAERRORs. 3 retries is not enough, so I've made it 10.0 *)



          (* * kbr: "19-Mar-86 17:18" Had problems copying an Intellicorp sysout floppy to {DSK}, but if we change the number
	  of retries from 10 to 20, the problem (DATAERRORs) goes away. So I've set the number of retries to 40! *)



          (* * kbr: "19-Mar-86 17:18" MESA code uses ActualNumberOfRetriesWhenDMAHit = 50 when handlingError inside 
	  UpdateOperation on FLOPPYHEADDOVE.MESA. So I've set the number of retries to 50! *)


		    (COND
		      ((OR (EQ STATUS (QUOTE OK))
			     (EQ STATUS (QUOTE TIMEOUT)))
			[COND
			  (\DOVEFLOPPY.TRACEFLG (COND
						  ((EQ I 1)
						    (PRIN1 "." TRACEWINDOW))
						  (T (PRIN1 "R" TRACEWINDOW)
						     (PRIN1 I TRACEWINDOW]
			(RETURN))
		      (\DOVEFLOPPY.TRACEFLG (PRIN1 STATUS TRACEWINDOW)
					    (PRIN1 "-" TRACEWINDOW)))
                                                             (* kbr: "19-Mar-86 17:18" Try recalibrating and 
							     resetting every fourth time though loop instead of 
							     every time through loop. *)
		    (COND
		      ((EQ (IMOD I 4)
			     1)
			(COND
			  (\DOVEFLOPPY.TRACEFLG (PRIN1 "RECALIBRATE-" TRACEWINDOW)))
			(SETQ STATUS (\DOVEFLOPPY.TRANSFER CYL HD SEC BUFF MODE T T))
			(DISMISS 50))
		      (T (SETQ STATUS (\DOVEFLOPPY.TRANSFER CYL HD SEC BUFF MODE NIL NIL]
	    (RETURN STATUS])

(\DOVEFLOPPY.BYTESWAPIOCB
  (LAMBDA (IOCB)                                             (* kbr: " 5-Oct-85 16:37")
    (replace (DOVEFLOPPYIOCB BYTESTOTRANSFER) of IOCB with (\DoveIO.ByteSwap
								   (fetch (DOVEFLOPPYIOCB 
										  BYTESTOTRANSFER)
								      of IOCB)))
    (replace (DOVEFLOPPYIOCB BYTESTRANSFERRED) of IOCB with (\DoveIO.ByteSwap
								    (fetch (DOVEFLOPPYIOCB 
										 BYTESTRANSFERRED)
								       of IOCB)))
    (replace (DOVEFLOPPYIOCB COUNTERCONTROLREG) of IOCB with (\DoveIO.ByteSwap
								     (fetch (DOVEFLOPPYIOCB 
										COUNTERCONTROLREG)
									of IOCB)))
    (replace (DOVEFLOPPYIOCB FIRSTDMATRANSFERCOUNT) of IOCB with (\DoveIO.ByteSwap
									 (fetch (DOVEFLOPPYIOCB
										    
									    FIRSTDMATRANSFERCOUNT)
									    of IOCB)))
    (replace (DOVEFLOPPYIOCB FIRSTDMACONTROLWORD) of IOCB with (\DoveIO.ByteSwap
								       (fetch (DOVEFLOPPYIOCB
										  FIRSTDMACONTROLWORD)
									  of IOCB)))
    (replace (DOVEFLOPPYIOCB NUMBEROFMIDDLEDMATRANSFERS) of IOCB
       with (\DoveIO.ByteSwap (fetch (DOVEFLOPPYIOCB NUMBEROFMIDDLEDMATRANSFERS) of IOCB)))
    (replace (DOVEFLOPPYIOCB MIDDLEDMATRANSFERCOUNT) of IOCB with (\DoveIO.ByteSwap
									  (fetch (DOVEFLOPPYIOCB
										     
									   MIDDLEDMATRANSFERCOUNT)
									     of IOCB)))
    (replace (DOVEFLOPPYIOCB MIDDLEDMACONTROLWORD) of IOCB with (\DoveIO.ByteSwap
									(fetch (DOVEFLOPPYIOCB
										   
									     MIDDLEDMACONTROLWORD)
									   of IOCB)))
    (replace (DOVEFLOPPYIOCB LASTDMATRANSFERCOUNT) of IOCB with (\DoveIO.ByteSwap
									(fetch (DOVEFLOPPYIOCB
										   
									     LASTDMATRANSFERCOUNT)
									   of IOCB)))
    (replace (DOVEFLOPPYIOCB LASTDMACONTROLWORD) of IOCB with (\DoveIO.ByteSwap
								      (fetch (DOVEFLOPPYIOCB 
									       LASTDMACONTROLWORD)
									 of IOCB)))
    (replace (DOVEFLOPPYIOCB FINALDMACOUNT) of IOCB with (\DoveIO.ByteSwap (fetch
										   (DOVEFLOPPYIOCB
										     FINALDMACOUNT)
										    of IOCB)))
    (replace (DOVEFLOPPYIOCB NUMBEROFFDCCOMMANDS) of IOCB with (\DoveIO.ByteSwap
								       (fetch (DOVEFLOPPYIOCB
										  NUMBEROFFDCCOMMANDS)
									  of IOCB)))
    (replace (DOVEFLOPPYIOCB CURRENTFDCCOMMAND) of IOCB with (\DoveIO.ByteSwap
								     (fetch (DOVEFLOPPYIOCB 
										CURRENTFDCCOMMAND)
									of IOCB)))))

(\DOVEFLOPPY.CLEARDISKCHANGED
  (LAMBDA NIL                                                (* mpl " 4-Aug-85 12:39")
    (replace (DOVEFLOPPYDCB PILOTDISKCHANGED) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
							of \DoveFloppy.FCBPointer)
       with 0)))

(\DOVEFLOPPY.DISKCHANGED
  (LAMBDA NIL                                                (* mpl " 4-Aug-85 12:39")
    (NOT (EQ 0 (fetch (DOVEFLOPPYDCB PILOTDISKCHANGED) of (fetch (DOVEFLOPPYFCB 
										   FLOPPYDCB0BASE)
								     of \DoveFloppy.FCBPointer))))))

(\DOVEFLOPPY.DOOROPEN
  (LAMBDA NIL                                                (* mpl " 4-Aug-85 12:40")
    (NOT (EQ 0 (fetch (DOVEFLOPPYDCB DOOROPEN) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
							     of \DoveFloppy.FCBPointer))))))

(\DOVEFLOPPY.GETERRORSTATUS
  (LAMBDA (IOCB)                                             (* kbr: " 5-Oct-85 16:40")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.ST0MASKS \DOVEFLOPPY.ST1MASKS \DOVEFLOPPY.ST2MASKS))
    (PROG (CMDINDEX CMDLOC CMDBYTES ST0 ST1 ST2 STATUS)
	    (SETQ CMDINDEX (SUB1 (fetch (DOVEFLOPPYIOCB CURRENTFDCCOMMAND) of IOCB)))
	    (SETQ CMDLOC (\ADDBASE (LOCF (fetch (DOVEFLOPPYIOCB FDCCOMMANDS) of IOCB))
				       (ITIMES CMDINDEX \DOVEFLOPPY.FDCCMDLENGTH)))
	    (SETQ CMDBYTES (LOCF (fetch (DOVEFLOPPYFDCCOMMAND RESULTBYTES) of CMDLOC)))
	    (SETQ ST0 (fetch (DOVEFLOPPYCMDBYTES CB1) of CMDBYTES))
	    (SETQ ST1 (fetch (DOVEFLOPPYCMDBYTES CB2) of CMDBYTES))
	    (SETQ ST2 (fetch (DOVEFLOPPYCMDBYTES CB3) of CMDBYTES))
	    (SETQ STATUS NIL)
	    (COND
	      ((EQ (fetch (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB)
		     \DOVEFLOPPY.INPROGRESS)
		(SETQ STATUS (QUOTE TIMEOUT))))
	    (SETQ STATUS (OR STATUS (for I in \DOVEFLOPPY.ST0MASKS
					   do (COND
						  ((NOT (EQ 0 (LOGAND (CAR I)
									    ST0)))
						    (RETURN (CDR I)))))))
	    (SETQ STATUS (OR STATUS (for I in \DOVEFLOPPY.ST1MASKS
					   do (COND
						  ((NOT (EQ 0 (LOGAND (CAR I)
									    ST1)))
						    (RETURN (CDR I)))))))
	    (SETQ STATUS (OR STATUS (for I in \DOVEFLOPPY.ST2MASKS
					   do (COND
						  ((NOT (EQ 0 (LOGAND (CAR I)
									    ST2)))
						    (RETURN (CDR I)))))))
	    (RETURN (OR STATUS (QUOTE OK))))))

(\DOVEFLOPPY.INIT
  (LAMBDA NIL                                                (* mpl " 7-Aug-85 20:45")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.CURRENTCONTEXT))
    (SETQ \DoveFloppy.FCBPointer (\DoveIO.GetHandlerIORegionPtr DoveIO.floppyHandler))
    (PROG1 (\DOVEFLOPPY.STOPHANDLER)
	     (SETQ \DOVEFLOPPY.CURRENTCONTEXT (create DOVEFLOPPYCONTEXT
							  DRIVETYPE ← (QUOTE SA455)
							  SECTORSPERTRACK ← 9
							  NUMBEROFCYLINDERS ← 40
							  NUMBEROFHEADS ← 2
							  DENSITY ← (QUOTE DOUBLE)
							  SECTORLENGTH ← 512
							  DISKCHANGED ← NIL))
	     (\DOVEFLOPPY.INITDCB))))

(\DOVEFLOPPY.INITDCB
  [LAMBDA NIL                                                (* kbr: "20-Apr-86 13:16")
    (replace (DOVEFLOPPYDCB DOOROPEN) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE) of 
                                                                               \DoveFloppy.FCBPointer
                                                ) with 0)
    (replace (DOVEFLOPPYDCB PILOTDISKCHANGED) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE) of 
                                                                               \DoveFloppy.FCBPointer
                                                        ) with 0)
    (replace (DOVEFLOPPYDCB DIAGNOSTICDISKCHANGED) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
                                                         of \DoveFloppy.FCBPointer) with 0)
                                                             (* Magic constant 6712 is byteswap of 
                                                             Mesa's 14362 magic constant.
                                                             *)
    (replace (DOVEFLOPPYDCB Port80ControlWord) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE) of 
                                                                               \DoveFloppy.FCBPointer
                                                         ) with 6712)
          
          (* kbr: "20-Apr-86 13:15" Added the following two replaces.
          From an INSPECT window I can tell that the value of these fields were 177 and 
          2, but I have no idea where they originally got set from, and I have looked to 
          try to find out how. According to OSBUNORTH people, 
          HeadLoadTimePlusNotInDMAmode must be 20 to allow 40ms time for head settling 
          before write operations. Without this change, what will happen is that 
          occasionally the DAYBREAK floppy heads will still be vibrating around at the 
          time of the write operation. Later, reads will not be able to read the 
          malformed data and will cause DATAERRORs.
          *)

    (replace (DOVEFLOPPYDCB StepRateTimePlusHeadUnloadTime) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
                                                                  of \DoveFloppy.FCBPointer)
       with 177)
    (replace (DOVEFLOPPYDCB HeadLoadTimePlusNotInDMAmode) of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
                                                                of \DoveFloppy.FCBPointer)
       with 20])

(\DOVEFLOPPY.INITIOCB
  (LAMBDA (IOCB)                                             (* kbr: " 5-Oct-85 16:44")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.COMMANDS \DOVEFLOPPY.IMPLIEDSEEKOPS 
			     \DoveFloppy.DataTransferCode \DOVEFLOPPY.DATATRANSFEROPS))
    (PROG (DCBPTR OP)
	    (SETQ DCBPTR (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE) of \DoveFloppy.FCBPointer))
	    (SETQ OP (fetch (DOVEFLOPPYIOCB OPERATION) of IOCB))
	    (\CLEARWORDS (LOCF (fetch (DOVEFLOPPYIOCB FDCOPERATION) of IOCB))
			   81)
	    (\DoveIO.MakeOpieAddress (LOCF (fetch (DOVEFLOPPYIOCB NEXTIOCB) of IOCB))
				       NIL)
	    (\DoveIO.MakeOpieAddress (LOCF (fetch (DOVEFLOPPYIOCB DATAADDRESS) of IOCB))
				       (fetch (DOVEFLOPPYIOCB BUFFER) of IOCB))
	    (replace (DOVEFLOPPYIOCB ALTERNATESECTORS) of IOCB with NIL)
	    (replace (DOVEFLOPPYIOCB FDCOPERATION) of IOCB with (CDR (FASSOC OP 
									     \DOVEFLOPPY.COMMANDS)))
	    (replace (DOVEFLOPPYIOCB MULTITRACKMODE) of IOCB with T)
	    (replace (DOVEFLOPPYIOCB SKIPDELETEDSECTOR) of IOCB with NIL)
	    (replace (DOVEFLOPPYIOCB CURRENTRETRYCOUNT) of IOCB with 1)
	    (replace (DOVEFLOPPYIOCB ISQUEUED) of IOCB with \DOVEFLOPPY.BYTEFALSE)
	    (replace (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB with \DOVEFLOPPY.OPERATIONBUILT)
	    (replace (DOVEFLOPPYIOCB RESETFDCBEFOREPROCESSING) of IOCB
	       with (COND
			((fetch (DOVEFLOPPYIOCB RESETFIRST?) of IOCB)
			  \DOVEFLOPPY.BYTETRUE)
			(T \DOVEFLOPPY.BYTEFALSE)))
	    (replace (DOVEFLOPPYIOCB RECALIBRATEBEFOREPROCESSING) of IOCB
	       with (COND
			((fetch (DOVEFLOPPYIOCB RECALIBRATEFIRST?) of IOCB)
			  \DOVEFLOPPY.BYTETRUE)
			(T \DOVEFLOPPY.BYTEFALSE)))
	    (replace (DOVEFLOPPYIOCB DRIVENUMBER) of IOCB with 0)
	    (replace (DOVEFLOPPYIOCB FDCHUNG) of IOCB with \DOVEFLOPPY.BYTEFALSE)
	    (replace (DOVEFLOPPYIOCB COUNTERCONTROLREG) of IOCB with \DOVEFLOPPY.STOPCOUNTER)
	    (replace (DOVEFLOPPYIOCB FIRSTDMACONTROLWORD) of IOCB with \DOVEFLOPPY.STOPDMA)
	    (replace (DOVEFLOPPYIOCB MIDDLEDMACONTROLWORD) of IOCB with \DOVEFLOPPY.STOPDMA)
	    (replace (DOVEFLOPPYIOCB LASTDMACONTROLWORD) of IOCB with \DOVEFLOPPY.STOPDMA)
	    (replace (DOVEFLOPPYIOCB DATATRANSFERCODE) of IOCB with (CDR (FASSOC OP 
								      \DOVEFLOPPY.DATATRANSFEROPS)))
	    (COND
	      ((FMEMB OP \DOVEFLOPPY.IMPLIEDSEEKOPS)
		(\DOVEFLOPPY.SETUPPRIMITIVEFDCOP IOCB (QUOTE SEEK))
		(\DOVEFLOPPY.SETUPPRIMITIVEFDCOP IOCB (QUOTE SENSEINTERRUPTSTATUS))))
	    (COND
	      ((NOT (FMEMB OP (QUOTE (NOP SEEK))))
		(\DOVEFLOPPY.SETUPPRIMITIVEFDCOP IOCB OP)
		(COND
		  ((EQ OP (QUOTE RECALIBRATE))
		    (\DOVEFLOPPY.SETUPPRIMITIVEFDCOP IOCB (QUOTE SENSEINTERRUPTSTATUS)))))))))

(\DOVEFLOPPY.INITIATE
  (LAMBDA (IOCB)                                             (* kbr: "21-Oct-85 17:00")

          (* * This fn makes the IOP go.)



          (* * We don't care about queues of IOCBs to floppies... what a waste!)


    (PROG (TIMER RESULTS)                                  (* \DoveIO.LockMem is pointless here)
	    (\DOVEFLOPPY.VALIDATEIOCB IOCB)
	    (\DOVEFLOPPY.INITIOCB IOCB)
	    (\DOVEFLOPPY.SETUPDMAINFO IOCB)
	    (replace (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB with \DOVEFLOPPY.WAITING)
	    (replace (DOVEFLOPPYIOCB ISQUEUED) of IOCB with \DOVEFLOPPY.BYTETRUE)
	    (\DOVEFLOPPY.BYTESWAPIOCB IOCB)                (* Lock buffer before doing anything)
	    (\LOCKPAGES IOCB 1)
	    (\PUTBASE (fetch (DOVEFLOPPYIOCB BUFFER) of IOCB)
			0
			(\GETBASE (fetch (DOVEFLOPPYIOCB BUFFER) of IOCB)
				    0))
	    (\LOCKPAGES (fetch (DOVEFLOPPYIOCB BUFFER) of IOCB)
			  1)
	    (replace (DOVEFLOPPYFCB FLOPPYSTOPHANDLER) of \DoveFloppy.FCBPointer with 
									    \DOVEFLOPPY.BYTEFALSE)
	    (COND
	      ((EQ \DOVEFLOPPY.BYTETRUE (fetch (DOVEFLOPPYFCB FLOPPYFDCHUNG) of 
									   \DoveFloppy.FCBPointer))
		(replace (DOVEFLOPPYFCB FLOPPYRESETFDC) of \DoveFloppy.FCBPointer with 
									     \DOVEFLOPPY.BYTETRUE)))
	    (replace (Dove.QueueBlock LispQueueNext) of (fetch (DOVEFLOPPYFCB FLOPPYPILOTQUEUE)
							       of \DoveFloppy.FCBPointer)
	       with IOCB)
	    (\DoveIO.NotifyIOP (fetch (DOVEFLOPPYFCB FLOPPYWORKMASK) of \DoveFloppy.FCBPointer))
	    (SETQ TIMER (SETUPTIMER 2000))
	    (until (OR (TIMEREXPIRED? TIMER)
			   (EQ (fetch (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB)
				 \DOVEFLOPPY.OPERATIONCOMPLETED)
			   (EQ (fetch (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB)
				 \DOVEFLOPPY.OPERATIONFAILED))
	       do (BLOCK))
	    (SETQ RESULTS (COND
		((OR (EQ (fetch (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB)
			     \DOVEFLOPPY.OPERATIONCOMPLETED)
		       (EQ (fetch (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB)
			     \DOVEFLOPPY.OPERATIONFAILED))

          (* NOTE: An expired TIMER doesn't necessarily imply FLOPPY failure. It can be that the process scheduler simply 
	  didn't get back to FLOPPY soon enough (e.g. user holds mouse button down long time.) A previous version of this 
	  COND tested (TIMEREXPIRED? TIMER) in the first branch, which was wrong. *)


		  (QUOTE OK))
		(T (\DOVEFLOPPY.STOPHANDLER)
		   (QUOTE TIMEOUT))))
	    (\DOVEFLOPPY.BYTESWAPIOCB IOCB)
	    (\UNLOCKPAGES IOCB 1)
	    (\UNLOCKPAGES (fetch (DOVEFLOPPYIOCB BUFFER) of IOCB)
			    1)
	    (COND
	      ((EQ RESULTS (QUOTE TIMEOUT))
		(replace (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB with \DOVEFLOPPY.INPROGRESS)))
	    (RETURN (fetch (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB)))))

(\DOVEFLOPPY.SETUPDMAINFO
  (LAMBDA (IOCB)                                             (* kbr: " 5-Oct-85 17:52")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.CURRENTCONTEXT \DOVEFLOPPY.FORMATINFO 
			     \DOVEFLOPPY.SECTORLENGTHS))
    (PROG (FORMATINFO SECTORHEADER)
	    (SETQ FORMATINFO (CDR (FASSOC (fetch (DOVEFLOPPYCONTEXT DENSITY) of 
								       \DOVEFLOPPY.CURRENTCONTEXT)
						(CADR (FASSOC (fetch (DOVEFLOPPYCONTEXT 
										     SECTORLENGTH)
								     of \DOVEFLOPPY.CURRENTCONTEXT)
								  \DOVEFLOPPY.FORMATINFO)))))
	    (replace (DOVEFLOPPYIOCB COUNTERCONTROLREG) of IOCB with \DOVEFLOPPY.STARTCOUNTER)
	    (SELECTQ (fetch (DOVEFLOPPYIOCB OPERATION) of IOCB)
		       (FORMATTRACK (for I from 1 to (fetch (DOVEFLOPPYFORMATINFO 
										  SECTORSPERTRACK)
							      of FORMATINFO)
				       do (SETQ SECTORHEADER (\ADDBASE (fetch (DOVEFLOPPYIOCB
											BUFFER)
										of IOCB)
									     (ITIMES 2
										       (SUB1 I))))
                                                             (* Set up SECTORHEADER *)
					    (replace (DOVEFLOPPYSECTORHEADER CYLINDER)
					       of SECTORHEADER with (fetch (DOVEFLOPPYIOCB
										   CYLINDER)
									   of IOCB))
					    (replace (DOVEFLOPPYSECTORHEADER HEAD) of 
										     SECTORHEADER
					       with (fetch (DOVEFLOPPYIOCB HEAD) of IOCB))
					    (replace (DOVEFLOPPYSECTORHEADER SECTOR) of 
										     SECTORHEADER
					       with I)
					    (replace (DOVEFLOPPYSECTORHEADER ENCODEDSECTORLENGTH)
					       of SECTORHEADER
					       with (CDR (FASSOC (fetch (DOVEFLOPPYCONTEXT
										  SECTORLENGTH)
									  of 
								       \DOVEFLOPPY.CURRENTCONTEXT)
								       \DOVEFLOPPY.SECTORLENGTHS))))
                                                             (* Set up IOCB *)
				    (replace (DOVEFLOPPYIOCB BYTESTOTRANSFER) of IOCB
				       with (ITIMES 4 (fetch (DOVEFLOPPYFORMATINFO 
										  SECTORSPERTRACK)
							     of FORMATINFO)))
				    (replace (DOVEFLOPPYIOCB FIRSTDMATRANSFERCOUNT) of IOCB
				       with (fetch (DOVEFLOPPYIOCB BYTESTOTRANSFER) of IOCB))
				    (replace (DOVEFLOPPYIOCB FIRSTDMACONTROLWORD) of IOCB
				       with \DOVEFLOPPY.STARTDMAWRITE))
		       (PROGN (replace (DOVEFLOPPYIOCB BYTESTOTRANSFER) of IOCB
				   with (fetch (DOVEFLOPPYCONTEXT SECTORLENGTH) of 
								       \DOVEFLOPPY.CURRENTCONTEXT))
				(replace (DOVEFLOPPYIOCB FIRSTDMATRANSFERCOUNT) of IOCB
				   with (fetch (DOVEFLOPPYIOCB BYTESTOTRANSFER) of IOCB))
				(SELECTC (fetch (DOVEFLOPPYIOCB DATATRANSFERCODE) of IOCB)
					   (\DOVEFLOPPY.READ (replace (DOVEFLOPPYIOCB 
									      FIRSTDMACONTROLWORD)
								of IOCB with 
									 \DOVEFLOPPY.STARTDMAREAD)
							     (replace (DOVEFLOPPYIOCB 
									     MIDDLEDMACONTROLWORD)
								of IOCB with 
									 \DOVEFLOPPY.STARTDMAREAD)
							     (replace (DOVEFLOPPYIOCB 
									       LASTDMACONTROLWORD)
								of IOCB with 
									 \DOVEFLOPPY.STARTDMAREAD))
					   (\DOVEFLOPPY.WRITE (replace (DOVEFLOPPYIOCB 
									      FIRSTDMACONTROLWORD)
								 of IOCB with 
									\DOVEFLOPPY.STARTDMAWRITE)
							      (replace (DOVEFLOPPYIOCB 
									     MIDDLEDMACONTROLWORD)
								 of IOCB with 
									\DOVEFLOPPY.STARTDMAWRITE)
							      (replace (DOVEFLOPPYIOCB 
									       LASTDMACONTROLWORD)
								 of IOCB with 
									\DOVEFLOPPY.STARTDMAWRITE))
					   (PROGN (replace (DOVEFLOPPYIOCB FIRSTDMACONTROLWORD)
						       of IOCB with (LOGOR (fetch
										   (DOVEFLOPPYIOCB
										     
									      FIRSTDMACONTROLWORD)
										    of IOCB)
										 
								 \DOVEFLOPPY.DMAINTERRUPTWHENDONE))
						    (replace (DOVEFLOPPYIOCB 
								       NUMBEROFMIDDLEDMATRANSFERS)
						       of IOCB with 0)
						    (replace (DOVEFLOPPYIOCB LASTDMATRANSFERCOUNT)
						       of IOCB with 0))))))))

(\DOVEFLOPPY.SETUPPRIMITIVEFDCOP
  (LAMBDA (IOCB OPERATION)                                   (* kbr: " 5-Oct-85 17:00")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.SECTORLENGTHS \DOVEFLOPPY.COMMANDS 
			     \DOVEFLOPPY.CURRENTCONTEXT \DOVEFLOPPY.FORMATINFO 
			     \DOVEFLOPPY.DATATRANSFEROPS \DOVEFLOPPY.#COMMANDBYTES 
			     \DOVEFLOPPY.#RESULTBYTES \DOVEFLOPPY.FDCBYTEONEMASKS 
			     \DOVEFLOPPY.FDCBYTETWOMASKS \DOVEFLOPPY.WAITFORINTERRUPTCMDS))
    (PROG (FDCCMDINDEX FDCCMD ENCODEDSECTORLENGTH FORMATINFO CURRENTCMDRECORD CMDBYTES)
	    (SETQ FDCCMDINDEX (ADD1 (fetch (DOVEFLOPPYIOCB NUMBEROFFDCCOMMANDS) of IOCB)))
	    (SETQ FDCCMD (CDR (FASSOC OPERATION \DOVEFLOPPY.COMMANDS)))
	    (SETQ ENCODEDSECTORLENGTH (CDR (FASSOC (fetch (DOVEFLOPPYCONTEXT SECTORLENGTH)
							    of \DOVEFLOPPY.CURRENTCONTEXT)
							 \DOVEFLOPPY.SECTORLENGTHS)))
	    (SETQ FORMATINFO (CDR (FASSOC (fetch (DOVEFLOPPYCONTEXT DENSITY) of 
								       \DOVEFLOPPY.CURRENTCONTEXT)
						(CADR (FASSOC (fetch (DOVEFLOPPYCONTEXT 
										     SECTORLENGTH)
								     of \DOVEFLOPPY.CURRENTCONTEXT)
								  \DOVEFLOPPY.FORMATINFO)))))
	    (SETQ CURRENTCMDRECORD (\ADDBASE (LOCF (fetch (DOVEFLOPPYIOCB FDCCOMMANDS)
							  of IOCB))
						 (ITIMES \DOVEFLOPPY.FDCCMDLENGTH (SUB1 
										      FDCCMDINDEX))))
	    (replace (DOVEFLOPPYIOCB NUMBEROFFDCCOMMANDS) of IOCB with FDCCMDINDEX)
	    (replace (DOVEFLOPPYIOCB DATATRANSFERCODE) of IOCB
	       with (CDR (FASSOC (fetch (DOVEFLOPPYIOCB OPERATION) of IOCB)
				       \DOVEFLOPPY.DATATRANSFEROPS)))
                                                             (* Set up CURRENTCMDRECORD *)
	    (replace (DOVEFLOPPYFDCCOMMAND FDCCODE) of CURRENTCMDRECORD with FDCCMD)
	    (replace (DOVEFLOPPYFDCCOMMAND DATATRANSFERCODE) of CURRENTCMDRECORD
	       with (CDR (FASSOC OPERATION \DOVEFLOPPY.DATATRANSFEROPS)))
	    (replace (DOVEFLOPPYFDCCOMMAND NUMBEROFCOMMANDBYTES) of CURRENTCMDRECORD
	       with (CDR (FASSOC OPERATION \DOVEFLOPPY.#COMMANDBYTES)))
	    (replace (DOVEFLOPPYFDCCOMMAND NUMBEROFRESULTBYTES) of CURRENTCMDRECORD
	       with (CDR (FASSOC OPERATION \DOVEFLOPPY.#RESULTBYTES)))
	    (replace (DOVEFLOPPYFDCCOMMAND MUSTWAITFORINTERRUPT) of CURRENTCMDRECORD
	       with (COND
			((FMEMB OPERATION \DOVEFLOPPY.WAITFORINTERRUPTCMDS)
			  \DOVEFLOPPY.BYTETRUE)
			(T \DOVEFLOPPY.BYTEFALSE)))          (* Set up CMDBYTES *)
	    (SETQ CMDBYTES (LOCF (fetch (DOVEFLOPPYFDCCOMMAND COMMANDBYTES) of CURRENTCMDRECORD)
				   ))
	    (replace (DOVEFLOPPYCMDBYTES CB1) of CMDBYTES with (CDR (FASSOC OPERATION 
								      \DOVEFLOPPY.HARDFDCCOMMANDS)))
	    (COND
	      ((fetch (DOVEFLOPPYIOCB MULTITRACKMODE) of IOCB)
		(replace (DOVEFLOPPYCMDBYTES CB1) of CMDBYTES with (LOGOR
									   (fetch (
DOVEFLOPPYCMDBYTES CB1) of CMDBYTES)
									   
								   \DOVEFLOPPY.HARDMULTITRACKMODE))))
	    (COND
	      ((EQ (fetch (DOVEFLOPPYCONTEXT DENSITY) of \DOVEFLOPPY.CURRENTCONTEXT)
		     (QUOTE DOUBLE))
		(replace (DOVEFLOPPYCMDBYTES CB1) of CMDBYTES with (LOGOR
									   (fetch (
DOVEFLOPPYCMDBYTES CB1) of CMDBYTES)
									   
								    \DOVEFLOPPY.HARDDOUBLEDENSITY))))
	    (COND
	      ((fetch (DOVEFLOPPYIOCB SKIPDELETEDSECTOR) of IOCB)
		(replace (DOVEFLOPPYCMDBYTES CB1) of CMDBYTES with (LOGOR
									   (fetch (
DOVEFLOPPYCMDBYTES CB1) of CMDBYTES)
									   
								\DOVEFLOPPY.HARDSKIPDELETEDSECTOR))))
	    (replace (DOVEFLOPPYCMDBYTES CB1) of CMDBYTES with (LOGAND (fetch (
DOVEFLOPPYCMDBYTES CB1) of CMDBYTES)
									       (CDR (FASSOC
											OPERATION 
								      \DOVEFLOPPY.FDCBYTEONEMASKS))))
	    (replace (DOVEFLOPPYCMDBYTES CB2) of CMDBYTES with 0)
	    (COND
	      ((EQ (fetch (DOVEFLOPPYIOCB HEAD) of IOCB)
		     1)
		(replace (DOVEFLOPPYCMDBYTES CB2) of CMDBYTES with (LOGOR
									   (fetch (
DOVEFLOPPYCMDBYTES CB2) of CMDBYTES)
									   \DOVEFLOPPY.HARDHEADONE))))
	    (replace (DOVEFLOPPYCMDBYTES CB2) of CMDBYTES with (LOGAND (fetch (
DOVEFLOPPYCMDBYTES CB2) of CMDBYTES)
									       (CDR (FASSOC
											OPERATION 
								      \DOVEFLOPPY.FDCBYTETWOMASKS))))
	    (replace (DOVEFLOPPYCMDBYTES CB3) of CMDBYTES with (fetch (DOVEFLOPPYIOCB 
											 CYLINDER)
									of IOCB))
	    (replace (DOVEFLOPPYCMDBYTES CB4) of CMDBYTES with (fetch (DOVEFLOPPYIOCB HEAD)
									of IOCB))
	    (replace (DOVEFLOPPYCMDBYTES CB5) of CMDBYTES with (fetch (DOVEFLOPPYIOCB SECTOR)
									of IOCB))
	    (replace (DOVEFLOPPYCMDBYTES CB6) of CMDBYTES with ENCODEDSECTORLENGTH)
	    (replace (DOVEFLOPPYCMDBYTES CB7) of CMDBYTES with (fetch (DOVEFLOPPYFORMATINFO
										SECTORSPERTRACK)
									of FORMATINFO))
	    (replace (DOVEFLOPPYCMDBYTES CB8) of CMDBYTES with (fetch (DOVEFLOPPYFORMATINFO
										READWRITEGAPLENGTH)
									of FORMATINFO))
	    (replace (DOVEFLOPPYCMDBYTES CB9) of CMDBYTES with (COND
								       ((EQ (fetch (
DOVEFLOPPYCMDBYTES CB6) of CMDBYTES)
									      0)
									 128)
								       (T 255)))
	    (SELECTQ OPERATION
		       (FORMATTRACK (replace (DOVEFLOPPYCMDBYTES CB3) of CMDBYTES with 
									      ENCODEDSECTORLENGTH)
				    (replace (DOVEFLOPPYCMDBYTES CB4) of CMDBYTES
				       with (fetch (DOVEFLOPPYFORMATINFO SECTORSPERTRACK)
						 of FORMATINFO))
				    (replace (DOVEFLOPPYCMDBYTES CB5) of CMDBYTES
				       with (fetch (DOVEFLOPPYFORMATINFO FORMATGAPLENGTH)
						 of FORMATINFO))
				    (replace (DOVEFLOPPYCMDBYTES CB6) of CMDBYTES
				       with (fetch (DOVEFLOPPYFCB FLOPPYFILLERFORFORMATTING)
						 of \DoveFloppy.FCBPointer)))
		       ((SCANEQUAL SCANHIGHOREQUAL SCANLOWOREQUAL)
			 (replace (DOVEFLOPPYCMDBYTES CB9) of CMDBYTES with 1))
		       (SPECIFY (replace (DOVEFLOPPYCMDBYTES CB2) of CMDBYTES
				   with (fetch (DOVEFLOPPYDCB StepRateTimePlusHeadUnloadTime)
					     of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
						     of \DoveFloppy.FCBPointer)))
				(replace (DOVEFLOPPYCMDBYTES CB3) of CMDBYTES
				   with (fetch (DOVEFLOPPYDCB HeadLoadTimePlusNotInDMAmode)
					     of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
						     of \DoveFloppy.FCBPointer))))
		       NIL))))

(\DOVEFLOPPY.STOPHANDLER
  (LAMBDA NIL                                                (* kbr: "21-Oct-85 17:02")
    (PROG (TIMER STATUS)
	    (replace (DOVEFLOPPYFCB FLOPPYSTOPHANDLER) of \DoveFloppy.FCBPointer with 
									     \DOVEFLOPPY.BYTETRUE)
	    (\DoveIO.NotifyIOP (fetch (DOVEFLOPPYFCB FLOPPYWORKMASK) of \DoveFloppy.FCBPointer))
	    (SETQ TIMER (SETUPTIMER 500))
	    (until (OR (TIMEREXPIRED? TIMER)
			   (EQ \DOVEFLOPPY.BYTETRUE (fetch (DOVEFLOPPYFCB FLOPPYHANDLERISSTOPPED)
							 of \DoveFloppy.FCBPointer)))
	       do (BLOCK))

          (* * This line clears out all 3 queueblocks in the fcb. beware!)


	    (\CLEARWORDS (fetch (DOVEFLOPPYFCB FLOPPYDIAGNOSTICQUEUE) of \DoveFloppy.FCBPointer)
			   (ITIMES 3 (MESASIZE Dove.QueueBlock)))
	    (replace (DOVEFLOPPYFCB FLOPPYSTOPHANDLER) of \DoveFloppy.FCBPointer with 
									    \DOVEFLOPPY.BYTEFALSE)
	    (SETQ STATUS (COND
		((EQ \DOVEFLOPPY.BYTETRUE (fetch (DOVEFLOPPYFCB FLOPPYHANDLERISSTOPPED)
					       of \DoveFloppy.FCBPointer))
                                                             (* A previous version of this COND had 
							     (TIMEREXPIRED? TIMER) as the first test, which was 
							     wrong. *)
		  (QUOTE OK))
		(T (QUOTE TIMEOUT))))
	    (RETURN STATUS))))

(\DOVEFLOPPY.TRANSFER
  (LAMBDA (CYL HD SEC BUFF MODE RESET? RECAL?)               (* kbr: " 5-Oct-85 17:04")
    (PROG (STATUS)
	    (COND
	      ((NULL \DOVEFLOPPY.IOCB)
		(SETQ \DOVEFLOPPY.IOCB (NCREATE (QUOTE VMEMPAGEP)))))
                                                             (* Set up IOCB. *)
	    (replace (DOVEFLOPPYIOCB CYLINDER) of \DOVEFLOPPY.IOCB with CYL)
	    (replace (DOVEFLOPPYIOCB HEAD) of \DOVEFLOPPY.IOCB with HD)
	    (replace (DOVEFLOPPYIOCB SECTOR) of \DOVEFLOPPY.IOCB with SEC)
	    (replace (DOVEFLOPPYIOCB BUFFER) of \DOVEFLOPPY.IOCB with BUFF)
	    (replace (DOVEFLOPPYIOCB OPERATION) of \DOVEFLOPPY.IOCB with MODE)
	    (replace (DOVEFLOPPYIOCB RESETFIRST?) of \DOVEFLOPPY.IOCB with RESET?)
	    (replace (DOVEFLOPPYIOCB RECALIBRATEFIRST?) of \DOVEFLOPPY.IOCB with RECAL?)
	    (SETQ STATUS (COND
		((EQ (\DOVEFLOPPY.INITIATE \DOVEFLOPPY.IOCB)
		       \DOVEFLOPPY.OPERATIONCOMPLETED)
		  (QUOTE OK))
		(T (\DOVEFLOPPY.GETERRORSTATUS \DOVEFLOPPY.IOCB))))
	    (RETURN STATUS))))

(\DOVEFLOPPY.VALIDATEIOCB
  (LAMBDA (IOCB)                                             (* kbr: " 5-Oct-85 17:08")
    (DECLARE (GLOBALVARS \DOVEFLOPPY.CURRENTCONTEXT \DOVEFLOPPY.COMMANDS))
    (PROG (DCBPTR)
	    (SETQ DCBPTR (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE) of \DoveFloppy.FCBPointer))
	    (COND
	      ((NOT (FASSOC (fetch (DOVEFLOPPYIOCB OPERATION) of IOCB)
				\DOVEFLOPPY.COMMANDS))
		(HELP "Invalid operation " (fetch (DOVEFLOPPYIOCB OPERATION) of IOCB))))
	    (COND
	      ((NOT (fetch (DOVEFLOPPYIOCB BUFFER) of IOCB))
		(HELP "No buffer supplied!")))
	    (COND
	      ((OR (ILESSP (fetch (DOVEFLOPPYIOCB CYLINDER) of IOCB)
			       0)
		     (IGREATERP (fetch (DOVEFLOPPYIOCB CYLINDER) of IOCB)
				  (fetch (DOVEFLOPPYCONTEXT NUMBEROFCYLINDERS) of 
								       \DOVEFLOPPY.CURRENTCONTEXT)))
		(HELP "Invalid Cylinder " (fetch (DOVEFLOPPYIOCB CYLINDER) of IOCB))))
	    (COND
	      ((OR (ILESSP (fetch (DOVEFLOPPYIOCB HEAD) of IOCB)
			       0)
		     (IGREATERP (fetch (DOVEFLOPPYIOCB HEAD) of IOCB)
				  (fetch (DOVEFLOPPYCONTEXT NUMBEROFHEADS) of 
								       \DOVEFLOPPY.CURRENTCONTEXT)))
		(HELP "Invalid Head " (fetch (DOVEFLOPPYIOCB HEAD) of IOCB))))
	    (COND
	      ((EQ (fetch (DOVEFLOPPYDCB DRIVEACQUIREDBYPCE) of DCBPTR)
		     \DOVEFLOPPY.BYTETRUE)
		(HELP "The PCE is using this drive!")))
	    (replace (DOVEFLOPPYIOCB OPERATIONSTATE) of IOCB with \DOVEFLOPPY.INPROGRESS))))

(\DOVEFLOPPY.WRITEPROTECTED
  (LAMBDA NIL                                                (* kbr: " 5-Oct-85 17:45")
    (NOT (EQ 0 (LOGAND \DOVEFLOPPY.WRITEPROTECT (fetch (DOVEFLOPPYDCB DRIVESTATUSHEAD0)
							 of (fetch (DOVEFLOPPYFCB FLOPPYDCB0BASE)
								 of \DoveFloppy.FCBPointer)))))))
)

(RPAQ? \DOVEFLOPPY.IOCB NIL)

(RPAQ? \DOVEFLOPPY.CURRENTCONTEXT NIL)

(RPAQ? \DoveFloppy.FCBPointer )
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS \DOVEFLOPPY.IOCB \DOVEFLOPPY.CURRENTCONTEXT \DOVEFLOPPY.HARDFDCCOMMANDS 
       \DoveFloppy.FCBPointer)
)
(PUTPROPS DOVEFLOPPY COPYRIGHT ("Xerox Corporation" 1985 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (20848 54081 (\DOVEFLOPPY.RESET 20858 . 21000) (\DOVEFLOPPY.SETCONTEXT 21002 . 21773) (
\DOVEFLOPPY.XFERDISK 21775 . 23699) (\DOVEFLOPPY.BYTESWAPIOCB 23701 . 26355) (
\DOVEFLOPPY.CLEARDISKCHANGED 26357 . 26639) (\DOVEFLOPPY.DISKCHANGED 26641 . 26939) (
\DOVEFLOPPY.DOOROPEN 26941 . 27213) (\DOVEFLOPPY.GETERRORSTATUS 27215 . 28937) (\DOVEFLOPPY.INIT 28939
 . 29583) (\DOVEFLOPPY.INITDCB 29585 . 32228) (\DOVEFLOPPY.INITIOCB 32230 . 35265) (
\DOVEFLOPPY.INITIATE 35267 . 38326) (\DOVEFLOPPY.SETUPDMAINFO 38328 . 42626) (
\DOVEFLOPPY.SETUPPRIMITIVEFDCOP 42628 . 49525) (\DOVEFLOPPY.STOPHANDLER 49527 . 50943) (
\DOVEFLOPPY.TRANSFER 50945 . 52108) (\DOVEFLOPPY.VALIDATEIOCB 52110 . 53747) (
\DOVEFLOPPY.WRITEPROTECTED 53749 . 54079)))))
STOP