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