1 ;;; Copyright (c) 1999 Massachusetts Institute of Technology
3 ;;; This program is free software; you can redistribute it and/or
4 ;;; modify it under the terms of the GNU General Public License as
5 ;;; published by the Free Software Foundation; either version 3 of the
6 ;;; License, or (at your option) any later version.
8 ;;; This program is distributed in the hope that it will be useful,
9 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ;;; General Public License for more details.
13 ;;; You should have received a copy of the GNU General Public License
14 ;;; along with this program; if not, write to the Free Software
15 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ;PNTR1: MODE,,(SIXBIT /NET/)
29 ;MODES=> BITS 3.1== READ FROM ANY
30 ; 3.2== READ FROM SPECIFIC
32 ; 3.4== SEND IMMEDIATE
33 ; 3.5== USE UNAME JNAME AS MY1 AND MY2
34 ; 3.6== USE UNAME AS HIS1
37 ; 4 HIS NAME 1 & HIS NAME 2 WERE ZERO
39 ; 7 ON WRITE, RELOCATION OF READ BUFFER FAILED
40 ; 11 ATTEMPT TO SEND TO SELF
42 ; 20 SEND IMMEDIATE, GUY WASN'T THERE
43 ; 22 BUFFER NOT IN YOUR CORE IMAGE
48 MSENTS==40 ;# OF ENTRIES IN THE TABLE
50 MSUSER: BLOCK MSENTS ;USER INDEX
51 MSCHNL: BLOCK MSENTS ;USERS CHANNEL
52 MSBADR: BLOCK MSENTS ;RELATIVE ADDRR OF USER'S BUFR
53 MSBCNT: BLOCK MSENTS ;SIZE OF USERS BUFFER
55 MSWRIT: BLOCK MSENTS ;SENDING NAME 1
56 MSWRT2: BLOCK MSENTS ;SENDING NAME 2
57 MSREAD: BLOCK MSENTS ;READING NAME 1
58 MSRED2: BLOCK MSENTS ;READING NAME 2
60 MSPSW: -1 ;SWITCH FOR MSP VARIABLES
61 0 ;EXTRA WORD, FOR SWTL ROUTINE
65 \fIPCO: PUSHJ P,SWTL ;LOCK THE MSP SWITCH
67 TLNE C,1 ; read from any?
69 TLNE C,2 ; read from specific?
71 TLNE C,4 ; send and hang?
73 TLNE C,8 ; send immediate?
75 JRST OPNL12 ; none of the above
77 ; read from any (RA) and read from specific (RS)
78 MSRA: SETOM H ; H/-1 =>RA 0=>RS
82 ; find first free user slot
83 MOVSI W,-MSENTS ; W/ slot index
84 MSR1: SKIPG MSUSER(W) ; is this slot free?
87 JRST OPNL6 ; no free slots, device full
89 ; W/ slot index of a free slot
90 MSR2: MOVEM U,MSUSER(W) ; occupies this slot
91 ; make sure we have a legal buffer
92 HRRZ D,A ; relative address of second buffer
93 MOVEI E,3(D) ; E/ relative address of data area
94 XCTR XRW,[MOVES (D)] ;CHECK COUNT FETCH?
95 XCTR XRW,[MOVES TT,2(D)] ;CHECK ACTUAL COUNT PLACE
97 ; bufr ok, now put data in table
98 MOVEM E,MSBADR(W) ; stores buffer address
101 ; store sender name only if RS
103 XCTR XR,[MOVE TT,(D)] ; his name 1
104 XCTR XR,[MOVE I,1(D)] ; his name 2
105 TLNE C,40 ; his1 = UNAME?
106 MOVE TT,UNAME(U) ; yes
108 MSR3: SETZB TT,I ; zero if RA
112 ; 3.5 bit in C means use UNAME JNAME as myname1 and myname2
113 TLNN C,20 ; skips if want default
118 ; else me1 is in B and me2 is in SRN3(U)
124 MOVEI TT,(R) ;GET CHANNEL
126 MOVEM TT,MSCHNL(W) ;STORE FOR LATER INTERRUPT
128 PUSHJ P,LSWPOP ;UNLOCK MSP SWITCH
130 ; now put tabl index in lh of IOCHNM(U)(R)
133 MSPIO,,MSPIO ; attempted IOT will get IOCER 10.
134 \f; send and hang (SH) and send immediate (SI)
135 MSSI: SETOM H ; H/-1=>SI 0=>SH
139 ; validate his buffer specs
140 HRRZ D,A ; relative buffer address
141 MOVEI E,3(D) ; E/ relative data addr
142 XCTR XRW,[MOVES (D)] ;CHECK NAME
143 XCTR XRW,[MOVES Q,2(D)] ;CHECK COUNT
146 ; E/ absolute data addr
148 XCTR XR,[MOVE T,(D)] ; T/ his name 1
149 TLNE C,40 ; 3.6 bit means use UNAME
150 MOVE T,UNAME(U) ; yes
151 XCTR XR,[MOVE TT,1(D)] ; TT/ his name 2
152 JUMPN T,.+3 ; T and TT can not both be zero
155 MOVEM TT,EPDL(U) ; EPDL(U)/ hisname2
157 ; 3.5 bit in C means use UNAME JNAME as myname1 and myname2
158 TLNN C,20 ; skips if wants default
163 ; else myname1 is in B and myname2 is in SRN(U)
166 MOVEM TT,EPDL3(U) ; EPDL3/ myname1
167 MOVEM I,SRN4(U) ; SRN4/ myname2
169 ; see if entry is in the table
171 SKIPA ; no, will havee to wait
172 JRST MSS2 ; yes, service the transfer
173 JUMPL H,OPNL20 ; was an SI, lose
174 MSS1: XCTR XR,[MOVE T,(D)] ; in case it got munged
175 TLNE C,40 ; 3.6 bit means use UNAME
179 ; wait for entry to appear in table
180 MSDM3: PUSH P,T ;LSWPOP CLOBBERS T
181 PUSHJ P,LSWPOP ;UNLOCK MSPSW FOR WAITING
183 SKIPA ; forces a call to ufls
185 PUSHJ P,UFLS ; hang . . . .
186 PUSHJ P,SWTL ;RELOCK SWITCH NOW
188 POP P,T ;RESTORE T AFTER CLOBBERING BY SWTL
189 PUSHJ P,MSSTBL ; read has been done, get details
190 JRST MSS1 ; oops, must have been aborted
192 ; FALLS THRU IF MSSTBL SKIPS
193 ; table index of the user is now in T
194 MSS2: MOVE H,T ; H/ table index
195 MOVE A,MSUSER(H) ; A/ user index
197 JRST [PUSHJ P,LSWPOP ;POP MSPSW
199 PUSHJ P,RPCLSR ; stop or i'll shoot
200 PUSHJ P,SOSSET ;SET TO SOS USTP(A) ON PCLSR
203 ; get the absolute address of the read data buffer
204 MSS3: MOVE A,MSBADR(H) ; relative
205 ;SET UP PAGE MAP FOR RECEIVER (USER IN MSUSER(H))
207 MOVE J,MSUSER(H) ;USER TO RECEIVE
208 PUSHJ P,MPLDJ ;LOAD MAP
209 ; fix count (sender cnt in Q, receiver cnt in MSBCNT(H))
210 CAMG Q,MSBCNT(H) ; will it fit?
212 XCTRI XRW,[SETOM -1(A)] ; no, indicate overflow will be lost
213 CAIA ;REFERENCE WORKED, SKIP
214 JRST MSS7 ;FAIL, RESTORE STOPS ETC.
215 MOVE B,MSBCNT(H) ; B/ count
217 MSS4: MOVE B,Q ; B/ count
220 XCTRI XRW,[MOVEM TT,-1(A)] ; amount that will be xfered
221 CAIA ;REFERENCE WORKED, SKIP
222 JRST MSS7 ;FAIL, RESTORE STOPS ETC.
224 ; if MSWRIT was zero (RA), fill it in
225 MSS5: SKIPN MSWRIT(H)
229 XCTRI XRW,[MOVEM TT,-3(A)] ; read's him1
230 CAIA ;REFERENCE WORKED, SKIP
231 JRST MSS7 ;FAIL, RESTORE STOPS ETC.
233 XCTRI XRW,[MOVEM TT,-2(A)] ; read's him2
234 CAIA ;REFERENCE WORKED, SKIP
235 JRST MSS7 ;FAIL, RESTORE STOPS ETC.
237 ; RESTORE USER MAP TO CURRENT USER
240 ; XFER => B/ CNT A/READ BUFR E/WRIT BUFR J/UNRELOCATED BUFFER (READ)
241 HRRM A,IOCHST-IOCHNM(R) ;STORE RECEIVER ADDRESS FOR UBO
245 MOVE C,[SETZ W] ;POINTER FOR UBO
246 MOVE A,MSUSER(H) ;GET OTHER USERS NUMBER FOR UBO
247 PUSHJ P,UBO ;USER BLOCK OUTPUT - DO WRITE TRANSFER
250 PUSHJ P,LSWPOP ;UNDO RPCLSR (SOS USTP(MSUSR(H)))
251 MOVE A,MSUSER(H) ;GET TARGET USER
252 MOVE B,MSCHNL(H) ;CHANNEL HE OPENED
253 MOVE B,CHNBIT(B) ;BIT CORRESPONDING TO CHAN
254 TDNE B,MSKST2(A) ;SKIP IF NOT ENABLED
255 IORM B,IFPIR(A) ;SET HIS INTERRUPT
257 ; flush read entry from the table
267 PUSHJ P,LSWPOP ;UNLOCK MSPSW
270 SETOM A ; LH IOCHNM==-1 MEANS SEND (FOR CLOS)
271 JSP Q,OPSLD1 ;DOES POPJ BACK TO UUOH
273 ; (DOES NOT COME BACK)
275 ;HERE FOR FAILURE OF XCTRI WHILE MAP SET TO RECEIVER
276 MSS7: POP P,R ;RESTORE STACK
277 PUSHJ P,LSWPOP ;RESTART USER (SOS USTP)
278 PUSHJ P,TPFLT ;TAKE PAGE FAULT, CAUSE PAGE LOAD
279 PUSHJ P,MPLDZ ;RESTORE MY PAGE MAP
282 ; FIND LOSER IN TABLE SKIP IF WINS
283 ; IN => T/READ1 EPDL/READ2 EPDL3/WRITE1 SRN4/WRITE2
284 ; OUT => IF WINS, T/TABLE OFFSET
290 MOVE B,EPDL(U) ; B/ READ2
291 MOVE C,EPDL3(U) ; C/ WRITE1
292 MOVE D,SRN4(U) ; D/ WRITE2
293 MSSTB1: CAMN T,MSREAD(A)
296 SKIPN MSWRIT(A) ; if it was read from any
297 SKIPE MSWRT2(A) ; win if WRIT and WRT2 are both zero
305 MSSTB2: AOBJN A,MSSTB1
312 ; R/ addr of IOCHNM(USER)(CHNL)
314 MSCLOS: TRNE A,400000 ; -1 means write
316 CAIL A,MSENTS ; in bounds of table?
318 CAME U,MSUSER(A) ; is this still me?
321 ; yes, make this a free slot