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