.title Map Socket .sbttl sktskt.mac ; 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 NULL is returned, else a pointer to the beginning ; of the buffer is returned (always PAR 7 -> 160000). ; .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 ; 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 ; rgnflg: .word 0 ;region active flag mru: .word -1 ;most recently used region .word -1 .word -1 .word -1 .word -1 .word -1 .word -1 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*8. ;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 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