]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame - cbios/boot.180
use ?xmove (DMA) to copy ccp to/from extra bank
[z180-stamp-cpm3.git] / cbios / boot.180
CommitLineData
ea5293bb
L
1 title 'Boot loader module for CP/M 3.0'\r
2\r
3\r
4\r
5 public hwinit,?init,?ldccp,?rlccp\r
6\r
f80331a6
L
7 public f_cpu\r
8\r
1e1c17d3 9 extrn boot,?conin\r
d12d8b38 10 extrn pr.inln,pr.crlf,pr.dec,pr.decl\r
f80331a6 11 extrn ioini1l,msginit,mmuinit,intinit,cpu_frq\r
f4471ef9 12 extrn prt0ini,gs_rtc\r
ea5293bb 13 extrn @civec,@covec,@aivec,@aovec,@lovec\r
573b9c25 14 extrn @cbnk,?move,?xmove\r
ea5293bb
L
15\r
16 include config.inc\r
17 include z180reg.inc\r
18\r
19\r
ea5293bb
L
20ccpsize equ 0c80h\r
21\r
40df51ae
L
22 ; CP/M BDOS Function Interfaces\r
23\r
24resetdsk equ 13\r
25open equ 15\r
26read equ 20\r
27setdma equ 26\r
28setmulti equ 44\r
29bdos equ 5\r
30\r
31\r
ea5293bb
L
32 if banked\r
33tpa$bank equ 1\r
34 else\r
35tpa$bank equ 0\r
36 endif\r
37\r
38\r
39 dseg ; init done from banked memory\r
40\r
41hwinit:\r
42 ld a,(INIDONE)\r
43 cp INIDONEVAL\r
44 jr z,hwini_skip\r
45 ld hl,hwini_tab\r
46 call ioini1l\r
47 ld a,0c3h\r
1e1c17d3 48 ld hl,boot\r
ea5293bb
L
49 ld (0),a\r
50 ld (1),hl\r
51hwini_skip:\r
ea5293bb 52 call msginit\r
f80331a6 53 call cpu_frq\r
43bb4ff6
L
54 ld (f_cpu),hl\r
55 ld (f_cpu+2),de\r
ea5293bb
L
56 ret\r
57\r
58?init:\r
c5868b68
L
59; ld hl,1000000000000000b ; assign console to AVRCON:\r
60 ld hl,0100000000000000b ; assign console to ASCI0:\r
ea5293bb
L
61 ld (@civec),hl\r
62 ld (@covec),hl\r
63 ld hl,0000000000000000b ; assign printer to nothing:\r
64 ld (@lovec),hl\r
65 ld hl,0100000000000000b ; assign AUX to ASCI0:\r
66 ld (@aivec),hl\r
67 ld (@aovec),hl\r
68\r
69\r
d12d8b38 70 call intinit ; setup interrupts and vectors\r
f4471ef9
L
71 call prt0ini ; init timer\r
72 ei\r
50f3b8f0
L
73 ld c,2\r
74 call gs_rtc ; get time and date\r
ea5293bb
L
75\r
76 xor a\r
d12d8b38 77 ld (@cbnk),a ; right now in bank 0\r
ea5293bb 78\r
d12d8b38
L
79 call pr.inln ; print signon message\r
80 db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS',13,10,0\r
81\r
82 call pr.inln\r
50f3b8f0 83 db 'Estimated CPU clock [Hz]: ',0\r
d12d8b38 84\r
43bb4ff6
L
85 ld hl,(f_cpu)\r
86 ld de,(f_cpu+2)\r
d12d8b38
L
87 call pr.decl\r
88 call pr.crlf\r
ea5293bb
L
89 ret\r
90\r
91\r
573b9c25 92 cseg ; boot loading must be done from resident memory\r
ea5293bb
L
93\r
94; This version of the boot loader loads the CCP from a file\r
95; called CCP.COM on the system drive (A:).\r
96\r
573b9c25 97 ; First time, load the A:CCP.COM file into TPA\r
ea5293bb 98?ldccp:\r
40df51ae
L
99 ld c,resetdsk\r
100 call bdos\r
ea5293bb 101 xor a\r
573b9c25 102 ld (ccp$fcb+15),a ; zero extent\r
ea5293bb 103 ld hl,0\r
573b9c25 104 ld (fcb$nr),hl ; start at beginning of file\r
ea5293bb 105 ld de,ccp$fcb\r
573b9c25 106 ld c,open ; open file containing CCP\r
40df51ae 107 call bdos\r
ea5293bb 108 inc a\r
573b9c25 109 jp z,no$ccp ; error if no file...\r
ea5293bb 110 ld de,0100h\r
40df51ae
L
111 ld c,setdma ; start of TPA\r
112 call bdos\r
ea5293bb 113 ld de,128\r
573b9c25 114 ld c,setmulti ; allow up to 16k bytes\r
40df51ae 115 call bdos\r
ea5293bb 116 ld de,ccp$fcb\r
573b9c25
L
117 ld c,read ; load the thing\r
118 call bdos ; read records\r
d12d8b38 119\r
573b9c25 120 ; now, copy CCP to bank 0 for reloading\r
ea5293bb 121\r
573b9c25
L
122 ld bc,2*256 + tpa$bank ; c: src$bnk, b: dst$bnk\r
123 jr mov_ccp\r
ea5293bb 124\r
573b9c25 125 ; just copy in the other direction\r
ea5293bb 126?rlccp:\r
573b9c25
L
127 ld bc,tpa$bank*256 + 2 ; c: src$bnk, b: dst$bnk\r
128mov_ccp:\r
129 call ?xmove\r
ea5293bb 130 ld hl,0100h\r
573b9c25
L
131 ld d,h\r
132 ld e,l\r
133 ld bc,ccpsize ; clone 3K, just in case\r
134 call ?move\r
ea5293bb
L
135 ret\r
136\r
573b9c25
L
137no$ccp: ; here if we couldn't find the file\r
138 call pr.inln ; report this...\r
139 db 13,10,'BIOS Err on A: No CCP.COM file',0\r
140\r
141 call ?conin ; get a response\r
142 jr ?ldccp ; and try again\r
143\r
ea5293bb 144\r
ea5293bb
L
145ccp$fcb:db 1,'CCP ','COM',0,0,0,0\r
146 ds 16\r
147fcb$nr: db 0,0,0\r
148\r
149\r
f80331a6 150 dseg\r
ea5293bb
L
151hwini_tab:\r
152 db (hwini0_e-$)/2 ;count\r
153 db rcr,CREFSH ;configure DRAM refresh\r
154 db dcntl,CWAITIO ;wait states\r
155 db ccr,M_NCD ;No Clock Divide\r
156 db cmr,PHI_X2 ;X2 Clock Multiplier\r
157;TODO: db omr, ;Operation Mode Control Register\r
158hwini0_e:\r
159 db 0 ;stop mark\r
160\r
f80331a6
L
161 cseg\r
162f_cpu dw 0,0 ;detected CPU clock frequency [Hz]\r
ea5293bb
L
163\r
164 end\r