]>
Commit | Line | Data |
---|---|---|
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 | |
f80331a6 L |
7 | public f_cpu\r |
8 | \r | |
1e1c17d3 | 9 | extrn boot,?conin\r |
d12d8b38 | 10 | extrn pr.inln,pr.crlf,pr.dec,pr.decl\r |
f80331a6 | 11 | extrn ioini1l,msginit,mmuinit,intinit,cpu_frq\r |
f4471ef9 | 12 | extrn prt0ini,gs_rtc\r |
ea5293bb | 13 | extrn @civec,@covec,@aivec,@aovec,@lovec\r |
573b9c25 | 14 | extrn @cbnk,?move,?xmove\r |
ea5293bb | 15 | \r |
411cf4de | 16 | include version.inc\r |
ea5293bb L |
17 | include config.inc\r |
18 | include z180reg.inc\r | |
19 | \r | |
20 | \r | |
ea5293bb L |
21 | ccpsize equ 0c80h\r |
22 | \r | |
40df51ae L |
23 | ; CP/M BDOS Function Interfaces\r |
24 | \r | |
25 | resetdsk equ 13\r | |
26 | open equ 15\r | |
27 | read equ 20\r | |
28 | setdma equ 26\r | |
29 | setmulti equ 44\r | |
30 | bdos equ 5\r | |
31 | \r | |
32 | \r | |
ea5293bb L |
33 | if banked\r |
34 | tpa$bank equ 1\r | |
35 | else\r | |
36 | tpa$bank equ 0\r | |
37 | endif\r | |
38 | \r | |
39 | \r | |
40 | dseg ; init done from banked memory\r | |
41 | \r | |
42 | hwinit:\r | |
43 | ld a,(INIDONE)\r | |
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 | |
52 | hwini_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 | |
ea5293bb L |
57 | ret\r |
58 | \r | |
59 | ?init:\r | |
c5868b68 L |
60 | ; ld hl,1000000000000000b ; assign console to AVRCON:\r |
61 | ld hl,0100000000000000b ; assign console to ASCI0:\r | |
ea5293bb L |
62 | ld (@civec),hl\r |
63 | ld (@covec),hl\r | |
64 | ld hl,0000000000000000b ; assign printer to nothing:\r | |
65 | ld (@lovec),hl\r | |
66 | ld hl,0100000000000000b ; assign AUX to ASCI0:\r | |
67 | ld (@aivec),hl\r | |
68 | ld (@aovec),hl\r | |
69 | \r | |
70 | \r | |
d12d8b38 | 71 | call intinit ; setup interrupts and vectors\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 |
129 | mov_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 |
138 | no$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 |
146 | ccp$fcb:db 1,'CCP ','COM',0,0,0,0\r |
147 | ds 16\r | |
148 | fcb$nr: db 0,0,0\r | |
149 | \r | |
150 | \r | |
f80331a6 | 151 | dseg\r |
ea5293bb L |
152 | hwini_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 |
159 | hwini0_e:\r |
160 | db 0 ;stop mark\r | |
161 | \r | |
f80331a6 L |
162 | cseg\r |
163 | f_cpu dw 0,0 ;detected CPU clock frequency [Hz]\r | |
ea5293bb L |
164 | \r |
165 | end\r |