;+ ; TITLE: AUT??? - AUTOLOAD OVERLAY LOADING AND MAPPING ; ROUTINE COMMON CODE FOR THE MODULES : ; AUTO - STANDARD AUTOLOAD WITHOUT AST INTERLOCKING ; AUTOT - AUTOLOAD WITH AST INTERLOCKING SUPPORT ; AUTOUT - AUTOLOAD WITH AST INTERLOCKING AND TRACING ; VERSION: X10.03 ; SYSTEM: Development System ; SUBSYSTEM: SYSTEM LIBRARIES ; ENTRY POINTS: $AUTO, $ALBPL, $ALBP1, $ALBP2 ; SOURCE FILE: AUTCOM.MAC (SEE ALSO AUTO.MAC, AUTOT.MAC, AUTOUT.MAC) ; SOFTWARE TREE: ZSYSLB.STS ; PROGRAMMER: Wayne E. Baisley ; DATE: November 30, 1984 ; ; ; REVISION DATE PROGRAMMER DESCRIPTION ; -------- -------- -------------- ----------------------------- ; ; 1) WB100 11/30/84 W. E. Baisley Completely new release based on ; RSX-11M V4.1 / RSX-11M-Plus V2.1. ; ; NOTES: There are several conditional-assembly flags for this module, to ; support the varieties needed : ; ; AST Defined if AST interlocking support is desired ; ; CLUSTER Defined if Cluster Library support is desired ; ; TRACE Defined if overlay trace support is desired ; ; With three flags, eight combinations are possible, of course. ; However, only three combinations are supported at this time. ;- .nlist toc .sbttl Version X10.03 .if df AST .if df TRACE .list .title Autout .nlist .iff ;if df TRACE .list .title Autot .nlist .endc ;if df TRACE .iff ;if df AST .list .title Auto .nlist .iftf ;if df AST .list .ident /X10.03/ ;+ .nlist .ift ;if df AST .if df TRACE .list ; TITLE: AUTOUT - AUTOLOAD OVERLAY LOADING AND MAPPING ; ROUTINE WITH AST INTERLOCKING, CLUSTER LIBRARY ; AND OVERLAY TRACE SUPPORT .nlist .iff ;if df TRACE .list ; TITLE: AUTOT - AUTOLOAD OVERLAY LOADING AND MAPPING ROUTINE ; WITH AST INTERLOCKING AND CLUSTER LIBRARY SUPPORT .nlist .endc ;if df TRACE .iff ;if df AST .list ; TITLE: AUTO - AUTOLOAD OVERLAY LOADING AND MAPPING ROUTINE ; WITH CLUSTER LIBRARY SUPPORT .nlist .iftf ;if df AST .list ; VERSION: X10.03 ; SYSTEM: Development System ; SUBSYSTEM: SYSTEM LIBRARIES ; ENTRY POINT: $AUTO .nlist .ift ;if df AST .if df TRACE .list ; SOURCE FILES: AUTOUT.MAC, AUTCOM.MAC .nlist .iff ;if df TRACE .list ; SOURCE FILES: AUTOT.MAC, AUTCOM.MAC .nlist .endc ;if df TRACE .iff ;if df AST .list ; SOURCE FILES: AUTO.MAC, AUTCOM.MAC .nlist .iftf ;if df AST .list ; SOFTWARE TREE: ZSYSLB.STS ; PROGRAMMER: Wayne E. Baisley ; DATE: March 9, 1984 ; ; ; REVISION DATE PROGRAMMER DESCRIPTION ; -------- -------- -------------- ----------------------------- ; ; 1) WB100 03/09/84 W. E. Baisley Completely new release based on ; RSX-11M V4.1 / RSX-11M-Plus V2.1. ; ; Notes: ; ; $Auto is called from the autoload overlay transfer vectors set up by the Task ; Builder in the $$ALVC psect. ; ; Inputs: ; ; 0(sp)=Address of the Data Portion of the Segment Descriptor Address ; in the Autoload Vector ; 2(sp)=Return address of the caller of the vectored routine ; ; Outputs: ; ; Loads and maps the called routine as required, calls the routine, and ; restore the Cluster context if necessary before returning to the caller. ; The Carry Bit is preserved, but the other condition codes returned by ; the overlaid routine are destroyed. ; .page ; ; The autoload vectors have the following format: ; ; +-------------------------------+ ; 0 | | ; +-- JSR PC,@.NAUTO --+ ; 2 | | ; +-------------------------------+ ; 4 | Segment Descriptor Address | ; +-------------------------------+ ; 6 | Virtual Entry Point Address | ; +-------------------------------+ ; ; For tasks with separate I-(nstruction) and D-(ata) Spaces, the format is : ; ; +-------------------------------+ ; 0 | MOV (PC)+,-(SP) | ; +-------------------------------+ ; 2 | Address of D-Space Portion | ; +-------------------------------+ I-Space Portion ; 4 | | ; +-- JMP @.NAUTO --+ ; 6 | | ; +-------------------------------+ ; ; +-------------------------------+ ; 0 | Segment Descriptor Address | ; +-------------------------------+ D-Space Portion ; 2 | Virtual Entry Point Address | ; +-------------------------------+ ; .page ; ; The autoload overlay routines accomplish their Cluster Library overlay context ; maintenance operations by means of a push-down stack which is an extension ; to the overlay work area. The Segment Stack area, located in the $$STCK ; psect, has the structure : ; ; +-------------------------------+ <- .nstlm ; | Empty | ; +-------------------------------+ ; . ; . ; . ; +-------------------------------+ ; | Nth Pair Of Words Of | <- .nstpt, while running ; +--- Saved Segment ---+ ; | Descriptor & Return Addrs | ; +-------------------------------+ ; . ; . ; . ; +-------------------------------+ ; | 1st Pair Of Words Of | ; +--- Saved Segment ---+ ; | Descriptor & Return Addrs | ; +-------------------------------+ <- .nstpt, initially ; ; The Segment Stack area is allocated at assembly time by Exdat, with a default size ; of 12. words. This is sufficient for Cluster Library and overlaid AST/SST calls 6 ; levels deep. Note well that if the Stack overflows your program will be killed via ; an IOT instruction! The Segment Stack area may be enlarged, as in this example : ; ; TKB>extsct=$$stck:20 !make the Segment Stack 16. words long ; .page ; ; The work area is located in the $$OVDT psect and is structured as follows : ; ; +-------------------------------+ ; 0 | Overlay Load LUN | .novly, n.ovly * ; +-------------------------------+ ; 2 | Address of First Segment Desc | .nstbl, n.stbl + ; +-------------------------------+ ; 4 | Overlay Load | .niost, n.iost ; +--- I/O ---+ ; 6 | Status Block | ; +-------------------------------+ ; 10 | Overlay Load Error Subroutine | .naler, n.aler + ; +---------------+---------------+ ; 13, 12 | AST Interlock | Seg Desc Size | .nfast, n.fast @ .nszsg, n.szsg * ; +---------------+---------------+ ; 14 | Load and Map Segment Routine | .nrdsg, n.rdsg + ; +-------------------------------+ ; 16 | Unmap Segment(s) Routine | .nmrks, n.mrks + ; +-------------------------------+ ; 20 | Displaced Seg Desc Tmp Storage| .ndtds, n.dtds ; +-------------------------------+ ; 22 | Autoload Routine | .nauto, n.auto + ; +---------------+---------------+ ; 25, 24 | Unused |AST Cluster Flg| .ncast, n.cast ! ; +---------------+---------------+ ; 26 | Top Address Of Segment Stack | .nstlm, n.stlm ! ; +-------------------------------+ ; 30 | Segment Stack Pointer | .nstpt, n.stpt ! ; +-------------------------------+ ; ; * - The Overlay Load LUN and the Segment Descriptor Size words are filled ; in by the Task Builder. The Segment Descriptor size is 6, 8, or 9 ; words long, depending on whether manual loading and memory-resident ; overlays are used. The Task Builder Automatically allocates a Logical ; Unit, assigns the load device to it, and fills in the number. ; ; + - The address of the first Segment Descriptor, and the addresses of ; the Overlay Load Failure, Load and Map Segment, Unmap Conflicting ; Segment(s), and Autoload Routines are filled in at assembly time ; by the Ovdat module. ; ; @ - The AST Interlock flag byte is initialized by the Exdat module whenever ; AST interlocking is required (Task-Builder Manual V4.1, Section 4.5). ; ; ! - The Top Address of Segment Stack and Segment Stack Pointer are filled ; in and the Segment Stack area is allocated at assembly time by the ; module Exdat. These optional words are present only if the module ; Exdat is included in your task, either implicitly because of $Marke's ; references, or explicitly in the Task-Build command file ; (I.e., lb:[1,1]syslib/lb:exdat). .page ; ; The Segment Descriptors, which are created by the Task Builder in the ; $$SGD0 psect, have the following format : ; ; +--------+----------------------+ ; 0 | Status | Relative Disk Address| s.stat ; +--------+------------------+---+ ; 2 | Virtual Load Address | F | s.addr ! ; +---------------------------+---+ ; 4 | Segment Length in Bytes | s.size ; +-------------------------------+ ; 6 | Link Up (away from root) | s.lkup ; +-------------------------------+ ; 10 | Link Down (toward root) | s.lkdn ; +-------------------------------+ ; 12 | Link Next (to neighbor) | s.lknt ; +-------------------------------+ ; 14 | Segment Name | s.name * ; +--- in ---+ ; 16 | Radix-50 | ; +-------------------------------+ ; 20 | Window Descriptor Address | s.pwdb * ; +-------------------------------+ ; ; For overlaid task segments with separate I- and D- spaces a segment descriptor ; extension is provided : ; ; +--------+----------------------+ ; 0 | Unused | D-Space Disk Address | s.dsta ; +--------+----------------------+ ; 2 | D-Space Virtual Load Address | s.dadr ; +-------------------------------+ ; 4 |D-Space Segment Length in Bytes| s.dsiz + ; +-------------------------------+ ; 6 | D-Space Window Descriptor Addr| s.dwdb ; +-------------------------------+ ; ; ! - Bit 0 of the Virtual Load Address word is set if the segment is for ; a task with separate I- and D- spaces. ; ; * - The Segment Name is appended only if the manual load routine ($Load) ; is used or if memory-resident overlays are included, in which case ; the Window Descriptor Address is also appended. The optional words ; are also included for tasks with separate I- and D- spaces. ; ; The status nibble is composed of the following flag bits : ; ; 100000 = Task-resident flag (Always set to 1) ; 40000 = (ss.nal) Segment has no disk allocation ; 20000 = (ss.dsk) Segment has been loaded from disk ; 10000 = (ss.nld) Segment is not loaded ; ; + - The D-Space Segment Length is zero if this segment is I-space only. ; .page ; ; The Window Descriptors, which are created by the Task Builder in the ; $$WNDS psect, have the following format : ; ; +---------------+---------------+ ; 1, 0 | Base APR | Window ID | w.napr, w.nid ; +---------------+---------------+ ; 2 | Virtual Base Address | w.nbas ; +-------------------------------+ ; 4 | Window Size in 64-byte blocks | w.nsiz ; +-------------------------------+ ; 6 | Region ID | w.nrid ; +-------------------------------+ ; 10 | Offset in Partition | w.noff ; +-------------------------------+ ; 12 | Length to Map | w.nlen ; +-------------------------------+ ; 14 | Status Word | w.nsts ; +-------------------------------+ ; 16 | Send/Receive Buffer Addr = 0 | w.nsrb ; +-------------------------------+ ; 20 | Flags Word | w.nflg * ; +-------------------------------+ ; 22 | Region Descriptor Address | w.nrda * ; +-------------------------------+ ; ; The first eight words of the Window Descriptor structure constitute a ; standard RSX-11M/M+ Window Descriptor Block, which is used in the window ; mapping directives for memory-resident overlays. If an overlay is part ; of the task, the Region ID is zero, and the Region Descriptor Address is ; zero if one has not (yet?) been allocated. For a memory-resident overlay ; in a shared region, there will be a Region Descriptor and the Region ID ; is copied from it whenever the region is attached. ; ; * - The Flags Word and Region Descriptor Address are always included in ; this structure by the Task Builder. The flag WF.MAP (bit 15) is set ; whenever this window (and consequently its region) is mapped. ; .page ; ; The Region Descriptors, which are created by the Task Builder in the ; $$RGDS psect, have the following format : ; ; +-------------------------------+ ; 0 | Region ID | r.gid ; +-------------------------------+ ; 2 | Region Size in 64-byte blocks | r.gsiz ; +-------------------------------+ ; 4 | Region Name | r.gnam ; +--- in ---+ ; 6 | Radix-50 | ; +-------------------------------+ ; 10 | Partition Name | r.gpar ; +--- in ---+ ; 12 | Radix-50 | ; +-------------------------------+ ; 14 | Region Status | r.gsts ; +-------------------------------+ ; 16 | Protection Codes = 0 | r.gpro ; +-------------------------------+ ; 20 | Flags Word | r.gflg * ; +-------------------------------+ ; ; * - The Flags Word is always included in this structure by the Task ; Builder. The flag RF.MAP (bit 15) is set whenever this region is ; mapped. ;- .enabl mcl .list meb alodf$ ;define the segment descriptor symbols .nlist .if df CLUSTER .list exddf$ ;define the overlay work area extension symbols .nlist .iff ;if df CLUSTER .list ovddf$ ;define the overlay work area symbols .nlist .endc ;if df CLUSTER .if df TRACE .list autflg = 31. ;overlay load event flag, borrowed for - ;synchronization with the AUT... task .page ; ; The logging section sends AUT... a packet with the following data : ; ; +-------------------------------+ ; 0 | Status | Segment, Window and Region ; +-------------------------------+ ; 2 | Autoload Vector Address | ; +-------------------------------+ ; 4 | Called Entry Point | ; +-------------------------------+ ; 6 | Segment Name | ; +--- in ---+ ; 10 | Radix-50 | ; +-------------------------------+ ; 12 | Region Name | If applicable ; +--- in ---+ ; 14 | Radix-50 | ; +-------------------------------+ ; 16 | Directive Status Word | ; +-------------------------------+ ; 20 | Task Local | ; +--- Event ---+ ; 22 | Flags | ; +-------------------------------+ ; 24 | Global | ; +--- Event ---+ ; 26 | Flags | ; +-------------------------------+ ; 30 | Synchronization Event Flag # | ; +-------------------------------+ ; ; The status word is composed of the following flag bits : ; ; 100000 = Routine is being called from AST level ; 40000 = Segment is not disk-resident ; 20000 = Segment is currently in memory ; 10000 = Segment is not loaded and/or not mapped ; 4000 = Segment has an external window ; 2000 = This segment's window is mapped ; 1000 = This segment's region is mapped ; ; After sending off the data message, this routine waits for AUT... to set ; the overlay load event flag (31.). This action avoids excessive pool ; usage. ; .psect aut... aut...: .rad50 *AUT...* ;receiver's task name .page ; ; Send off a message to AUT... ; .nlist .iftf ;if df TRACE .list .psect $$auto ro .enabl lsb $auto:: .nlist .ift ;if df TRACE .list mov r0,-(sp) ;free a register - mov r1,-(sp) ;or two mov 4(sp),r1 ;get the autoload vector 2nd half address tst -(sp) ;make room for the dsar$s status later mov #autflg,-(sp) ;plug in the flag we're waiting on sub #<4*2>,sp ;make room for the event flags mov sp,r0 ;copy the address mov @#$dsw,-(sp) ;record the current directive status dsar$s ;disable AST's for now mov @#$dsw,<6*2>(sp) ;remember whether they were already so rdaf$s r0 ;get the event flags clr -(sp) ;blank the segment and region name areas ... clr -(sp) ; clr -(sp) ; clr -(sp) ; mov 2(r1),-(sp) ;copy the target routine's virtual address mov r1,-(sp) ;set up the original autoload - sub #4,(sp) ;transfer vector address mov (r1),r1 ;pick up the segment descriptor address mov (r1),-(sp) ;copy the segment's status bic #ss.rda!100000,(sp) ;wipe out the disk address field and trash mov @#n.ovpt,r0 ;pick up the work area address mov n.szsg(r0),r0 ;determine how much optional - sub #s.name,r0 ;data we have beq 40$ ;if eq there is none; no region name, etc. mov s.name+0(r1), 6(sp) ;otherwise, copy the segment name ... mov s.name+2(r1),10(sp) ; cmp r0,#s.lgth-s.name ;were any wdb's allocated ? blo 40$ ;if lo no, we're done mov s.pwdb(r1),r1 ;pick up the wdb address beq 40$ ;if eq there isn't one bis #4000,(sp) ;otherwise, indicate the extra data bit #wf.map,w.nflg(r1) ;is this window mapped ? beq 20$ ;if eq no bis #2000,(sp) ;otherwise, mark it for the send 20$: .page mov w.nrda(r1),r1 ;pick up the rdb address beq 40$ ;if eq there isn't one mov r.gnam+0(r1),12(sp) ;otherwise, copy the region name ... mov r.gnam+2(r1),14(sp) ; bit #rf.map,r.gflg(r1) ;is this region mapped ? beq 40$ ;if eq no bis #1000,(sp) ;otherwise, mark it for the send 40$: mov sp,r0 ;copy the send data buffer address setf$s #autflg ;set the event flag stse$s #autflg ;stop for the event flag bcc 60$ ;if cc we didn't stop for long bis #100000,(sp) ;otherwise, we must be at AST state 60$: clef$s #autflg ;clear the event flag sdat$s #aut...,r0 ;ship it off bcs 80$ ;if cs AUT... must not be installed wtse$s #autflg ;otherwise, wait for AUT... to wake us 80$: add #<13.*2>,sp ;clean up our mess cmp (sp)+,#is.suc ;were AST's previously disabled ? bne 100$ ;if ne no enar$s ;otherwise, re-enable them 100$: mov (sp)+,r1 ;restore the registers ... mov (sp)+,r0 ; .dsabl lsb .enabl lsb .page .nlist .endc ;if df TRACE .list mov @(sp),-(sp) ;fetch the segment descriptor address bit #ss.nld,@(sp)+ ;is this segment neither mapped nor loaded ? bne 20$ ;if ne no, we must do so add #2,(sp) ;otherwise, point to the routine's addr $albp1:: ;AutoLoad BreakPoint position "1" mov @(sp)+,pc ;jump very indirectly ; ; Load we must ; 20$: jsr r5,.savr1 ;save registers 1-5 mov @#n.ovpt,r1 ;get the overlay work area address .nlist .ift ;if df AST .list call dsar ;disable ASTs, if appropriate .nlist .iftf ;if df AST .list mov 14(sp),r5 ;fetch the saved autoload vector addr mov (r5)+,r2 ;pick up the segment descriptor address mov (r5),14(sp) ;set up the routine's addr for return call @n.mrks(r1) ;unmap anything that's in the way ; ; Map every segment we need ; $albpl:: ;AutoLoad BreakPoint position "Loop" clr r3 ;let $rdsg use the default Event Flag clr r5 ;let $rdsg use the default AST 30$: clr r4 ;let $rdsg use the default IOSB call @n.rdsg(r1) ;attempt to load and/or map the segment bcc 40$ ;if cc we have done so call @n.aler(r1) ;call the error handling routine br 30$ ;if we return it must not have been bad 40$: mov s.lkdn(r2),r2 ;move a step closer to the window's root .nlist .if df CLUSTER .list beq 60$ ;if eq we've already done the root .nlist .iff ;if df CLUSTER .list beq $albp2 ;if eq we've already done the root .nlist .endc ;if df CLUSTER .list bit #ss.nld,(r2) ;is this segment loaded and mapped ? bne 30$ ;if ne no, go do this one also br 40$ ;otherwise, look deeper .nlist .if df CLUSTER .list 60$: mov n.dtds(r1),r2 ;was there a displaced segment descriptor ? beq $albp2 ;if eq no, simply transfer callr $pdls ;otherwise intercept the return .nlist .endc ;if df CLUSTER .list $albp2:: ;AutoLoad BreakPoint position "2" .nlist .ift ;if df AST .list callr enar ;reenable ASTs and jump to the routine .nlist .iff ;if df AST .list return ;enter the called routine .nlist .iftf ;if df AST .list .dsabl lsb .psect $$rtq ro,ovr,gbl dsar: .nlist .ift ;if df AST .list dsar$s ;disable AST recognition rolb n.fast(r1) ;put the carry into bit 0 .nlist .iftf ;if df AST .list return .psect $$rtr ro,ovr,gbl enar: .nlist .ift ;if df AST .list clc rorb n.fast(r1) ;were ASTs disabled earlier ? bcs 20$ ;if cs no enar$s ;reenable them 20$: .nlist .iftf ;if df AST .list return .nlist .if df CLUSTER .list .psect $$pdls ro,ovr $pdls: ;sneaky non-reference to $pdls routine .nlist .endc ;if df CLUSTER .endc ;if df AST .list .end