1518
|
1 ********************************************************************
|
|
2 * rammer - Nitros-9 level 2 ram disk
|
|
3 *
|
|
4 * $id: rammer.asm,v 1.0 2004/02/06 01:00:00 Gault exp $
|
|
5 *
|
|
6 * Alan Dekok's version of rammer - based on original Keving Darling version
|
|
7 *
|
|
8 * note: Highly modified for use on non-standard Coco systems. RAM not
|
|
9 * taken from 2Meg OS-9 memory!
|
|
10 *
|
|
11 * edt/rev yyyy/mm/dd modified by
|
|
12 * comment
|
|
13 * ------------------------------------------------------------------
|
|
14 * 4 ????/??/?? ???
|
|
15 * original Kevin Darling version.
|
|
16 *
|
|
17 * 5 2000/03/14 L. Curtis Boyle
|
|
18 * several changes
|
|
19 *
|
|
20 * 5r2 2000/05/09 L. Curtis Boyle
|
|
21 * Allowed driver to go past 400k, attempted some fixes for handling /md,
|
|
22 * so that setting vfy=0 on /r0 would not completely crash the system.
|
|
23 * Fixed some error reporting bugs that would crash the system, and
|
|
24 * moved entry table to between read/write to allow short branches to both.
|
|
25 *
|
|
26 * 6r2 2004/2/2 R. Gault
|
|
27 * Highly modified for use with nocan 8/64meg board & emulators.
|
|
28 * The RAM disk uses no OS-9 memory, just memory above 2Meg. The size of
|
|
29 * the drive is by default 6Meg, 14Meg, or 62Meg but can be changed by altering
|
|
30 * the descriptor, r0.
|
|
31
|
|
32 H6309 set 1 0=6809 1=6309
|
|
33 Nocan set 0 0=64Meg Nocan 1=8Meg MESS and Nocan3 2=16Meg Collyer
|
|
34
|
|
35 * Select the correct pair for the system RAM
|
|
36
|
|
37 ifeq Nocan-1
|
|
38 *MaxLSN is $5FFF for 8Meg system use 6Meg RAM disk
|
|
39 MaxMSB set 0
|
|
40 MaxLSW set $5FFF
|
|
41 endc
|
|
42
|
|
43 ifeq Nocan
|
|
44 *MaxLSN is $3DFFF for 64Meg system use 62Meg RAM disk
|
|
45 MaxMSB set 3
|
|
46 MaxLSW set $DFFF
|
|
47 endc
|
|
48
|
|
49 ifeq Nocan-2
|
|
50 *MaxLSN is $DFFF for 16Meg system use 14Meg RAM disk
|
|
51 MaxMSB set 0
|
|
52 MaxLSW set $DFFF
|
|
53 endc
|
|
54
|
|
55 nam rammer
|
|
56 ttl nitros-9 level 2 ram disk
|
|
57
|
|
58 ifp1
|
|
59 use /dd/defs/defsfile
|
|
60 endc
|
|
61
|
|
62 tylg set drivr+objct
|
|
63 atrv set reent+rev
|
|
64 rev set 1
|
|
65 edition set 6
|
|
66
|
|
67 mod eom,name,tylg,atrv,start,size
|
|
68
|
|
69
|
|
70 u0000 rmb drvbeg+drvmem reserve room for 1 entry drive table
|
|
71 ff9b rmb 1
|
|
72 stack rmb 25
|
|
73 size equ .
|
|
74
|
|
75 fcb dir.+share.+pread.+pwrit.+pexec.+read.+write.+exec.
|
|
76
|
|
77 name fcs /Rammer/
|
|
78 fcb edition
|
|
79
|
|
80 start lbra init
|
|
81 lbra read
|
|
82 lbra write
|
|
83 lbra getstat
|
|
84 lbra getstat actually setstat (no calls, so same routine)
|
|
85 lbra term terminate (returns memory)
|
|
86
|
|
87 * terminate routine - deallocates ram
|
|
88 term clrb exit without error
|
|
89 rts
|
|
90
|
|
91 * init routine - only gets called once.
|
|
92 * called if you iniz the device as well
|
|
93 * entry: y=address of device descriptor
|
|
94 * u=device mem area
|
|
95 * note: all of device mem (except v.port) is cleared to 0's
|
|
96 init lda #1
|
|
97 sta v.ndrv,u only can handle 1 drive descriptor
|
|
98 leax drvbeg,u point to start of drive table
|
|
99 lda #$ff
|
|
100 sta ,x set DD.TOT to bad value
|
|
101 sta V.TRAK,x set track to bad value
|
|
102 ifeq Nocan-1
|
|
103 * This may be the wrong place to read this byte. It may be necessary
|
|
104 * to read it prior to each sector read/write if the video bits are
|
|
105 * altered by a user's program.
|
|
106 lda >$9B save default $FF9B image for future use
|
|
107 sta ff9b,u
|
|
108 endc
|
|
109 clrb no error & return
|
|
110 rts
|
|
111
|
|
112 * entry: b:x=lsn to read
|
|
113 * y=path dsc. ptr
|
|
114 * u=device mem ptr
|
|
115 read pshs y,x preserve path & device mem ptrs
|
|
116 bsr ovtest
|
|
117 bcs error
|
|
118 bsr l00c8 calculate mmu block & offset for sector
|
|
119 bsr l00ae transfer sector from ram drive to pd.buf
|
|
120 puls y,x restore ptrs
|
|
121 cmpx #0 sector 0?
|
|
122 bne getstat no, exit without error
|
|
123 ldx pd.buf,y get buffer ptr
|
|
124 leay drvbeg,u point to start of drive table
|
|
125 ifne H6309
|
|
126 ldw #dd.siz copy the info we need into drive table
|
|
127 tfm x+,y+
|
|
128 else
|
|
129 ldb #dd.siz copy the info we need into drive table
|
|
130 readlp lda ,x+
|
|
131 sta ,y+
|
|
132 decb
|
|
133 bne readlp
|
|
134 endc
|
|
135 * getstat/setstat - no calls, just exit w/o error
|
|
136 getstat clrb
|
|
137 rts
|
|
138
|
|
139 error leas 2,s
|
|
140 error2 ldb #247 seek error
|
|
141 rts
|
|
142
|
|
143 ovtest cmpb #MaxMSB prevent access to LSN > than "hardware" supports
|
|
144 bls good
|
|
145 cmpx #MaxLSW
|
|
146 bls good
|
|
147 orcc #1
|
|
148 rts
|
|
149 good andcc #$FE
|
|
150 rts
|
|
151
|
|
152 * entry: b:x = lsn to write
|
|
153 * y=path dsc. ptr
|
|
154 * u=device mem ptr
|
|
155 write equ *
|
|
156 bsr ovtest
|
|
157 bcs error2
|
|
158 bsr l00c8 calculate mmu block & offset for sector
|
|
159 exg x,y x=sector buffer ptr, y=offset within mmu block
|
|
160 * transfer between rbf sector buffer & ram drive image sector buffer
|
|
161 * called by both read and write (with x,y swapping between the two)
|
|
162 l00ae orcc #intmasks shut irq's off
|
|
163 ifeq Nocan
|
|
164 sta >$ff80 Nocan64; map ram drive block into MMU block #0
|
|
165 endc
|
|
166 ifeq Nocan-1
|
|
167 sta >$FF9B Nocan3 or MESS
|
|
168 endc
|
|
169 ifeq Nocan-2
|
|
170 sta >$FF70 Collyer
|
|
171 endc
|
|
172 stb >$ffa0
|
|
173 ifne H6309
|
|
174 ldw #$0100 256 byte transfer
|
|
175 tfm x+,y+ copy between the two buffers
|
|
176 else
|
|
177 clrb
|
|
178 writelp lda ,x+
|
|
179 sta ,y+
|
|
180 decb
|
|
181 bne writelp
|
|
182 endc
|
|
183 ifeq Nocan
|
|
184 clr >$ff80 Nocan64
|
|
185 endc
|
|
186 ifeq Nocan-1
|
|
187 ldb ff9b,u Nocan3 or MESS
|
|
188 stb >$FF9B
|
|
189 endc
|
|
190 ifeq Nocan-2
|
|
191 clr >$FF70 Collyer
|
|
192 endc
|
|
193 clr >$ffa0 remap in system block 0
|
|
194 andcc #^(intmasks) turn irq's back on
|
|
195 rts
|
|
196
|
|
197 * subroutine to calculate mmu block # and offset based on sector # requested
|
|
198 * entry: y=path dsc. ptr
|
|
199 * u=device mem ptr
|
|
200 * b:x=LSN to calculate for beyond 2megs; ie. $200000
|
|
201 * that means ram drive has minimum value at $ff80 of 1 and
|
|
202 * mmu block number = lsn/32 + $100
|
|
203 * exit: a=mmu block # to send to $ff80
|
|
204 * b=mmu block # to send to $ffa0
|
|
205 * x=offset within mmu block to get sector from (always <8k)
|
|
206 * y=sector buffer ptr
|
|
207 l00c8 equ *
|
|
208 pshs b,x
|
|
209 lda 2,s
|
|
210 anda #$1f
|
|
211 clrb
|
|
212 tfr d,x regX now offset into MMU block
|
|
213 ifeq H6309
|
|
214 lsl 2,s lsn*8/$10=lsn/$20
|
|
215 rol 1,s
|
|
216 rol ,s
|
|
217 lsl 2,s
|
|
218 rol 1,s
|
|
219 rol ,s
|
|
220 lsl 2,s
|
|
221 rol 1,s
|
|
222 rol ,s
|
|
223 ldd ,s
|
|
224 else
|
|
225 ldw ,s++
|
|
226 lda ,s+
|
|
227 lsla
|
|
228 rolw
|
|
229 lsla
|
|
230 rolw
|
|
231 lsla this value now not needed
|
|
232 rolw
|
|
233 tfr w,d
|
|
234 endc
|
|
235 inca make it past the 2megs of os-9
|
|
236 ifeq Nocan-1
|
|
237 lsla shift it to MMU bits 5&6 for Nocan3 or MESS
|
|
238 lsla
|
|
239 lsla
|
|
240 lsla
|
|
241 * !!! This next line could be a problem if video bits are altered.
|
|
242 * It would require reading the bits prior to every sector read/write!!!
|
|
243 ora ff9b,u OR in video bits
|
|
244 endc
|
|
245 ifeq H6309
|
|
246 leas 3,s
|
|
247 endc
|
|
248 ldy pd.buf,y get sector buffer address
|
|
249 rts
|
|
250
|
|
251 emod
|
|
252 eom equ *
|
|
253 end
|
|
254
|