.title Map Socket .sbttl sktskt.mac ; DECUS C Calling Format ; ; jsr r5,csv$ ;save r2,r3, and r4 ; ;r5 is parameter base ; ;c$pmtr(r5) is first argument ; ;c$pmtr+2(r5) is second argument ; ;... ; ;return args in r0 ; ... ; user code ; ... ; ; jmp cret$ ;restore r2-r5 and return ; rts pc ;does the same (cret$ follows csv$) ; ; csv$ and cret$ need be used only if arguments are used ; ; The mapskt routine: ; ; (char *)mapskt((int) global_sknum) ; ; This routine creates and maps a unique 8K byte region ; for each unique socket request. If the region cannot be ; created a (-1) is returned, else a pointer to the beginning ; of the buffer is returned (always PAR 7 -> 160000). ; .include "os.mac" ;RT11 or TSX-Plus ? .radix 10. ;decimal radix nsckts = 32. ;maximum number of sockets .mcall .rdbbk .wdbbk .crrg .craw .elrg .mcall .exit .sbttl Region Definition Blocks .psect c$data .macro RDBLOCK i,j sckt'i''j: .rdbbk 4096./32.,0, .endm ...cnt = 0 .rept nsckts ...ten = ...cnt/10. ...one = ...cnt-<...ten*10.> ...cnt = ...cnt+1 RDBLOCK \...ten,\...one .endr .sbttl Region Definition Block Table .macro RDTABLE i,j .word sckt'i''j' .endm rgnlist: ...cnt = 0 .rept nsckts ...ten = ...cnt/10. ...one = ...cnt-<...ten*10.> ...cnt = ...cnt+1 RDTABLE \...ten,\...one .endr wdb: .wdbbk 7,4096./32.,0,0,4096./32.,ws.map argmnt: .blkw 2 ;argument area .page .sbttl Least Recently Used Table ; RT11 allows only 5 regions to be accessible simultaneously ; from a single job. ; ; TSX+ allows only 8 regions to be accessible simultaneously ; from a single job. ; ; (1) This table is ordered from the most recently ; used to the least recently used region. If the table ; contains the requested region a simple shuffle of the ; more recently used regions places the requested region ; at the beginning of the table. A window to the ; requested region is then mapped. ; ; request for region 03 ; ; mru 07 03 ; 06 07 ; 05 06 ; 04 ---->>>> 05 ; 03 04 ; 02 02 ; 01 01 ; lru 00 00 ; eru xx xx ; ; ; (2) If the required region is not accessable, then the ; table is shifted toward eru. The region specified by ; eru is released and the region specified by mru is ; is allocated and mapped. ; ; request for region 10 ; ; mru 03 10 ; 07 03 ; 06 07 ; 05 ---->>>> 06 ; 04 05 ; 02 04 ; 01 02 ; lru 00 01 ; eru xx 00 ; .iif ne rt$sys mrucnt = 5 ;RT11 limit .iif ne ts$sys mrucnt = 8 ;TSX+ limit rgnflg: .word 0 ;region active flag mru: .word -1 ;most recently used region .rept .word -1 .endr lru: .word -1 ;least recently used region eru: .word -1 ;region to release .page .sbttl Map Socket Routine .psect c$code mapskt:: jsr r5,csv$ mov c$pmtr(r5),r0 ;get socket number cmp r0,#nsckts ;limit argument bhis 9$ ;out of range - exit clr rgnflg ;no active region flag clr r1 ;mru table offset cmp mru(r1),r0 ;current active region ? beq 7$ ;yes - remapping not required br 2$ ;no - enter scanner 1$: cmp mru(r1),r0 ;found active region ? bne 2$ ;no - skip inc rgnflg ;set flag and br 3$ ;go shuffle table 2$: add #2,r1 ;next entry cmp r1,#2*mrucnt ;end of table ? blt 1$ 3$: mov mru-2(r1),mru(r1) ;shuffle table sub #2,r1 ;finished ? bgt 3$ ;no - loop mov r0,mru ;most recently used entry tst rgnflg ;region active ? bne 6$ ;yes - skip cmp #-1,eru ;deactivate a region ? beq 5$ ;no - skip mov eru,r1 ;get region number to release asl r1 ;word offset mov #-1,eru ;reset eru flag 4$: .elrg #argmnt,rgnlist(r1) ;release region (implicit unmap) 5$: mov mru,r1 ;get region to activate asl r1 ;word offset mov rgnlist(r1),r2 ;enable region allocation mov #,r.gsts(r2) .crrg #argmnt,r2 ;activate region bcs 8$ ;error - skip 6$: mov mru,r1 ;get region to map asl r1 ;word offset mov @rgnlist(r1),wdb+w.nrid ;id value .craw #argmnt,#wdb ;create a window and map the region bcs 8$ ;error - skip 7$: mov wdb+w.nbas,r0 ;return the pointer jmp cret$ 8$: mov #-1,mru ;drop region 9$: mov #-1,r0 ;error exit jmp cret$ .end