39fa5920cc98929586c017fc435e4cc7af895003
[pdp8.git] / sw / dumprest / usb_enabled / older / RESTR0.PA
1 / RK05 RESTORE Program
2 / This program will receive a RK05 image and write it to the disk. The
3 / entire disk it written, with each sector having a reread check.
4 /
5 / This program should be started before the program (PC) sending the data
6 /
7 / See dump for the format of the serial data.
8 / To run start at 0200.
9 / SR 9-11 should be drive
10 / Should halt at HLT at label GDHLT (140) with AC = 0 if it worked.
11 / Hit cont to display in AC number of recoverable errors
12 / At normal exit hitting cont again will restart the program
13 /
14 / The current location being written to will be displayed in the AC
15 / while running. It is (cylinder * 16 + sector) / 2
16
17 DSKP=6741
18 DCLR=6742
19 DLAG=6743
20 DLCA=6744
21 DRST=6745
22 DLDC=6746
23
24 INAD=400 / Address of serial input, 30 for console
25 KCF2=6000 INAD
26 KSF2=6001 INAD
27 KCC2=6002 INAD
28 KRS2=6004 INAD
29 KIE2=6005 INAD
30 KRB2=6006 INAD
31
32 OUTAD=410 / Address of serial output, 40 for console
33 TFL2=6000 OUTAD
34 TSF2=6001 OUTAD
35 TCF2=6002 OUTAD
36 TPC2=6004 OUTAD
37 TSK2=6005 OUTAD
38 TLS2=6006 OUTAD
39
40 *20
41 ERRCNT, 7760 / Stop when err count = 0, init at startup
42 DRIVE, 0 / Drive # * 2
43 K0200, 0200
44 K4000, 4000
45 FLD, 10 / Use field 1 for data buffer
46 TRACK, 0
47 MAXTRK, 4537
48 EXBIT, 0
49 WRTDAT, 4000
50 REDDAT, 0000
51 WRTLOC, 0000 / Address to write data to disk
52 BUFLOC, 0000 / Address to store next word received
53 NUMSEC, 0 / Number of sectors received but not written
54 RDBUF, 1000 / Buffer for reread check
55 DSPTRK, 0
56 LOC, 0
57 LEN, 0
58 K6, 6
59 K17, 17
60 K377, 377
61 K7400, 7400
62 KN1, 7777
63 CHKSUM, 0
64 TEMP, 0
65 LAST, 0
66 DONEFG, 0 / 1 when end of data flag received
67 STATE, 0 / Where in serial data we are 0 = Need ff sector head,
68 / -1 = byte1, ... -3 = byte 3
69 BUFCNT, 0 / Count of words received in sector
70 ISRAC, 0
71 ISRFLG, 0
72 RISR, ISR
73 DECIMAL
74 NBLKSZ, -256
75 OCTAL
76 WRITEF, WRITE
77 RECALF, RECAL
78 STARTF, START
79
80 *1000
81 1234
82 4321
83
84 *1
85 JMP I RISR / Interrupt handler
86
87 *140
88 GDHLT, / HLT / Stop with sum of all words (including -checksum)
89 FINISH,
90 JMP I XFINI
91 XFINI, FINI
92
93 / HLT / Normal good halt
94 / JMP START / And restart if requested
95
96 / REBOOT FROM RK05
97 BO1, 6743
98 BO2, JMP 31
99 / Should be 0
100 / CLA
101 / TAD K17
102 / TAD ERRCNT
103 / HLT / # of errors
104 JMP I STARTF
105
106 *200
107 START, CDF 0 / Init all our variables
108 CAF
109 / CLA CLL OSR / Init variables changed during run
110 / RAL
111 / AND K6 / Clear out high bits such as 0200 start address
112 / DCA DRIVE
113 CLA / PHPH
114 DCA TRACK
115 DCA EXBIT
116 DCA CHKSUM
117 DCA STATE
118 DCA WRTLOC
119 DCA BUFLOC
120 DCA NUMSEC
121 DCA DONEFG
122 TAD K17
123 CIA
124 DCA ERRCNT
125
126 FLUSH, KSF2 / Get waiting TTI bytes out of the way.
127 JMP EMPTY
128 KRB2
129 JMP FLUSH
130 EMPTY,
131 / ION / Turn on serial interrupt handler
132 CLA CLL IAC / Set bit 11 to enable interrupts
133 KIE2
134 KRB2
135 / RPE / PTR Testing, use paper tape with emulator
136 / RFC
137 RECAL, CLA CLL IAC / Recal drive, clear errors and set to cyl 0
138 DCLR / From manual
139 TAD DRIVE
140 DLDC
141 CLA CLL CML RTL
142 DCLR
143 DSKP
144 JMP .-1
145 TAD K0200
146 TAD DRIVE
147 DLDC
148 DSKP
149 JMP .-1
150 DRST
151 CIA
152 TAD K4000
153 SZA CLA
154 JMP BADSTA
155 JMP I WRITEF
156 BADSTA, HLT
157
158 PAGE
159 WRITE, CLA CLL
160 TAD EXBIT
161 RAR
162 TAD TRACK
163 RAR
164 DCA DSPTRK / Save track for display
165 CDAT, CLA
166 TAD DSPTRK / Display write location
167 AND DSPTRK / Kill time to make brighter
168 AND DSPTRK
169 AND DSPTRK
170 IOF / Turn off interrupts so we can safely update
171 CLA / # of sectors in buffer
172 TAD NUMSEC
173 SNA
174 JMP NODAT
175 TAD KN1
176 DCA NUMSEC
177 IAC / 1 flags sector to write
178 NODAT, SNA / PHPH no ION if we have still data to write.
179 ION
180 SZA
181 JMP DOWRT / Got data write it
182 TAD DONEFG / No more data flag?
183 SNA
184 JMP CDAT / No, try again
185 JMP DONE / yes
186 DOWRT, CLA CLL IAC / We have one waiting, write it
187 DCLR
188 TAD WRTLOC
189 DLCA
190 TAD DRIVE
191 TAD WRTDAT
192 TAD FLD
193 TAD EXBIT
194 DLDC
195 TAD TRACK
196 DLAG
197 CLL
198 TAD DSPTRK
199 DSKP
200 JMP .-1
201 DRST
202 CIA
203 TAD K4000
204 SZA CLA
205 JMP ERROR
206 RDCHK, CLA CLL IAC / And now reread sector
207 DCLR
208 TAD RDBUF
209 DLCA
210 TAD DRIVE
211 TAD REDDAT
212 TAD EXBIT
213 DLDC
214 TAD TRACK
215 DLAG
216 CLA CLL
217 TAD DSPTRK
218 DSKP
219 JMP .-1
220 DRST
221 CIA
222 TAD K4000
223 SZA CLA
224 JMP ERROR
225 TAD RDBUF
226 DCA LOC
227 TAD NBLKSZ
228 DCA LEN
229 CHKDAT, CDF 10 / And now compare
230 TAD I WRTLOC
231 CIA
232 CDF 0
233 TAD I LOC
234 SZA
235 HLT / Big trouble, sector is bad without CRC error
236 ISZ WRTLOC
237 ISZ LOC
238 ISZ LEN
239 JMP CHKDAT
240 CLA CLL
241 INCTRK, ISZ TRACK / Increment track and exbit value for next sector
242 JMP WRITE
243 ISZ EXBIT
244 JMP WRITE
245 HLT
246 DONE, CLA CLL CMA / Done, wait for one more word
247 TAD BUFLOC
248 AND K17
249 SZA
250 JMP DONE
251 TAD CHKSUM / Get final checksum, receive has added checksum
252 SZA / word to running sum, Halt here if checksum
253 HLT / is not zero.
254 JMP GDHLT
255
256 ERROR, ISZ ERRCNT / To many errors?
257 JMP I RECALF / No, recal drive and try again
258 DRST / Yes, leave error in AC and halt
259 HLT
260
261 PAGE
262 ISR,
263 DCA ISRAC / Save AC
264 GTF
265 DCA ISRFLG / And flags
266 CDF 10 / Buffer in field 1
267 / RSF / PTR
268 KSF2 / Have character waiting
269 HLT / Stop, not our interrupt
270 / JMP IRET / No, not our interrupt
271 CLA
272 / RRB RFC / PTR
273 KRB2 / Get character
274 DCA TEMP
275 TAD STATE / Find out where in sequence we are
276 SNA
277 JMP SBLK / Start of block
278 IAC
279 SNA
280 JMP BYTE1
281 IAC
282 SNA
283 JMP BYTE2
284 CLA / Byte 3
285 TAD TEMP
286 CLL
287 RTL
288 RTL
289 TAD LAST
290 DCA I BUFLOC
291 TAD CHKSUM
292 TAD I BUFLOC
293 DCA CHKSUM
294 TAD BUFLOC
295 IAC
296 DCA BUFLOC
297 STA / -1 for byte 1
298 DCA STATE
299 ISZ BUFCNT
300 JMP IRET
301 DCA STATE / End of sector, set to 0 to check header byte
302 ISZ NUMSEC / Inc number of sectors buffered
303 TAD K17
304 CIA
305 TAD NUMSEC
306 SNA
307 HLT / To many buffered, halt. Must of had to many
308 / retries in a row
309 IRET, CLA
310 TAD ISRFLG
311 RTF
312 IOF / PH Turn off interrupts before one can happen...!!!
313 CLA
314 TAD ISRAC
315 JMP I 0
316 BYTE2, CLA
317 TAD TEMP
318 RTL
319 RTL
320 RTL
321 RTL
322 AND K7400
323 TAD LAST
324 DCA I BUFLOC
325 TAD CHKSUM
326 TAD I BUFLOC
327 DCA CHKSUM
328 ISZ BUFLOC
329 ISZ BUFCNT
330 TAD TEMP
331 RTR
332 RTR
333 AND K17
334 DCA LAST
335 CMA
336 TAD STATE
337 DCA STATE
338 JMP IRET
339 BYTE1, CLA
340 TAD TEMP
341 DCA LAST
342 CMA
343 TAD STATE
344 DCA STATE
345 JMP IRET
346 SBLK, TAD K377
347 CIA
348 TAD TEMP / Is is a ff?
349 SNA
350 JMP FLAGOK / Yes
351 IAC / Is it a fe?
352 SZA
353 HLT / No, halt
354 IAC
355 DCA DONEFG
356 FLAGOK, STA / -1 for byte 1
357 DCA STATE
358 TAD NBLKSZ / And setup to look for 256 words
359 DCA BUFCNT
360 JMP IRET
361
362 / OLD ROUTINE, COLD RK05 REBOOT
363 OFINI, CLA
364 TAD BO1
365 DCA 30
366 TAD BO2
367 DCA 31
368 CAF
369 JMP 30
370
371 *7600
372 FINI,
373 HLT
374 JMP I K200
375 K200, 200
376
377
378 $