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