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