1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 nstd_dim:
28 proc;
29 return;
30
31 dcl (name1, type, name2, rw, order)
32 char (*);
33 dcl st bit (72);
34 dcl (sdb_ptr, wksp, ap) ptr;
35 dcl (
36 error_table_$no_backspace,
37 error_table_$undefined_order_request,
38 error_table_$bad_mode,
39 error_table_$buffer_big,
40 error_table_$bad_arg,
41 error_table_$ionmat
42 ) ext fixed bin (35);
43 dcl code fixed bin (35);
44 dcl setbit bit (18),
45 rdycmd fixed bin (6),
46 fix_sw bit (1),
47 attach_sw bit (1),
48 j fixed bin;
49 dcl (off, nelem, nelemt, ring, count, i)
50 fixed bin (17);
51 dcl density fixed bin;
52 dcl temp_name char (32);
53 dcl 1 wait_list,
54 2 n fixed bin (17),
55 2 chn fixed bin (71);
56 dcl 1 message,
57 2 channel fixed bin (71),
58 2 mess fixed bin (71),
59 2 sender bit (36),
60 2 origin,
61 3 dersig bit (18) unaligned,
62 3 ring bit (18) unaligned,
63 2 channel_index fixed bin (17);
64 dcl dum (tseg.buffer_size (1)) fixed bin (35) based;
65 dcl sst bit (18) aligned based;
66 dcl ord char (32);
67
68 dcl (addr, addrel, bit, length, null, ptr, rel, rtrim, search, substr, unspec)
69 builtin;
70 dcl (bin, bool, divide, index, max, string, lbound, hbound)
71 builtin;
72
73 dcl hcs_$make_seg entry (char (*), char (*), char (*), fixed bin, ptr, fixed bin (35));
74
75 dcl (
76 tdcm_$tdcm_attach,
77 tdcm_$tdcm_detach,
78 tdcm_$tdcm_set_signal,
79 tdcm_$tdcm_reset_signal,
80 tdcm_$tdcm_iocall
81 ) entry (ptr, fixed bin (35)),
82 tdcm_$tdcm_set_buf_size
83 entry (ptr, fixed bin, fixed bin (35)),
84 tdcm_$tdcm_message entry (ptr, char (*), fixed bin, fixed bin (35));
85 dcl cv_dec_check_ entry (char (*), fixed bin (35)) returns (fixed bin (35));
86
87 dcl ipc_$create_ev_chn ext entry (fixed bin (71), fixed bin (35));
88 dcl hcs_$delentry_seg entry (ptr, fixed bin (35));
89 dcl (
90 ioa_,
91 ioa_$rsnnl
92 ) entry options (variable);
93 dcl ipc_$block entry (ptr, ptr, fixed bin (35));
94 dcl instance fixed bin (35) int static init (1);
95
96 dcl segnm char (32);
97 dcl sav_stat bit (36);
98 dcl newerr fixed bin based (ap);
99
100 dcl cleanup condition;
101
102 dcl 1 hsbc aligned,
103 2 padx bit (2) unaligned,
104 2 maj bit (4) unaligned,
105 2 min bit (6) unaligned,
106 2 pady bit (24);
107
108 dcl 1 stream_data_block aligned based (sdb_ptr),
109 2 outer_module_name char (32) aligned,
110 2 device_name_list ptr,
111 2 tseg_ptr ptr,
112 2 retry_cnt fixed bin,
113 2 some_bits aligned,
114 3 no_data_sw bit (1) unaligned,
115 3 fix_rec bit (1) unaligned,
116 3 eot_bit bit (1) unaligned,
117 3 eof_bit bit (1) unaligned,
118 3 rewind bit (1) unaligned,
119 3 unload bit (1) unaligned,
120 3 fix_init bit (1) unaligned,
121 3 spare_bits bit (29) unaligned,
122 2 max_rec_len fixed bin,
123 2 fix_rec_size fixed bin,
124 2 buf_mask bit (18),
125 2 buf_count fixed bin,
126 2 data_count fixed bin,
127 2 bufchk fixed bin,
128 2 device_name,
129 3 next_device_ptr ptr,
130 3 name_size fixed bin (17),
131 3 name char (256) aligned,
132 2 tsegarea fixed bin (71);
133
134
135 dcl 1 ord_tab (18) aligned internal static,
136
137 2 oname char (32) aligned
138 init ( "back", "eof", "reset_status", "forward_record", "forward_file",
139 NOTE
140 "backspace_file", "erase", "high", "low", "protect", "unload", "rewind",
141
142 "d200", "d556", "d800", "d1600", "d6250", "data_security_erase"),
143
144
145 2 cmd bit (6) aligned
146 init ( "46"b3, "55"b3, "40"b3, "44"b3, "45"b3, "47"b3, "54"b3, "60"b3,
147 "61"b3, "62"b3, "72"b3, "70"b3, "64"b3, "61"b3, "60"b3, "65"b3, "41"b3, "73"b3);
148
149
150 %include tseg;
151
152
153
154 set_block_size:
155 entry (a_user_block_size, a_code);
156
157
158
159
160 dcl a_user_block_size fixed bin,
161 a_code fixed bin (35);
162
163 dcl user_block_size fixed bin int static;
164
165 dcl user_block_size_sw bit (1) int static init ("0"b);
166
167
168 if a_user_block_size ^= 0 then do;
169 user_block_size = a_user_block_size;
170 user_block_size_sw = "1"b;
171 end;
172 else user_block_size_sw = "0"b;
173
174 a_code = 0;
175 return;
176
177
178
179
180
181
182
183
184
185
186
187 nstd_attach:
188 entry (name1, type, name2, rw, st, sdb_ptr);
189
190 attach_sw = "0"b;
191 if sdb_ptr ^= null then do;
192
193 substr (st, 1, 36) = unspec (error_table_$ionmat);
194 return;
195 end;
196
197 on cleanup call clear_attach;
198
199
200
201
202
203
204 call ioa_$rsnnl ("nstd_sdb^d_", segnm, code, instance);
205 instance = instance + 1;
206
207 call hcs_$make_seg ("", segnm, "", 01011b, sdb_ptr, code);
208
209 if sdb_ptr = null then do;
210 BAD_OUT:
211 substr (st, 1, 36) = unspec (code);
212 substr (st, 52, 1) = "1"b;
213 return;
214 end;
215
216 outer_module_name = "nstd_";
217 device_name_list = addr (device_name);
218 next_device_ptr = null;
219 name_size = 32;
220 name = name2;
221 tseg_ptr = addr (tsegarea);
222 tsegp = tseg_ptr;
223 tseg.version_num = tseg_version_2;
224
225 stream_data_block.retry_cnt = 10;
226 fix_init = "0"b;
227
228
229
230 call ipc_$create_ev_chn (tseg.ev_chan, code);
231 if code ^= 0 then
232 go to BAD_ATTACH;
233
234 tseg.sync = 1;
235 tseg.get_size = 1;
236 tseg.buffer_offset = 0;
237 tseg.bufferptr (1) = bin (rel (addr (tseg.buffer (1))), 17);
238
239 do i = 1 to 12;
240 tseg.mode (i) = 0;
241 end;
242
243
244
245 if (rw ^= "r" & rw ^= "w" & rw ^= "rw" & rw ^= "") then do;
246 code = error_table_$bad_mode;
247 go to BAD_ATTACH;
248 end;
249
250
251 if rw = "r" then
252 ring, tseg.write_sw = 0;
253 else ring, tseg.write_sw = 1;
254
255 if index (name2, ",7track") ^= 0 then
256 tseg.tracks = 1;
257 else tseg.tracks = 0;
258
259 call tdcm_$tdcm_attach (tsegp, code);
260 if code ^= 0 then
261 go to BAD_ATTACH;
262 attach_sw = "1"b;
263
264 max_rec_len = 2800;
265 i = index (name2, ",block=") + 7;
266 if i <= 7 then do;
267 i = index (name2, ",blk=") + 5;
268 if i <= 5 then
269 i = index (name2, ",bk=") + 4;
270 end;
271 if i > 4 then do;
272 if i > length (name2) then do;
273 code = error_table_$bad_arg;
274 goto BAD_ATTACH;
275 end;
276 j = search (substr (name2, i), ", ") - 1;
277 if j < 0 then
278 j = length (name2) - i + 1;
279 max_rec_len = cv_dec_check_ (substr (name2, i, j), code);
280 if code ^= 0 then do;
281 code = error_table_$bad_arg;
282 goto BAD_ATTACH;
283 end;
284 end;
285
286
287
288 else if user_block_size_sw then
289 max_rec_len = max (user_block_size, max_rec_len);
290
291
292 call tdcm_$tdcm_set_buf_size (tsegp, max_rec_len, code);
293 if code ^= 0 then
294 goto BAD_ATTACH;
295
296 density = 800;
297 tseg.density = "00100"b;
298
299 i = index (name2, ",density=") + 9;
300 if i <= 9 then
301 i = index (name2, ",den=") + 5;
302 if i > 5 then do;
303 if i > length (name2) then do;
304 code = error_table_$bad_arg;
305 goto BAD_ATTACH;
306 end;
307 j = search (substr (name2, i), ", ") - 1;
308 if j < 0 then
309 j = length (name2) - i + 1;
310 density = cv_dec_check_ (substr (name2, i, j), code);
311 if code ^= 0 then do;
312 code = error_table_$bad_arg;
313 goto BAD_ATTACH;
314 end;
315 end;
316
317 if density = 1600 then do;
318 rdycmd = bin ("65"b3);
319 tseg.density = "00010"b;
320 end;
321
322 else if density = 800 then do;
323 rdycmd = bin ("60"b3);
324 tseg.density = "00100"b;
325 end;
326
327 else if density = 556 then do;
328 rdycmd = bin ("61"b3);
329 tseg.density = "01000"b;
330 end;
331
332 else if density = 200 then do;
333 rdycmd = bin ("64"b3);
334 tseg.density = "10000"b;
335 end;
336
337 else if density = 6250 then do;
338 rdycmd = bin ("41"b3);
339 tseg.density = "00001"b;
340 end;
341
342 else do;
343 code = error_table_$bad_arg;
344 goto BAD_ATTACH;
345 end;
346
347 call tdcm_$tdcm_set_signal (tsegp, code);
348
349 if code ^= 0 then
350 go to BAD_ATTACH;
351
352 call ioa_ ("Tape ^a will be mounted with ^[a^;no^] write ring.", name, (ring = 1));
353
354 temp_name = name;
355 call tdcm_$tdcm_message (tsegp, temp_name, ring, code);
356
357 if code ^= 0 then
358 go to BAD_ATTACH;
359
360
361 name = temp_name;
362 name_size = length (rtrim (name));
363
364
365
366
367 call wait;
368 if code ^= 0 then
369 go to BAD_ATTACH;
370 call ioa_ ("Tape ^a mounted on drive ^a with ^[a^;no^] write ring.", name, tseg.drive_name, (ring = 1));
371 return;
372
373
374 BAD_ATTACH:
375 substr (st, 52, 1) = "1"b;
376 substr (st, 1, 36) = unspec (code);
377 call clear_attach;
378 return;
379
380 DCM_ERR:
381 substr (st, 1, 36) = unspec (code);
382 return;
383
384
385
386
387
388
389
390
391
392
393
394 nstd_read:
395 entry (sdb_ptr, wksp, off, nelem, nelemt, st);
396
397 nelemt = 0;
398 call check_rewind;
399 count = stream_data_block.retry_cnt;
400
401 if fix_rec then do;
402
403 if fix_init then do;
404 no_data_sw = "1"b;
405 tseg.buffer_offset = 0;
406 tseg.buffer_count = buf_count;
407 tseg.write_sw = 0;
408 call tdcm_$tdcm_iocall (tsegp, code);
409 fix_init = "0"b;
410 end;
411
412 if tseg.write_sw = 0 then
413 go to fix_read;
414 call reset_fix_rec;
415 end;
416
417 tseg.write_sw = 0;
418 if nelem > max_rec_len then
419 go to BAD_BUF;
420
421 RLOOP:
422 tseg.buffer_size (1) = nelem;
423 tseg.buffer_count = 1;
424 tseg.command_count = 0;
425 tseg.buffer_offset = 0;
426
427 call tdcm_$tdcm_iocall (tsegp, code);
428 if code ^= 0 then
429 go to DCM_ERR;
430
431 if tseg.completion_status = 1 then do;
432
433 call move (1);
434
435 GOOD_OUT:
436 substr (st, 1, 36) = "0"b;
437 nelemt = tseg.buffer_size (1);
438 return;
439 end;
440
441
442
443 RECOV:
444 if substr (tseg.hardware_status, 3, 4) = "0100"b then
445 go to BAD_ORD;
446 if substr (tseg.hardware_status, 3, 4) = "0011"b
447 then if (substr (tseg.hardware_status, 7, 6) & "100010"b) = "000010"b then
448 go to BAD_ORD;
449
450 RECOV1:
451 if count > 0 then do;
452
453 count = count - 1;
454 tseg.command_count = 1;
455 tseg.command_queue (1) = 100110b;
456 call tdcm_$tdcm_iocall (tsegp, code);
457 if code ^= 0 then
458 go to DCM_ERR;
459 if tseg.completion_status ^= 1 then do;
460 substr (st, 1, 36) = unspec (error_table_$no_backspace);
461
462 return;
463 end;
464 if tseg.write_sw = 1 then
465 go to WLOOP;
466 go to RLOOP;
467
468 end;
469
470 else do;
471
472 nelemt = tseg.buffer_size (1);
473 if tseg.write_sw = 0 then
474 call move (1);
475
476 end;
477
478
479
480 BAD_ORD:
481 substr (st, 1, 1) = "1"b;
482
483
484
485 if stream_data_block.unload then
486 stream_data_block.rewind = "0"b;
487
488 substr (st, 25, 12) = tseg.hardware_status;
489 return;
490
491
492 fix_read:
493 fix_sw = "0"b;
494
495 fix_com:
496 if nelem ^= fix_rec_size then
497 go to BAD_BUF;
498
499 if no_data_sw then do;
500
501 if eof_bit then do;
502 substr (st, 1, 1) = "1"b;
503 substr (st, 25, 12) = substr (sav_stat, 1, 12);
504
505 eof_bit = "0"b;
506 fix_init = "1"b;
507 return;
508 end;
509
510 if eot_bit then do;
511 substr (st, 1, 1) = "1"b;
512 substr (st, 25, 12) = "000011100000"b;
513 return;
514 end;
515
516 bufchk = tseg.buffer_offset;
517 setbit = bit (bin (tseg.buffer_offset, 18), 18);
518
519 restart:
520 setbit = bool (setbit, buf_mask, "0110"b);
521 tseg.buffer_offset = bin (setbit, 17);
522 tseg.sync = 0;
523 tseg.buffer_count = buf_count;
524 call tdcm_$tdcm_iocall (tsegp, code);
525 if code ^= 0 then
526 go to DCM_ERR;
527 if tseg.completion_status ^< 2 then do;
528
529 string (hsbc) = tseg.hardware_status;
530 if hsbc.maj = "0100"b then do;
531 data_count = tseg.error_buffer - 1;
532 sav_stat = tseg.hardware_status;
533 if data_count = 0 then
534 go to BAD_ORD;
535 eof_bit = "1"b;
536 no_data_sw = "0"b;
537 go to fix_out;
538 end;
539
540 if hsbc.maj ^= "0011"b then
541 go to BAD_ORD;
542
543 if hsbc.min & "100000"b then do;
544 setbit = bool (setbit, buf_mask, "0110"b);
545
546 tseg.buffer_offset = bin (setbit, 17) + tseg.error_buffer;
547
548 tseg.buffer_count = buf_count - tseg.error_buffer;
549
550 call tdcm_$tdcm_iocall (tsegp, code);
551 setbit = bool (setbit, buf_mask, "0110"b);
552 tseg.buffer_offset = bin (setbit, 17);
553
554 tseg.buffer_count = buf_count;
555 call tdcm_$tdcm_iocall (tsegp, code);
556
557 substr (st, 1, 1) = "1"b;
558 substr (st, 25, 12) = "000011100000"b;
559
560 eot_bit = "1"b;
561 return;
562 end;
563
564 do j = 1 to count;
565 setbit = bool (setbit, buf_mask, "0110"b);
566
567 tseg.buffer_offset = bin (setbit, 17);
568
569 do i = 1 to tseg.error_buffer;
570 tseg.command_queue (i) = 100110b;
571
572 end;
573 tseg.command_count = tseg.error_buffer;
574
575 tseg.buffer_count = 0;
576 tseg.sync = 1;
577 call tdcm_$tdcm_iocall (tsegp, code);
578
579 if code ^= 0 then
580 go to DCM_ERR;
581 if tseg.completion_status ^< 2 then do;
582
583 substr (st, 1, 36) = unspec (error_table_$no_backspace);
584 return;
585 end;
586 tseg.buffer_count = buf_count;
587 call tdcm_$tdcm_iocall (tsegp, code);
588
589 if tseg.completion_status < 2 then
590 go to restart;
591 end;
592 go to BAD_ORD;
593 end;
594
595 no_data_sw = "0"b;
596 data_count = buf_count;
597 end;
598
599
600 fix_out:
601 call move (bufchk + 1);
602 bufchk = bufchk + 1;
603 data_count = data_count - 1;
604 if data_count = 0 then
605 no_data_sw = "1"b;
606 nelemt = nelem;
607 substr (st, 1, 36) = "0"b;
608 return;
609
610
611
612
613
614
615
616
617 nstd_write:
618 entry (sdb_ptr, wksp, off, nelem, nelemt, st);
619
620 nelemt = 0;
621 call check_rewind;
622 count = stream_data_block.retry_cnt;
623
624 if fix_rec then do;
625 if fix_init then do;
626 tseg.sync = 0;
627 no_data_sw = "0"b;
628 data_count = buf_count;
629 tseg.buffer_offset = buf_count;
630 bufchk = 0;
631 tseg.write_sw = 1;
632 fix_init = "0"b;
633 end;
634
635 if tseg.write_sw = 1 then
636 go to fix_r_write;
637 call reset_fix_rec;
638 end;
639
640
641 tseg.write_sw = 1;
642 if nelem > max_rec_len then do;
643
644 BAD_BUF:
645 substr (st, 1, 36) = unspec (error_table_$buffer_big);
646
647 return;
648 end;
649
650 WLOOP:
651 tseg.buffer_size (1) = nelem;
652 tseg.command_count = 0;
653 tseg.buffer_count = 1;
654 tseg.buffer_offset = 0;
655
656 call move (1);
657 call tdcm_$tdcm_iocall (tsegp, code);
658 if code ^= 0 then
659 go to DCM_ERR;
660 if tseg.completion_status = 1 then
661 go to GOOD_OUT;
662 if substr (tseg.hardware_status, 3, 5) = "00111"b then do;
663
664 nelemt = tseg.buffer_size (1);
665 go to BAD_ORD;
666 end;
667 go to RECOV1;
668
669
670
671
672 fix_r_write:
673 fix_sw = "1"b;
674 go to fix_com;
675
676
677
678
679
680
681
682 nstd_order:
683 entry (sdb_ptr, order, ap, st);
684
685 call check_rewind;
686
687 ord = order;
688
689 if fix_rec then
690 call reset_fix_rec;
691
692 do i = lbound (ord_tab, 1) to hbound (ord_tab, 1);
693
694 if ord = ord_tab (i).oname then do;
695
696 tseg.command_queue (1) = bin (ord_tab (i).cmd);
697
698 if i = 11 then
699 stream_data_block.unload = "1"b;
700 if i = 12 then
701 stream_data_block.rewind = "1"b;
702 go to COM;
703 end;
704
705 end;
706
707
708 if ord = "fixed_record_length" then do;
709
710 fix_rec = "1"b;
711 fix_rec_size = newerr;
712 buf_count = divide (max_rec_len, fix_rec_size, 17, 0);
713
714 if buf_count < 1 then
715 go to BAD_BUF;
716 if buf_count > 6 then
717 buf_count = 6;
718 tseg.get_size = 0;
719 buf_mask = bit (bin (buf_count, 18), 18);
720 eof_bit, eot_bit = "0"b;
721 tseg.sync = 0;
722 do i = 1 to 2 * buf_count;
723 tseg.buffer_size (i) = fix_rec_size;
724 tseg.bufferptr (i) = bin (rel (addrel (addr (tseg.buffer (1)), (i - 1) * fix_rec_size)), 17);
725
726 end;
727 fix_init = "1"b;
728 go to ORD_OUT;
729 end;
730
731
732 if ord = "bcd" then do;
733 do i = 1 to 12;
734 tseg.mode (i) = 1;
735 end;
736 go to ORD_OUT;
737 end;
738 if ord = "binary" then do;
739 do i = 1 to 12;
740 tseg.mode (i) = 0;
741 end;
742 go to ORD_OUT;
743 end;
744 if ord = "nine" then do;
745 do i = 1 to 12;
746 tseg.mode (i) = 2;
747 end;
748 go to ORD_OUT;
749 end;
750 if ord = "saved_status" then do;
751 STAT:
752 ap -> sst = tseg.hardware_status;
753 go to ORD_OUT;
754 end;
755 if ord = "request_status" then do;
756 tseg.command_count = 1;
757 tseg.command_queue (1) = 000000b;
758 call tdcm_$tdcm_iocall (tsegp, code);
759 if code ^= 0 then
760 go to DCM_ERR;
761 if tseg.completion_status ^= 1 then
762 go to BAD_ORD;
763 go to STAT;
764 end;
765 if ord = "err_count" then do;
766 if ap = null then do;
767 stream_data_block.retry_cnt = 10;
768 go to ORD_OUT;
769 end;
770 if newerr > 100 | newerr < 0 then
771 go to UOR;
772 stream_data_block.retry_cnt = newerr;
773 go to ORD_OUT;
774 end;
775
776 UOR:
777 substr (st, 1, 36) = unspec (error_table_$undefined_order_request);
778
779 return;
780
781 COM:
782 if stream_data_block.rewind then do;
783
784 call tdcm_$tdcm_set_signal (tsegp, code);
785 if code ^= 0 then
786 go to DCM_ERR;
787 end;
788
789 tseg.command_count = 1;
790 call tdcm_$tdcm_iocall (tsegp, code);
791 if tseg.completion_status ^= 1 then
792 go to BAD_ORD;
793
794 if stream_data_block.rewind then
795 if substr (tseg.hardware_status, 3, 4) = "0"b
796 & substr (tseg.hardware_status, 11, 1) then do;
797
798
799 stream_data_block.rewind = "0"b;
800 call tdcm_$tdcm_reset_signal (tsegp, code);
801
802 if code ^= 0 then
803 go to DCM_ERR;
804 end;
805
806 ORD_OUT:
807 substr (st, 1, 36) = "0"b;
808 return;
809
810 nstd_getsize:
811 entry (sdb_ptr, size, st);
812
813 dcl size fixed bin;
814
815 size = 36;
816
817 return;
818
819
820
821
822
823
824 nstd_detach:
825 entry (sdb_ptr, type, name2, st);
826
827 call check_rewind;
828 if fix_rec then do;
829 call reset_fix_rec;
830 end;
831 if stream_data_block.unload then
832 go to DET;
833 tseg.buffer_count = 0;
834 tseg.command_queue (1) = 111000b;
835 tseg.command_count = 1;
836 call tdcm_$tdcm_iocall (tsegp, code);
837 if code ^= 0 then
838 go to DCM_ERR;
839 if tseg.completion_status ^= 1 then
840 go to BAD_ORD;
841
842 DET:
843 call tdcm_$tdcm_detach (tsegp, code);
844 if code ^= 0 then
845 go to DCM_ERR;
846
847 call hcs_$delentry_seg (sdb_ptr, code);
848 if code ^= 0 then do;
849 substr (st, 1, 36) = unspec (code);
850 go to DET_BIT;
851 end;
852
853 substr (st, 1, 36) = "0"b;
854 DET_BIT:
855 substr (st, 52, 1) = "1"b;
856 return;
857
858
859
860 nstd_cmode:
861 entry (sdb_ptr, rw, oldrw, st);
862
863 dcl oldrw char (*);
864
865 tsegp = tseg_ptr;
866
867 if tseg.write_sw = 1 then
868 oldrw = "w";
869 else oldrw = "r";
870
871 if (rw ^= "w") & (rw ^= "r") & (rw ^= "rw") & (rw ^= "") then do;
872 substr (st, 1, 36) = unspec (error_table_$bad_mode);
873 return;
874 end;
875
876 if fix_rec then
877 call reset_fix_rec;
878
879 if rw = "r" then
880 tseg.write_sw = 0;
881 else tseg.write_sw = 1;
882
883 substr (st, 1, 36) = "0"b;
884 return;
885
886
887
888
889
890 reset_fix_rec:
891 proc;
892 tseg.sync = 1;
893 fix_rec = "0"b;
894
895 if fix_init then do;
896 fix_init = "0"b;
897 return;
898 end;
899
900 if tseg.write_sw = 1 then do;
901
902 setbit = bit (bin (tseg.buffer_offset, 18), 18);
903 setbit = bool (setbit, buf_mask, "0110"b);
904 tseg.buffer_offset = bin (setbit, 17);
905 tseg.buffer_count = bufchk;
906 tseg.command_count = 0;
907 call tdcm_$tdcm_iocall (tsegp, code);
908 if code ^= 0 then
909 go to DCM_ERR;
910 if tseg.completion_status ^< 2 then
911 go to BAD_ORD;
912 if ord = "eof" then do;
913 fix_rec = "0"b;
914 fix_init = "1"b;
915 end;
916 return;
917 end;
918
919 if eof_bit then do;
920 data_count = data_count + 1;
921 eof_bit = "0"b;
922 go to BACKSPACE;
923 end;
924
925 tseg.buffer_count = 0;
926 tseg.command_count = 0;
927 call tdcm_$tdcm_iocall (tsegp, code);
928 if code ^= 0 then
929 go to DCM_ERR;
930
931 if tseg.completion_status = 0 then
932 go to BACKSPACE;
933 if tseg.completion_status = 1 then do;
934 data_count = data_count + buf_count;
935 go to BACKSPACE;
936 end;
937 data_count = data_count + tseg.error_buffer;
938
939 BACKSPACE:
940 tseg.buffer_count = 0;
941 do i = 1 to data_count;
942 tseg.command_count = 1;
943 tseg.command_queue (1) = 100110b;
944 call tdcm_$tdcm_iocall (tsegp, code);
945 if code ^= 0 then
946 go to DCM_ERR;
947 end;
948
949 return;
950
951 end;
952
953
954
955
956
957
958
959 wait:
960 proc;
961
962
963 READY_CHK:
964 wait_list.n = 1;
965 wait_list.chn = tseg.ev_chan;
966 call ipc_$block (addr (wait_list), addr (message), code);
967
968 if code ^= 0 then do;
969 substr (st, 1, 36) = unspec (code);
970 return;
971 end;
972
973
974
975
976 tseg.command_count = 1;
977 tseg.buffer_count = 0;
978 tseg.command_queue (1) = rdycmd;
979 call tdcm_$tdcm_iocall (tsegp, code);
980 if code ^= 0 then
981 return;
982 if tseg.completion_status ^= 1 then
983 go to READY_CHK;
984
985 stream_data_block.rewind = "0"b;
986 call tdcm_$tdcm_reset_signal (tsegp, code);
987 return;
988
989 end;
990
991
992
993
994
995 move:
996 proc (no);
997
998 dcl no fixed bin;
999 dcl ptseg ptr;
1000 dcl puser ptr;
1001
1002 ptseg = ptr (tsegp, tseg.bufferptr (no));
1003 puser = addrel (wksp, off);
1004
1005 if tseg.write_sw = 1 then
1006 ptseg -> dum = puser -> dum;
1007 else puser -> dum = ptseg -> dum;
1008
1009 return;
1010 end move;
1011
1012
1013
1014 clear_attach:
1015 proc;
1016
1017 if attach_sw then
1018 call tdcm_$tdcm_detach (tsegp, code);
1019 if sdb_ptr ^= null then
1020 call hcs_$delentry_seg (sdb_ptr, code);
1021
1022 return;
1023
1024 end clear_attach;
1025
1026
1027
1028
1029
1030 check_rewind:
1031 proc;
1032
1033 tsegp = tseg_ptr;
1034 if stream_data_block.rewind then do;
1035 rdycmd = 100000b;
1036 call wait;
1037 if code ^= 0 then
1038 go to DCM_ERR;
1039 end;
1040
1041 return;
1042
1043 end check_rewind;
1044
1045 end;