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

Subversion Repositories System09

[/] [System09/] [branches/] [mkfiles_rev1/] [src/] [Flex9/] [f9-dkide.asm] - Blame information for rev 95

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 davidgb
*
2
** FLEX 9 COMPACT FLASH / IDE DISK DRIVERS
3
*
4
* FOR SYS09BUG ON THE XESS XSA-3S1000 & XST3.0
5
* WITH I/O MAPPED AT $XE000
6
* AND ROM MAPPED AT $XF000
7
*
8
* These drivers should work with either
9
* an IDE disk drive or a IDE CF adapter card
10
* It uses 16 bit transfer mode,
11
* as some IDE drives do not support
12
* the set feature command found on CF cards
13
* that allows for 8 bit operation
14
*
15
*
16
IMASK  EQU $10     IRQ MASK CC
17
FMASK  EQU $40     FIRQ MASK CC
18
*
19
CF_BASE    EQU $E100
20
CF_DATA    EQU CF_BASE+0
21
CF_ERROR   EQU CF_BASE+2 ; read error
22
CF_FEATURE EQU CF_BASE+2 ; write feature
23
CF_SECCNT  EQU CF_BASE+4
24
CF_SECNUM  EQU CF_BASE+6
25
CF_CYLLO   EQU CF_BASE+8
26
CF_CYLHI   EQU CF_BASE+10
27
CF_HEAD    EQU CF_BASE+12
28
CF_STATUS  EQU CF_BASE+14 ; read status
29
CF_COMAND  EQU CF_BASE+14 ; write command
30
CF_AUX     EQU CF_BASE+30 ; Reset register
31
*
32
* Command Equates
33
*
34
CMDREAD    EQU $20 ; Read Single sector
35
CMDWRITE   EQU $30 ; Write Single sector
36
AUXRESET   EQU $06
37
AUXRSTREL  EQU $02
38
HEADLBA    EQU $E0
39
*
40
* Status bit equates
41
*
42
BSY        EQU $80
43
DRDY       EQU $40
44
DRQ        EQU $08
45
ERR        EQU $01
46
       ORG   $DE00
47
*
48
* DISK DRIVER JUMP TABLE
49
*
50
READ   JMP   READSC
51
WRITE  JMP   WRITSC
52
VERIFY JMP   BUSY
53
RESTOR JMP   RESTR1
54
DRIVE  JMP   DRVSEL
55
DRVRDY JMP   CHKDRV
56
QUICK  JMP   CHKDRV
57
COLDDR JMP   INITDR
58
WARMDR JMP   WARMD1
59
SEEK   JMP   SEEKTS
60
*
61
* RAM SPACE
62
*
63
DRVNUM FCB   0
64
*
65
*
66
* INITIALIZE CF CARD
67
*
68
INITDR LDD #AUXRESET
69
       STD CF_AUX
70
       LDD #AUXRSTREL
71
       STD CF_AUX
72
       LDD  #HEADLBA
73
       STD  CF_HEAD
74
       BRA WAITRDY
75
*
76
* RESTORE DISK DRIVER (SEEK TRACK 00)
77
*
78
RESTR1 BSR   DRVSEL
79
       CLRA           ; Track 0
80
       LDB   #$01     ; Sector 1
81
*
82
* Seek track and sector
83
* A holds track number (0 - ??)
84
* B holds sector number (1 - ??)
85
* Sector numbers starts from 1
86
* subtract 1 to start from sector 0 on CF
87
*
88
SEEKTS DECB
89
       PSHS A
90
       CLRA
91
       STD  CF_SECNUM
92
       LDB ,S
93
       STD  CF_CYLLO
94
       LDB  DRVNUM
95
       STD  CF_CYLHI
96
       LDB  #$01
97
       STD  CF_SECCNT
98
       PULS A
99
       CLRB
100
WARMD1 RTS
101
*
102
* READ SECTORS FROM CF
103
*
104
*
105
READSC BSR  SEEKTS
106
       LDD  #CMDREAD ; IDE READ MULTIPLE
107
       STD  CF_COMAND
108
       BSR  WAITRDY
109
*
110
* READ LOOP
111
*
112
       PSHS Y
113
       LDY  #256
114
RDLP1  BSR  WAITDRQ
115
       LDD  CF_DATA
116
       STB  ,X+
117
       LEAY -1,Y
118
       BNE  RDLP1
119
       PULS Y
120
*
121
       BSR  WAITRDY
122
       CLRB
123
       RTS
124
*
125
* WRITE SECTOR TO CF
126
*
127
WRITSC BSR  SEEKTS   ; SEEK TRACK & SECTOR
128
       LDD  #CMDWRITE; IDE WRITE MULTIPLE
129
       STD  CF_COMAND
130
       BSR  WAITRDY
131
*
132
* WRITE LOOP
133
*
134
       PSHS Y
135
       LDY #256
136
       CLRA
137
WRTLP1 BSR  WAITDRQ
138
       LDB  ,X+
139
       STD  CF_DATA
140
       LEAY -1,Y
141
       BNE  WRTLP1
142
       PULS Y
143
*
144
       BSR  WAITRDY
145
       CLRB
146
       RTS
147
*
148
* CHECK FOR BUSY
149
* Doubles as VERIFY
150
*
151
BUSY   CLRB            Never busy
152
       RTS
153
*
154
* DRIVE SELECT DISK DRIVER
155
*
156
DRVSEL LDA   3,X       GET DRIVE # FROM FCB
157
       CMPA  #3
158
       BLS   DRVS2     IF > 3, SET IT TO 0
159
       CLRA
160
DRVS2  STA   DRVNUM
161
       CLRB            ; SET Z, CLEAR C
162
       RTS
163
*
164
* CHECK DRIVE READY DISK DRIVER
165
*
166
CHKDRV LDA  3,X
167
       CLRB             ; CLEAR C, SET Z
168
       RTS
169
*
170
* WAIT UNTIL READY
171
*
172
WAITRDY LDD  CF_STATUS
173
        BITB #BSY
174
        BNE  WAITRDY
175
        LDD  CF_STATUS
176
        BITB #DRDY
177
        BEQ  WAITRDY
178
        RTS
179
*
180
* WAIT FOR DATA REQUEST
181
*
182
WAITDRQ LDD  CF_STATUS
183
        BITB #DRQ
184
        BEQ  WAITDRQ
185
        RTS
186
*
187
        END
188
 

powered by: WebSVN 2.1.0

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