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