]>
Commit | Line | Data |
---|---|---|
1 | ; CP/M BIOS for avrcpm\r | |
2 | ; Copyright (C) 2010 Sprite_tm\r | |
3 | ;\r | |
4 | ; This program is free software: you can redistribute it and/or modify\r | |
5 | ; it under the terms of the GNU General Public License as published by\r | |
6 | ; the Free Software Foundation, either version 3 of the License, or\r | |
7 | ; (at your option) any later version.\r | |
8 | ;\r | |
9 | ; This program is distributed in the hope that it will be useful,\r | |
10 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
11 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
12 | ; GNU General Public License for more details.\r | |
13 | ;\r | |
14 | ; You should have received a copy of the GNU General Public License\r | |
15 | ; along with this program. If not, see <http://www.gnu.org/licenses/>.\r | |
16 | ;\r | |
17 | ; $Id: bios.asm 71 2010-08-06 19:38:10Z leo $\r | |
18 | ;\r | |
19 | \r | |
20 | maclib CFGACPM.LIB\r | |
21 | \r | |
22 | cr equ 0dh\r | |
23 | lf equ 0ah\r | |
24 | \r | |
25 | aseg\r | |
26 | org 100h\r | |
27 | .phase bios\r | |
28 | .z80\r | |
29 | \r | |
30 | nsects equ ($-ccp)/128 ;warm start sector count\r | |
31 | \r | |
32 | jp boot\r | |
33 | wboote: \r | |
34 | jp wboot\r | |
35 | jp const\r | |
36 | jp conin\r | |
37 | jp conout\r | |
38 | jp list\r | |
39 | jp punch\r | |
40 | jp reader\r | |
41 | jp home\r | |
42 | jp seldsk\r | |
43 | jp settrk\r | |
44 | jp setsec\r | |
45 | jp setdma\r | |
46 | jp read\r | |
47 | jp write\r | |
48 | jp listst\r | |
49 | jp sectran\r | |
50 | jp 0 ;zsdos (?)\r | |
51 | jp 0 ;zsdos (?)\r | |
52 | jp 0 ;zsdos (?)\r | |
53 | jp clock ;zsdos compatible clock set/get\r | |
54 | \r | |
55 | \r | |
56 | .8080\r | |
57 | maclib AVRCPM.LIB\r | |
58 | \r | |
59 | ;Drive A B C D E F G H I J K L\r | |
60 | ;drvtbl:dtbl <dpha,dphb,dphc,dphd, , , , ,dphi,dphj,dphk,dphl>\r | |
61 | ;drvtbl:dtbl <dpha, , , , , , , ,dphi,dphj,dphk,dphl>\r | |
62 | ;drvtbl: dtbl < , , , , , , , ,dphi,dphj,dphk,dphl>\r | |
63 | drvtbl:dtbl < , , , , , , , ,dphi>\r | |
64 | \r | |
65 | ; Name spt bls dks dir cks off\r | |
66 | ; dpb dpb243, 26, 1024, 243, 64, 64, 2\r | |
67 | ; dpb dp8192s,32, 4096,2046, 512, 512, 2\r | |
68 | ; dpb dp8192, 32, 4096,2046,1024,1024, 2\r | |
69 | ; dpb dpbrd, 32, 1024, 56, 32, 0, 2\r | |
70 | dpb rd192, 32, 1024, 192, 32, 0, 0\r | |
71 | ; dpb rd1016, 32, 2048, 508, 192, 0, 2\r | |
72 | ; dpb rd1024, 32, 2048, 512, 192, 0, 0\r | |
73 | ; dpb rd0960, 32, 2048, 480, 192, 0, 0\r | |
74 | \r | |
75 | ;dpha: dph dpb243\r | |
76 | ;dphb: dph dpb243\r | |
77 | ;dphc: dph dpb243\r | |
78 | ;dphd: dph dpb243\r | |
79 | ;dpha: dph dp8192s\r | |
80 | ;dphb: dph dp8192s\r | |
81 | ;dphc: dph dp8192\r | |
82 | ;dphd: dph dp8192\r | |
83 | ;dphi: dph rd1016\r | |
84 | dphi: dph rd192\r | |
85 | ;dphj: dph rd1024\r | |
86 | ;dphk: dph rd1024\r | |
87 | ;dphl: dph rd0960\r | |
88 | \r | |
89 | .z80\r | |
90 | \r | |
91 | signon:\r | |
92 | db cr,lf\r | |
93 | db msize/10+'0'\r | |
94 | db msize - (msize/10)*10 + '0' ;modulo doesn't work?\r | |
95 | db "k cp/m vers 2.2"\r | |
96 | msgnl: db cr,lf,0\r | |
97 | \r | |
98 | msgnodisk:\r | |
99 | db "No disk!"\r | |
100 | db cr,lf,0\r | |
101 | \r | |
102 | const:\r | |
103 | in a,(UARTCSR)\r | |
104 | and UARTRXRDY\r | |
105 | ret z\r | |
106 | or 0ffh\r | |
107 | ret\r | |
108 | \r | |
109 | conin:\r | |
110 | in a,(UARTCSR)\r | |
111 | rra\r | |
112 | jp nc,conin\r | |
113 | \r | |
114 | in a,(UARTDR)\r | |
115 | ret\r | |
116 | \r | |
117 | conout:\r | |
118 | ld a,c\r | |
119 | out (UARTDR),a\r | |
120 | ret\r | |
121 | \r | |
122 | list:\r | |
123 | ret\r | |
124 | \r | |
125 | listst:\r | |
126 | ld a,0\r | |
127 | ret\r | |
128 | \r | |
129 | punch:\r | |
130 | ret\r | |
131 | \r | |
132 | reader:\r | |
133 | ld a,01Fh\r | |
134 | ret\r | |
135 | \r | |
136 | prmsg:\r | |
137 | ld a,(hl)\r | |
138 | or a\r | |
139 | ret z\r | |
140 | push hl\r | |
141 | ld c,a\r | |
142 | call conout\r | |
143 | pop hl\r | |
144 | inc hl\r | |
145 | jp prmsg\r | |
146 | \r | |
147 | prhex:\r | |
148 | ld a,c\r | |
149 | push af\r | |
150 | rra \r | |
151 | rra \r | |
152 | rra \r | |
153 | rra \r | |
154 | call prhexdigit\r | |
155 | pop af\r | |
156 | ; fall thru\r | |
157 | \r | |
158 | prhexdigit:\r | |
159 | and 00fh\r | |
160 | cp 10\r | |
161 | jp c,prd1\r | |
162 | add a,7\r | |
163 | prd1:\r | |
164 | add a,'0'\r | |
165 | ld c,a\r | |
166 | jp conout\r | |
167 | \r | |
168 | boot:\r | |
169 | ld sp,buff\r | |
170 | ld hl,signon\r | |
171 | call prmsg\r | |
172 | \r | |
173 | ld a,low bcb\r | |
174 | out (13),a\r | |
175 | ld a, high bcb\r | |
176 | out (14),a\r | |
177 | \r | |
178 | xor a\r | |
179 | ld (bootdsk),a\r | |
180 | ld e,a\r | |
181 | ld c,a\r | |
182 | call seldsk\r | |
183 | jp nz,boot0\r | |
184 | ld hl,msgnodisk\r | |
185 | call prmsg\r | |
186 | halt\r | |
187 | boot0:\r | |
188 | call getdpb\r | |
189 | ld a,(de) ;dpb[0] is sectors_per_track\r | |
190 | ld (bootspt),a\r | |
191 | ld e,0\r | |
192 | ld c,'I'-'A'\r | |
193 | call seldsk\r | |
194 | jp z,boot1 ;no ram disk\r | |
195 | \r | |
196 | call getdpb ;de = dpb of first ram disk\r | |
197 | \r | |
198 | ; Check, if we have reserved tracks.\r | |
199 | \r | |
200 | ld hl,13\r | |
201 | add hl,de\r | |
202 | \r | |
203 | ld a,(hl) ;# of reserved tracks \r | |
204 | inc hl\r | |
205 | or (hl)\r | |
206 | jp z,boot1 ;Skip if not.\r | |
207 | \r | |
208 | ; Save CPM to ram disk.\r | |
209 | \r | |
210 | ld a,(de) ;sectors per track\r | |
211 | ld (bootspt),a\r | |
212 | ld a,'I'-'A'\r | |
213 | ld (bootdsk),a\r | |
214 | call home\r | |
215 | ld b,nsects\r | |
216 | ld c,0 ;track\r | |
217 | ld d,1 ;sektor (0 based, skip ipl)\r | |
218 | ld hl,ccp\r | |
219 | store1:\r | |
220 | push bc\r | |
221 | push de\r | |
222 | push hl\r | |
223 | ld c,d\r | |
224 | ld b,0\r | |
225 | call setsec\r | |
226 | pop bc ;dma\r | |
227 | push bc\r | |
228 | call setdma\r | |
229 | ld c,0\r | |
230 | call write\r | |
231 | \r | |
232 | pop hl ;dma\r | |
233 | ld de,128\r | |
234 | add hl,de\r | |
235 | pop de ;d = sec\r | |
236 | pop bc ;b = # of secs, c = track\r | |
237 | dec b\r | |
238 | jp z,boot1\r | |
239 | \r | |
240 | inc d\r | |
241 | ld a,(bootspt)\r | |
242 | dec a\r | |
243 | cp d ;if sector >= spt then change tracks\r | |
244 | jp nc,store1\r | |
245 | \r | |
246 | ld d,0\r | |
247 | inc c\r | |
248 | push bc\r | |
249 | push de\r | |
250 | push hl\r | |
251 | ld b,0\r | |
252 | call settrk \r | |
253 | pop hl\r | |
254 | pop de\r | |
255 | pop bc\r | |
256 | jp store1\r | |
257 | \r | |
258 | boot1: \r | |
259 | xor a\r | |
260 | ld (iobyte),a\r | |
261 | ld (cdisk),a\r | |
262 | jp gocpm \r | |
263 | \r | |
264 | wboot: ;re-load CP/M\r | |
265 | ld sp,buff\r | |
266 | ld a,1 shl BOOT_FUNC ;init (de)blocking\r | |
267 | out (22),a\r | |
268 | ld a,(bootdsk)\r | |
269 | ld c,a\r | |
270 | ld e,0 ;clear reselection flag\r | |
271 | call seldsk\r | |
272 | call home\r | |
273 | ld b,nsects\r | |
274 | ld c,0 ;track\r | |
275 | ld d,1 ;sektor (0 based)\r | |
276 | ld hl,ccp\r | |
277 | load1:\r | |
278 | push bc\r | |
279 | push de\r | |
280 | push hl\r | |
281 | ld c,d\r | |
282 | ld b,0\r | |
283 | call setsec\r | |
284 | pop bc\r | |
285 | push bc\r | |
286 | call setdma\r | |
287 | call read\r | |
288 | cp 0 ;read error?\r | |
289 | jp nz,wboot\r | |
290 | \r | |
291 | pop hl\r | |
292 | ld de,128\r | |
293 | add hl,de\r | |
294 | pop de\r | |
295 | pop bc\r | |
296 | dec b\r | |
297 | jp z,gocpm\r | |
298 | \r | |
299 | inc d\r | |
300 | ld a,(bootspt)\r | |
301 | dec a\r | |
302 | cp d ;if sector >= spt then change tracks\r | |
303 | jp nc,load1\r | |
304 | \r | |
305 | ld d,0\r | |
306 | inc c\r | |
307 | push bc\r | |
308 | push de\r | |
309 | push hl\r | |
310 | ld b,0\r | |
311 | call settrk \r | |
312 | pop hl\r | |
313 | pop de\r | |
314 | pop bc\r | |
315 | jp load1\r | |
316 | \r | |
317 | gocpm:\r | |
318 | ld a,0c3h\r | |
319 | ld (0),a\r | |
320 | ld hl,wboote\r | |
321 | ld (1),hl\r | |
322 | ld (5),a\r | |
323 | ld hl,bdos\r | |
324 | ld (6),hl\r | |
325 | \r | |
326 | ld bc,buff\r | |
327 | call setdma\r | |
328 | ld a,(cdisk)\r | |
329 | ld c,a\r | |
330 | jp ccp\r | |
331 | \r | |
332 | msgSel: db 13,10,"Sel: ",0\r | |
333 | \r | |
334 | getdpb:\r | |
335 | ld de,10\r | |
336 | add hl,de\r | |
337 | ld e,(hl)\r | |
338 | inc hl\r | |
339 | ld d,(hl) ;de = dpb\r | |
340 | ret\r | |
341 | \r | |
342 | seldsk:\r | |
343 | ld a,c\r | |
344 | out (15),a\r | |
345 | \r | |
346 | ld a,e ;reselection bit\r | |
347 | rrca\r | |
348 | jp c,getdph ;skip, if disk already active\r | |
349 | ld hl,0\r | |
350 | in a,(15) ;querry, if disk exists\r | |
351 | or a\r | |
352 | ret z\r | |
353 | getdph:\r | |
354 | ld hl,drvtbl\r | |
355 | ld b,0\r | |
356 | add hl,bc\r | |
357 | add hl,bc\r | |
358 | ld a,(hl) ;get table entry for selected disk\r | |
359 | inc hl\r | |
360 | ld h,(hl)\r | |
361 | ld l,a \r | |
362 | or h ;return zero, if no entry (no disk)\r | |
363 | ret\r | |
364 | \r | |
365 | \r | |
366 | home:\r | |
367 | ld a,1 shl HOME_FUNC\r | |
368 | out (22),a\r | |
369 | \r | |
370 | ld bc,0 ; same as seek to track 0\r | |
371 | settrk:\r | |
372 | ld a,c\r | |
373 | out (16),a\r | |
374 | ld a,b\r | |
375 | out (17),a\r | |
376 | ret\r | |
377 | \r | |
378 | setsec:\r | |
379 | ld a,c\r | |
380 | out (18),a\r | |
381 | ret\r | |
382 | \r | |
383 | setdma:\r | |
384 | ld a,c\r | |
385 | out (20),a\r | |
386 | ld a,b\r | |
387 | out (21),a\r | |
388 | ret\r | |
389 | \r | |
390 | read:\r | |
391 | ld a,1 shl READ_FUNC\r | |
392 | out (22),a\r | |
393 | in a,(22)\r | |
394 | and 1\r | |
395 | ret\r | |
396 | \r | |
397 | write:\r | |
398 | ld a,c\r | |
399 | and 3 ;mask write type\r | |
400 | or 1 shl WRITE_FUNC\r | |
401 | out (22),a\r | |
402 | in a,(22)\r | |
403 | and 1\r | |
404 | ret\r | |
405 | \r | |
406 | sectran:\r | |
407 | ;translate sector bc using table at de, res into hl\r | |
408 | ld h,b\r | |
409 | ld l,c\r | |
410 | ld a,d\r | |
411 | or e\r | |
412 | ret z\r | |
413 | ex de,hl\r | |
414 | add hl,bc\r | |
415 | ld l,(hl)\r | |
416 | ld h,0\r | |
417 | ret\r | |
418 | \r | |
419 | ;------------------------------------------------------------------------\r | |
420 | ; ZSDOS clock drivers may use registers BC and D without restoring them, \r | |
421 | ; but must preserve the Z80's alternate and index registers. \r | |
422 | ; Other registers must be used exactly as follows:\r | |
423 | ;\r | |
424 | ; Enter: C = 00H to Read the Clock, 01H to Set the Clock\r | |
425 | ; DE = Address of a 6-byte field to Receive or from which \r | |
426 | ; to Set time in DateStamper format (BCD digits as: \r | |
427 | ; YY MM DD HH MM SS). 24-hour operation is assumed.\r | |
428 | ;\r | |
429 | ; Exit : A = 01H for a successful operation,\r | |
430 | ; 0FFH for a failure of any sort (Can't set, etc.)\r | |
431 | ;\r | |
432 | ; When Reading the Clock:\r | |
433 | ; E = Original contents of Entry value of DE plus 5\r | |
434 | ; HL = Entry value of DE plus 5 (Seconds field)\r | |
435 | \r | |
436 | clock:\r | |
437 | dec c\r | |
438 | jr z,clk_set\r | |
439 | inc c\r | |
440 | ret nz\r | |
441 | \r | |
442 | clk_get:\r | |
443 | ld hl,5\r | |
444 | add hl,de\r | |
445 | push hl\r | |
446 | ld bc,6*256 + CLOCKPORT-1\r | |
447 | ld e,(hl)\r | |
448 | clk_gl:\r | |
449 | inc c\r | |
450 | ind\r | |
451 | jr nz,clk_gl\r | |
452 | pop hl\r | |
453 | jr clk_e\r | |
454 | \r | |
455 | \r | |
456 | clk_set:\r | |
457 | ld a,(hl)\r | |
458 | cp 78h\r | |
459 | ld a,19h\r | |
460 | jr nc,clk_s1\r | |
461 | ld a,20h\r | |
462 | clk_s1:\r | |
463 | out (CLOCKPORT+6),a\r | |
464 | ld bc,6*256 + CLOCKPORT+6\r | |
465 | clk_sl:\r | |
466 | dec c\r | |
467 | outi\r | |
468 | jr nz,clk_sl\r | |
469 | dec hl\r | |
470 | clk_e:\r | |
471 | ld a,1\r | |
472 | ret\r | |
473 | \r | |
474 | ;------------------------------------------------------------------------\r | |
475 | \r | |
476 | bcb: dw drvtbl\r | |
477 | dw dirbuf\r | |
478 | dw enddat\r | |
479 | \r | |
480 | bootdsk:ds 1\r | |
481 | bootspt:ds 1\r | |
482 | \r | |
483 | .8080\r | |
484 | endef\r | |
485 | \r | |
486 | end\r | |
487 | \r |