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