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