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

Subversion Repositories System09

[/] [System09/] [trunk/] [src/] [upld/] [upld_cf8.asm] - Diff between revs 59 and 66

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

Rev 59 Rev 66
*
*
** FLEX 9 DISK DRIVERS
** FLEX 9 DISK DRIVERS
*
*
* FOR SYS09BUG ON THE DIGILENT SPARTAN 3 STARTER BOARD
* FOR SYS09BUG ON THE DIGILENT SPARTAN 3 STARTER BOARD
* WITH I/O MAPPED AT $XE000
* WITH I/O MAPPED AT $XE000
* AND ROM MAPPED AT $XF000
* AND ROM MAPPED AT $XF000
* THE DIGILENT SPARTAN 3 STARTER BOARD HAS 1MBYTE OF SRAM
* THE DIGILENT SPARTAN 3 STARTER BOARD HAS 1MBYTE OF SRAM
* THE FIRST 64K IS USED BY FLEX,
* THE FIRST 64K IS USED BY FLEX,
* THE SECOND 128K IS USED AS A ROM DISK
* THE SECOND 128K IS USED AS A ROM DISK
* THE REMAINING RAM IS USED FOR A RAM DISK
* THE REMAINING RAM IS USED FOR A RAM DISK
*
*
*
*
CFLAG   EQU $01     CARRY FLAG
CFLAG   EQU $01     CARRY FLAG
VFLAG   EQU $02     OVERFLOW FLAG
VFLAG   EQU $02     OVERFLOW FLAG
ZFLAG   EQU $04     ZERO FLAG
ZFLAG   EQU $04     ZERO FLAG
NFLAG   EQU $08     NEGATIVE FLAG
NFLAG   EQU $08     NEGATIVE FLAG
IFLAG   EQU $10     IRQ MASK CC
IFLAG   EQU $10     IRQ MASK CC
HFLAG   EQU $20     HALF CARRY
HFLAG   EQU $20     HALF CARRY
FFLAG   EQU $40     FIRQ MASK CC
FFLAG   EQU $40     FIRQ MASK CC
EFLAG   EQU $80     ENTIRE FLAG
EFLAG   EQU $80     ENTIRE FLAG
*
*
MAPPAG  EQU $00     PAGE $0000 DAT ADDRESS
MAPPAG  EQU $00     PAGE $0000 DAT ADDRESS
*
*
* Serial Port
* Serial Port
*
*
ACIAS   EQU $E000
ACIAS   EQU $E000
ACIAC1  EQU ACIAS
ACIAC1  EQU ACIAS
ACIAD1  EQU ACIAS+1
ACIAD1  EQU ACIAS+1
DELCON  EQU 1250    Delay (Processor clock in MHz * 50)
DELCON  EQU 1250    Delay (Processor clock in MHz * 50)
*
*
* XMODEM Control characters
* XMODEM Control characters
*
*
SOH     EQU $01
SOH     EQU $01
EOT     EQU $04
EOT     EQU $04
ACK     EQU $06
ACK     EQU $06
NAK     EQU $15
NAK     EQU $15
CAN     EQU $18
CAN     EQU $18
*
*
* Some dummy Constants
* Some dummy Constants
*
*
RMAXTRK EQU 48
RMAXTRK EQU 48
RMAXSEC EQU 14
RMAXSEC EQU 14
RTOTSEC EQU RMAXTRK*RMAXSEC-RMAXSEC
RTOTSEC EQU RMAXTRK*RMAXSEC-RMAXSEC
*
*
* Start
* Start
*
*
        ORG $0100
        ORG $0100
START   LBSR  UXSUB
START   LBSR  UXSUB
        JMP  [$F800]  Jump to monitor on Completion.
        JMP  [$F800]  Jump to monitor on Completion.
*
*
*
*
* RAM SPACE
* RAM SPACE
*
*
DRVNUM  FCB  0
DRVNUM  FCB  0
TRACK   FCB  0
TRACK   FCB  0
SECTOR  FCB  0
SECTOR  FCB  0
CHKSUM  FCB  0
CHKSUM  FCB  0
BLKNUM  FCB  0 Xmodem block number
BLKNUM  FCB  0 Xmodem block number
BYTCNT  FCB  0 Xmodem byte count
BYTCNT  FCB  0 Xmodem byte count
XSTATE  FDB  0 Xmodem State Vector
XSTATE  FDB  0 Xmodem State Vector
DELCNT  FCB  $00,$00,$00 Xmodem Poll timer
DELCNT  FCB  $00,$00,$00 Xmodem Poll timer
MAXTRK  FCB  0
MAXTRK  FCB  0
MAXSEC  FCB  0
MAXSEC  FCB  0
        ORG  $0200
        ORG  $0200
*
*
* SECTOR BUFFER
* SECTOR BUFFER
*
*
BUFFER  RMB  256
BUFFER  RMB  256
*
*
* ACIA INPUT TEST
* ACIA INPUT TEST
*
*
INTEST  LDA ACIAC1
INTEST  LDA ACIAC1
        BITA #$01
        BITA #$01
        RTS
        RTS
*
*
* RESET ACIA
* RESET ACIA
*
*
ACIRST  LDA #$03 master reset
ACIRST  LDA #$03 master reset
        STA  ACIAC1
        STA  ACIAC1
        LDA #$11
        LDA #$11
        STA ACIAC1
        STA ACIAC1
        RTS
        RTS
*
*
* ACIA INPUT
* ACIA INPUT
*
*
INTER   LDA  #16
INTER   LDA  #16
        STA  DELCNT+0
        STA  DELCNT+0
        CLR  DELCNT+1
        CLR  DELCNT+1
        CLR  DELCNT+2
        CLR  DELCNT+2
INTER0  LDA  ACIAC1
INTER0  LDA  ACIAC1
        BITA #$01
        BITA #$01
        BNE  INTER1
        BNE  INTER1
        BITA #$78
        BITA #$78
        BEQ  INTER2
        BEQ  INTER2
        BSR  ACIRST
        BSR  ACIRST
        BRA  INTER
        BRA  INTER
*
*
INTER1  LDA  ACIAD1
INTER1  LDA  ACIAD1
        ANDCC #$FF-VFLAG
        ANDCC #$FF-VFLAG
        RTS
        RTS
*
*
INTER2  DEC  DELCNT+2
INTER2  DEC  DELCNT+2
        BNE  INTER0
        BNE  INTER0
        DEC  DELCNT+1
        DEC  DELCNT+1
        BNE  INTER0
        BNE  INTER0
        DEC  DELCNT+0
        DEC  DELCNT+0
        BNE  INTER0
        BNE  INTER0
        CLRA
        CLRA
        ORCC #VFLAG
        ORCC #VFLAG
        RTS
        RTS
*
*
* ACIA OUTPUT
* ACIA OUTPUT
*
*
OUTTER  PSHS A
OUTTER  PSHS A
*
*
OUTTE1  LDA ACIAC1
OUTTE1  LDA ACIAC1
        BITA #$02
        BITA #$02
        BNE  OUTTE2
        BNE  OUTTE2
        BITA #$78
        BITA #$78
        BEQ  OUTTE1
        BEQ  OUTTE1
        BSR  ACIRST
        BSR  ACIRST
        BRA  OUTTE1
        BRA  OUTTE1
*
*
OUTTE2  PULS A
OUTTE2  PULS A
        STA ACIAD1
        STA ACIAD1
        RTS
        RTS
*
*
* Print Data
* Print Data
*
*
PDATA0  BSR  OUTTER
PDATA0  BSR  OUTTER
PDATA1  LDA  ,X+
PDATA1  LDA  ,X+
        CMPA #$04
        CMPA #$04
        BNE  PDATA0
        BNE  PDATA0
        RTS
        RTS
*
*
** 'UX' Xmodem ROM Disk upload
** 'UX' Xmodem ROM Disk upload
*
*
UXMES0  FCB $0D,$0A
UXMES0  FCB $0D,$0A
        FCC 'Xmodem ROM Disk Upload'
        FCC 'Xmodem ROM Disk Upload'
        FCB 4
        FCB 4
UXMES1  FCB $0D,$0A
UXMES1  FCB $0D,$0A
        FCC 'Upload Complete'
        FCC 'Upload Complete'
        FCB 4
        FCB 4
UXMES2  FCB $0D,$0A
UXMES2  FCB $0D,$0A
        FCC 'Upload Error'
        FCC 'Upload Error'
        FCB 4
        FCB 4
UXMSG3  FCB $0D,$0A
UXMSG3  FCB $0D,$0A
        FCC 'Drive Number :'
        FCC 'Drive Number :'
        FCB 4
        FCB 4
UXMSG4  FCB $0D,$0A
UXMSG4  FCB $0D,$0A
        FCC 'Are You Sure ? (Y/N)'
        FCC 'Are You Sure ? (Y/N)'
        FCB 4
        FCB 4
*
*
* Print Banner
* Print Banner
*
*
UXSUB   LDX #UXMES0
UXSUB   LDX #UXMES0
        LBSR PDATA1
        LBSR PDATA1
*
*
* Prompt for Disk drive number (0 to 3)
* Prompt for Disk drive number (0 to 3)
*
*
        LDX #UXMSG3
        LDX #UXMSG3
        LBSR PDATA1
        LBSR PDATA1
UXSUB1  LBSR INTER
UXSUB1  LBSR INTER
        BVS  UXSUB1
        BVS  UXSUB1
        LBSR OUTTER
        LBSR OUTTER
        CMPA #'0
        CMPA #'0
        LBLO UXEXIT
        LBLO UXEXIT
        CMPA #'3
        CMPA #'3
        LBHI UXEXIT
        LBHI UXEXIT
        SUBA #'0
        SUBA #'0
        STA  DRVNUM
        STA  DRVNUM
*
*
* Report selected drive
* Report selected drive
*
*
        LDX #UXMSG3
        LDX #UXMSG3
        LBSR PDATA1
        LBSR PDATA1
        LDA  DRVNUM
        LDA  DRVNUM
        ADDA #'0
        ADDA #'0
        LBSR OUTTER
        LBSR OUTTER
*
*
* Ask for confirmation (Y/N)
* Ask for confirmation (Y/N)
*
*
        LDX #UXMSG4
        LDX #UXMSG4
        LBSR PDATA1
        LBSR PDATA1
UXSUB2  LBSR INTER
UXSUB2  LBSR INTER
        BVS  UXSUB2
        BVS  UXSUB2
        LBSR OUTTER
        LBSR OUTTER
        ANDA #$5F
        ANDA #$5F
        CMPA #'N
        CMPA #'N
        LBEQ UXEXIT
        LBEQ UXEXIT
        CMPA #'Y
        CMPA #'Y
        BNE  UXSUB
        BNE  UXSUB
*
*
* We have confirmation ... now load the disk image
* We have confirmation ... now load the disk image
*
*
        LBSR INITDR
        LBSR INITDR
        LDU  #XSTST
        LDU  #XSTST
        STU  XSTATE
        STU  XSTATE
        LDA  #1
        LDA  #1
        STA  BLKNUM
        STA  BLKNUM
*
*
* Sector1
* Sector1
*
*
        LDX  #BUFFER
        LDX  #BUFFER
*
*
        CLRA         TRACK 0
        CLRA         TRACK 0
        LDB  #$01    SECTOR 1
        LDB  #$01    SECTOR 1
        STA  TRACK
        STA  TRACK
        STB  SECTOR
        STB  SECTOR
*
*
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
        LBSR XACK
        LBSR XACK
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
*
*
        LDX  #BUFFER
        LDX  #BUFFER
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        LBSR WRITSC
        LBSR WRITSC
        LBSR XACK
        LBSR XACK
*
*
* Sector 2
* Sector 2
*
*
        LDX  #BUFFER
        LDX  #BUFFER
*
*
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        INCB
        INCB
        STA  TRACK
        STA  TRACK
        STB  SECTOR
        STB  SECTOR
*
*
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
        LBSR XACK
        LBSR XACK
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
*
*
        LDX  #BUFFER
        LDX  #BUFFER
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        LBSR WRITSC
        LBSR WRITSC
*
*
        LBSR XACK
        LBSR XACK
*
*
* Sector 3 - SIR
* Sector 3 - SIR
*
*
        LDX  #BUFFER
        LDX  #BUFFER
*
*
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        INCB
        INCB
        STA  TRACK
        STA  TRACK
        STB  SECTOR
        STB  SECTOR
*
*
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
        LBSR XACK
        LBSR XACK
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
*
*
        LDX  #BUFFER
        LDX  #BUFFER
        LDA  38,X
        LDA  38,X
        INCA
        INCA
        STA  MAXTRK
        STA  MAXTRK
        LDB  39,X
        LDB  39,X
        INCB
        INCB
        STB  MAXSEC
        STB  MAXSEC
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        LBSR WRITSC
        LBSR WRITSC
*
*
        LBSR XACK
        LBSR XACK
*
*
* Sector 4 to Last Track & Sector
* Sector 4 to Last Track & Sector
*
*
*
*
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        INCB
        INCB
*
*
UXLOOP  LDX  #BUFFER
UXLOOP  LDX  #BUFFER
        STA  TRACK
        STA  TRACK
        STB  SECTOR
        STB  SECTOR
*
*
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
        LBSR XACK
        LBSR XACK
        LBSR XREAD
        LBSR XREAD
        LBCS UXERR
        LBCS UXERR
*
*
        LDX  #BUFFER
        LDX  #BUFFER
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        LBSR WRITSC
        LBSR WRITSC
        LBSR XACK
        LBSR XACK
*
*
        LDA  TRACK
        LDA  TRACK
        LDB  SECTOR
        LDB  SECTOR
        INCB
        INCB
        CMPB MAXSEC
        CMPB MAXSEC
        BNE  UXLOOP
        BNE  UXLOOP
        LDB  #1
        LDB  #1
        INCA
        INCA
        CMPA MAXTRK
        CMPA MAXTRK
        BNE  UXLOOP
        BNE  UXLOOP
*
*
*
*
*  Write Boot sector
*  Write Boot sector
*
*
        LDX  #$C000
        LDX  #$C000
        CLRA         TRACK 0
        CLRA         TRACK 0
        LDB  #$01    SECTOR 1
        LDB  #$01    SECTOR 1
        STA  TRACK
        STA  TRACK
        STB  SECTOR
        STB  SECTOR
        LBSR WRITSC
        LBSR WRITSC
*
*
UXEXIT  LDX  #UXMES1
UXEXIT  LDX  #UXMES1
        JMP  PDATA1
        JMP  PDATA1
*
*
UXERR   LDX  #UXMES2
UXERR   LDX  #UXMES2
        LBRA PDATA1
        LBRA PDATA1
*
*
* Get a Byte using XModem protocol
* Get a Byte using XModem protocol
* Carry clear => no errors
* Carry clear => no errors
* Carry set   => errors
* Carry set   => errors
*
*
XREAD   PSHS U
XREAD   PSHS U
        LDU  XSTATE
        LDU  XSTATE
*
*
XBYTE0  LBSR INTER
XBYTE0  LBSR INTER
        BVC  XBYTE1
        BVC  XBYTE1
        LDA  #NAK
        LDA  #NAK
        LBSR OUTTER
        LBSR OUTTER
        LDU  #XSTST
        LDU  #XSTST
        BRA  XBYTE0
        BRA  XBYTE0
*
*
XBYTE1  JSR  ,U
XBYTE1  JSR  ,U
        BNE  XBYTE0
        BNE  XBYTE0
        STU  XSTATE
        STU  XSTATE
        PULS U,PC
        PULS U,PC
*
*
* START - LOOK FOR SOH (START OF HEADER) = $01
* START - LOOK FOR SOH (START OF HEADER) = $01
*
*
XSTST   CMPA #SOH
XSTST   CMPA #SOH
        BNE  XSTST1
        BNE  XSTST1
        LDU  #XSTBL
        LDU  #XSTBL
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
        RTS
        RTS
*
*
XSTST1  CMPA #EOT
XSTST1  CMPA #EOT
        BNE  XSTST2
        BNE  XSTST2
        LDA  #ACK
        LDA  #ACK
        LBSR OUTTER
        LBSR OUTTER
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
        RTS
        RTS
*
*
XSTST2  CMPA #CAN
XSTST2  CMPA #CAN
        BNE  XSTST3
        BNE  XSTST3
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
        RTS
        RTS
*
*
XSTST3  ANDCC #$FF-CFLAG-ZFLAG
XSTST3  ANDCC #$FF-CFLAG-ZFLAG
        RTS
        RTS
*
*
* Got SOH
* Got SOH
* Now get block number
* Now get block number
*
*
XSTBL   CMPA BLKNUM
XSTBL   CMPA BLKNUM
        BNE  XSTBLE
        BNE  XSTBLE
        LDU  #XSTCOM
        LDU  #XSTCOM
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
        RTS
        RTS
*
*
* Error in block number
* Error in block number
*
*
XSTBLE  LDA  #NAK
XSTBLE  LDA  #NAK
        LBSR OUTTER
        LBSR OUTTER
        LDU  #XSTST
        LDU  #XSTST
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
        RTS
        RTS
*
*
* Get complement of block number
* Get complement of block number
*
*
XSTCOM  COMA
XSTCOM  COMA
        CMPA BLKNUM
        CMPA BLKNUM
        BNE  XSTBLE
        BNE  XSTBLE
        CLR  CHKSUM
        CLR  CHKSUM
        LDA  #128
        LDA  #128
        STA  BYTCNT
        STA  BYTCNT
        LDU  #XSTDA
        LDU  #XSTDA
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
        RTS
        RTS
*
*
* Get data bytes
* Get data bytes
*
*
XSTDA   PSHS A
XSTDA   PSHS A
        ADDA CHKSUM
        ADDA CHKSUM
        STA  CHKSUM
        STA  CHKSUM
        PULS A
        PULS A
        DEC  BYTCNT
        DEC  BYTCNT
        BNE  XSTDA1
        BNE  XSTDA1
        LDU  #XSTCK
        LDU  #XSTCK
XSTDA1  STA  ,X+
XSTDA1  STA  ,X+
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
        RTS
        RTS
*
*
* Byte count reached zero
* Byte count reached zero
* Check checksum byte
* Check checksum byte
*
*
XSTCK   CMPA CHKSUM
XSTCK   CMPA CHKSUM
        BNE  XSTCK1 retry if wrong checksum
        BNE  XSTCK1 retry if wrong checksum
*
*
* Checksum OK ...
* Checksum OK ...
* increment block number
* increment block number
* Don't send ACK until data written to CF
* Don't send ACK until data written to CF
*
*
        INC  BLKNUM
        INC  BLKNUM
        LDU  #XSTST
        LDU  #XSTST
        ANDCC #$FF-CFLAG No abort
        ANDCC #$FF-CFLAG No abort
        ORCC #ZFLAG      Valid data (exit)
        ORCC #ZFLAG      Valid data (exit)
        RTS
        RTS
*
*
* Checksum Error detected ...
* Checksum Error detected ...
* Reset Sector counter in ACCB to last 128 byte boundary
* Reset Sector counter in ACCB to last 128 byte boundary
* and send NAK
* and send NAK
*
*
XSTCK1  PSHS B
XSTCK1  PSHS B
        TFR  X,D
        TFR  X,D
        DECB
        DECB
        ANDB #128
        ANDB #128
        TFR  D,X
        TFR  D,X
        PULS B
        PULS B
        LDA  #NAK
        LDA  #NAK
XSTCK2  LBSR OUTTER
XSTCK2  LBSR OUTTER
        LDU  #XSTST
        LDU  #XSTST
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
        RTS
        RTS
*
*
* Acknowledge Data Received
* Acknowledge Data Received
*
*
XACK    PSHS A
XACK    PSHS A
        LDA  #ACK
        LDA  #ACK
        LBSR OUTTER
        LBSR OUTTER
        PULS A,PC
        PULS A,PC
*
*
*
*
** FLEX 9 COMPACT FLASH DISK DRIVERS
** FLEX 9 COMPACT FLASH DISK DRIVERS
*
*
* FOR SYS09BUG 1.2 ON THE BURCHED B5-X300
* FOR SYS09BUG 1.2 ON THE BURCHED B5-X300
* WITH I/O MAPPED AT $XE000
* WITH I/O MAPPED AT $XE000
* AND ROM MAPPED AT $XF000
* AND ROM MAPPED AT $XF000
* THE BURCHED B5-X300 HAS 256KBYTES OF SRAM
* THE BURCHED B5-X300 HAS 256KBYTES OF SRAM
* THE FIRST 64K IS USED BY FLEX,
* THE FIRST 64K IS USED BY FLEX,
* THE SECOND 192K MAY BE USED AS A RAM DISK
* THE SECOND 192K MAY BE USED AS A RAM DISK
*
*
*
*
IMASK  EQU $10     IRQ MASK CC
IMASK  EQU $10     IRQ MASK CC
FMASK  EQU $40     FIRQ MASK CC
FMASK  EQU $40     FIRQ MASK CC
DATREG EQU $FFF0   DAT REGISTERS
DATREG EQU $FFF0   DAT REGISTERS
*
*
CF_BASE    EQU $E040
CF_BASE    EQU $E040
CF_DATA    EQU CF_BASE+0
CF_DATA    EQU CF_BASE+0
CF_ERROR   EQU CF_BASE+1 ; read error
CF_ERROR   EQU CF_BASE+1 ; read error
CF_FEATURE EQU CF_BASE+1 ; write feature
CF_FEATURE EQU CF_BASE+1 ; write feature
CF_SCNT    EQU CF_BASE+2
CF_SCNT    EQU CF_BASE+2
CF_SNUM    EQU CF_BASE+3
CF_SNUM    EQU CF_BASE+3
CF_CLO     EQU CF_BASE+4
CF_CLO     EQU CF_BASE+4
CF_CHI     EQU CF_BASE+5
CF_CHI     EQU CF_BASE+5
CF_HEAD    EQU CF_BASE+6
CF_HEAD    EQU CF_BASE+6
CF_STATUS  EQU CF_BASE+7 ; read status
CF_STATUS  EQU CF_BASE+7 ; read status
CF_COMAND  EQU CF_BASE+7 ; write command
CF_COMAND  EQU CF_BASE+7 ; write command
*
*
* Command Equates
* Command Equates
*
*
CMDREAD    EQU $20 ; Read Single sector
CMDREAD    EQU $20 ; Read Single sector
CMDWRITE   EQU $30 ; Write Single sector
CMDWRITE   EQU $30 ; Write Single sector
CMDFEATURE EQU $EF
CMDFEATURE EQU $EF
FEAT8BIT   EQU $01 ; enable 8 bit transfers
FEAT8BIT   EQU $01 ; enable 8 bit transfers
HEADLBA    EQU $E0
HEADLBA    EQU $E0
*
*
* Status bit equates
* Status bit equates
*
*
BSY        EQU $80
BSY        EQU $80
DRDY       EQU $40
DRDY       EQU $40
DRQ        EQU $08
DRQ        EQU $08
ERR        EQU $01
ERR        EQU $01
*
*
*
*
* INITIALIZE CF CARD FOR 8 BIT LBA MODE
* INITIALIZE CF CARD FOR 8 BIT LBA MODE
*
*
INITDR BSR WAITRDY
INITDR BSR WAITRDY
       LDA  #HEADLBA
       LDA  #HEADLBA
       STA  CF_HEAD
       STA  CF_HEAD
       LDA #FEAT8BIT
       LDA #FEAT8BIT
       STA CF_FEATURE
       STA CF_FEATURE
       LDA #CMDFEATURE
       LDA #CMDFEATURE
       STA CF_COMAND
       STA CF_COMAND
       BRA WAITRDY
       BRA WAITRDY
*
*
* Seek track and sector
* Seek track and sector
* A holds track number (0 - ??)
* A holds track number (0 - ??)
* B holds sector number (1 - ??)
* B holds sector number (1 - ??)
* Sector numbers starts from 1
* Sector numbers starts from 1
* subtract 1 to start from sector 0 on CF
* subtract 1 to start from sector 0 on CF
*
*
SEEKTS DECB
SEEKTS DECB
       STB  CF_SNUM
       STB  CF_SNUM
       STA  CF_CLO
       STA  CF_CLO
       LDB  DRVNUM
       LDB  DRVNUM
       STB  CF_CHI
       STB  CF_CHI
       LDB  #$01
       LDB  #$01
       STB  CF_SCNT
       STB  CF_SCNT
       CLRB
       CLRB
       RTS
       RTS
*
*
* READ SECTORS FROM CF
* READ SECTORS FROM CF
*
*
*
*
READSC BSR  SEEKTS
READSC BSR  SEEKTS
       LDA  #CMDREAD ; IDE READ MULTIPLE
       LDA  #CMDREAD ; IDE READ MULTIPLE
       STA  CF_COMAND
       STA  CF_COMAND
       BSR  WAITRDY
       BSR  WAITRDY
*
*
* READ LOOP
* READ LOOP
*
*
       CLRB
       CLRB
RDLP1  BSR  WAITDRQ
RDLP1  BSR  WAITDRQ
       LDA  CF_DATA
       LDA  CF_DATA
       STA  ,X+
       STA  ,X+
       DECB
       DECB
       BNE  RDLP1
       BNE  RDLP1
*
*
       CLRB
       CLRB
RDLP2  BSR  WAITDRQ
RDLP2  BSR  WAITDRQ
       LDA  CF_DATA
       LDA  CF_DATA
       DECB
       DECB
       BNE  RDLP2
       BNE  RDLP2
*
*
       BSR  WAITRDY
       BSR  WAITRDY
       CLRB
       CLRB
       RTS
       RTS
*
*
* WRITE SECTOR TO CF
* WRITE SECTOR TO CF
*
*
WRITSC BSR  SEEKTS   ; SEEK TRACK & SECTOR
WRITSC BSR  SEEKTS   ; SEEK TRACK & SECTOR
       LDA  #CMDWRITE ; IDE WRITE MULTIPLE
       LDA  #CMDWRITE ; IDE WRITE MULTIPLE
       STA  CF_COMAND
       STA  CF_COMAND
       BSR  WAITRDY
       BSR  WAITRDY
*
*
* WRITE LOOP
* WRITE LOOP
*
*
       CLRB
       CLRB
WRTLP1 BSR  WAITDRQ
WRTLP1 BSR  WAITDRQ
       LDA  ,X+
       LDA  ,X+
       STA  CF_DATA
       STA  CF_DATA
       DECB
       DECB
       BNE  WRTLP1
       BNE  WRTLP1
*
*
       CLRB
       CLRB
WRTLP2 BSR  WAITDRQ
WRTLP2 BSR  WAITDRQ
       CLRA
       CLRA
       STA  CF_DATA
       STA  CF_DATA
       DECB
       DECB
       BNE WRTLP2
       BNE WRTLP2
*
*
       BSR  WAITRDY
       BSR  WAITRDY
       CLRB
       CLRB
       RTS
       RTS
*
*
* CHECK FOR BUSY
* CHECK FOR BUSY
* Doubles as VERIFY
* Doubles as VERIFY
*
*
BUSY   CLRB            Never busy
BUSY   CLRB            Never busy
       RTS
       RTS
*
*
* DRIVE SELECT DISK DRIVER
* DRIVE SELECT DISK DRIVER
*
*
DRVSEL LDA   3,X       GET DRIVE # FROM FCB
DRVSEL LDA   3,X       GET DRIVE # FROM FCB
       CMPA  #3
       CMPA  #3
       BLS   DRVS2     IF > 3, SET IT TO 0
       BLS   DRVS2     IF > 3, SET IT TO 0
       CLRA
       CLRA
DRVS2  STA   DRVNUM
DRVS2  STA   DRVNUM
       CLRB            ; SET Z, CLEAR C
       CLRB            ; SET Z, CLEAR C
       RTS
       RTS
*
*
* CHECK DRIVE READY DISK DRIVER
* CHECK DRIVE READY DISK DRIVER
*
*
CHKDRV LDA  3,X
CHKDRV LDA  3,X
       CLRB             ; CLEAR C, SET Z
       CLRB             ; CLEAR C, SET Z
       RTS
       RTS
*
*
* WAIT UNTIL READY
* WAIT UNTIL READY
*
*
WAITRDY LDA  CF_STATUS
WAITRDY LDA  CF_STATUS
        BITA #BSY
        BITA #BSY
        BNE  WAITRDY
        BNE  WAITRDY
        LDA  CF_STATUS
        LDA  CF_STATUS
        BITA #DRDY
        BITA #DRDY
        BEQ  WAITRDY
        BEQ  WAITRDY
        RTS
        RTS
*
*
* WAIT FOR DATA REQUEST
* WAIT FOR DATA REQUEST
*
*
WAITDRQ LDA  CF_STATUS
WAITDRQ LDA  CF_STATUS
        BITA #DRQ
        BITA #DRQ
        BEQ  WAITDRQ
        BEQ  WAITDRQ
        RTS
        RTS
*
*
*******************************************************
*******************************************************
*
*
* Bootstrap FLEX Loader
* Bootstrap FLEX Loader
*
*
* SBUG1.8 loads the bootstap loader at $C000
* SBUG1.8 loads the bootstap loader at $C000
* however the Flex adaption manual has the
* however the Flex adaption manual has the
* bootstrap loader residing at $C100
* bootstrap loader residing at $C100
*
*
******************************************************
******************************************************
*
*
* Equates
* Equates
*
*
STACK   EQU $C0FF
STACK   EQU $C0FF
SCTBUF  EQU $C300
SCTBUF  EQU $C300
*
*
* Start of Utility
* Start of Utility
*
*
        ORG $C000
        ORG $C000
BOOT    BRA LOAD0
BOOT    BRA LOAD0
        FCB 0,0,0
        FCB 0,0,0
TRK     FCB 0        File start track
TRK     FCB 0        File start track
SCT     FCB 0        File start sector
SCT     FCB 0        File start sector
DNS     FCB 0        Density Flag (not used)
DNS     FCB 0        Density Flag (not used)
TADR    FDB $C000    Transfer address
TADR    FDB $C000    Transfer address
LADR    FDB 0        Load Address
LADR    FDB 0        Load Address
DRNUM   FCB 0        Drive number 0
DRNUM   FCB 0        Drive number 0
*
*
LOAD0   LDS  #STACK   Set up stack
LOAD0   LDS  #STACK   Set up stack
        LDD  TRK      Set up start track and sector
        LDD  TRK      Set up start track and sector
        STD  SCTBUF
        STD  SCTBUF
        LDY  #SCTBUF+256
        LDY  #SCTBUF+256
*
*
* Perform actual file load
* Perform actual file load
*
*
LOAD1   BSR GETCH    Get acharcater
LOAD1   BSR GETCH    Get acharcater
        CMPA #$02    Data record hearder ?
        CMPA #$02    Data record hearder ?
        BEQ  LOAD2   Skip, is so
        BEQ  LOAD2   Skip, is so
        CMPA #$16    Xfr address hearder ?
        CMPA #$16    Xfr address hearder ?
        BNE LOAD1    Loop if neither
        BNE LOAD1    Loop if neither
*
*
* Get transfer address
* Get transfer address
*
*
        BSR  GETCH
        BSR  GETCH
        STA  TADR
        STA  TADR
        BSR  GETCH
        BSR  GETCH
        STA  TADR+1
        STA  TADR+1
        BRA  LOAD1
        BRA  LOAD1
*
*
* Load data record
* Load data record
*
*
LOAD2  BSR  GETCH  Get load address
LOAD2  BSR  GETCH  Get load address
       STA  LADR
       STA  LADR
       BSR  GETCH
       BSR  GETCH
       STA  LADR+1
       STA  LADR+1
       BSR  GETCH  Get Bytes count
       BSR  GETCH  Get Bytes count
       TFR  A,B
       TFR  A,B
       TSTB
       TSTB
       BEQ  LOAD1 Loop if count = 0
       BEQ  LOAD1 Loop if count = 0
       LDX  LADR  Get load address
       LDX  LADR  Get load address
LOAD3  PSHS B,X
LOAD3  PSHS B,X
       BSR  GETCH  Get data character
       BSR  GETCH  Get data character
       PULS B,X
       PULS B,X
       STA  ,X+    Store at load address
       STA  ,X+    Store at load address
       DECB
       DECB
       BNE  LOAD3  Loop until count = 0
       BNE  LOAD3  Loop until count = 0
       BRA  LOAD1
       BRA  LOAD1
*
*
* Get Character routine
* Get Character routine
* Reads a sector if needed
* Reads a sector if needed
*
*
GETCH  CMPY #SCTBUF+256 out of data ?
GETCH  CMPY #SCTBUF+256 out of data ?
       BNE  GETCH4      Go read Character if not
       BNE  GETCH4      Go read Character if not
GETCH2 LDX  #SCTBUF     Point to buffer
GETCH2 LDX  #SCTBUF     Point to buffer
       LDD  0,X         Get forward Link
       LDD  0,X         Get forward Link
       BEQ  GO          if zero, file is loaded
       BEQ  GO          if zero, file is loaded
       BSR  READ        Read next sector
       BSR  READ        Read next sector
       BNE  BOOT        start over if error
       BNE  BOOT        start over if error
       LDY  #SCTBUF+4   Point past link
       LDY  #SCTBUF+4   Point past link
GETCH4 LDA  ,Y+         Else, get a character
GETCH4 LDA  ,Y+         Else, get a character
       RTS
       RTS
*
*
* File is loaded, Jump to it
* File is loaded, Jump to it
*
*
GO     JMP  [TADR]      Jump to transfer address
GO     JMP  [TADR]      Jump to transfer address
*
*
** FLEX 9 COMPACT FLASH DISK DRIVERS
** FLEX 9 COMPACT FLASH DISK DRIVERS
*
*
* FOR SYS09BUG 1.2 ON THE BURCHED B5-X300
* FOR SYS09BUG 1.2 ON THE BURCHED B5-X300
* WITH I/O MAPPED AT $XE000
* WITH I/O MAPPED AT $XE000
* AND ROM MAPPED AT $XF000
* AND ROM MAPPED AT $XF000
* THE BURCHED B5-X300 HAS 256KBYTES OF SRAM
* THE BURCHED B5-X300 HAS 256KBYTES OF SRAM
* THE FIRST 64K IS USED BY FLEX,
* THE FIRST 64K IS USED BY FLEX,
* THE SECOND 192K MAY BE USED AS A RAM DISK
* THE SECOND 192K MAY BE USED AS A RAM DISK
*
*
*
*
*IMASK  EQU $10     IRQ MASK CC
*IMASK  EQU $10     IRQ MASK CC
*FMASK  EQU $40     FIRQ MASK CC
*FMASK  EQU $40     FIRQ MASK CC
*DATREG EQU $FFF0   DAT REGISTERS
*DATREG EQU $FFF0   DAT REGISTERS
*
*
*CF_BASE    EQU $E040
*CF_BASE    EQU $E040
*CF_DATA    EQU CF_BASE+0
*CF_DATA    EQU CF_BASE+0
*CF_ERROR   EQU CF_BASE+1 ; read error
*CF_ERROR   EQU CF_BASE+1 ; read error
*CF_FEATURE EQU CF_BASE+1 ; write feature
*CF_FEATURE EQU CF_BASE+1 ; write feature
*CF_SCNT  EQU CF_BASE+2
*CF_SCNT  EQU CF_BASE+2
*CF_SNUM  EQU CF_BASE+3
*CF_SNUM  EQU CF_BASE+3
*CF_CLO   EQU CF_BASE+4
*CF_CLO   EQU CF_BASE+4
*CF_CHI   EQU CF_BASE+5
*CF_CHI   EQU CF_BASE+5
*CF_HEAD    EQU CF_BASE+6
*CF_HEAD    EQU CF_BASE+6
*CF_STATUS  EQU CF_BASE+7 ; read status
*CF_STATUS  EQU CF_BASE+7 ; read status
*CF_COMAND  EQU CF_BASE+7 ; write command
*CF_COMAND  EQU CF_BASE+7 ; write command
*
*
* Command Equates
* Command Equates
*
*
*CMDREAD    EQU $20 ; Read Single sector
*CMDREAD    EQU $20 ; Read Single sector
*CMDWRITE   EQU $30 ; Write Single sector
*CMDWRITE   EQU $30 ; Write Single sector
*CMDFEATURE EQU $EF
*CMDFEATURE EQU $EF
*FEAT8BIT   EQU $01 ; enable 8 bit transfers
*FEAT8BIT   EQU $01 ; enable 8 bit transfers
*HEADLBA    EQU $E0
*HEADLBA    EQU $E0
*
*
* Status bit equates
* Status bit equates
*
*
*BSY        EQU $80
*BSY        EQU $80
*DRDY       EQU $40
*DRDY       EQU $40
*DRQ        EQU $08
*DRQ        EQU $08
*ERR        EQU $01
*ERR        EQU $01
*
*
* Seek track and sector
* Seek track and sector
* A holds track number (0 - ??)
* A holds track number (0 - ??)
* B holds sector number (1 - ??)
* B holds sector number (1 - ??)
* Sector numbers starts from 1
* Sector numbers starts from 1
* subtract 1 to start from sector 0 on CF
* subtract 1 to start from sector 0 on CF
*
*
SEEK   DECB
SEEK   DECB
       STB  CF_SNUM
       STB  CF_SNUM
       STA  CF_CLO
       STA  CF_CLO
       LDB  DRNUM
       LDB  DRNUM
       STB  CF_CHI
       STB  CF_CHI
       LDB  #$01
       LDB  #$01
       STB  CF_SCNT
       STB  CF_SCNT
       CLRB
       CLRB
       RTS
       RTS
*
*
* READ SECTORS FROM CF
* READ SECTORS FROM CF
*
*
*
*
READ   BSR  SEEK
READ   BSR  SEEK
       LDA  #CMDREAD ; IDE READ MULTIPLE
       LDA  #CMDREAD ; IDE READ MULTIPLE
       STA  CF_COMAND
       STA  CF_COMAND
       BSR  WTRDY
       BSR  WTRDY
*
*
* READ LOOP
* READ LOOP
*
*
       CLRB
       CLRB
READ1  BSR  WTDRQ
READ1  BSR  WTDRQ
       LDA  CF_DATA
       LDA  CF_DATA
       STA  ,X+
       STA  ,X+
       DECB
       DECB
       BNE  READ1
       BNE  READ1
*
*
       CLRB
       CLRB
READ2  BSR  WTDRQ
READ2  BSR  WTDRQ
       LDA  CF_DATA
       LDA  CF_DATA
       DECB
       DECB
       BNE  READ2
       BNE  READ2
*
*
       BSR  WTRDY
       BSR  WTRDY
       CLRB
       CLRB
       RTS
       RTS
*
*
* WAIT UNTIL READY
* WAIT UNTIL READY
*
*
WTRDY   LDA  CF_STATUS
WTRDY   LDA  CF_STATUS
        BITA #BSY
        BITA #BSY
        BNE  WTRDY
        BNE  WTRDY
        LDA  CF_STATUS
        LDA  CF_STATUS
        BITA #DRDY
        BITA #DRDY
        BEQ  WTRDY
        BEQ  WTRDY
        RTS
        RTS
*
*
* WAIT FOR DATA REQUEST
* WAIT FOR DATA REQUEST
*
*
WTDRQ   LDA  CF_STATUS
WTDRQ   LDA  CF_STATUS
        BITA #DRQ
        BITA #DRQ
        BEQ  WTDRQ
        BEQ  WTDRQ
        RTS
        RTS
*
*
       END START
       END START
 
 

powered by: WebSVN 2.1.0

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