]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blob - cbios/boot.180
WIP
[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 signon
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,?move,?xmove
15
16 maclib z180reg.inc
17 maclib config.inc
18 maclib version.inc
19
20
21 ccpsize equ 0c80h
22
23 ; CP/M BDOS Function Interfaces
24
25 resetdsk equ 13
26 open equ 15
27 read equ 20
28 setdma equ 26
29 setmulti equ 44
30 bdos equ 5
31
32
33 if banked
34 tpa$bank equ 1
35 else
36 tpa$bank equ 0
37 endif
38
39
40 dseg ; init done from banked memory
41
42 hwinit:
43 ld a,(INIDONE)
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,0100000000000000b ; 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 signon:
82 db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS v'
83 defvers
84 db 13,10
85 db 'Estimated CPU clock [Hz]: ',0
86
87 ld hl,(f_cpu)
88 ld de,(f_cpu+2)
89 call pr.decl
90 call pr.crlf
91 ret
92
93
94 cseg ; boot loading must be done from resident memory
95
96 ; This version of the boot loader loads the CCP from a file
97 ; called CCP.COM on the system drive (A:).
98
99 ; First time, load the A:CCP.COM file into TPA
100 ?ldccp:
101 ld c,resetdsk
102 call bdos
103 xor a
104 ld (ccp$fcb+15),a ; zero extent
105 ld hl,0
106 ld (fcb$nr),hl ; start at beginning of file
107 ld de,ccp$fcb
108 ld c,open ; open file containing CCP
109 call bdos
110 inc a
111 jp z,no$ccp ; error if no file...
112 ld de,0100h
113 ld c,setdma ; start of TPA
114 call bdos
115 ld de,128
116 ld c,setmulti ; allow up to 16k bytes
117 call bdos
118 ld de,ccp$fcb
119 ld c,read ; load the thing
120 call bdos ; read records
121
122 ; now, copy CCP to bank 0 for reloading
123
124 ld bc,2*256 + tpa$bank ; c: src$bnk, b: dst$bnk
125 jr mov_ccp
126
127 ; just copy in the other direction
128 ?rlccp:
129 ld bc,tpa$bank*256 + 2 ; c: src$bnk, b: dst$bnk
130 mov_ccp:
131 call ?xmove
132 ld hl,0100h
133 ld d,h
134 ld e,l
135 ld bc,ccpsize ; clone 3K, just in case
136 call ?move
137 ret
138
139 no$ccp: ; here if we couldn't find the file
140 call pr.inln ; report this...
141 db 13,10,'BIOS Err on A: No CCP.COM file',0
142
143 call ?conin ; get a response
144 jr ?ldccp ; and try again
145
146
147 ccp$fcb:db 1,'CCP ','COM',0,0,0,0
148 ds 16
149 fcb$nr: db 0,0,0
150
151
152 dseg
153 hwini_tab:
154 db (hwini0_e-$)/2 ;count
155 db rcr,CREFSH ;configure DRAM refresh
156 db dcntl,CWAITIO ;wait states
157 db ccr,M_NCD ;No Clock Divide
158 db cmr,PHI_X2 ;X2 Clock Multiplier
159 db omcr,~M_IOC ;Operation Mode Control Register
160 hwini0_e:
161 db 0 ;stop mark
162
163 cseg
164 f_cpu dw 0,0 ;detected CPU clock frequency [Hz]
165
166 end