]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blob - cbios/boot.180
18a53f45d86f12f688e94d0be882547838c17aaa
[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 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 call intinit ; setup interrupts and vectors
57 ret
58
59 ?init:
60 ; ld hl,1000000000000000b ; assign console to AVRCON:
61 ld hl,0010000000000000b ; assign console to ASCI1:
62 ld (@civec),hl
63 ld (@covec),hl
64 ld hl,0000000000000000b ; assign printer to nothing:
65 ld (@lovec),hl
66 ld hl,0100000000000000b ; assign AUX to ASCI0:
67 ld (@aivec),hl
68 ld (@aovec),hl
69
70
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 v'
81 defvers
82 db 13,10
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 ; First time, load the A:CCP.COM file into TPA
98 ?ldccp:
99 ld c,resetdsk
100 call bdos
101 xor a
102 ld (ccp$fcb+15),a ; zero extent
103 ld hl,0
104 ld (fcb$nr),hl ; start at beginning of file
105 ld de,ccp$fcb
106 ld c,open ; open file containing CCP
107 call bdos
108 inc a
109 jp z,no$ccp ; error if no file...
110 ld de,0100h
111 ld c,setdma ; start of TPA
112 call bdos
113 ld de,128
114 ld c,setmulti ; allow up to 16k bytes
115 call bdos
116 ld de,ccp$fcb
117 ld c,read ; load the thing
118 call bdos ; read records
119
120 ; now, copy CCP to bank 0 for reloading
121
122 ld bc,2*256 + tpa$bank ; c: src$bnk, b: dst$bnk
123 jr mov_ccp
124
125 ; just copy in the other direction
126 ?rlccp:
127 ld bc,tpa$bank*256 + 2 ; c: src$bnk, b: dst$bnk
128 mov_ccp:
129 call ?xmove
130 ld hl,0100h
131 ld d,h
132 ld e,l
133 ld bc,ccpsize ; clone 3K, just in case
134 call ?move
135 ret
136
137 no$ccp: ; here if we couldn't find the file
138 call pr.inln ; report this...
139 db 13,10,'BIOS Err on A: No CCP.COM file',0
140
141 call ?conin ; get a response
142 jr ?ldccp ; and try again
143
144
145 ccp$fcb:db 1,'CCP ','COM',0,0,0,0
146 ds 16
147 fcb$nr: db 0,0,0
148
149
150 dseg
151 hwini_tab:
152 db (hwini0_e-$)/2 ;count
153 db rcr,CREFSH ;configure DRAM refresh
154 db dcntl,CWAITIO ;wait states
155 db ccr,M_NCD ;No Clock Divide
156 db cmr,PHI_X2 ;X2 Clock Multiplier
157 db omcr,~M_IOC ;Operation Mode Control Register
158 hwini0_e:
159 db 0 ;stop mark
160
161 cseg
162 f_cpu dw 0,0 ;detected CPU clock frequency [Hz]
163
164 end