]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame_incremental - cbios/boot.180
New memory map: bank 1 and common are now contiguous
[z180-stamp-cpm3.git] / cbios / boot.180
... / ...
CommitLineData
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
7 public f_cpu\r
8\r
9 extrn boot,?conin\r
10 extrn pr.inln,pr.crlf,pr.dec,pr.decl\r
11 extrn ioini1l,msginit,mmuinit,intinit,cpu_frq\r
12 extrn prt0ini,gs_rtc\r
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
20ccpsize equ 0c80h\r
21\r
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
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 msginit\r
53 call cpu_frq\r
54 ld (f_cpu),hl\r
55 ld (f_cpu+2),de\r
56 ret\r
57\r
58?init:\r
59; ld hl,1000000000000000b ; assign console to AVRCON:\r
60 ld hl,0100000000000000b ; assign console to ASCI0:\r
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
70 call intinit ; setup interrupts and vectors\r
71 call prt0ini ; init timer\r
72 ei\r
73 ld c,2\r
74 call gs_rtc ; get time and date\r
75\r
76 xor a\r
77 ld (@cbnk),a ; right now in bank 0\r
78\r
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
83 db 'Estimated CPU clock [Hz]: ',0\r
84\r
85 ld hl,(f_cpu)\r
86 ld de,(f_cpu+2)\r
87 call pr.decl\r
88 call pr.crlf\r
89 ret\r
90\r
91\r
92 cseg ; boot loading must be done from resident memory\r
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
97\r
98?ldccp:\r
99 ; First time, load the A:CCP.COM file into TPA\r
100 ld c,resetdsk\r
101 call bdos\r
102 xor a\r
103 ld (ccp$fcb+15),a ; zero extent\r
104 ld hl,0\r
105 ld (fcb$nr),hl ; start at beginning of file\r
106 ld de,ccp$fcb\r
107 ld c,open ; open file containing CCP\r
108 call bdos\r
109 inc a\r
110 jp z,no$ccp ; error if no file...\r
111 ld de,0100h\r
112 ld c,setdma ; start of TPA\r
113 call bdos\r
114 ld de,128\r
115 ld c,setmulti ; allow up to 16k bytes\r
116 call bdos\r
117 ld de,ccp$fcb\r
118 ld c,read ; load the thing\r
119 call bdos ; read records\r
120 ; now,\r
121 ; copy CCP to bank 0 for reloading\r
122 ld hl,0100h\r
123 ld bc,ccpsize ; clone 3K, just in case\r
124 ld a,(@cbnk)\r
125 push af ; save current bank\r
126ld$1:\r
127 ld a,tpa$bank\r
128 call ?bnksl ; select TPA\r
129 ld a,(hl)\r
130 push af ; get a byte\r
131 ld a,2\r
132 call ?bnksl ; select extra bank\r
133 pop af\r
134 ld (hl),a ; save the byte\r
135 cpi ; bump pointer, drop count\r
136 jp pe,ld$1\r
137 pop af\r
138 call ?bnksl ; restore original bank\r
139 ret\r
140\r
141no$ccp: ; here if we couldn't find the file\r
142 call pr.inln ; report this...\r
143 db 13,10,'BIOS Err on A: No CCP.COM file',0\r
144\r
145 call ?conin ; get a response\r
146 jp ?ldccp ; and try again\r
147\r
148\r
149?rlccp:\r
150 ld hl,0100h\r
151 ld bc,ccpsize ; clone 3K\r
152rl$1:\r
153 ld a,2\r
154 call ?bnksl ; select extra bank\r
155 ld a,(hl) ; get a byte\r
156 ex af,af'\r
157 ld a,tpa$bank\r
158 call ?bnksl ; select TPA\r
159 ex af,af'\r
160 ld (hl),a ; save the byte\r
161 cpi ; bump pointer, drop count\r
162 jp pe,rl$1\r
163 ret\r
164\r
165\r
166ccp$fcb:db 1,'CCP ','COM',0,0,0,0\r
167 ds 16\r
168fcb$nr: db 0,0,0\r
169\r
170\r
171 dseg\r
172hwini_tab:\r
173 db (hwini0_e-$)/2 ;count\r
174 db rcr,CREFSH ;configure DRAM refresh\r
175 db dcntl,CWAITIO ;wait states\r
176 db ccr,M_NCD ;No Clock Divide\r
177 db cmr,PHI_X2 ;X2 Clock Multiplier\r
178;TODO: db omr, ;Operation Mode Control Register\r
179hwini0_e:\r
180 db 0 ;stop mark\r
181\r
182 cseg\r
183f_cpu dw 0,0 ;detected CPU clock frequency [Hz]\r
184\r
185 end\r