-
Notifications
You must be signed in to change notification settings - Fork 0
/
k11m41.mac
2426 lines (1969 loc) · 64.6 KB
/
k11m41.mac
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.title k11m41 kermit i/o for RSX11M/M+ v4.1 and 2.1
.ident /5.0.05/ ; Jerry Hudgins (see below)
; define macros and things we want for KERMIT-11
.if ndf, K11INC
.ift
.include /IN:K11MAC.MAC/
.endc
.iif ndf, k11inc, .error ; INCLUDE for IN:K11MAC.MAC failed
.enabl gbl
; Copyright (C) 1983 1984 1985 1986 Change Software, Inc.
;
;
; This software is furnished under a license and may
; be used and copied only in accordance with the
; terms of such license and with the inclusion of
; the above copyright notice. This software or any
; other copies thereof may not be provided or other-
; wise made available to any other person. No title
; to and ownership of the software is hereby trans-
; ferred.
;
; The information in this software is subject to
; change without notice and should not be construed
; as a commitment by the author.
;
;
.sbttl edits
; 20-Jan-84 09:50:18 BDN Test and fix TTSPEED, SETSPD and BINREAD
;
; 03-Mar-84 Bob Denny 4.2.00 [RBD01]
; Rewrote namcvt(). Eliminated FCS parsing
; in favor of home-brew code which can handle
; the infinite variety of filespecs that may
; crop up when doing DECnet remote file access.
;
; 07-Mar-84 Bob Denny 5.0.00 [Edit trails removed]
; Fair rewrite, particularly of terminal handling.
; Changed within the existing KERMIT-11 architecture,
; which is better suited to RSTS/E (which seems to
; have a lot more terminal & communications options).
; Modes for RSX now allow operation at 9600 baud for
; packet communication. CONNECT is still a problem.
;
; 10-Mar-84 Bob Denny 5.0.01 The method used for CONNECT on RSTS/RSX
; will not work reliably on native RSX at baud rates
; over 1200 on a busy system. The "doconn()" routine
; was rewritten. Now there are 2 separate modules.
; Also, the binrea() function is now used only for
; packet reading, and has been greatly simplified.
;
; 16-mar-84 Brian Nelson
;
; Merged origional K11M41 with Bob Denny's mods.
;
; 11-Dec-85 Robin Miller 5.0.02 Attach the terminal in the TTYINI routine
; (RTM01) so incoming characters are not lost. On a /SLAVE
; terminal, the terminal must be attached so charac-
; ters will be placed in the typeahead buffer.
; Also detach the terminal in the TTYFIN routine.
;
; 11-Dec-85 Robin Miller 5.0.03 Change routine TTPARS to allow device names
; (RTM02) other name XK, TI, or TT for logical names. Also
; check for an error from ALUN$S directive in ASSDEV.
;
; 12-Dec-85 Robin Miller 5.0.04 Change routine ASSDEV to check for logged
; (RTM03) on terminal and to get real device name via GLUN$
; incase we've assigned a logical name.
;
;
; 25-Dec-85 Brian Nelson
; 08-Feb-86 Steve Heflin
; 10-Feb-86 Brian Nelson
; Finish added Steve Heflin's mods for ATOZ in.
;
; 03-Feb-89 Jerry Hudgins 5.0.05
; Moved GETPRV call in ASSDEV to ensure priv's are
; up for SF.SMC; will otherwise crash M+ V4.0. Set
; priv's on in EXIT routine also.
;
;
; RSX11M,M+ and P/OS support.
;
; If this looks like it's a mess, it's because it IS. It gets changed
; a little bit here and there (for the past 2 years), and thus has a
; number of contributions and changes from others, and changes due to
; 'NEW' versions of M+ and MicroRSX (ie, things stop working).
.sbttl macros
.macro moverr val,dst
movb val ,-(sp)
call $mover
movb (sp)+ ,dst
.endm moverr
.iif ndf, r$rsts, r$rsts = 0
.save
.psect CLECTX ,RW,D,GBL,REL,CON
.restore
ef.tmp = 17
ef.tt = 20
ef.tmo = 21
er.tmo == 176 ; for now, timeout
er.nod == 177 ; pseudo error for no data
nodata == er.nod
.library /LB:[1,1]EXEMC.MLB/
.mcall UCBDF$
UCBDF$
.sbttl data areas
.psect $idata rw,d,lcl,rel,con
fu$def::.word 0 ; if rms needs the DNA filled in
; The following defaults can be changed in the TKB command file as in:
;
; GBLPAT=K11PAK:DO$APP:1
; GBLPAT=K11PAK:DO$APP:0
; GBLPAT=K11PAK:DO$APP:0
do$dte::.word 0 ; if NE, force PROCOMM to default
do$app::.word 0 ; if NE, then append to logfiles
do$msg::.word 1 ; if EQ, then don't be verbose at times
do$tra::.word 1 ; if we look in logical name tables
; for an available terminal.
do$alt::.word 1 ; Force SET RSX CON ALT
.psect $idata rw,d,lcl,rel,con
;
; Terminal settings and parameter lists for line setting
;
;
; Add mods from Steve Heflin in (SSH and /41/ comments)
;
; Do not include the TC.TBC in the main GMC or SMC as we will
; not know if we are running on M, M+ or Micro-RSX. TC.TBS is
; not available on M. If built on M, the undefined global for
; TC.TBS won't hurt anything. BDN 20-DEC-1985 10:29
savass: ; Remote line saved attributes
savdlu::.byte TC.DLU,0 ; /{no}REMOTE /41/
.byte TC.SLV,0 ; /{no}SLAVE
.byte TC.BIN,0 ; /{no}READ_PASSALL /45/
.byte TC.NEC,0 ; /{no}ECHO /41/
.byte TC.RAT,0 ; /{no}TYPEAHEAD /41/
.byte TC.8BC,0 ; /{no}EIGHT_BIT /41/
savtbs: .byte TC.TBS,0 ; typeahead buffer size /41/
.byte TC.NBR,0 ; /{no}BROADCAST /41/
diarst = . - savass ; Restore this much for DIAL /45/
savxsp: .byte TC.XSP,0 ; /SPEED:xmt /41/
savrsp: .byte TC.RSP,0 ; /SPEED:rcv /41/
asvlen = .-savass ; /41/
setass: .byte TC.SLV,1 ; /SLAVE=TTnn:
.byte TC.NEC,1 ; /NOECHO /41/
.byte TC.RAT,1 ; /TYPEAHEAD /41/
.byte TC.8BC,1 ; /EIGHT_BIT /41/
settbs: .byte TC.TBS,220. ; typeahead buffer size /41/
.byte TC.NBR,1 ; /NOBROADCAST /41/
astlen = .-setass ; /41/
assdon: .word 0 ; flag remote save/set done
aslspd: ; Assigned line speed block/41/
aslxsp::.byte TC.XSP,0 ; /SPEED:xmt /41/
aslrsp::.byte TC.RSP,0 ; /SPEED:rcv /41/
iopend: .word 0 ; /36/ lun i/o waiting on
savchr: ; Saved line parameters
.byte TC.ACR,0 ; /{NO}WRAP
.byte TC.FDX,0 ; /{NO}FULLDUPLEX
.byte TC.HFF,0 ; /{NO}FORMFEED
.byte TC.HHT,0 ; /{NO}TAB
.byte TC.NEC,0 ; /{NO}ECHO
.byte TC.SLV,0 ; /{NO}SLAVE
.byte TC.SMR,0 ; /{NO}LOWERCASE
.byte TC.WID,0 ; /WIDTH = n
.byte TC.8BC,0 ; /{NO}EIGHTBIT
.byte TC.BIN,0 ; /{NO}RPA (BDN 04-Aug-84)
savlen = .-savchr
savdon: .word 0
;
; Local line buffer for binary reading
;
inilun: .word 0
linbuf: .blkb MAXLNG+<MAXLNG/10> ; /42/ (larger) Buffer itself
.even ; /42/ Safety
maxlin = .-linbuf ; Maximum read length
.even
linptr: .word linbuf ; Scan pointer
icrem: .rept 15. ; # characters remaining
.word 0
.endr
privon: .word 0 ; /41/ Save priv on/off status
ALSIZE == 440
SDBSIZ == 440
$albuf: .blkb ALSIZE ; /51/ Moved from K11DAT
$phnum: .blkb 60
$lnrea::.word RDLIN ; Default for packet reading
; Other r/w data for dialout line set routines /45/
;
.psect rwdata ,rw,d,lcl,rel,con ; read/write data
; Buffers for Autocall modem fix ; /45/
fixti2: .byte TC.DLU,2,TC.ABD,0 ; values we need for a modem /45/
sizti2 = . - fixti2 ; size of buffers for autocall /45/
; Read only code section
.psect $pdata ro,d,lcl,rel,con ; Read-only data
; System Macros used to get/set characteristics for dial out /45/
.mcall qiow$,dir$ ; call in system macroes /45/
ef.rem = 14. ; use remote event flag (14) /45/
set.dlu: qiow$ sf.smc,lun.ti,ef.rem,,,,<fixti2,sizti2> ; /45/
set.chars: qiow$ sf.smc,lun.ti,ef.rem,,,,<diachr,dialen> ; /45/
rest.chars: qiow$ sf.smc,lun.ti,ef.rem,,,,<datchr,datlen> ; /45/
; M+3.0 Carrier loss detection
dtrast: .byte TC.MHU,0
.word carast
dtrclr: .byte TC.MHU,0
.word 0
; Attributes needed to dialout /45/
diachr: .byte TC.BIN,1 ; binary mode to pass CNTR chars /45/
dialen = .-diachr ; - length of dialout char set /45/
; Other r/w data
.psect $pdata ro,d,lcl,rel,con ; Read-only data
datchr: ; Data mode line parameters
.byte TC.ACR,0 ; /NOWRAP
.byte TC.FDX,1 ; /FULLDUPLEX
.byte TC.HFF,1 ; /FORMFEED
.byte TC.HHT,1 ; /TAB
.byte TC.NEC,1 ; /NOECHO
.byte TC.SLV,1 ; /SLAVE
.byte TC.SMR,1 ; /LOWERCASE
.byte TC.WID,200. ; /WIDTH = 200.
.byte TC.8BC,1 ; /EIGHTBIT
.byte TC.BIN,0 ; /NORPA
datlen = . - datchr
ibmmod: .byte tc.bin,1 ; /RPA (need to read XON's)
.sbttl xinit - assign & attach command terminal
.mcall alun$s ,astx$s ,QIOW$S ,SREX$S ,FEAT$S
FE$EXT = 1
.psect $code
; XINIT - Assign and attach the command terminal
;
; This routine assigns and attaches the command terminal (the
; terminal that "ran" this copy of Kermit-11.
; *** N O T E *** Later, this routine should establish a ^C
; AST so that user can abort in-progress file transfers, and
; get Kermit out of server mode without having to send it a
; finish command. I'll wait for Brian to send me his changes
; for graceful transfer abort before I implement this, though.
;
; 23-Dec-85 19:28:43 BDN
;
; For P/OS, M+ v3 and Micro Rsx v3, also do a TLOG (or TRAN) and
; if we we a translation, do an implicit SET LINE. Can be disabled
; by setting DO$TRAN eq to zero.
.enabl lsb
xinit:: call rmsini ; /53/ Setup SST
FEAT$S #FE$EXT ; /56/ See if 4.2 or M+ 3.x
bcc 1$ ; /56/ Ok
mov sp ,rsx32 ; /56/ Set 3.2 flag
SREX$S #1$ ; /56/ See if this is OLD Rsx (3.2)
bcs 1$ ; /56/ Must be old RSX
clr rsx32 ; /56/ 4.0 or later, or M+ 1.0 and later
SREX$S ; /56/ Clear requested exit address
1$: mov #$albuf ,albuff ; /51/ Fill in
mov #$phnum ,phnum ; /51/ Fill in
clrb @phnum ; /51/ Zero it
clr @albuff ; /51/ Init to empty.
mov #$cmdbuf,cmdbuf ; /53/ $CMDBUF defined in K11RMS
mov #$argbuf,argbuf ; /53/ $ARGBUF defined in K11RMS
mov do$tran ,dotran ; /41/ flag for translation
mov do$msg ,infomsg ; /41/ flag for msg displaying
mov do$app ,logapp ; /41/ Append to logfile flag
mov do$dte ,procom ; /50/ Set default for PRO/COMM
message <Linked for RSX11M/M+ and P/OS >
tst #dapsup ; /56/
bne 4$ ; /56/
message <no DAP support> ; /56/
4$: message ; /56/
tst do$alt ; /46/ Force alternate code?
beq 5$ ; /46/ No
mov #xdorsx ,con$ds ; /46/ Yes
5$: mov #xdorsx ,altcon ; /44/
call getsys ; Find out whats running
cmpb r0 ,#SY$MPL ; M+?
bne 10$ ; No
mov sp ,fu$def ; m+, set SY: as def
10$: cmpb r0 ,#sy$pro ; p/os?
bne 20$ ; no
mov sp ,proflg ; yes, flag it
20$: tst dotran ; /41/ look for logical name
beq 30$ ; /41/ no
CALLS trntrm ,<#ttname> ; /41/ see if translation exits
tst r0 ; /41/ did this succeed ?
bne 30$ ; /41/ no
MESSAGE <Logical name translation returned >; /41/ inform the user
print #ttname ; /41/ print the equivalence name
MESSAGE ; /41/
STRCPY #ttdial ,#ttname ; /41/ copy it over here also
clr remote ; /41/ and we are local
br 40$ ; /41/ continue
30$: tst proflg ; /41/ assume default line for P/OS?
beq 40$ ; /41/ not P/OS
mov #poscon ,con$ds ; /44/ Force my connect code for p/os
STRCPY #ttname ,#xk$dev ; /41/ use xk0: device
STRCPY #ttdial ,#xk$dev ; /41/ use xk0: device
clr remote ; and we are local
clr con8bit ; clear bit 7
MESSAGE <Link default set to XK0: for P/OS>,cr ; tell the user
CALLS ttspeed ,<#ttname> ; /54/ Find out current speed
tst r0 ; /54/ Can't faile
beq 40$ ; /54/ It did
MESSAGE <Current speed: > ; /54/ A MESSAGE
DECOUT r0 ; /54/ Simple
MESSAGE ; cr/lf
40$: ALUN$S #LUN.TT,#"TI,#TIUNIT ; Assign command term.
QIOW$S #IO.ATT,#LUN.TT,#EF.TT,,#kbiost; Attach it, also
QIOW$S #SF.SMC,#LUN.TT,,,,,<#echoch,#2>
sub #10 ,sp ; /53/ Get terminal driver support
mov sp ,r2 ; /53/ A buffer
QIOW$S #IO.GTS,#LUN.TT,,,,,<r2,#4>
bcs 50$ ; /53/ Oops
bit #F2.EIO ,2(r2) ; /53/ Extended IO today?
beq 50$ ; /53/ No
mov #eioread,$lnread ; /53/ M+, try IO.EIO for version 3
50$: add #10 ,sp ; /53/ Pop buffer
clr tcdlu ; don't change tc.dlu
call setcc ; enable ^C asts
call inqter ; /45/ No, get the terminal type
mov r0 ,vttype ; /45/ Done
return
.save
.psect $xkdev ,ro,d,lcl,rel,con
echoch: .byte TC.NEC,0
xk$dev::.asciz /XK0:/
.even
.dsabl lsb
.restore
global <altcon, xdorsx ,con$ds ,poscon> ; /44/
global <lun.tt, tiunit>
global <ARGBUF,CMDBUF,$ARGBUF,$CMDBUF> ; /53/
global <DAPSUP,RSX32> ; /56/
inqbuf::mov #200. ,-(sp) ; /42/ Assume M+
call getsys ; /42/ M+ today?
cmpb r0 ,#SY$MPL ; /42/ If so, large buffering
beq 100$ ; /42/ M+
mov #500. ,(sp) ; /42/ Assume P/OS
tst proflg ; /42/ P/OS and XK:?
bne 100$ ; /42/ Yes, return(500)
mov #90. ,(sp) ; /42/ Vanilla RSX11M
100$: mov (sp)+ ,r0 ; /42/ Return buffering available
return ; /42/ for LONG PACKET support.
setcc:: QIOW$S #io.det,#lun.tt,#ef.tt,,#kbiost
QIOW$S #io.ata,#lun.tt,#ef.tt,,#kbiost,,<,0,#ttast>
return
ttast: cmpb (sp) ,#'c&37 ; control C ?
bne 100$ ; no
call cctrap ; yes, call handler to check it
tst iopend ; /36/ Is a QIO pending for packet?
beq 100$ ; /36/ no
QIOW$S #IO.KIL,iopend ; /36/ Yes, force an IO.ABO error
100$: tst (sp)+
astx$s ; and exit from ast service
global <cctrap>
.sbttl ttyini - Save & switch line to data mode
; T T Y I N I
;
; ttyini( %loc device_name ,%val channel_number ,%val ccflag )
;
;
; input: @r5 .asciz string of device name (Ignored on native RSX)
; 2(r5) channel number (LUN)
; 4(r5) mode bits: (Ignored on native RSX)
;
; output: r0 error codes
;
; On RSX, this routine does dynamic switching of terminal from
; interactive mode(s) to data mode(s). The ttysav(), ttyset()
; and noecho() routines are no-ops ...
;
; It is used only for packet communications. The "doconn()" in
; this module handles the setup and restoration of the terminal
; lines for CONNECT modes.
;
; ** Someday, the whole command terminal and communication line handling
; architecture should be smoothed out and simplified, once Brian and
; I get together and compare notes re: native RSX versus emulated RSX,
; and what is required for compatibility without too much pain ...
;
; Added SREX 22-Jun-84 11:15:46 Brian Nelson
;
; Bob Denny
;
.mcall srex$s ,exit$s
ttyini::save <r1>
call getprv ; /41/ May need privs
call ttpars ; Get unit number
bcs 1$
alun$s 2(r5),r1,r0 ; Assign LUN
mov $dsw,r0 ; get the result
bcc 2$ ; oops
1$: jmp 10$ ; Too far to branch
2$: clr r0 ; Make return success
clr savdon ; not saved tt settings yet
cmp 2(r5),#lun.co ; Command terminal (SAFETY)
beq 10$ ; (yes, ignore this)
QIOW$S #io.att,2(r5),#ef.tt ; Attach the terminal. (RTM01)
QIOW$S #sf.gmc,2(r5),#ef.tt,,#kbiost,,<#savchr,#savlen>
mov kbiost,r0
cmpb r0,#IS.SUC ; OK?
bne 10$ ; (no)
mov sp ,savdon ; we have done the save
mov 2(r5) ,inilun ; save this lun (BDN)
srex$s #abort ; in case server aborted (BDN)
tstb handch ; IBM crap (BDN 04-Aug-84)
beq 5$ ; no
QIOW$S #sf.smc,2(r5),#ef.tt,,#kbiost,,<#ibmmod,#2> ;
5$: QIOW$S #sf.smc,2(r5),#ef.tt,,#kbiost,,<#datchr,#datlen>
clr eioinit ;
mov kbiost,r0
cmpb r0,#IS.SUC ; OK?
bne 10$ ; (no)
clr r0 ; Yes - clear r0 = OK
QIOW$S #SF.SMC,2(r5),,,,,<#dtrast,#4> ; Set this up for carrier loss
10$: tst proflg ; if a pro/350, ignore errors
beq 100$ ; not a 350
clr r0 ; a 350, forget about the errors
100$: unsave <r1>
call drpprv ; /41/ No privs wanted now
return
rstsrv::tst inserv
beq 100$
call ..abort
100$: return
..abort:call getprv ; /41/ May need privs turned on
QIOW$S #sf.smc,inilun,#ef.tt,,#kbiost,,<#savchr,#savlen>
call drpprv ; /41/ Don't want privs anymore
return
abort: call ..abort
jmp exit
global <inserv>
; T T Y F I N
;
; ttyfin( %loc device_name ,%val channel_number )
;
;
; input: @r5 .asciz string of device name (Ignored on native RSX)
; 2(r5) channel number (LUN)
;
; No need for ttyrst()
;
ttyfin::call getprv ; /41/ May need privs up now
srex$s ; no more abort handling
cmp 2(r5),#lun.co ; Command terminal?
beq 10$ ; (yes, skip it)
QIOW$S #SF.SMC,2(r5),,,,,<#dtrclr,#4> ; Set this up for carrier loss
QIOW$S #io.det,2(r5),#ef.tt ; Attach the terminal. (RTM01)
tst savdon ; ever save the crap?
beq 10$ ; no, don't reset it
QIOW$S #sf.smc,2(r5),#ef.tt,,,,<#savchr,#savlen>
10$: call drpprv ; /41/ Don't want privs up
clr r0
return
; STUB ROUTINES - Not needed here
;
ttrini::
ttrfin::
ttysav::
ttyset::
ttyrst::
noecho::
echo::
clr r0
return
.sbttl get terminal name
; G T T N A M
;
; input: @r5 address of 8 character buffer for terminal name
; output: .asciz name of terminal
.mcall glun$s
gttnam::save <r1,r2,r3> ; save temps please
mov @r5 ,r3 ; point to output buffer please
sub #20 ,sp ; allocate a buffer for GLUN$S
mov sp ,r2 ; point to it please
glun$s #lun.tt ,r2 ; try it
cmpb @#$DSW ,#is.suc ; did it work ?
bne 90$ ; no, return the error code please
movb g.luna+0(r2),(r3)+ ; get the device name next
movb g.luna+1(r2),(r3)+ ; both bytes of it please
clr r1 ; get the unit number next please
bisb g.lunu(r2),r1 ; simple
clr r0 ; now compute the ascii name
div #10 ,r0 ; simple (in octal please for RSX)
mov r1 ,-(sp) ; save the low order unit number
cmp r0 ,#7 ; unit number > 77 octal ?
blos 10$ ; no
mov r0 ,r1 ; yes, do it again please
clr r0 ; simple
div #10 ,r0 ; and so on
add #'0 ,r0 ; convert to ascii please
movb r0 ,(r3)+ ; get the high part copied
mov r1 ,r0 ; and now put the next digit back
10$: mov (sp)+ ,r1 ; get the low digit back now
add #'0 ,r0 ; convert to ascii
add #'0 ,r1 ; likewise
movb r0 ,(r3)+ ; move the unit number in now
movb r1 ,(r3)+ ; at last ....
movb #': ,(r3)+ ; please insert a colon:
clrb @r3 ; make it .asciz
clr r0 ; no errors
br 100$ ; exit
90$: moverr @#$dsw ,r0 ; get the directive error code
100$: add #20 ,sp ; pop glun$s buffer
unsave <r3,r2,r1>
return
.sbttl Vanilla read from command terminal
; K B R E A D
;
; Read a line from the command terminal (80 characters max)
;
; Input: @r5 Address of 80 character buffer
;
; Output: r0 = 0 if OK, else error code
; r1 = Number of characters if OK, else 0
;
; Echoes a <LF> on completion to counter Dave Cutler's old
; FORTRAN record processing view of the world.
kbread::
QIOW$S #io.rvb,#5,#ef.tt,,#kbiost,,<@r5,#80.>
clr r0 ; assume no errors
mov kbiost+2,r1 ; return bytecount in r1
cmpb kbiost ,#is.suc ; successful read ?
beq 100$ ; yes
clr r1 ; no data please
moverr kbiost ,r0 ; return the error
100$: print #lf1
return
.save
.psect $PDATA ,D
lf1: .byte lf,0
.restore
.sbttl terminal read/write binary mode
; B I N R E A
;
; binread( %val channel_number, %val timeout )
;
;
; input: @r5 channel number
; 2(r5) timeout (if -1, then no wait) (do this for RSX??)
;
; output: r0 error
; r1 character read
;
; This version uses "normal" reading, as KERMIT sends its packets
; ending in its "EOL" character, which we need to be a <CR>. This
; makes reading packets a piece'o cake. We simply buffer lines
; here and scan off characters as needed. Terminal modes have
; been set for reasonably low driver overhead.
;
; No longer used by CONNECT
;
pakrea::
binrea::mov @r5 ,iopend ; /36/ save lun i/o is waiting on
tstb handch ; doing ibm style xon handshaking BDN
beq 5$ ; then we must do single char qios BDN
call xbinrea ; do that and exit BDN
br 100$ ; /36/ exit
5$: save <r2>
mov @r5 ,r2 ; lun to use today
asl r2 ; fix it for word indexing
10$: tst icrem(r2) ; Anything remaining in current line?
bne 40$ ; (yes)
jsr pc ,@$lnread ; Call someone to read data
bcs 50$ ; (read error)
br 10$ ; Try again
40$: clr r1 ; Move next char unsigned ...
bisb @linptr,r1 ; ... into r1
inc linptr ; Advance pointer
dec icrem(r2) ; Decrement # characters remaining
clr r0 ; Success
50$: unsave <r2>
100$: clr iopend ; /36/ i/o no longer pending
return ; Return
;
; RDLIN - Local read routine
;
; Inputs:
; @r5 LUN to read on
; 2(r5) timeout, seconds
;
; Outputs:
; C-bit clear Successful read (something read before timeout)
; icrem = number of characters in this line
; linptr -> 1st character in the line
;
; C-bit set Failed
; R0 = error code
; icrem = 0
.mcall mrkt$s ,wtse$s ,qiow$s
rdlin:
clr icrem(r2) ; Reset buffer counter
mov #linbuf,linptr ; Reset scan pointer
10$: clr r0 ; Assume no timeout
mov 2(r5),r1 ; R1 = timeout in seconds
ble 20$ ; (no timeout)
add #9.,r1 ; Round up to nearest 10 second clicks
div #10.,r0 ; Convert to 10 sec. clicks
20$: tst proflg ; pro/350?
bne 25$ ; yes
tst chario ; force pro/350 style reads today?
bne 25$ ; yes
tstb parity ; /39/ must check if TTDRV may never
beq 24$ ; /39/ see it's <CR> to terminate the
cmpb parity ,#PAR$NO ; /39/ line. Use a read with terminator
beq 24$ ; /39/ QIO if parity is on.
br 25$ ; /41/ IO.RTT did not work
;-/41/ mov #<IO.RTT!TF.RNE!TF.TMO>,r1 ; /39/
;-/41/ QIOW$S r1,@r5,#ef.tt,,#kbiost,,<#linbuf,#maxlin,r0,#tt$trm> ; /39/
;-/41/ br 30$ ; /39/
24$: QIOW$S #<io.rlb!tf.tmo>,@r5,#ef.tt,,#kbiost,,<#linbuf,#maxlin,r0>
br 30$
25$: call getprv ; /41/ May need for SF.GMC call
clr -(sp) ; get the typehead buffer size
mov sp ,r1 ; point to the parameter area
movb #tc.tbf ,@r1 ; we want amount in the buffer
QIOW$S #sf.gmc,@r5,#ef.tt,,,,<r1,#2>
movb 1(r1) ,r1 ; get the typeahead size
bne 26$ ; we have something to get there
inc r1 ; nothing, wait for one character
26$: QIOW$S #<io.ral!tf.tmo!tf.rne>,@r5,#ef.tt,,#kbiost,,<#linbuf,r1,r0>
tst (sp)+ ; pop sf.gmc buffer please
call drpprv ; /41/ Drop privs if need be
30$: movb kbiost ,r0 ; /41/
cmpb r0 ,#IE.DNR ; /45/ Did we drop carrier ?
bne 31$ ; /45/ No
mrkt$s #2,#1,#2 ; /45/ Yes, suspend for 1 second
wtse$s #2 ; /45/ ...
br 40$ ; /45/ Treat as timeout at upper lev
31$: cmpb r0 ,#IS.TMO ; timed out on the read ?
beq 40$ ; yes
cmpb r0 ,#IE.ABO ; /36/ from IO.KIL on control C ast?
beq 40$ ; /36/ yes, treat as a timeout then
cmpb r0 ,#IE.EOF ; /41/ End of file today (control Z)?
beq 80$ ; /41/ Yes, return control Z and 1 byte
cmpb kbiost+1,#33 ; /47/ Was \033 the terminator?
beq 80$ ; /41/ Yes, Again return control Z
cmpb linbuf ,#'Z&37 ; /41/ P/OS style reads and control Z?
beq 80$ ; /41/ Yes, exit
tst r0 ; Some kind of success?
bmi 90$ ; no
mov kbiost+2,icrem(r2) ; Yes, set up number of characters
mov #linbuf,r1 ; R1 --> line buffer
add icrem(r2),r1 ; R1 --> first free byte at end of line
movb kbiost+1,(r1) ; Get possible terminator character
beq 35$ ; (none)
inc icrem(r2) ; Adjust for terminator
35$: clrb (r1) ; Null terminate just for grins
clr r0 ; Clear r0 and C-bit
return ; Finished
40$: movb #er.tmo ,r0 ; return timeout error code
clr icrem(r2) ; just to be safe
sec ; say it failed
return
80$: movb #'Z&37 ,linbuf ; /41/ EOF or Escape sequence, return
mov #1 ,icrem(r2) ; /41/ control Z and char_count == 1
clc ; /41/ success
return ; /41/ exit
90$: clr icrem(r2) ; to be safe
sec ; Error
return ; bye
.sbttl Extended I/O read for M+ and MicroRsx version 3.x
.enabl lsb
; Added 27-Jun-86 13:24:18 Brian Nelson
;
; Now that I finally have an 11/73 running M+, I can do stuff
; like this.
E$MOD1 = 0 ; Modifier word 1
E$MOD2 = 2 ; Modifier word 2
E$BUFF = 4 ; Buffer address
E$LEN = 6 ; Buffer length
E$TMO = 10 ; Timeout (in seconds here)
E$PRM = 12 ; Prompt address
E$PRML = 14 ; Prompt length
E$PRMV = 16 ; Prompt VFC
E$TT = 20 ; Terminator table address
E$TTL = 22 ; Terminator table length
E$DFD = 24 ; Default data address
E$DFDL = 26 ; Default data length
.save ; Save current code psect
.psect rwdata ,d ; New psect
.even ; Insure
eiojnk: .word 0
eiolst: .word 0,0,0,0,0,0,0,0,0,0,0,0,0 ; Itemlist for IO.EIO
eioios: .word 0,0,0,0
eioini: .word 0
eiochr: .byte TC.BIN,0,TC.PTH,0
eiosav: .byte TC.BIN,0,TC.PTH,0
$$eiol = . - eiosav
.restore ; Restore old psect
eiorea::mov r3 ,-(sp) ; Save please
tst eioini ; Need to set chars for EIO?
bne 10$ ; No (reset to zero in TTYINI)
mov sp ,eioini ; Yes, change to /NORPA and /PASTHRU
tstb handch ; Hand shaking in effect?
bne 10$ ; Yes, leave TC.BIN on please
call getprv ; May need privs on
QIOW$S #SF.GMC,(r5),#EF.TT,,,,<#eiosav,#$$EIOL>
QIOW$S #SF.SMC,(r5),#EF.TT,,,,<#eiochr,#$$EIOL>
call drpprv ; Drop them now.
10$: clr ICREM(r2) ; Reset buffer counter
mov #linbuf,linptr ; Reset scan pointer
mov #eiolst ,r3 ; The itemlist
mov 2(r5) ,E$TMO(r3) ; Insert the timeout please
mov #linbuf ,E$BUFF(r3) ; Insert the buffer address next.
mov #maxlin ,E$LEN(r3) ; Insert the buffer size also.
mov #TF.TMO ,E$MOD1(r3) ; Insert desired read modifiers.
tst chario ; Do we read EXACTLY whats in buffer?
bne 15$ ; Yes.
tstb parity ; Is parity on ?
beq 20$ ; No, wait for terminators
cmpb parity ,#PAR$NO ; Well?
beq 20$ ; Ok. Otherwise, read typeahead ONLY
15$: clr E$TMO(r3) ; Yes, later we will not timeout first
bis #TF.RAL ,E$MOD1(r3) ; Also, we want everything AS IS!
;
20$: QIOW$S #IO.EIO!TF.RLB,(r5),#EF.TT,,#eioios,,<#eiolst,#30>
bcs 90$ ; The directive completely died
movb eioios ,r0 ; Get the QIO result.
cmpb r0 ,#IE.IFC ; Did it die because of this
beq 90$ ; Yes, reset to old read mode.
cmpb r0 ,#IE.ABO ; Did the ^C ast routine do IO.KIL
beq 80$ ; Yes, return(TIMEOUT)
cmpb r0 ,#IE.DNR ; Do we lack carrier now?
beq 70$ ; Yes, sleep a moment, return(TMO)
cmpb r0 ,#IE.EOF ; Well, what about END of FILE?
beq 60$ ; Thats it, return a control Z
tst r0 ; Did we get ANY kind of success?
bmi 90$ ; No, reset reader address, redo.
cmpb eioios+1,#33 ; Did we get ESCAPE as terminator?
beq 60$ ; Yes, also treat as control Z
cmpb linbuf ,#'Z&37 ; Does the buffer START with ^Z?
beq 60$ ; Yes, same thing.
cmpb r0 ,#IS.TMO ; Success with a TIMEOUT?
bne 30$ ; No
tst eioios+2 ; Yes, was there ANY data present?
bne 30$ ; There was data, return it please.
tstb E$TMO(r3) ; No data, but did we want only the
bne 80$ ; typeahead that was there? No
mov 2(r5) ,E$TMO(r3) ; Yes, stuff a REAL timeout in.
mov #1 ,E$LEN(r3) ; And only ONE character this time.
bis #TF.RAL ,E$MOD1(r3) ; Insure no waits for terminators.
br 20$ ; Try the read over again now.
;
30$: mov eioios+2,ICREM(r2) ; Return the size of the read now.
mov #linbuf ,r1 ; Get the buffer address
add ICREM(r2),r1 ; And point to the end of it.
movb eioios+1,(r1) ; Get possible terminator character
beq 40$ ; (none)
inc ICREM(r2) ; Adjust for terminator
40$: clrb (r1) ; Null terminate just for grins
clr r0 ; Clear r0 and C-bit
br 100$ ; Exit at last....
;
;
60$: movb #'Z&37 ,linbuf ; Force a control Z to be returned
inc ICREM(r2) ; Return exactly ONE character.
clc ; Successfull
br 100$ ; Exit
;
70$: MRKT$S #2,#1,#2 ; Lost carrier, suspend for a
WTSE$S #2 ; moment and return(TIMEOUT)
; Drop through to timeout
80$: movb #ER.TMO ,r0 ; Return timeout error code
sec ; Say the read failed
br 100$ ; And exit
;
90$: mov #rdlin ,$lnread ; Total failure, switch readers.
call getprv ; May need privs on
QIOW$S #SF.SMC,(r5),#EF.TT,,,,<#eiosav,#$$EIOL>
call drpprv ; Drop them now.
clc ; Force caller to try again.
100$: mov (sp)+ ,r3 ; Restore r3
return
.dsabl lsb
.sbttl BINWRITE(&buffer,size,channel)
; 0(r5) Buffer address
; 2(r5) buffer size
; 4(r5) channel number
; output: r0 error code
; Edit: /40/ 16-Dec-85 14:58:01 BDN Set timer in case line xoffed
.mcall mrkt$s ,cmkt$s ,QIOW$S ,astx$s ; /40/
.enabl lsb ; /40/
pakwri::
binwri::mov 4(r5) ,310$ ; /40/ Registers saved in ASTs?
mrkt$s #ef.tmo,#7,#2,#200$ ; /40/ start 7 second timeout
QIOW$S #io.wal,4(r5),#ef.tt,,#kbiost,,<@r5,2(r5)>
cmpb kbiost ,#IE.ABO ; /41/ Did the timeout occur?
beq 90$ ; /41/ Yes, try again
cmkt$s #ef.tmo,#200$ ; /40/ write ok, cancel timer
br 100$ ; /40/ and exit
90$: QIOW$S #io.wal,4(r5),#ef.tt,,#kbiost,,<@r5,2(r5)> ; /40/
100$: clr r0
return
200$: QIOW$S #IO.KIL,310$ ; /40/ abort the pending I/O
call getprv ; /41/ May need privs up now
QIOW$S #SF.SMC,310$,,,,,<#300$,#2> ; /40/ insure line is XON'ED
call drpprv ; /41/ Don't want privs anymore
tst (sp)+ ; /40/ pop timeout flag and
astx$s ; /40/ exit
.save
.psect $idata rw,d,lcl,rel,con
.even
300$: .byte TC.CTS,0
310$: .word 0
.restore
.dsabl lsb
.sbttl real binary i/o for doing ^X and ^Z things
; X B I N R E A
;
; binread( %val channel_number, %val timeout )
;
;
; XBINREAD is used in Kermit-11 for the DIAL command to read the
; responses from the modem on a character by character basis, and
; also is called once per packet if in local mode to check for
; typeahead in the form of CTRL E, X or Z to implement graceful
; transfer aborts. While this could be done under M/M+ via an un-
; solicited character AST, that won't work for RT11 and RSTS/E.
; Thus the sampling method (XBINREA called by CHKABO).
;
; /38/ Change QIO timed read to untimed with a MARKTIME (MRKT$S)
; to allow better granularity on the timeout interval. If time-
; out occures, do a IO.KIL
;
;
; input: @r5 channel number
; 2(r5) timeout (if -1, then no wait) (do this for RSX??)
;
; output: r0 error
; r1 character read
;
.mcall QIOW$S ,mrkt$s ,cmkt$s ,astx$s
xbinre::save <r2,r3> ; save a register for a friend
clr -(sp) ; allocate a buffer please
mov sp ,r2 ; and point to it now
clr -(sp) ; allocate a buffer for SF.GMC
mov sp ,r3 ; and point to it please
cmp 2(r5) ,#-1 ; get without any wait today ?
bne 20$ ; no, check for timeouts now
movb #tc.tbf ,@r3 ; create a .byte tc.tbf,0
QIOW$S #sf.gmc,@r5,#ef.tt,#50,#kbiost,,<r3,#2>