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

Subversion Repositories System09

[/] [System09/] [rev_86/] [src/] [Flex9/] [f9-dkfdc.asm] - Blame information for rev 200

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

Line No. Rev Author Line
1 59 davidgb
*
2
** FLEX 9 DISK DRIVERS
3
** FOR SINGLE/DOUBLE SIDED 5" DRIVES ONLY.
4
** USING FD1771.
5
** SIDES MAY BE TREATED AS SEPERATE DISKS.
6
**
7
** BY J.E.KENT   1 JAN 1982
8
*
9
*
10
** F.D. CONTROLLER
11
*
12
DRVREG EQU   $E014
13
MOTOR  EQU   %10000000
14
SIDESL EQU   %01000000
15
DRIVSL EQU   %00000001
16
CMDREG EQU   $E018
17
TRKREG EQU   $E019
18
SECREG EQU   $E01A
19
DATREG EQU   $E01B
20
*
21
** FD1771 DISK CONTROLLER INSTRUCTIONS
22
*
23
** TYPE I INSTRUCTIONS:
24
*
25
IREST EQU $00 RESTORE (SEEK TRACK 0)
26
ISEEK EQU $10 SEEK TRACK
27
ISTEP EQU $20 STEP ONE TRACK (IN/OUT)
28
ISTIN EQU $40 STEP IN ONE TRACK
29
ISTOUT EQU $60 STEP OUT ONE TRACK
30
*
31
** BIT FIELDS FOR TYPE I INSTRUCTIONS
32
*
33
SMR6 EQU $00 6MSEC STEPPING RATE
34
SMR12 EQU $01 12 MSEC STEPPING RATE
35
SMR20 EQU $02 20 MSEC
36
SMR40 EQU $03 40 MSEC
37
*
38
BVERIF EQU $04 VERIFY BIT (1=ON)
39
BHDLD EQU $08 HEAD LOAD (1=LOAD HEAD AT BEGINING)
40
BUPDAT EQU $10 UPDATE TRACK REGISTER (1=TRUE)
41
*
42
** TYPE II INSTRUCTIONS
43
*
44
IREAD EQU $80 READ SECTOR
45
IWRITE EQU $A0 WRITE SECTOR
46
*
47
** BIT FIELD FOR TYPE II
48
*
49
BDAMFB EQU $00 $FB DATA ADDRESS MARK
50
BDAMFA EQU $01 $FA DATA ADDREES MARK
51
BDAMF9 EQU $02 $F9 DATA ADDRESS MARK
52
BDAMF8 EQU $03 $F8 DATA ADDRESS MARK
53
BEHLD EQU $04 ENABLE HLD & 10 MSEC DELAY (1=ACTIVE)
54
BBLEN EQU $08 BLOCK LENGTH (1=IBM FORMAT 128 - 1024 BYTES)
55
BMREC EQU $10 MULTIPLE RECORD (0=SINGLE, 1=MULTIPLE)
56
*
57
** TYPE III INSTRUCTIONS
58
*
59
IRDADD EQU $C4 READ ADDRESS
60
IRDTRK EQU $E4 READ TRACK
61
IWRTRK EQU $F4 WRITE TRACK
62
*
63
** BIT FIELD TYPE III (READ TRACK ONLY)
64
*
65
BSYNC EQU $01 SYNCRONIZE FLAG (0=SYNC TO AM)
66
*
67
** TYPE IV NSTRUCTION
68
*
69
IFINTR EQU $D0 FORCE INTERRUPT
70
*
71
** FORCED INTERRUPT BITS (TYPE IV INSTRUCTION)
72
*
73
FI0 EQU $01 NOT READY TO READY TRANSITION
74
FI1 EQU $02 READY TO NOT READY TRANSITION
75
FI2 EQU $04 INDEX PULSE
76
FI3 EQU $08 EVERY 10 MSEC
77
*
78
** DISK DRIVER PATCHES
79
*
80
       ORG   $DE00
81
*
82
** JUMP TABLE TO DISK DRIVERS
83
*
84
READ   JMP   READSC
85
WRITE  JMP   WRITSC
86
VERIFY JMP   VERIF1
87
RESTOR JMP   RESTR1
88
DRIVE  JMP   DRVSEL
89
DRVRDY JMP   CHKDRV
90
QUICK  JMP   CHKDRV
91
COLDDR JMP   INITDR
92
WARMDR JMP   WARMD1
93
SEEK   JMP   SEEK1
94
*
95
** CURRNT DRIVE NUMBER ($DE1E)
96
*
97
CURDRV FCB   $00
98
*
99
** HEAD POSITION TABLE ($DE1F)
100
*
101
TRKTBL FCB   $00       DRIVE 0
102
       FCB   $00       DRIVE 1
103
       FCB   $00       DRIVE 2
104
       FCB   $00       DRIVE 3
105
*
106
** ??? ($DE23)
107
*
108
       FCB 0
109
*
110
** DENSITY TABLE: ($DE24)
111
** HOLDS SECTORS/TRACK FOR DRIVE
112
** 5" SINGLE DENSITY => 10 SECTORS/TRACK
113
*
114
DNSTBL FCB 10,10,10,10 ALL MINIS
115
*
116
** DRIVE & DISK CHARACTERISTICS
117
*
118
* BITS 1,0 STEPPING RATES
119
* BIT  2   TRACKS/DISK (0=40 TRACK, 1=80 TRACK)
120
* BIT  3   TRACKS/DRIVE (0=40 TRACK, 1=80 TRACK)
121
*
122
BDVTPI EQU $08
123
BDKTPI EQU $04
124
DDCTBL EQU *
125
 FCB BDVTPI+BDKTPI+SMR6
126
 FCB BDVTPI+BDKTPI+SMR6
127
 FCB SMR40
128
 FCB SMR40
129
*
130
** DISK DRIVERS
131
*
132
* DRIVER INITIATION
133
*
134
INITDR LDX   #CURDRV
135
       LDB   #5
136
INITD2 CLR   ,X+
137
       DECB
138
       BNE   INITD2
139
WARMD1 RTS
140
*
141
* READ ONE SECTOR
142
*
143
READSC BSR   SEEK1
144
       LDA   #IREAD+BBLEN+BEHLD
145
READ2  ORCC  #$10
146
*      SEI             DISABLE INTERRUPTS
147
       STA   CMDREG
148
       LBSR  DLY47
149
       LDB   #$00
150
RDLOOP LDA   CMDREG
151
       BITA  #$02
152
       BNE   RDBYTE
153
       BITA  #$01
154
       BNE   RDLOOP
155
       TFR   A,B
156
       BRA   RDEXIT
157
*
158
RDBYTE LDA   DATREG
159
       STA   ,X+
160
       DECB
161
       BNE   RDLOOP
162
       BSR   WAIT
163
RDEXIT BITB  #$1C
164
       ANDCC #$EF
165
*      CLI
166
       RTS
167
*
168
** WAIT UNTIL CONTROLLER READY
169
*
170
WAIT   LDB   CMDREG
171
       BITB  #$01
172
       BNE   WAIT
173
       RTS
174
*
175
** SEEK1 TRACK AND SECTOR
176
** ACCA = TRACK NUMBER
177
** ACCB = SECTOR NUMBER
178
*
179
SEEK1  STB   SECREG    SET SECTOR
180
       CMPB  #10       DOUBLE-SIDED ?
181
       BHI   SEEK2     DOUBLE SIDED, FLIP
182
       LDB   CURDRV    BACK SIDE OF DISK ?
183
       CMPB  #1        DRIVE 2-3 BACK SIDE
184
       BHI   SEEK3
185
       ANDB  #$FF-SIDESL SELECT SIDE 0
186
       BRA   SEEK4
187
*
188
SEEK2  LDB   CURDRV   SELECT SIDE 1
189
SEEK3  ANDB  #DRIVSL
190
       ORB   #SIDESL
191
SEEK4  STB   DRVREG
192
*
193
       CMPA  TRKREG    DIFFERENT TO LAST ?
194
       BEQ   FOUND
195
       PSHS A          SAVE TRACK NO. ON STACK
196
*
197
* IF 80 TRACK DRIVE, & 40 TRACK DISK, FIRST SEEK
198
* SHOULD NOT UPDATE TRACK REGISTER NOR VERIFY.
199
*
200
       SUBA TRKREG  CALC. DIFFERENCE
201
       TFR  A,B
202
       PSHS Y
203
*
204
** GET STEPPING RATE FROM TABLE
205
*
206
       LDY  #DDCTBL
207
       LDA  CURDRV
208
       ANDA #$01
209
       LDA  A,Y
210
       PULS Y
211
*
212
** CHECK DRIVE AND DISK TYPE
213
*
214
       BITA #BDVTPI DRIVE TRACK DENSITY = 48 TPI ?
215
       BEQ  SEEKVU  YES, SKIP
216
       BITA #BDKTPI DISK TRACK DENSITY = 96 TPI ?
217
       BNE  SEEKVU  YES, SKIP (DRIVE & DISK MATCH)
218
*
219
** HERE IF 40TRACK DISK IN 80 TRACK DRIVE
220
** USE STEP INSTRUCTIONS TO PREVENT UPDATE OF TRACK REG.
221
*
222
       ANDA #$03    LEAVE STEPPING RATE BITS
223
       TSTB
224
       BPL  STEPIN
225
       NEGB
226
       ORA  #ISTOUT
227
       BRA  STEPLP
228
STEPIN ORA  #ISTIN
229
STEPLP PSHS B
230
       BSR  SEEK5
231
       PULS B
232
       DECB
233
       BNE  STEPLP
234
*
235
** SEEK TRACK WITH VERIFY & UPDATE
236
*
237
SEEKVU ANDA #$03    RETAIN STEPPING RATE
238
       ORA  #ISEEK+BHDLD ($18)
239
       PULS B          RESTORE DEST TRACK NO.
240
       STB   DATREG    YES, SEEK1 NEW TRACK
241
       LBSR  DLY47
242
SEEK5  STA   CMDREG
243
       LBSR  DLY47
244
       BSR   WAIT
245
       BITB  #$10      CHECK FOR SEEK1 ERROR
246
FOUND  JMP   DLY47
247
*
248
** WRITE SECTOR TO DISK
249
*
250
WRITSC BSR   SEEK1
251
       LDA   #IWRITE+BBLEN+BEHLD ($AC)
252
WRITE2 ORCC  #$10
253
*      SEI
254
       STA   CMDREG
255
       LBSR  DLY47
256
       LDB   #$00
257
WRLOOP LDA   CMDREG
258
       BITA  #$02
259
       BNE   WRBYTE
260
       BITA  #$01
261
       BNE   WRLOOP
262
       TFR   A,B
263
       BRA   WREXIT
264
*
265
WRBYTE LDA   ,X+
266
       STA   DATREG
267
       DECB
268
       BNE   WRLOOP
269
       LBSR  WAIT
270
WREXIT BITB  #$5C
271
       ANDCC  #$EF
272
*      CLI
273
       RTS
274
*
275
** VERIFY SECTOR WRITTEN
276
*
277
VERIF1 LDA   #IREAD+BBLEN+BEHLD ($8C)
278
VERIF2 ORCC  #$10
279
*      SEI
280
       STA   CMDREG
281
       LBSR  DLY47
282
       LBSR  WAIT
283
       ANDCC #$EF
284
*      CLI
285
       BITB  #$18
286
       RTS
287
*
288
** SEEK TRACK ZERO
289
*
290
RESTR1 PSHS  X
291
       BSR   DRVSEL
292
       LDX  #DDCTBL
293
       LDA  CURDRV
294
       ANDA #1
295
       LDA  A,X
296
       ANDA #$03
297
       ORA  #IREST+BHDLD
298
       STA   CMDREG
299
       BSR   DLY47
300
       LBSR  WAIT
301
       BITB  #$D8      CHECK FOR ERROR
302
       PULS  X,PC
303
*
304
** SELECT DRIVE
305
** IX -> FCB
306
** ACCA =  NEW DRIVE NUMBER
307
*
308
*  SAVE OLD TRACK NUMBER IN TABLE
309
*  AND SET UP TRACK FOR NEW DRIVE
310
*
311
*
312
DRVSEL LDA   3,X
313
       CMPA  #3
314
       BLS   DRSEL1
315
       LDB   #$0F      SET ERROR VALUE
316
*       SEC
317
       ORCC  #$01
318
       RTS
319
*
320
* SAVE TRACK POSITION OF PREVIOUS DRIVE
321
*
322
DRSEL1 BSR   PNTDRV
323
       LDB   TRKREG
324
       STB   ,X
325
*
326
* SELECT NEW DRIVE
327
*
328
DRSEL3 STA   CURDRV    MAY BE 0 - 3
329
       CMPA  #1
330
       BLS   DRSEL4    ONE DIRECTORY ?
331
       ANDA  #DRIVSL   ROUND OFF
332
       ORA   #SIDESL   SELECT SIDE 1
333
DRSEL4 STA   DRVREG
334
*
335
* RESTORE LAST TRACK POSITION FOR THIS DRIVE
336
*
337
       BSR   PNTDRV
338
       LDA   ,X
339
       STA   TRKREG
340
       BSR   DLY47
341
       BRA   OK
342
*
343
** CHECK IF DRIVE READY
344
*
345
CHKDRV LDA   3,X
346
       CMPA  #3
347
       BLS   OK
348
       LDB   #$80
349
*       SEC
350
       ORCC  #$01
351
       RTS
352
 
353
OK     CLRB
354
*       CLC
355
       ANDCC #$FE
356
       RTS
357
*
358
* POINT TO TRACK TABLE ENTRY FOR THIS DRIVE
359
*
360
PNTDRV LDX   #TRKTBL
361
       LDB   CURDRV
362
       ANDB   #DRIVSL
363
       ABX
364
       RTS
365
*
366
** DELAY ROUTINE
367
*
368
DLY47  LBSR  DLY19
369
DLY19  LBSR  DLY5US
370
DLY5US RTS
371
       END
372
 

powered by: WebSVN 2.1.0

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