.title K11RTI One shot init code .ident /3.51/ ; 23-May-86 18:23:36 BDN Creation from K11RT4.MAC ; 07-Jun-86 05:39:17 BDN XM edits. ; ; As is most exec specific code, this has turned into a MESS. ; ; There are some significant assumptions made here. One is ; that for the virtual KERMIT (K11XM.SAV) is that APR7 ; (160000-177777) is available and does NOT contain any code ; overlays. This is because for XM image we create a dynamic ; region mapped from APR7 to allow placement of buffers and ; the like up there. In the case of the disk overlayed image ; (K11RT4.MAC) we just do a .SETTOP to 177776 and allocate ; buffers there, allowing the USR to swap if need be over the ; buffers. Additionally, the .FETCH buffer is, for the disk ; overlayed (non-virtual) K11RT4.SAV, allocated from this ; .SETTOP area. In the case of XM, however, we have a ; problem. In order to reduce the size of the ROOT to allow ; K11XM to run as a foreground job we ended up with the top ; of the root mapped by APR1 (20000-37777). Now it is a well ; known fact that XM places many constraints on what you can ; put in the range, QUE elements being the best known example ; of something you CAN NOT put there. It also turns out that ; you must NEVER try to load a handler into that area either. ; If you do, depending on the address, you can expect very ; erratic behavior from the handler, if not outright failure ; and a system crash. Such was the case on the PRO/350. The ; XC driver would MOST of the time work ok, but the system ; would ALWAYS crash on a .HRESET directive. Addtionally the ; XC OFFDRV .SPFUN, while setting the 'shutdown' flag in the ; driver, would be ignored at program exit. Thus any ; outstanding XC reads would attempt to enter a non-existent ; completion routine when the remote server timed out, and ; hang the PRO. ; ; The correct method to control this buffer (K11XM.COM only) ; is to set the extend size for the psect HNBUFF at link ; time. ; ; There are a couple of things here for TSX+ also. One, the ; TSX+ directive for altering the physical address space ; limit is used, this is simply an EMT 375 with R0 pointing ; to an argument block of the form ; ; .byte 0,141 ; .word TOP_ADDRESS_DESIRED ; ; This is done because, as in the case of the RSTS/E RT11 ; emulator, the .SETTOP directive only returns the current ; high limit, it has no effect on the memory allocation. Both ; systems thus have special directives to actually alter the ; memory size, alternativly one can patch location 56 (for ; both) to force additional allocation. The other, left in ; for historical reasons, asks for the TSX+ 'Line Number' in ; order to determine if the system is TSX+. I have left that ; in the init code instead of setting the flag in the ; previously described directive because I have no idea if ; the other directive works on older versions of TSX+. .sbttl Macro references and local read/write data .include /IN:K11MAC.MAC/ .psect dirmap ,rw,d,gbl,rel,ovr dirnam: .blkw 1 dirbfr: .blkw 1 .psect rwdata ,rw,d,lcl,rel,con time: .word 0,40 mtsts: .word 0,0,0,0,0 timbuf: .word 0,0 timbf1: .word 0,0 tenth: .word 0,6 totall: .word 0 cr = 15 lf = 12 ff = 14 soh = 1 maxsiz = 1000 errbyt == 52 topmem = 50 JSW = 44 ; RMON offsets CONFIG = 300 ; Primary RT11 configuration word CONFG2 = 370 ; The second one SYSGEN = 372 ; RT11 SYSGEN options offset $USRLC = 266 ; Location of the USR offset SYSVER = 276 ; The system major and minor version ; Flags PRO350 = 20000 ; In CONFG2, set if a PRO/350 or 380 TSXPLU = 100000 ; In CONFG2, set if TSX+ (not used) ; VIRTUAL = 2000 ; In the JSW, if set, a virtual job SJSYS = 1 ; In CONFIG, clear if a SJ system XMSYS = 10000 ; In CONFIG, set if XM and SJSYS off ; HNSIZE = 6000 ; Allocation for handlers in SJ/FB ; Macros needed .MCALL .QSET,.TWAIT,.FETCH,.GVAL,.SETTOP,.SERR,.HERR,.GTIM .MCALL .DSTAT,.MTSTAT,.EXIT,.GTJB ; Macros needed for the XM dynamic region support .MCALL .WDBBK ,.WDBDF ,.RDBBK ,.RDBDF ,.CRRG ,.CRAW .save ; Save CURRENT Psect .psect MAPWIN ,rw,d,gbl,rel,con ; Insure window data in ROOT ; ALLOC = 14000 ; How much to allocate for NOW .WDBDF .RDBDF apr7wi::.WDBBK 7,ALLOC/100,0,0,ALLOC/100,WS.MAP apr7re::.RDBBK ALLOC/100 mapwrk::.blkw 7 .restore ; Pop Last PSECT .sbttl Start RT11 specific things .enabl lsb .psect $CODE ,ro,i,lcl,rel,con xinit:: mov sp ,infomsg ; Default to verbosity mov #$$BUFP ,totall ; Determine total allocation add #100+200+100+100,totall ; For TT, Directory, PHNUM buffering add #1000 ,totall ; For Misc buffering STRCPY #defdir ,#dkname ; Set default device name .GTIM #rtwork ,#timbuf ; Insure clock rollover .GVAL #rtwork,#CONFIG ; Check for what we are running on bit #SJSYS ,r0 ; Can't run on SJ (perhaps) bne 10$ ; Ok, FB or XM .PRINT #nosj ; No, die dec montyp ; Exec type saved br 20$ ; 10$: bit #XMSYS ,r0 ; Check for XM system. beq 20$ ; No, must be FB inc montyp ; Its XM, save flag. mov #$limit+2,hilimit ; We really want VIRTUAL limit 20$: .GTJB #rtwork,#jobsts ; So we know if BG or FG job. .QSET #rtque,#nrtque ; Allocate extra que elements mov sp ,rtvol ; Assume volume header checks mov @#50 ,r5 ; Save low core HIGH LIMIT ; .SERR ; TSX+, grab some extra memory mov #tsxmem ,r0 ; But inhibit aborts under RT11 mov #160000 ,r2 ; Top limit minimum for VIRTUAL add totall ,r2 ; Got it. bit #VIRTUAL,@#JSW ; Is this the virtual overlay bne 30$ ; save image. If ne, YES mov r5 ,r2 ; Disk overlayed, reset amount add #HNSIZE ,r2 ; of memory desired then. add totall ,r2 ; Done. mov r2 ,2(r0) ; Insert the new size now. dec r2 ; 30$: EMT 375 ; Call TSX now bcs 40$ ; Must be RT11 today cmp r0 ,r2 ; TSX+, did it give us enough? bhis 40$ ; Yes, Keep on going message ,CR 40$: .HERR ; Re-enable RT11 aborts now ; mov #freept ,r2 ; Setup a pointer to this mov @hilimit,@r2 ; Free core list for SJ/FB .FETCH add #3 ,@r2 ; + 2 to pointer above us please bic #1 ,@r2 ; Insure even address ; bit #VIRTUAL,@#JSW ; Is this the K11XM image running? bne 50$ ; No, do a normal .SETTOP ; .SETTOP #-2 ; SJ or FB, or TSX and disk overlays br 70$ ; Ask for all of it, ignore the USR ; 50$: .CRRG #mapwrk ,#apr7re ; Its K11XM.SAV on RTXM or TSX+ bcs 60$ ; We will instead create a region. mov apr7re+r.gid,apr7wi+w.nrid; This will allow future expansion. .CRAW #mapwrk ,#apr7wi ; Create address window and MAP it. mov #ALLOC+160000,r0 ; Assume for now that we got it. bcc 70$ ; Successfull 60$: movb @#ERRBYT,r1 ; It failed, get the error code and MESSAGE DECOUT r1 ; Dump the error code MESSAGE ; A CR/LF mov r1 ,r0 ; Error code call maperr ; Get the error text address .PRINT r0 ; Dump the text .EXIT ; And go away now on mapping failure. ; ; 70$: mov r0 ,r1 ; Save the current MAX address. mov r1 ,maxtop ; Again, save the highest possible addr cmp @r2 ,r1 ; Is there REALLY space available? bhi 80$ ; No, DIE sub @r2 ,r1 ; Compute space available now. cmp totall ,r1 ; Space availble for buffer pool? blo 90$ ; Yes, it's ok 80$: .PRINT #nobuf ; Print an error message and DIE clr r0 ; Exit .EXIT ; Bye now. 90$: mov #2 ,r3 ; Offset into BUFDEF and BUFLST mov #4 ,r0 ; Four buffers to set up 100$: mov @r2 ,BUFLST(r3) ; Setup our buffer addresses now mov @r2 ,BUFDEF(r3) ; into the appropiate pointers. add #MAXSIZ ,@r2 ; Fix FREEPT up to point to next. add #2 ,r3 ; Point to next list entry sob r0 ,100$ ; Simple mov @r2 ,xklgbuf ; A special buffer for XC/XL/CL add #$$LBUF ,@r2 ; Add in the allocation now. mov @r2 ,albuff ; Allocate this buffer add #ALSIZE ,@r2 ; And move the pointer up clr @albuff ; Insure this is cleared out. mov @r2 ,$prtbuf ; Allocate a tt output buffer add #100 ,@r2 ; And move up again. mov @r2 ,dirnam ; Allocate more static buffers add #200 ,@r2 ; Move up mov @r2 ,dirbfr ; Allocate more dir listing buffers add #100 ,@r2 ; And move on up. mov @r2 ,phnum ; Save a phonenumber for REDIAL clrb @phnum ; Clear it add #100 ,@r2 ; Next please ; All done with buffer allocation. mov r2 ,fetpt ; Setup pointers for .FETCH now. mov @hilimit,fetptmax ; Max address for .FETCHING tst montyp ; But if this is XM, then we must ble 110$ ; force handlers into LOWCORE mov #xmflow ,xmfetpt ; We must insure APR0 .FETCHING add #3 ,xmfetpt ; low core overlay instead. bic #1 ,xmfetpt ; Insure EVEN mov #xmfetpt,fetpt ; Now insert address of pointer mov #xmftop ,fetptmax ; This is the top of XM .FETCH space ; 110$: clr proflg ; assume not a pro/350 clr tsxflg ; assume not TSX+ clr tsxcl ; assume not tsx and cl ; ; --- Use tried-and-true method to detect TSX+ ; .SERR ; Stop abort from RT-11 mov #tsxlin ,r0 ; Set the EMT EMT 375 ; Do it bcs 120$ ; Not TSX if an error mov #1,tsxflg ; it's TSX+, folks mov #1 ,tsxsav ; /45/ Have to save TSXFLG mov sp,remote ; assume remote if TSX+ print #k$tsx ; say who we are 120$: .HERR ; Reenable heavy-duty aborts tst tsxflg ; Where now? beq 130$ ; Off to more RT11 checks jmp 170$ ; No, TSX - skip to the end 130$: .GVAL #rtwork,#SYSVER ; check for RT version 5 please cmpb r0 ,#5 ; must be version 5 for PRO/350 blo 140$ ; no, can't be a pro .GVAL #rtwork,#CONFG2 ; get config word number two bit #PRO350 ,r0 ; is this a pro/350 ? beq 140$ ; no STRCPY #ttname ,#xc$dev ; /42/ use strcpy, use XC: STRCPY #ttdial ,#xc$dev ; /42/ use strcpy, use XC: mov sp ,proflg ; it's a pro/350, folks clr remote ; we want to be a local kermit PRINT #xcmsg ; say so br 170$ ; 140$: .DSTAT #rtwork ,#XCR50 ; /39/ check for XC and XL bcc 160$ ; /39/ found XC .DSTAT #rtwork ,#XLR50 ; /39/ no XC try XL bcc 160$ ; /39/ found XL .MTSTAT #rtwork ,#mtsts ; /39/ No XC: or XL:, look for bcs 150$ ; /39/ multiple terminal service tst mtsts+4 ; /39/ Any LUNS generated ? bne 160$ ; /39/ Yes 150$: .PRINT #noxcmt ; /39/ No, warn user of such fact mov sp ,remote ; /39/ Place us in remote mode and mov #-1 ,tsxflg ; /39/ Fake it using TSX code. mov #PAR$SPACE,parity ; /39/ Force 8 bit quoting 160$: CALLS gttnam ,<#errtxt> ; Get the name of the console tt: PRINT #ttn ; And say what it should be PRINT #errtxt ; Print it PRINT #crlf ; Finish the line 170$: mov sp ,clkflg .GTIM #rtwork ,#timbuf ; Get current time please .TWAIT #rtwork ,#tenth ; Wait a little while (1/10 sec) .GTIM #rtwork ,#timbf1 ; Get current time please cmp timbuf ,timbf1 ; See if time is same please bne 180$ ; No cmp timbuf+2,timbf1+2 ; Continue bne 180$ ; Not the same .PRINT #noclock ; Yes, issue a warning message clr clkflg ; Clear clock flag to NONE 180$: 190$: 200$: clr r0 ; no errors return .save .psect rwdata ,rw,d,lcl,rel,con tsxlin: .byte 0,110 ; TSX-Plus get-line-number emt tsxmem: .byte 0,141 ; TSX-Plus GET More Memory .word 163000 + $$BUFP ; Should be enough .psect $pdata dkdev: .rad50 /DK / nobuf: .ascii /??Kermit-11-F Insufficient space available for buffer pool/ .byte cr,lf .ascii /allocation. Please unload handlers or do a SET USR SWAP/ .byte cr,lf,0 nosj:: .asciz /Kermit-11 may not run correctly on a SJ monitor/ ttn: .asciz /RT-11 default terminal line set to unit / noclock:.ascii /This system does not appear to have a line clock./ .asciz /Kermit-11 may not run correctly./ xc$dev: .asciz /XC0:/ xcmsg: .asciz #PRO/350 comm port set to XC0:# k$tsx: .ascii /TSX-Plus remote mode/ crlf: .byte cr,lf,0 noxcmt: .ascii / This system lacks both XC and XL drivers, and has not been/ .byte cr,lf .ascii /generated for Multiple Terminal support. Only the CONSOLE/ .byte cr,lf .ascii /will be usable for Kermit. Eight bit prefixing support will/ .byte cr,lf .ascii /be required of the other Kermit for the transfer of binary/ .byte cr,lf .asciz /files./ .even xcr50: .rad50 /XC / xlr50: .rad50 /XL / dkname: .asciz /DK:/ .even .restore .dsabl lsb inqbuf::mov #90. ,r0 ; /42/ Large packets, no buffers return ; /42/ for RT11 however. GLOBAL GLOBAL .end