]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame - cbios/boot.180
set default con: to asci0[19200]
[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
d12d8b38
L
9 extrn ?boot,?conin\r
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
L
13 extrn @civec,@covec,@aivec,@aovec,@lovec\r
14 extrn @cbnk,?bnksl\r
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
48 ld hl,?boot\r
49 ld (0),a\r
50 ld (1),hl\r
51hwini_skip:\r
52 call mmuinit ; setup mmu registers\r
53 call msginit\r
f80331a6 54 call cpu_frq\r
43bb4ff6
L
55 ld (f_cpu),hl\r
56 ld (f_cpu+2),de\r
ea5293bb
L
57 ret\r
58\r
59?init:\r
c5868b68
L
60; ld hl,1000000000000000b ; assign console to AVRCON:\r
61 ld hl,0100000000000000b ; assign console to ASCI0:\r
ea5293bb
L
62 ld (@civec),hl\r
63 ld (@covec),hl\r
64 ld hl,0000000000000000b ; assign printer to nothing:\r
65 ld (@lovec),hl\r
66 ld hl,0100000000000000b ; assign AUX to ASCI0:\r
67 ld (@aivec),hl\r
68 ld (@aovec),hl\r
69\r
70\r
d12d8b38 71 call intinit ; setup interrupts and vectors\r
f4471ef9
L
72 call prt0ini ; init timer\r
73 ei\r
50f3b8f0
L
74 ld c,2\r
75 call gs_rtc ; get time and date\r
ea5293bb
L
76\r
77 xor a\r
d12d8b38 78 ld (@cbnk),a ; right now in bank 0\r
ea5293bb 79\r
d12d8b38
L
80 call pr.inln ; print signon message\r
81 db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS',13,10,0\r
82\r
83 call pr.inln\r
50f3b8f0 84 db 'Estimated CPU clock [Hz]: ',0\r
d12d8b38 85\r
43bb4ff6
L
86 ld hl,(f_cpu)\r
87 ld de,(f_cpu+2)\r
d12d8b38
L
88 call pr.decl\r
89 call pr.crlf\r
ea5293bb
L
90 ret\r
91\r
92\r
d12d8b38 93 cseg ; boot loading must be done from resident memory\r
ea5293bb
L
94\r
95; This version of the boot loader loads the CCP from a file\r
96; called CCP.COM on the system drive (A:).\r
97\r
98\r
99?ldccp:\r
100 ; First time, load the A:CCP.COM file into TPA\r
40df51ae
L
101 ld c,resetdsk\r
102 call bdos\r
ea5293bb
L
103 xor a\r
104 ld (ccp$fcb+15),a ; zero extent\r
105 ld hl,0\r
106 ld (fcb$nr),hl ; start at beginning of file\r
107 ld de,ccp$fcb\r
40df51ae
L
108 ld c,open ; open file containing CCP\r
109 call bdos\r
ea5293bb
L
110 inc a\r
111 jp z,no$ccp ; error if no file...\r
112 ld de,0100h\r
40df51ae
L
113 ld c,setdma ; start of TPA\r
114 call bdos\r
ea5293bb 115 ld de,128\r
40df51ae
L
116 ld c,setmulti ; allow up to 16k bytes\r
117 call bdos\r
ea5293bb 118 ld de,ccp$fcb\r
40df51ae
L
119 ld c,read ; load the thing\r
120 call bdos ; read records\r
ea5293bb
L
121 ; now,\r
122 ; copy CCP to bank 0 for reloading\r
123 ld hl,0100h\r
124 ld bc,ccpsize ; clone 3K, just in case\r
125 ld a,(@cbnk)\r
126 push af ; save current bank\r
127ld$1:\r
128 ld a,tpa$bank\r
129 call ?bnksl ; select TPA\r
130 ld a,(hl)\r
131 push af ; get a byte\r
132 ld a,2\r
133 call ?bnksl ; select extra bank\r
134 pop af\r
135 ld (hl),a ; save the byte\r
40df51ae
L
136 cpi ; bump pointer, drop count\r
137 jp pe,ld$1\r
ea5293bb
L
138 pop af\r
139 call ?bnksl ; restore original bank\r
140 ret\r
141\r
142no$ccp: ; here if we couldn't find the file\r
d12d8b38
L
143 call pr.inln ; report this...\r
144 db 13,10,'BIOS Err on A: No CCP.COM file',0\r
145\r
ea5293bb
L
146 call ?conin ; get a response\r
147 jp ?ldccp ; and try again\r
148\r
149\r
150?rlccp:\r
151 ld hl,0100h\r
152 ld bc,ccpsize ; clone 3K\r
153rl$1:\r
154 ld a,2\r
155 call ?bnksl ; select extra bank\r
50f3b8f0
L
156 ld a,(hl) ; get a byte\r
157 ex af,af'\r
ea5293bb
L
158 ld a,tpa$bank\r
159 call ?bnksl ; select TPA\r
50f3b8f0 160 ex af,af'\r
ea5293bb 161 ld (hl),a ; save the byte\r
50f3b8f0
L
162 cpi ; bump pointer, drop count\r
163 jp pe,rl$1\r
ea5293bb
L
164 ret\r
165\r
166\r
ea5293bb
L
167ccp$fcb:db 1,'CCP ','COM',0,0,0,0\r
168 ds 16\r
169fcb$nr: db 0,0,0\r
170\r
171\r
f80331a6 172 dseg\r
ea5293bb
L
173hwini_tab:\r
174 db (hwini0_e-$)/2 ;count\r
175 db rcr,CREFSH ;configure DRAM refresh\r
176 db dcntl,CWAITIO ;wait states\r
177 db ccr,M_NCD ;No Clock Divide\r
178 db cmr,PHI_X2 ;X2 Clock Multiplier\r
179;TODO: db omr, ;Operation Mode Control Register\r
180hwini0_e:\r
181 db 0 ;stop mark\r
182\r
f80331a6
L
183 cseg\r
184f_cpu dw 0,0 ;detected CPU clock frequency [Hz]\r
ea5293bb
L
185\r
186 end\r