OpenCores
URL https://opencores.org/ocsvn/System09/System09/trunk

Subversion Repositories System09

[/] [System09/] [rev_86/] [src/] [Flex9/] [f9-dkfdc.asm] - Diff between revs 66 and 112

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 66 Rev 112
*
*
** FLEX 9 DISK DRIVERS
** FLEX 9 DISK DRIVERS
** FOR SINGLE/DOUBLE SIDED 5" DRIVES ONLY.
** FOR SINGLE/DOUBLE SIDED 5" DRIVES ONLY.
** USING FD1771.
** USING FD1771.
** SIDES MAY BE TREATED AS SEPERATE DISKS.
** SIDES MAY BE TREATED AS SEPERATE DISKS.
**
**
** BY J.E.KENT   1 JAN 1982
** BY J.E.KENT   1 JAN 1982
*
*
*
*
** F.D. CONTROLLER
** F.D. CONTROLLER
*
*
DRVREG EQU   $E014
DRVREG EQU   $E014
MOTOR  EQU   %10000000
MOTOR  EQU   %10000000
SIDESL EQU   %01000000
SIDESL EQU   %01000000
DRIVSL EQU   %00000001
DRIVSL EQU   %00000001
CMDREG EQU   $E018
CMDREG EQU   $E018
TRKREG EQU   $E019
TRKREG EQU   $E019
SECREG EQU   $E01A
SECREG EQU   $E01A
DATREG EQU   $E01B
DATREG EQU   $E01B
*
*
** FD1771 DISK CONTROLLER INSTRUCTIONS
** FD1771 DISK CONTROLLER INSTRUCTIONS
*
*
** TYPE I INSTRUCTIONS:
** TYPE I INSTRUCTIONS:
*
*
IREST EQU $00 RESTORE (SEEK TRACK 0)
IREST EQU $00 RESTORE (SEEK TRACK 0)
ISEEK EQU $10 SEEK TRACK
ISEEK EQU $10 SEEK TRACK
ISTEP EQU $20 STEP ONE TRACK (IN/OUT)
ISTEP EQU $20 STEP ONE TRACK (IN/OUT)
ISTIN EQU $40 STEP IN ONE TRACK
ISTIN EQU $40 STEP IN ONE TRACK
ISTOUT EQU $60 STEP OUT ONE TRACK
ISTOUT EQU $60 STEP OUT ONE TRACK
*
*
** BIT FIELDS FOR TYPE I INSTRUCTIONS
** BIT FIELDS FOR TYPE I INSTRUCTIONS
*
*
SMR6 EQU $00 6MSEC STEPPING RATE
SMR6 EQU $00 6MSEC STEPPING RATE
SMR12 EQU $01 12 MSEC STEPPING RATE
SMR12 EQU $01 12 MSEC STEPPING RATE
SMR20 EQU $02 20 MSEC
SMR20 EQU $02 20 MSEC
SMR40 EQU $03 40 MSEC
SMR40 EQU $03 40 MSEC
*
*
BVERIF EQU $04 VERIFY BIT (1=ON)
BVERIF EQU $04 VERIFY BIT (1=ON)
BHDLD EQU $08 HEAD LOAD (1=LOAD HEAD AT BEGINING)
BHDLD EQU $08 HEAD LOAD (1=LOAD HEAD AT BEGINING)
BUPDAT EQU $10 UPDATE TRACK REGISTER (1=TRUE)
BUPDAT EQU $10 UPDATE TRACK REGISTER (1=TRUE)
*
*
** TYPE II INSTRUCTIONS
** TYPE II INSTRUCTIONS
*
*
IREAD EQU $80 READ SECTOR
IREAD EQU $80 READ SECTOR
IWRITE EQU $A0 WRITE SECTOR
IWRITE EQU $A0 WRITE SECTOR
*
*
** BIT FIELD FOR TYPE II
** BIT FIELD FOR TYPE II
*
*
BDAMFB EQU $00 $FB DATA ADDRESS MARK
BDAMFB EQU $00 $FB DATA ADDRESS MARK
BDAMFA EQU $01 $FA DATA ADDREES MARK
BDAMFA EQU $01 $FA DATA ADDREES MARK
BDAMF9 EQU $02 $F9 DATA ADDRESS MARK
BDAMF9 EQU $02 $F9 DATA ADDRESS MARK
BDAMF8 EQU $03 $F8 DATA ADDRESS MARK
BDAMF8 EQU $03 $F8 DATA ADDRESS MARK
BEHLD EQU $04 ENABLE HLD & 10 MSEC DELAY (1=ACTIVE)
BEHLD EQU $04 ENABLE HLD & 10 MSEC DELAY (1=ACTIVE)
BBLEN EQU $08 BLOCK LENGTH (1=IBM FORMAT 128 - 1024 BYTES)
BBLEN EQU $08 BLOCK LENGTH (1=IBM FORMAT 128 - 1024 BYTES)
BMREC EQU $10 MULTIPLE RECORD (0=SINGLE, 1=MULTIPLE)
BMREC EQU $10 MULTIPLE RECORD (0=SINGLE, 1=MULTIPLE)
*
*
** TYPE III INSTRUCTIONS
** TYPE III INSTRUCTIONS
*
*
IRDADD EQU $C4 READ ADDRESS
IRDADD EQU $C4 READ ADDRESS
IRDTRK EQU $E4 READ TRACK
IRDTRK EQU $E4 READ TRACK
IWRTRK EQU $F4 WRITE TRACK
IWRTRK EQU $F4 WRITE TRACK
*
*
** BIT FIELD TYPE III (READ TRACK ONLY)
** BIT FIELD TYPE III (READ TRACK ONLY)
*
*
BSYNC EQU $01 SYNCRONIZE FLAG (0=SYNC TO AM)
BSYNC EQU $01 SYNCRONIZE FLAG (0=SYNC TO AM)
*
*
** TYPE IV NSTRUCTION
** TYPE IV NSTRUCTION
*
*
IFINTR EQU $D0 FORCE INTERRUPT
IFINTR EQU $D0 FORCE INTERRUPT
*
*
** FORCED INTERRUPT BITS (TYPE IV INSTRUCTION)
** FORCED INTERRUPT BITS (TYPE IV INSTRUCTION)
*
*
FI0 EQU $01 NOT READY TO READY TRANSITION
FI0 EQU $01 NOT READY TO READY TRANSITION
FI1 EQU $02 READY TO NOT READY TRANSITION
FI1 EQU $02 READY TO NOT READY TRANSITION
FI2 EQU $04 INDEX PULSE
FI2 EQU $04 INDEX PULSE
FI3 EQU $08 EVERY 10 MSEC
FI3 EQU $08 EVERY 10 MSEC
*
*
** DISK DRIVER PATCHES
** DISK DRIVER PATCHES
*
*
       ORG   $DE00
       ORG   $DE00
*
*
** JUMP TABLE TO DISK DRIVERS
** JUMP TABLE TO DISK DRIVERS
*
*
READ   JMP   READSC
READ   JMP   READSC
WRITE  JMP   WRITSC
WRITE  JMP   WRITSC
VERIFY JMP   VERIF1
VERIFY JMP   VERIF1
RESTOR JMP   RESTR1
RESTOR JMP   RESTR1
DRIVE  JMP   DRVSEL
DRIVE  JMP   DRVSEL
DRVRDY JMP   CHKDRV
DRVRDY JMP   CHKDRV
QUICK  JMP   CHKDRV
QUICK  JMP   CHKDRV
COLDDR JMP   INITDR
COLDDR JMP   INITDR
WARMDR JMP   WARMD1
WARMDR JMP   WARMD1
SEEK   JMP   SEEK1
SEEK   JMP   SEEK1
*
*
** CURRNT DRIVE NUMBER ($DE1E)
** CURRNT DRIVE NUMBER ($DE1E)
*
*
CURDRV FCB   $00
CURDRV FCB   $00
*
*
** HEAD POSITION TABLE ($DE1F)
** HEAD POSITION TABLE ($DE1F)
*
*
TRKTBL FCB   $00       DRIVE 0
TRKTBL FCB   $00       DRIVE 0
       FCB   $00       DRIVE 1
       FCB   $00       DRIVE 1
       FCB   $00       DRIVE 2
       FCB   $00       DRIVE 2
       FCB   $00       DRIVE 3
       FCB   $00       DRIVE 3
*
*
** ??? ($DE23)
** ??? ($DE23)
*
*
       FCB 0
       FCB 0
*
*
** DENSITY TABLE: ($DE24)
** DENSITY TABLE: ($DE24)
** HOLDS SECTORS/TRACK FOR DRIVE
** HOLDS SECTORS/TRACK FOR DRIVE
** 5" SINGLE DENSITY => 10 SECTORS/TRACK
** 5" SINGLE DENSITY => 10 SECTORS/TRACK
*
*
DNSTBL FCB 10,10,10,10 ALL MINIS
DNSTBL FCB 10,10,10,10 ALL MINIS
*
*
** DRIVE & DISK CHARACTERISTICS
** DRIVE & DISK CHARACTERISTICS
*
*
* BITS 1,0 STEPPING RATES
* BITS 1,0 STEPPING RATES
* BIT  2   TRACKS/DISK (0=40 TRACK, 1=80 TRACK)
* BIT  2   TRACKS/DISK (0=40 TRACK, 1=80 TRACK)
* BIT  3   TRACKS/DRIVE (0=40 TRACK, 1=80 TRACK)
* BIT  3   TRACKS/DRIVE (0=40 TRACK, 1=80 TRACK)
*
*
BDVTPI EQU $08
BDVTPI EQU $08
BDKTPI EQU $04
BDKTPI EQU $04
DDCTBL EQU *
DDCTBL EQU *
 FCB BDVTPI+BDKTPI+SMR6
 FCB BDVTPI+BDKTPI+SMR6
 FCB BDVTPI+BDKTPI+SMR6
 FCB BDVTPI+BDKTPI+SMR6
 FCB SMR40
 FCB SMR40
 FCB SMR40
 FCB SMR40
*
*
** DISK DRIVERS
** DISK DRIVERS
*
*
* DRIVER INITIATION
* DRIVER INITIATION
*
*
INITDR LDX   #CURDRV
INITDR LDX   #CURDRV
       LDB   #5
       LDB   #5
INITD2 CLR   ,X+
INITD2 CLR   ,X+
       DECB
       DECB
       BNE   INITD2
       BNE   INITD2
WARMD1 RTS
WARMD1 RTS
*
*
* READ ONE SECTOR
* READ ONE SECTOR
*
*
READSC BSR   SEEK1
READSC BSR   SEEK1
       LDA   #IREAD+BBLEN+BEHLD
       LDA   #IREAD+BBLEN+BEHLD
READ2  ORCC  #$10
READ2  ORCC  #$10
*      SEI             DISABLE INTERRUPTS
*      SEI             DISABLE INTERRUPTS
       STA   CMDREG
       STA   CMDREG
       LBSR  DLY47
       LBSR  DLY47
       LDB   #$00
       LDB   #$00
RDLOOP LDA   CMDREG
RDLOOP LDA   CMDREG
       BITA  #$02
       BITA  #$02
       BNE   RDBYTE
       BNE   RDBYTE
       BITA  #$01
       BITA  #$01
       BNE   RDLOOP
       BNE   RDLOOP
       TFR   A,B
       TFR   A,B
       BRA   RDEXIT
       BRA   RDEXIT
*
*
RDBYTE LDA   DATREG
RDBYTE LDA   DATREG
       STA   ,X+
       STA   ,X+
       DECB
       DECB
       BNE   RDLOOP
       BNE   RDLOOP
       BSR   WAIT
       BSR   WAIT
RDEXIT BITB  #$1C
RDEXIT BITB  #$1C
       ANDCC #$EF
       ANDCC #$EF
*      CLI
*      CLI
       RTS
       RTS
*
*
** WAIT UNTIL CONTROLLER READY
** WAIT UNTIL CONTROLLER READY
*
*
WAIT   LDB   CMDREG
WAIT   LDB   CMDREG
       BITB  #$01
       BITB  #$01
       BNE   WAIT
       BNE   WAIT
       RTS
       RTS
*
*
** SEEK1 TRACK AND SECTOR
** SEEK1 TRACK AND SECTOR
** ACCA = TRACK NUMBER
** ACCA = TRACK NUMBER
** ACCB = SECTOR NUMBER
** ACCB = SECTOR NUMBER
*
*
SEEK1  STB   SECREG    SET SECTOR
SEEK1  STB   SECREG    SET SECTOR
       CMPB  #10       DOUBLE-SIDED ?
       CMPB  #10       DOUBLE-SIDED ?
       BHI   SEEK2     DOUBLE SIDED, FLIP
       BHI   SEEK2     DOUBLE SIDED, FLIP
       LDB   CURDRV    BACK SIDE OF DISK ?
       LDB   CURDRV    BACK SIDE OF DISK ?
       CMPB  #1        DRIVE 2-3 BACK SIDE
       CMPB  #1        DRIVE 2-3 BACK SIDE
       BHI   SEEK3
       BHI   SEEK3
       ANDB  #$FF-SIDESL SELECT SIDE 0
       ANDB  #$FF-SIDESL SELECT SIDE 0
       BRA   SEEK4
       BRA   SEEK4
*
*
SEEK2  LDB   CURDRV   SELECT SIDE 1
SEEK2  LDB   CURDRV   SELECT SIDE 1
SEEK3  ANDB  #DRIVSL
SEEK3  ANDB  #DRIVSL
       ORB   #SIDESL
       ORB   #SIDESL
SEEK4  STB   DRVREG
SEEK4  STB   DRVREG
*
*
       CMPA  TRKREG    DIFFERENT TO LAST ?
       CMPA  TRKREG    DIFFERENT TO LAST ?
       BEQ   FOUND
       BEQ   FOUND
       PSHS A          SAVE TRACK NO. ON STACK
       PSHS A          SAVE TRACK NO. ON STACK
*
*
* IF 80 TRACK DRIVE, & 40 TRACK DISK, FIRST SEEK
* IF 80 TRACK DRIVE, & 40 TRACK DISK, FIRST SEEK
* SHOULD NOT UPDATE TRACK REGISTER NOR VERIFY.
* SHOULD NOT UPDATE TRACK REGISTER NOR VERIFY.
*
*
       SUBA TRKREG  CALC. DIFFERENCE
       SUBA TRKREG  CALC. DIFFERENCE
       TFR  A,B
       TFR  A,B
       PSHS Y
       PSHS Y
*
*
** GET STEPPING RATE FROM TABLE
** GET STEPPING RATE FROM TABLE
*
*
       LDY  #DDCTBL
       LDY  #DDCTBL
       LDA  CURDRV
       LDA  CURDRV
       ANDA #$01
       ANDA #$01
       LDA  A,Y
       LDA  A,Y
       PULS Y
       PULS Y
*
*
** CHECK DRIVE AND DISK TYPE
** CHECK DRIVE AND DISK TYPE
*
*
       BITA #BDVTPI DRIVE TRACK DENSITY = 48 TPI ?
       BITA #BDVTPI DRIVE TRACK DENSITY = 48 TPI ?
       BEQ  SEEKVU  YES, SKIP
       BEQ  SEEKVU  YES, SKIP
       BITA #BDKTPI DISK TRACK DENSITY = 96 TPI ?
       BITA #BDKTPI DISK TRACK DENSITY = 96 TPI ?
       BNE  SEEKVU  YES, SKIP (DRIVE & DISK MATCH)
       BNE  SEEKVU  YES, SKIP (DRIVE & DISK MATCH)
*
*
** HERE IF 40TRACK DISK IN 80 TRACK DRIVE
** HERE IF 40TRACK DISK IN 80 TRACK DRIVE
** USE STEP INSTRUCTIONS TO PREVENT UPDATE OF TRACK REG.
** USE STEP INSTRUCTIONS TO PREVENT UPDATE OF TRACK REG.
*
*
       ANDA #$03    LEAVE STEPPING RATE BITS
       ANDA #$03    LEAVE STEPPING RATE BITS
       TSTB
       TSTB
       BPL  STEPIN
       BPL  STEPIN
       NEGB
       NEGB
       ORA  #ISTOUT
       ORA  #ISTOUT
       BRA  STEPLP
       BRA  STEPLP
STEPIN ORA  #ISTIN
STEPIN ORA  #ISTIN
STEPLP PSHS B
STEPLP PSHS B
       BSR  SEEK5
       BSR  SEEK5
       PULS B
       PULS B
       DECB
       DECB
       BNE  STEPLP
       BNE  STEPLP
*
*
** SEEK TRACK WITH VERIFY & UPDATE
** SEEK TRACK WITH VERIFY & UPDATE
*
*
SEEKVU ANDA #$03    RETAIN STEPPING RATE
SEEKVU ANDA #$03    RETAIN STEPPING RATE
       ORA  #ISEEK+BHDLD ($18)
       ORA  #ISEEK+BHDLD ($18)
       PULS B          RESTORE DEST TRACK NO.
       PULS B          RESTORE DEST TRACK NO.
       STB   DATREG    YES, SEEK1 NEW TRACK
       STB   DATREG    YES, SEEK1 NEW TRACK
       LBSR  DLY47
       LBSR  DLY47
SEEK5  STA   CMDREG
SEEK5  STA   CMDREG
       LBSR  DLY47
       LBSR  DLY47
       BSR   WAIT
       BSR   WAIT
       BITB  #$10      CHECK FOR SEEK1 ERROR
       BITB  #$10      CHECK FOR SEEK1 ERROR
FOUND  JMP   DLY47
FOUND  JMP   DLY47
*
*
** WRITE SECTOR TO DISK
** WRITE SECTOR TO DISK
*
*
WRITSC BSR   SEEK1
WRITSC BSR   SEEK1
       LDA   #IWRITE+BBLEN+BEHLD ($AC)
       LDA   #IWRITE+BBLEN+BEHLD ($AC)
WRITE2 ORCC  #$10
WRITE2 ORCC  #$10
*      SEI
*      SEI
       STA   CMDREG
       STA   CMDREG
       LBSR  DLY47
       LBSR  DLY47
       LDB   #$00
       LDB   #$00
WRLOOP LDA   CMDREG
WRLOOP LDA   CMDREG
       BITA  #$02
       BITA  #$02
       BNE   WRBYTE
       BNE   WRBYTE
       BITA  #$01
       BITA  #$01
       BNE   WRLOOP
       BNE   WRLOOP
       TFR   A,B
       TFR   A,B
       BRA   WREXIT
       BRA   WREXIT
*
*
WRBYTE LDA   ,X+
WRBYTE LDA   ,X+
       STA   DATREG
       STA   DATREG
       DECB
       DECB
       BNE   WRLOOP
       BNE   WRLOOP
       LBSR  WAIT
       LBSR  WAIT
WREXIT BITB  #$5C
WREXIT BITB  #$5C
       ANDCC  #$EF
       ANDCC  #$EF
*      CLI
*      CLI
       RTS
       RTS
*
*
** VERIFY SECTOR WRITTEN
** VERIFY SECTOR WRITTEN
*
*
VERIF1 LDA   #IREAD+BBLEN+BEHLD ($8C)
VERIF1 LDA   #IREAD+BBLEN+BEHLD ($8C)
VERIF2 ORCC  #$10
VERIF2 ORCC  #$10
*      SEI
*      SEI
       STA   CMDREG
       STA   CMDREG
       LBSR  DLY47
       LBSR  DLY47
       LBSR  WAIT
       LBSR  WAIT
       ANDCC #$EF
       ANDCC #$EF
*      CLI
*      CLI
       BITB  #$18
       BITB  #$18
       RTS
       RTS
*
*
** SEEK TRACK ZERO
** SEEK TRACK ZERO
*
*
RESTR1 PSHS  X
RESTR1 PSHS  X
       BSR   DRVSEL
       BSR   DRVSEL
       LDX  #DDCTBL
       LDX  #DDCTBL
       LDA  CURDRV
       LDA  CURDRV
       ANDA #1
       ANDA #1
       LDA  A,X
       LDA  A,X
       ANDA #$03
       ANDA #$03
       ORA  #IREST+BHDLD
       ORA  #IREST+BHDLD
       STA   CMDREG
       STA   CMDREG
       BSR   DLY47
       BSR   DLY47
       LBSR  WAIT
       LBSR  WAIT
       BITB  #$D8      CHECK FOR ERROR
       BITB  #$D8      CHECK FOR ERROR
       PULS  X,PC
       PULS  X,PC
*
*
** SELECT DRIVE
** SELECT DRIVE
** IX -> FCB
** IX -> FCB
** ACCA =  NEW DRIVE NUMBER
** ACCA =  NEW DRIVE NUMBER
*
*
*  SAVE OLD TRACK NUMBER IN TABLE
*  SAVE OLD TRACK NUMBER IN TABLE
*  AND SET UP TRACK FOR NEW DRIVE
*  AND SET UP TRACK FOR NEW DRIVE
*
*
*
*
DRVSEL LDA   3,X
DRVSEL LDA   3,X
       CMPA  #3
       CMPA  #3
       BLS   DRSEL1
       BLS   DRSEL1
       LDB   #$0F      SET ERROR VALUE
       LDB   #$0F      SET ERROR VALUE
*       SEC
*       SEC
       ORCC  #$01
       ORCC  #$01
       RTS
       RTS
*
*
* SAVE TRACK POSITION OF PREVIOUS DRIVE
* SAVE TRACK POSITION OF PREVIOUS DRIVE
*
*
DRSEL1 BSR   PNTDRV
DRSEL1 BSR   PNTDRV
       LDB   TRKREG
       LDB   TRKREG
       STB   ,X
       STB   ,X
*
*
* SELECT NEW DRIVE
* SELECT NEW DRIVE
*
*
DRSEL3 STA   CURDRV    MAY BE 0 - 3
DRSEL3 STA   CURDRV    MAY BE 0 - 3
       CMPA  #1
       CMPA  #1
       BLS   DRSEL4    ONE DIRECTORY ?
       BLS   DRSEL4    ONE DIRECTORY ?
       ANDA  #DRIVSL   ROUND OFF
       ANDA  #DRIVSL   ROUND OFF
       ORA   #SIDESL   SELECT SIDE 1
       ORA   #SIDESL   SELECT SIDE 1
DRSEL4 STA   DRVREG
DRSEL4 STA   DRVREG
*
*
* RESTORE LAST TRACK POSITION FOR THIS DRIVE
* RESTORE LAST TRACK POSITION FOR THIS DRIVE
*
*
       BSR   PNTDRV
       BSR   PNTDRV
       LDA   ,X
       LDA   ,X
       STA   TRKREG
       STA   TRKREG
       BSR   DLY47
       BSR   DLY47
       BRA   OK
       BRA   OK
*
*
** CHECK IF DRIVE READY
** CHECK IF DRIVE READY
*
*
CHKDRV LDA   3,X
CHKDRV LDA   3,X
       CMPA  #3
       CMPA  #3
       BLS   OK
       BLS   OK
       LDB   #$80
       LDB   #$80
*       SEC
*       SEC
       ORCC  #$01
       ORCC  #$01
       RTS
       RTS
OK     CLRB
OK     CLRB
*       CLC
*       CLC
       ANDCC #$FE
       ANDCC #$FE
       RTS
       RTS
*
*
* POINT TO TRACK TABLE ENTRY FOR THIS DRIVE
* POINT TO TRACK TABLE ENTRY FOR THIS DRIVE
*
*
PNTDRV LDX   #TRKTBL
PNTDRV LDX   #TRKTBL
       LDB   CURDRV
       LDB   CURDRV
       ANDB   #DRIVSL
       ANDB   #DRIVSL
       ABX
       ABX
       RTS
       RTS
*
*
** DELAY ROUTINE
** DELAY ROUTINE
*
*
DLY47  LBSR  DLY19
DLY47  LBSR  DLY19
DLY19  LBSR  DLY5US
DLY19  LBSR  DLY5US
DLY5US RTS
DLY5US RTS
       END
       END
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.