]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame - cbios/boot.180
baudrate configurable
[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
ea5293bb 9 extrn ?boot,?pmsg,?conin\r
f80331a6 10 extrn ioini1l,msginit,mmuinit,intinit,cpu_frq\r
ea5293bb
L
11 extrn @civec,@covec,@aivec,@aovec,@lovec\r
12 extrn @cbnk,?bnksl\r
13\r
14 include config.inc\r
15 include z180reg.inc\r
16\r
17\r
18bdos equ 5\r
19\r
20ccpsize equ 0c80h\r
21\r
22 if banked\r
23tpa$bank equ 1\r
24 else\r
25tpa$bank equ 0\r
26 endif\r
27\r
28\r
29 dseg ; init done from banked memory\r
30\r
31hwinit:\r
32 ld a,(INIDONE)\r
33 cp INIDONEVAL\r
34 jr z,hwini_skip\r
35 ld hl,hwini_tab\r
36 call ioini1l\r
37 ld a,0c3h\r
38 ld hl,?boot\r
39 ld (0),a\r
40 ld (1),hl\r
41hwini_skip:\r
42 call mmuinit ; setup mmu registers\r
43 call msginit\r
f80331a6
L
44 call cpu_frq\r
45 ld (f_cpu),de\r
46 ld (f_cpu+2),hl\r
ea5293bb
L
47 ret\r
48\r
49?init:\r
50 ld hl,0100000000000000b ; assign console to ASCI1:\r
51 ld (@civec),hl\r
52 ld (@covec),hl\r
53 ld hl,0000000000000000b ; assign printer to nothing:\r
54 ld (@lovec),hl\r
55 ld hl,0100000000000000b ; assign AUX to ASCI0:\r
56 ld (@aivec),hl\r
57 ld (@aovec),hl\r
58\r
59\r
60 call intinit ; setup interrupts and vectors\r
61\r
62 xor a\r
63 ld (@cbnk),a ; right now in bank 0\r
64\r
65 ld hl,signon$msg\r
66 call ?pmsg ; print signon message\r
67 ret\r
68\r
69\r
70 cseg ; boot loading most be done from resident memory\r
71\r
72; This version of the boot loader loads the CCP from a file\r
73; called CCP.COM on the system drive (A:).\r
74\r
75\r
76?ldccp:\r
77 ; First time, load the A:CCP.COM file into TPA\r
78 xor a\r
79 ld (ccp$fcb+15),a ; zero extent\r
80 ld hl,0\r
81 ld (fcb$nr),hl ; start at beginning of file\r
82 ld de,ccp$fcb\r
83 call open ; open file containing CCP\r
84 inc a\r
85 jp z,no$ccp ; error if no file...\r
86 ld de,0100h\r
87 call setdma ; start of TPA\r
88 ld de,128\r
89 call setmulti ; allow up to 16k bytes\r
90 ld de,ccp$fcb\r
91 call read ; load the thing\r
92 ; now,\r
93 ; copy CCP to bank 0 for reloading\r
94 ld hl,0100h\r
95 ld bc,ccpsize ; clone 3K, just in case\r
96 ld a,(@cbnk)\r
97 push af ; save current bank\r
98ld$1:\r
99 ld a,tpa$bank\r
100 call ?bnksl ; select TPA\r
101 ld a,(hl)\r
102 push af ; get a byte\r
103 ld a,2\r
104 call ?bnksl ; select extra bank\r
105 pop af\r
106 ld (hl),a ; save the byte\r
107 inc hl\r
108 dec bc ; bump pointer, drop count\r
109 ld a,b\r
110 or c ; test for done\r
111 jp nz,ld$1\r
112 pop af\r
113 call ?bnksl ; restore original bank\r
114 ret\r
115\r
116no$ccp: ; here if we couldn't find the file\r
117 ld hl,ccp$msg\r
118 call ?pmsg ; report this...\r
119 call ?conin ; get a response\r
120 jp ?ldccp ; and try again\r
121\r
122\r
123?rlccp:\r
124 ld hl,0100h\r
125 ld bc,ccpsize ; clone 3K\r
126rl$1:\r
127 ld a,2\r
128 call ?bnksl ; select extra bank\r
129 ld a,(hl)\r
130 push af ; get a byte\r
131 ld a,tpa$bank\r
132 call ?bnksl ; select TPA\r
133 pop af\r
134 ld (hl),a ; save the byte\r
135 inc hl\r
136 dec bc ; bump pointer, drop count\r
137 ld a,b\r
138 or c ; test for done\r
139 jp nz,rl$1\r
140 ret\r
141\r
142\r
143 ; CP/M BDOS Function Interfaces\r
144\r
145open:\r
146 ld c,15\r
147 jp bdos ; open file control block\r
148\r
149setdma:\r
150 ld c,26\r
151 jp bdos ; set data transfer address\r
152\r
153setmulti:\r
154 ld c,44\r
155 jp bdos ; set record count\r
156\r
157read:\r
158 ld c,20\r
159 jp bdos ; read records\r
160\r
161\r
162signon$msg:\r
163 db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS',13,10,0\r
164\r
165ccp$msg:db 13,10,'BIOS Err on A: No CCP.COM file',0\r
166\r
167\r
168ccp$fcb:db 1,'CCP ','COM',0,0,0,0\r
169 ds 16\r
170fcb$nr: db 0,0,0\r
171\r
172\r
f80331a6 173 dseg\r
ea5293bb
L
174hwini_tab:\r
175 db (hwini0_e-$)/2 ;count\r
176 db rcr,CREFSH ;configure DRAM refresh\r
177 db dcntl,CWAITIO ;wait states\r
178 db ccr,M_NCD ;No Clock Divide\r
179 db cmr,PHI_X2 ;X2 Clock Multiplier\r
180;TODO: db omr, ;Operation Mode Control Register\r
181hwini0_e:\r
182 db 0 ;stop mark\r
183\r
f80331a6
L
184 cseg\r
185f_cpu dw 0,0 ;detected CPU clock frequency [Hz]\r
ea5293bb
L
186\r
187 end\r