A large commit.
[pdp8.git] / sw / dumprest / usb_enabled / RESTR0.PA
CommitLineData
81e70d48
PH
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
41ERRCNT, 7760 / Stop when err count = 0, init at startup
42DRIVE, 0 / Drive # * 2
43K0200, 0200
44K4000, 4000
45FLD, 10 / Use field 1 for data buffer
46TRACK, 0
47MAXTRK, 4537
48EXBIT, 0
49WRTDAT, 4000
50REDDAT, 0000
51WRTLOC, 0000 / Address to write data to disk
52BUFLOC, 0000 / Address to store next word received
53NUMSEC, 0 / Number of sectors received but not written
54RDBUF, 1000 / Buffer for reread check
55DSPTRK, 0
56LOC, 0
57LEN, 0
58K6, 6
59K17, 17
60K377, 377
61K7400, 7400
62KN1, 7777
63CHKSUM, 0
64TEMP, 0
65LAST, 0
66DONEFG, 0 / 1 when end of data flag received
67STATE, 0 / Where in serial data we are 0 = Need ff sector head,
68 / -1 = byte1, ... -3 = byte 3
69BUFCNT, 0 / Count of words received in sector
70ISRAC, 0
71ISRFLG, 0
72RISR, ISR
73 DECIMAL
74NBLKSZ, -256
75 OCTAL
76WRITEF, WRITE
77RECALF, RECAL
78STARTF, START
79
80 *1000
81 1234
82 4321
83
84 *1
85 JMP I RISR / Interrupt handler
86
87 *140
88GDHLT, / HLT / Stop with sum of all words (including -checksum)
89FINISH,
90 JMP I XFINI
91XFINI, FINI
92
93/ HLT / Normal good halt
94/ JMP START / And restart if requested
95
96 / REBOOT FROM RK05
97BO1, 6743
98BO2, 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
107START, 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
126FLUSH, KSF2 / Get waiting TTI bytes out of the way.
127 JMP EMPTY
128 KRB2
129 JMP FLUSH
130EMPTY,
131 CLA CLL IAC / Set bit 11 to enable interrupts
132 KIE2
133 KRB2
134/ RPE / PTR Testing, use paper tape with emulator
135/ RFC
136RECAL, CLA CLL IAC / Recal drive, clear errors and set to cyl 0
137 DCLR / From manual
138 TAD DRIVE
139 DLDC
140 CLA CLL CML RTL
141 DCLR
142 DSKP
143 JMP .-1
144 TAD K0200
145 TAD DRIVE
146 DLDC
147 DSKP
148 JMP .-1
149 DRST
150 CIA
151 TAD K4000
152 SZA CLA
153 JMP BADSTA
154 JMP I WRITEF
155BADSTA, HLT
156
157 PAGE
158WRITE, CLA CLL
159 TAD EXBIT
160 RAR
161 TAD TRACK
162 RAR
163 /DCA DSPTRK / Save track for display
164CDAT,
165 /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
178NODAT, 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
186DOWRT, 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 JMP NOREAD / PHPH Don't want to read back and compare!
207RDCHK, CLA CLL IAC / And now reread sector
208 DCLR
209 TAD RDBUF
210 DLCA
211 TAD DRIVE
212 TAD REDDAT
213 TAD EXBIT
214 DLDC
215 TAD TRACK
216 DLAG
217 CLA CLL
218 TAD DSPTRK
219 DSKP
220 JMP .-1
221 DRST
222 CIA
223 TAD K4000
224 SZA CLA
225 JMP ERROR
226 TAD RDBUF
227 DCA LOC
228 TAD NBLKSZ
229 DCA LEN
230CHKDAT, CDF 10 / And now compare
231 TAD I WRTLOC
232 CIA
233 CDF 0
234 TAD I LOC
235 SZA
236 HLT / Big trouble, sector is bad without CRC error
237 ISZ WRTLOC
238 ISZ LOC
239 ISZ LEN
240 JMP CHKDAT
241 CLA CLL
242NOREAD,
243INCTRK, ISZ TRACK / Increment track and exbit value for next sector
244 JMP WRITE
245 ISZ EXBIT
246 JMP WRITE
247 HLT
248DONE, ION
249 CLA CLL CMA / Done, wait for one more word
250 TAD BUFLOC
251 AND K17
252 SZA
253 JMP DONE
254 TAD CHKSUM / Get final checksum, receive has added checksum
255 SZA / word to running sum, Halt here if checksum
256 HLT / is not zero.
257 JMP GDHLT
258
259ERROR, ISZ ERRCNT / To many errors?
260 JMP I RECALF / No, recal drive and try again
261 DRST / Yes, leave error in AC and halt
262 HLT
263
264 PAGE
265ISR,
266 DCA ISRAC / Save AC
267 GTF
268 DCA ISRFLG / And flags
269 CDF 10 / Buffer in field 1
270/ RSF / PTR
271 KSF2 / Have character waiting
272 HLT / Stop, not our interrupt
273/ JMP IRET / No, not our interrupt
274 CLA
275/ RRB RFC / PTR
276 KRB2 / Get character
277 DCA TEMP
278 TAD STATE / Find out where in sequence we are
279 SNA
280 JMP SBLK / Start of block
281 IAC
282 SNA
283 JMP BYTE1
284 IAC
285 SNA
286 JMP BYTE2
287 CLA / Byte 3
288 TAD TEMP
289 CLL
290 RTL
291 RTL
292 TAD LAST
293 DCA I BUFLOC
294 TAD CHKSUM
295 TAD I BUFLOC
296 DCA CHKSUM
297 TAD BUFLOC
298 IAC
299 DCA BUFLOC
300 STA / -1 for byte 1
301 DCA STATE
302 ISZ BUFCNT
303 JMP IRET
304 DCA STATE / End of sector, set to 0 to check header byte
305 ISZ NUMSEC / Inc number of sectors buffered
306 TAD K17
307 CIA
308 TAD NUMSEC
309 SNA
310 HLT / To many buffered, halt. Must of had to many
311 / retries in a row
312IRET, CLA
313 TAD ISRFLG
314 RTF
315 IOF / PH Turn off interrupts before one can happen...!!!
316 CLA
317 TAD ISRAC
318 JMP I 0
319BYTE2, CLA
320 TAD TEMP
321 RTL
322 RTL
323 RTL
324 RTL
325 AND K7400
326 TAD LAST
327 DCA I BUFLOC
328 TAD CHKSUM
329 TAD I BUFLOC
330 DCA CHKSUM
331 ISZ BUFLOC
332 ISZ BUFCNT
333 TAD TEMP
334 RTR
335 RTR
336 AND K17
337 DCA LAST
338 CMA
339 TAD STATE
340 DCA STATE
341 JMP IRET
342BYTE1, CLA
343 TAD TEMP
344 DCA LAST
345 CMA
346 TAD STATE
347 DCA STATE
348 JMP IRET
349SBLK, TAD K377
350 CIA
351 TAD TEMP / Is is a ff?
352 SNA
353 JMP FLAGOK / Yes
354 IAC / Is it a fe?
355 SZA
356 HLT / No, halt
357 IAC
358 DCA DONEFG
359FLAGOK, STA / -1 for byte 1
360 DCA STATE
361 TAD NBLKSZ / And setup to look for 256 words
362 DCA BUFCNT
363 JMP IRET
364
365/ OLD ROUTINE, COLD RK05 REBOOT
366OFINI, CLA
367 TAD BO1
368 DCA 30
369 TAD BO2
370 DCA 31
371 CAF
372 JMP 30
373
374*7600
375FINI,
376 HLT
377 JMP I K200
378K200, 200
379
380
381$