]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blob - cbios/boot.180
BIOS debugging with ddtz: Set 3F to 81 to en fifo inits.
[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 public f_cpu
7
8 extrn boot,?conin
9 extrn pr.inln,pr.crlf,pr.dec,pr.decl
10 extrn ioini1l,msginit,mmuinit,intinit,cpu_frq
11 extrn prt0ini,gs_rtc
12 extrn @civec,@covec,@aivec,@aovec,@lovec
13 extrn @cbnk,?move,?xmove
14
15 maclib z180reg.inc
16 maclib config.inc
17 maclib version.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 and 80h
44 cp INIDONEVAL
45 jr z,hwini_skip
46 ld hl,hwini_tab
47 call ioini1l
48 ld a,0c3h
49 ld hl,boot
50 ld (0),a
51 ld (1),hl
52 hwini_skip:
53 call msginit
54 call cpu_frq
55 ld (f_cpu),hl
56 ld (f_cpu+2),de
57 call intinit ; setup interrupts and vectors
58 ret
59
60 ?init:
61 ; ld hl,1000000000000000b ; assign console to AVRCON:
62 ld hl,0010000000000000b ; assign console to ASCI1:
63 ld (@civec),hl
64 ld (@covec),hl
65 ld hl,0000000000000000b ; assign printer to nothing:
66 ld (@lovec),hl
67 ld hl,0000000000000000b ; assign AUX to ASCI0:
68 ld (@aivec),hl
69 ld (@aovec),hl
70
71
72 call prt0ini ; init timer
73 ei
74 ld c,2
75 call gs_rtc ; get time and date
76
77 xor a
78 ld (@cbnk),a ; right now in bank 0
79
80 call pr.inln ; print signon message
81 db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS v'
82 defvers
83 db 13,10
84 db 'Estimated CPU clock [Hz]: ',0
85
86 ld hl,(f_cpu)
87 ld de,(f_cpu+2)
88 call pr.decl
89 call pr.crlf
90 ret
91
92
93 cseg ; boot loading must be done from resident memory
94
95 ; This version of the boot loader loads the CCP from a file
96 ; called CCP.COM on the system drive (A:).
97
98 ; First time, load the A:CCP.COM file into TPA
99 ?ldccp:
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
121 ; now, copy CCP to bank 0 for reloading
122
123 ld bc,2*256 + tpa$bank ; c: src$bnk, b: dst$bnk
124 jr mov_ccp
125
126 ; just copy in the other direction
127 ?rlccp:
128 ld bc,tpa$bank*256 + 2 ; c: src$bnk, b: dst$bnk
129 mov_ccp:
130 call ?xmove
131 ld hl,0100h
132 ld d,h
133 ld e,l
134 ld bc,ccpsize ; clone 3K, just in case
135 call ?move
136 ret
137
138 no$ccp: ; here if we couldn't find the file
139 call pr.inln ; report this...
140 db 13,10,'BIOS Err on A: No CCP.COM file',0
141
142 call ?conin ; get a response
143 jr ?ldccp ; and try again
144
145
146 ccp$fcb:db 1,'CCP ','COM',0,0,0,0
147 ds 16
148 fcb$nr: db 0,0,0
149
150
151 dseg
152 hwini_tab:
153 db (hwini0_e-$)/2 ;count
154 db rcr,CREFSH ;configure DRAM refresh
155 db dcntl,CWAITIO ;wait states
156 db ccr,M_NCD ;No Clock Divide
157 db cmr,PHI_X2 ;X2 Clock Multiplier
158 db omcr,~M_IOC ;Operation Mode Control Register
159 hwini0_e:
160 db 0 ;stop mark
161
162 cseg
163 f_cpu dw 0,0 ;detected CPU clock frequency [Hz]
164
165 end