]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame - cbios/boot.180
BIOS debugging with ddtz: Set 3F to 81 to en fifo inits.
[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
f80331a6
L
6 public f_cpu\r
7\r
1e1c17d3 8 extrn boot,?conin\r
d12d8b38 9 extrn pr.inln,pr.crlf,pr.dec,pr.decl\r
f80331a6 10 extrn ioini1l,msginit,mmuinit,intinit,cpu_frq\r
f4471ef9 11 extrn prt0ini,gs_rtc\r
ea5293bb 12 extrn @civec,@covec,@aivec,@aovec,@lovec\r
573b9c25 13 extrn @cbnk,?move,?xmove\r
ea5293bb 14\r
7c72cfe3
L
15 maclib z180reg.inc\r
16 maclib config.inc\r
17 maclib version.inc\r
ea5293bb
L
18\r
19\r
ea5293bb
L
20ccpsize equ 0c80h\r
21\r
40df51ae
L
22 ; CP/M BDOS Function Interfaces\r
23\r
24resetdsk equ 13\r
25open equ 15\r
26read equ 20\r
27setdma equ 26\r
28setmulti equ 44\r
29bdos equ 5\r
30\r
31\r
ea5293bb
L
32 if banked\r
33tpa$bank equ 1\r
34 else\r
35tpa$bank equ 0\r
36 endif\r
37\r
38\r
39 dseg ; init done from banked memory\r
40\r
41hwinit:\r
42 ld a,(INIDONE)\r
72ba3737 43 and 80h\r
ea5293bb
L
44 cp INIDONEVAL\r
45 jr z,hwini_skip\r
46 ld hl,hwini_tab\r
47 call ioini1l\r
48 ld a,0c3h\r
1e1c17d3 49 ld hl,boot\r
ea5293bb
L
50 ld (0),a\r
51 ld (1),hl\r
52hwini_skip:\r
ea5293bb 53 call msginit\r
f80331a6 54 call cpu_frq\r
43bb4ff6
L
55 ld (f_cpu),hl\r
56 ld (f_cpu+2),de\r
d6829fd3 57 call intinit ; setup interrupts and vectors\r
ea5293bb
L
58 ret\r
59\r
60?init:\r
c5868b68 61; ld hl,1000000000000000b ; assign console to AVRCON:\r
f1710b47 62 ld hl,0010000000000000b ; assign console to ASCI1:\r
ea5293bb
L
63 ld (@civec),hl\r
64 ld (@covec),hl\r
65 ld hl,0000000000000000b ; assign printer to nothing:\r
66 ld (@lovec),hl\r
72ba3737 67 ld hl,0000000000000000b ; assign AUX to ASCI0:\r
ea5293bb
L
68 ld (@aivec),hl\r
69 ld (@aovec),hl\r
70\r
71\r
f4471ef9
L
72 call prt0ini ; init timer\r
73 ei\r
50f3b8f0
L
74 ld c,2\r
75 call gs_rtc ; get time and date\r
ea5293bb
L
76\r
77 xor a\r
d12d8b38 78 ld (@cbnk),a ; right now in bank 0\r
ea5293bb 79\r
d12d8b38 80 call pr.inln ; print signon message\r
411cf4de
L
81 db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS v'\r
82 defvers\r
83 db 13,10\r
50f3b8f0 84 db 'Estimated CPU clock [Hz]: ',0\r
d12d8b38 85\r
43bb4ff6
L
86 ld hl,(f_cpu)\r
87 ld de,(f_cpu+2)\r
d12d8b38
L
88 call pr.decl\r
89 call pr.crlf\r
ea5293bb
L
90 ret\r
91\r
92\r
573b9c25 93 cseg ; boot loading must be done from resident memory\r
ea5293bb
L
94\r
95; This version of the boot loader loads the CCP from a file\r
96; called CCP.COM on the system drive (A:).\r
97\r
573b9c25 98 ; First time, load the A:CCP.COM file into TPA\r
ea5293bb 99?ldccp:\r
40df51ae
L
100 ld c,resetdsk\r
101 call bdos\r
ea5293bb 102 xor a\r
573b9c25 103 ld (ccp$fcb+15),a ; zero extent\r
ea5293bb 104 ld hl,0\r
573b9c25 105 ld (fcb$nr),hl ; start at beginning of file\r
ea5293bb 106 ld de,ccp$fcb\r
573b9c25 107 ld c,open ; open file containing CCP\r
40df51ae 108 call bdos\r
ea5293bb 109 inc a\r
573b9c25 110 jp z,no$ccp ; error if no file...\r
ea5293bb 111 ld de,0100h\r
40df51ae
L
112 ld c,setdma ; start of TPA\r
113 call bdos\r
ea5293bb 114 ld de,128\r
573b9c25 115 ld c,setmulti ; allow up to 16k bytes\r
40df51ae 116 call bdos\r
ea5293bb 117 ld de,ccp$fcb\r
573b9c25
L
118 ld c,read ; load the thing\r
119 call bdos ; read records\r
d12d8b38 120\r
573b9c25 121 ; now, copy CCP to bank 0 for reloading\r
ea5293bb 122\r
573b9c25
L
123 ld bc,2*256 + tpa$bank ; c: src$bnk, b: dst$bnk\r
124 jr mov_ccp\r
ea5293bb 125\r
573b9c25 126 ; just copy in the other direction\r
ea5293bb 127?rlccp:\r
573b9c25
L
128 ld bc,tpa$bank*256 + 2 ; c: src$bnk, b: dst$bnk\r
129mov_ccp:\r
130 call ?xmove\r
ea5293bb 131 ld hl,0100h\r
573b9c25
L
132 ld d,h\r
133 ld e,l\r
134 ld bc,ccpsize ; clone 3K, just in case\r
135 call ?move\r
ea5293bb
L
136 ret\r
137\r
573b9c25
L
138no$ccp: ; here if we couldn't find the file\r
139 call pr.inln ; report this...\r
140 db 13,10,'BIOS Err on A: No CCP.COM file',0\r
141\r
142 call ?conin ; get a response\r
143 jr ?ldccp ; and try again\r
144\r
ea5293bb 145\r
ea5293bb
L
146ccp$fcb:db 1,'CCP ','COM',0,0,0,0\r
147 ds 16\r
148fcb$nr: db 0,0,0\r
149\r
150\r
f80331a6 151 dseg\r
ea5293bb
L
152hwini_tab:\r
153 db (hwini0_e-$)/2 ;count\r
154 db rcr,CREFSH ;configure DRAM refresh\r
155 db dcntl,CWAITIO ;wait states\r
156 db ccr,M_NCD ;No Clock Divide\r
157 db cmr,PHI_X2 ;X2 Clock Multiplier\r
a28ee78c 158 db omcr,~M_IOC ;Operation Mode Control Register\r
ea5293bb
L
159hwini0_e:\r
160 db 0 ;stop mark\r
161\r
f80331a6
L
162 cseg\r
163f_cpu dw 0,0 ;detected CPU clock frequency [Hz]\r
ea5293bb
L
164\r
165 end\r