Google
 

Trailing-Edge - PDP-10 Archives - CFS_TSU04_19910205_1of1 - update/cblsrc/lcmipc.mac
There are 8 other files named lcmipc.mac in the archive. Click here to see a list.
; UPD ID= 3566 on 6/3/81 at 4:29 PM by NIXON                            
TITLE LCMIPC -%1.0(004) COBOL V12./LIBOL V12. MCS INTERFACE TO IPCF
SUBTTL D. TODD/DRT/AAG/CDO 

	SEARCH COPYRT
	SALL

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

COPYRIGHT (C) 1974, 1983, 1984 BY DIGITAL EQUIPMENT CORPORATION

	.COPYRIGHT		;Put standard copyright statement in REL file

	SEARCH	INTERM
IFE TOPS20,< SEARCH UUOSYM,MACTEN>
IFN TOPS20,<
	OPDEF PJRST [JRST]
	SEARCH UUOSYM	;STILL NEED UUOSYM!
>
	TWOSEG
	RELOC	400000	;TO THE HIGH SEGMENT

;REVISION HISTORY

;DMN	 3-JUN-80	[635] INCORPORATE MCS-10 FIXES FROM B.C.TEL.

;AC DEFINITIONS
T1=1
T2=T1+1
T3=T2+1
T4=T3+1
P=17

;ADDITIONAL DEFINITION
W2PLSH==-11		;SHIFT TO CONVERT WORDS TO PAGES
P2WLSH==11		;SHIFT TO CONVERT PAGES TO WORDS
PAGSIZ==^D512		;WORDS/PAGE
MNLEN==^D24		;MCS SYSTEM NAME LENGTH IN CHARACTERS
			;MUST BE .LE.29 AND .GE.1
PAGCSH==^D10		;[635] MAXIMUM PAGES ON FREE CHAIN


;INTERNAL ENTRY POINTS
	ENTRY	SNDPAG,RECPAG,GTPAG.,KILPAG,ONCE,SAVT
	ENTRY	CRPAG.

IFN TOPS20,<
	SNDPAG:	RECPAG:	GTPAG.:	KILPAG:	ONCE:	SAVT:	CRPAG.:
	OUTSTR	[ASCIZ	"?LIBOL IS NOT CONFIGURED TO SUPPORT TPS-20.
"]
	JRST	KILL.##
	END
>
IFE MCS,<
	SNDPAG:	RECPAG:	GTPAG.:	KILPAG:	ONCE:	SAVT:	CRPAG.:
	OUTSTR	[ASCIZ	"?LIBOL IS NOT CONFIGURED TO SUPPORT MCS.
"]
	JRST	KILL.##
	END
>


	INTERN	GETPG.	;[635]


;EXTERNAL DEFINITIONS FOUND IN LIBIMP
	EXTERNAL	PIDMCP,PIDLCM,IPCFLG
	EXTERNAL	PAKSND,MSGSND,PAKREC,MSGREC
	EXTERNAL	PAGOFF,PAGBIT
	EXTERN		PAGCNT,PAGLST	;[635]

;EXTERNAL FOUND IN LCM.MAC
	EXTERNAL	LCMFTL
;SUBROUTINE SNDPAG - SEND A PAGE TO THE MCP
;CALL	MOVEI	T1,PAGE NUMBER	;PAGE TO SEND
;	  CPOPJ			;CAN NOT SEND THE PAGE
;	CPOPJ1			;PAGE HAS BEEN SENT TO THE MCP
SNDPAG::				;ENTRY POINT
	PUSH	P,T1		;SAVE THE PAGE NUMBER
	HRLI	T1,PAGSIZ	;ADD THE PAGE SIZE
	MOVEM	T1,PAKSND+.IPCFP ;STORE THE POINTER
	MOVE	T1,PIDMCP	;GET THE PID OF MCP
	MOVEM	T1,PAKSND+.IPCFR	;STORE THE RECEIVER
	MOVE	T1,PIDLCM	;[635] GET MY PID
	MOVEM	T1,PAKSND+.IPCFS	;[635] STORE AS SENDER
	MOVEI	T1,IP.CFV	;SEND IN PAGE MODE
	PUSHJ	P,SNDIPC	;SEND TO IPCF
	  JRST	SNDPAE		;ERROR
	POP	P,T1		;RESTORE THE PAGE NUMBER
	PJRST	PUTPAG		;REMOVE THE PAGE FROM THE TABLES

SNDPAE:	EXCH	T1,(P)		;PUT THE ERROR BITS ON THE STACK
	JRST	T1POPJ		;RETURN WITH ERROR IN T1

;SUBROUTINE SNDIPC SEND A PACKET OR PAGE
;CALL	MOVE	T1,FLAGS
;	PUSHJ	P,SNDIPC
;RETURN	CPOPJ			;ERROR T1=ERROR CODE
;	CPOPJ1			;MESSAGE SENT
SNDIPC:				;ENTRY POINT
	MOVEM	T1,PAKSND+.IPCFL ;STORE THE FLAGS
SNDREP:	SKIPA	T1,.+1		;LOAD THE CONTROL WORD POINTER
	XWD	^D4,PAKSND	;ARGUMENT TO THE IPCFS UUO
	IPCFS.	T1,		;SEND THE MESSAGE
	  SKIPA			;ERROR
	JRST	CPOPJ1		;RETURN
	CAIE	T1,IPCRS%	;OVER QUOTA ERROR?
	CAIN	T1,IPCDD%	;NO-DISABLED DESTINATION?
	JRST	SNOZT		;YES-GO SLEEP FOR A BIT
	CAIE	T1,IPCRR%	;NO ROOM IN REC. QUEUE?
	CAIN	T1,IPCRY%	;NO ROOM IN SYSTEM
	JRST	SNOZT
	POPJ	P,

SNOZT:	SKIPA	T1,.+1		;OTHERWISE SLEEP A WHILE AND TRY AGAIN
	EXP	HB.IPC+1	; ONE WINK OR IPC INTERRUPT
	HIBER	T1,		; ...
	  SLEEP	T1,		; HIBER FAILED??
	JRST	SNDREP		;TRY AGAIN
;SUBROUTINE RECPAG - RECEIVE A PAGE FROM AN MPP
;CALL	PUSHJ	P,RECPAG
;RETURN	CPOPJ			;NO PAGES AVAILABLE
;	CPOPJ1			;GET A PAGE T1=XWD SIZE,PAGE NUMBER
;				;T1 = PAGE #
RECPAG::			;ENTRY POINT
	PUSHJ	P,GTPAG.	;GET A FREE PAGE (IPC POOL)
	  POPJ	P,		;ERROR RETURN
	PUSH	P,T1		;SAVE THE PAGE NUMBER
	HRLI	T1,PAGSIZ	;INSERT THE PAGE SIZE
	MOVEM	T1,PAKREC+.IPCFP ;STORE THE MESSAGE POINTER
	MOVE	T1,PIDLCM	;[513]
	MOVEM	T1,PAKREC+.IPCFR ;[513]
	SKIPA	T1,.+1		;GET THE RECEIVE FALGS
	EXP	IP.CFV+IP.CRP	;[513]
	PUSHJ	P,RECIPC	;GET THE PAGE
	  JRST	RECPAE		;RECEIVE PAGE ERROR
	PJRST	TPOPJ1		;SKIP RETURN
RECPAE:				;RECEVICE PAGE ERROR
	EXCH	T1,(P)		;GET THE APGE NUMBER BACK
	PUSHJ	P,PUTPAG	;RETURN THE PAGE
	  JFCL			;DON'T CARE
	JRST	T1POPJ		;RESTORE THE ERROR BITS(RETURN)

;SUBROUTINE RECIPC RECEIVE A MESSAGE FROM IPCF
;CALL	MOVE	T1,FLAGS
;	PUSHJ	P,RECIPC
;RETURN	CPOPJ			;ERROR T1=ERROR
;	CPOPJ1			;GOT THE MESSAGE
RECIPC:				;ENTRY POINT
	MOVEM	T1,PAKREC+.IPCFL	;STORE THE FLAGS
	SKIPA	T1,.+1		;LOAD THE ARGUEMNT
	XWD	^D4,PAKREC
	IPCFR.	T1,		;GET THE MESSAGE
	  POPJ	P,		;ERROR RETURN
	MOVEM	T1,IPCFLG	;STORE THE NEW FLAGS
	LDB	T1,IPCEBT	;GET THE ERROR FIELD
	JUMPN	T1,CPOPJ	;EXIT WITH ERROR
	JRST	CPOPJ1		;GOOD RETURN

IPCEBT:	POINT	6,PAKREC+.IPCFL,29

;SUBROUTINE TO REMOVE JUNK FROM THE RECEIVE QUEUE
;CALL	PUSHJ	P,PAKJNK		;REMOVE A JUNK PACKET
;CALL	PUSHJ	P,PAGJNK		;REMOVE A JUNK PAGE
;RETURN	CPOPJ

PAGJNK:	TROA	T1,IP.CFV	;REMOVE JUNK PAGES
PAKJNK:	TRZ	T1,IP.CFV	;REMOVE A JUNK PACKET
	ANDI	T1,IP.CFV	;SAVE ONLY THE PAGE BIT
	HRLI	T1,(IP.CFT!IP.CFB) ;SET PACKET TO LONG BIT
	SETZM	PAKREC+.IPCFP	;CLEAR THE LENGTH FIELD
	PUSHJ	P,RECIPC	;CLEAR THE PACKET
	  JFCL
	POPJ	P,		;RETURN
SUBTTL FREE PAGE TABLE ROUTINES
;SUBROUTINE GTPAG. - GET A FREE PAGE FROM THE IPC PAGES
;CALL	PUSHJ	P,T1
;RETURN	CPOPJ			;NO PAGES AVAILABLE
;	CPOPJ1			;OK T1= THE PAGE NUMBER

GTPAG..::			;ENTRY POINT
	MOVSI	T1,(1B0)	;SET UP A SIMPLE MASK
GETPA1:	TDNN	T1,PAGBIT	;CHECK FOR AN AVAILABLE PAGE
	JRST	GETPA2		;YES
	LSH	T1,-1		;NO SHIFT A BIT
	JUMPN	T1,GETPA1	;TRY AGAIN
	POPJ	P,		;NO PAGES
GETPA2:				;FOUND A PAGE
	IORM	T1,PAGBIT	;SET IN USE
	JFFO	T1,.+1		;COUNT THE LEADING ZEROS
	ADD	T2,PAGOFF	;ADD THE OFFSET
	MOVE	T1,T2		;COPY THE PAGE NUMBER
	JRST	CPOPJ1		;SKIP RETURN

;SUBROUTINE CRPAG. - CREATE A VITUAL PAGE ON THE PAGING DEVICE
;CALL	MOVEI	T1,PAGE NUMBER
;	PUSHJ	P,CRPAG.
;	CPOPJ			;CAN NOT CREAT PAGE
;	CPOPJ1			;PAGE CREATED
CRPAG.:				;ENTRY POINT
	MOVEI	T3,(T1)		;COPY THE PAGE NUMBER
	MOVEI	T2,1		;ARG LIST COUNT
	SKIPA	T1,.+1		;PAGE. UUO ARGUEMNT
CRPAG1:	XWD	.PAGCD,T2
	PAGE.	T1,
	  TLOA	T3,(PA.GCD)	;TRY TO MAKE IT VIRTUAL
	JRST	CPOPJ1		;SKIP RETURN
	MOVE	T1,CRPAG1
	PAGE.	T1,
	  POPJ	P,		;TO BAD-
	JRST 	CPOPJ1
;
;SUBROUTINE KILPAG CALLS REMPAG AND PUTPAG
KILPAG:				;[635] ENTRY POINT
;[635]	PUSH	P,T1		;SAVE PAGE #
	PUSHJ	P,REMPAG
	  HALT	.		;ERROR
;[635]	POP	P,T1		;GET PAGE # BACK
;[635]	PUSHJ	P,PUTPAG
;[635]	  POPJ	P,		;RETURN
	POPJ	P,		;RETURN
;
;
;
;SUBROUTINE PUTPAG MARK A PAGE AS BEING REMOVE FROM THE IPCR SPACE
;CALL	MOVEI	T1,PAGE NUMBER
;	PUSHJ	P,PUTPAG
;RETURN	CPOPJ			;PAGE ALREADY REMOVED
;	CPOPJ1			;OK
PUTPAG:				;ENTRY POINT
	SUB	T1,PAGOFF	;OFFSET THE PAGE NUMBER
	MOVSI	T2,(1B0)	;SET UP A MASK
	MOVNS	T1		;NEGATE THE PAGE NUMBER
	LSH	T2,(T1)		;POSITION THE BIT
	TDNN	T2,PAGBIT	;IS THE BIT ALREADY AOFF
	POPJ	P,		;YES, ERROR EXIT
	ANDCAM	T2,PAGBIT	;CLEAR THE BIT
	JRST	CPOPJ1		;EXIT

;SUBROUTINE REMPAG - REMOVE A PAGE FROM THE VIRTUAL ADDRESSING SPACE
;CALL	MOVEI	T1,PAGE NUMBER
;	PUSHJ	P,REMPAG
;RETURN	CPOPJ			;ERROR T1=ERROR CODE
;	CPOPJ1			;PAGE REMOVED
REMPAG:				;ENTRY POINT
	SKIPN	PAGCNT		;[635] ROOM FOR MORE PAGES ON CHAIN?
	JRST	REMPG1		;[635] NO - GO  DESTROY IT
	MOVEI	T1,(T1)		;[635] YES - JUST WANT RIGHT HALF
	LSH	T1,P2WLSH	;[635] CONVERT TO ADDRESS
	EXCH	T1,PAGLST	;[635] SAVE NEW PAGE POINTER, GET OLD ONE
	MOVEM	T1,@PAGLST	;[635] STORE OLD POINTER IN NEW PAGE
	SOS	PAGCNT		;[635] ONE LESS FREE PAGE
	JRST	CPOPJ1		;[635] RETURN

REMPG1:	MOVEI	T3,(T1)		;[635] COPY THE PAGE NUMBER
	TLO	T3,(1B0)	;DESTROY FLAG
	MOVEI	T2,1		;ARGUEMNT LIST COUNT
	SKIPA	T1,.+1		;PAGE. UUO ARGUMENT
	XWD	.PAGCD,T2
	PAGE.	T1,
	  POPJ	P,		;ERROR T1=ERROR CODE
	PUSHJ	P,PUTPAG	;[635] MARK PAGE AS BEING FREE
	  JFCL			;[635] IGNORE ANY ERROR
	JRST	CPOPJ1		;SKIP RETURN
;[635>] Subroutine GETPG. - Get a page from the free chain
;[635] CALL	PUSHJ	P,GETPG.
;[635] Return	CPOPJ	- No pages on the free chain, or pages destoyed
;[635] 		CPOPJ1	- T1 contains the page number

GETPG.:	SKIPN	T1,PAGLST	;[635] Is there a free page on the chain?
	POPJ	P,		;[635] No - caller will create a page
	LDB	T2,[POINT 9,T1,35-9]	;[635] Get the page number
	HRLI	T2,.PAGCA	;[635] Find access allowed
	PAGE.	T2,		;[635] In case someone did a core uuo
	  SETO	T2,		;[635] Error - assume non-existant
	TXNN	T2,PA.GNE	;[635] Does page exist?
	JRST	GETPG1		;[635] Yes - go ahead
	SETZM	PAGLST		;[635] No - zero pointer
				;[635] Since all pages will have gone
	POPJ	P,		;[635] And let caller create page

GETPG1:	MOVE	T1,(T1)		;[635] Get next page on the list (or null)
	EXCH	T1,PAGLST	;[635] Save it and get the current page address
	SETZM	0(T1)		;[635] Zero the first word of our page
	MOVEI	T2,(T1)		;[635] Copy the address
	HRLI	T2,(T2)		;[635] Get address,,address
	ADDI	T2,1		;[635] Get address,,address+1 (for blt)
	BLT	T2,^D511(T1)	;[635] Zero the page
	LSH	T1,W2PLSH	;[635] Convert the address to a page #
	AOS	PAGCNT		;[635] Increment the number of free pages
	JRST	CPOPJ1		;[635] And give the good return
SUBTTL COMMON SUBROUTINES
TPOPJ1:	POP	P,T1		;RESTORE T1
CPOPJ1:	AOSA	(P)		;SKIP RETURN
T1POPJ:	POP	P,T1		;RESTORE T1
CPOPJ:	POPJ	P,		;RETURN

SAVT::	EXCH	T1,(P)		;SAVE T1, GET RETURN ADR.
	PUSH	P,T2
	PUSH	P,T3		;SAVE T3
	PUSH	P,T4
	PUSH	P,.+3		;GET THE RETURN ADDRESS
	HRLI	T1,-4(P)	;GET THE ADDRESS OF P1
	JRA	T1,(T1)		;GO BACK TO CALL, RESTORE T1
	  CAIA	.		;POPJ RETURN
	AOS	-4(P)		;CPOPJ1 - SET SKIP RETURN
	POP	P,T4
	POP	P,T3
	POP	P,T2		;RESTORE T3 ACS
	POP	P,T1
	POPJ	P,		;AND RETURN
;SUBROUTINE SNOOZ - WAIT FOR IPCF ACTIVITY
;CALL	PUSHJ	P,SNOOZ
;RETURN	CPOPJ			;IPCF INTERRUPT T1=CONDITIONS
SNOOZ1:	SKIPA	T1,.+1		;LOAD FLAGS
	EXP	HB.IPC		;IPCF ONLY
	HIBER	T1,
	  SLEEP	T1,		;IF FAILURE
SNOOZ::	SKIPA	T1,.+1		;LOAD QUERY FLAGS
	XWD	4,PAKREC	;INTO RECEIVE AREA
	IPCFQ.	T1,		;DO THE QUERY
	  JRST	SNOOZ1		;TRY AGAIN ON ERRORS
	SKIPN	T1,PAKREC+.IPCFP;GET THE PACKET POINTE
	JRST	SNOOZ1		;NONE THERE TRY LATER
	HRR	T1,PAKREC+.IPCFL;GET THE FLAGS
	POPJ	P,		;RETURN WITH PACKET POINTER

;SUBROUTINE ONCE - GET THE WORLD STARTED
;CALL	PUSHJ	P,ONCE
;RETURN	CPOPJ			;WORLD IS STARTED

MHNAME:	SIXBIT/MCS-10/	;NAME OF MCS SYSTEMS (DONE BY SETNAM)

ONCE::				;ENTRY POINT
	SKIPE	PIDMCP		;MCP HAVE A PID
	POPJ	P,		;YES, EXIT
	SKIPN	T1,.JBHRL
	MOVEI	T1,657777	;MAGIC PAGE #
	MOVEI	T1,1(T1)
	LSH	T1,W2PLSH
	MOVEM	T1,PAGOFF	;STORE THE PAGE OFFSET
	MOVEI	T1,PAGCSH	;[635] INITIALISE THE MAXIMUM NUMBER OF
	MOVEM	T1,PAGCNT	;[635] PAGES ON THE FREE CHAIN
	SETZM	PAGLST		;[635] AND INDICATE NO PAGES CURRENTLY
	SETO	T1,		;OUR JOB
	CTLJOB	T1,		;GET CONTROLLING JOB NUMBER
	  SETO	T1,		;NOT IMPLEMENTED (CAN NOT HAPPEN)
	JUMPLE	T1,NOPTY	;JUMP IF NO CONTROLLING JOB
	HRL	T2,T1		;MOVE OVER THE JOB NUMBER
	HRRI	T2,.GTPRG	;FIND CONTROLLERS NAME
	GETTAB	T2,		;FROM THE MONITOR TABLES
	  SETZ	T2,		;NICE TRY THOUGH
	CAMN	T2,MHNAME	;CONTROLLED BY AN MCS SYSTEM
	  JRST	ONCE1		;YES, GO DO AUTOMATIC STUFF
NOPTY:				;NO PTY CONTROL
	OUTSTR	[ASCIZ/[LCM Enter the MCS-10 system name]
*/]
	SKIPA	T4,.+1		;LOAD A BYTE POINTER FORTHE ANSWER
	POINT	7,MSGSND+.IPCS2	;COPY SYSTEM AND
	SETZM	MSGSND+.IPCS1	;CLEAR THE ALTERNATE
	MOVEI	T3,MNLEN	;MAX NAME SIZE
NOPTY1:	INCHWL	T1		;GET A CHARACTER
	CAIN	T1,15		; DON'T STORE<CR>'S OR <LF>'S
	JRST	NOPTY1		;...
	CAIE	T1,12		;...
	IDPB	T1,T4		;STORE THE CHARACTER
	CAIE	T1,12		;LINE FEED
	SOJG	T3,NOPTY1	;OR END OF MESSAGE TEXT
	SETZ	T1,		;ADD A NULL BYTE
	IDPB	T1,T4		;TO TERMINATE THE ASCIZ STRING
	MOVEI	T1,.IPCIW	;FIND THE PID FOR MCP
	MOVEM	T1,MSGSND+.IPCS0	;STORE THE FUNCTION CODE
	SKIPA	T1,.+1		;LOAD THE MESSAGE POINTER
	XWD	10,MSGSND	;..
	MOVEM	T1,PAKSND+.IPCFP ;STORE
	SETZ	PAKSND+.IPCFS	;CLEAR SENDERS PID
	SETZB	T1,PAKSND+.IPCFR ;CLEAR RECEIVER PID(ASSUMES SYSINFO)
 	PUSHJ	P,SNDIPC	;SEND THE MESSAGE
	  JRST	LCMFTL		;NO SYSINFO ETC.
NOPTY2:	PUSHJ	P,SNOOZ		;WAIT FOR A RESPONSE
	TRNE	T1,IP.CFV	;PAGE MODE
	JRST	NOPTY3		;REMOVE IT
	ANDI	T1,IP.CFC	;ISOLATE THE FUNCTION CODE
	CAIN	T1,<.IPCCF>B32	;FROM INFO
	JRST	NOPTY4		;YES, GET THE PID OF MCP
	PUSHJ	P,PAKJNK	;RECEIVE THE JUNK
	JRST	NOPTY2		;TRY AGAIN
NOPTY3:	PUSHJ	P,PAGJNK	;REMOVE THE PAGE
	JRST	NOPTY2		;TRY AGAIN
NOPTY4:				;GOT A RESPONSE
	SKIPA	T1,.+1		;LOAD THE MESSAGE POINTER
	XWD	10,MSGREC
	MOVEM	T1,PAKREC+.IPCFP;STORE IN THE PACKET DESCRIPTOR
	SETZ	T1,		;CLEAR THE FLAGS
	PUSHJ	P,RECIPC	;GET THE PAGE
	JRST	ILLNAM		;NOT A VALID RESPONSE
	HRRZ	T1,MSGREC+.IPCS0	;GET THE FUNCTION CODE
	CAIE	T1,.IPCIW	;REQUESTING A PID
	JRST	NOPTY2		;NOT CORRECT RESPONSE
	MOVE	T1,MSGREC+.IPCS1;YES GET THE PID OF MCP
	MOVEM	T1,PIDMCP	;STORE THE PID OF MCP

;TELL THE MCP WE ARE AROUND VIA [SYS]INFO
;
	PJOB	T1,		; GET OUR JOB NUMBER
	PUSHJ	P,GPIDL		;SEE IF THERE ARE ANY PIDS HANGING AROUND FOR US
	  PJRST	GETPID		; NO PIDS SO MAKE ONE  AND TELL MCS
	POPJ	P,		;GOT A PID FROM GPIDL

ILLNAM:				;INVALID NAME FOR MCS-10
	OUTSTR	[ASCIZ/
%LCM - Unknown MCS-10 system try again
/]
	SKIPA	T1,.+1		;CLEAR THE PACKET TO TRY AGAIN
	XWD	MSGSND+.IPCS1,MSGSND+.IPCS1+1
	SETZM	MSGSND+.IPCS1
	BLT	T1,MSGSND+.IPCS1+<MNLEN/5+1>
	JRST	NOPTY
SUBTTL SET UP THE PID'S FOR US(LCM) AND MCP

ONCE1:					;CONNECT TO THE MCP
	PUSHJ	P,GPIDL		;GET THE PID LIST FOR MCP
	  JRST	LCMFTL		;FATAL ERROR
	MOVEM	T1,PIDMCP	;STORE THE PID OF MCP
	PJOB	T1,		;GET OUR JOB NUMBER
	PUSHJ	P,GPIDL		;GET OUR PID LIST
	  JRST	LCMFTL		; NO LIST... BUG IN MCS-10
	MOVEM	T1,PIDLCM	;STORE THE PID
	POPJ	P,		;RETURN OPEN COMPLETE

;SUBROUTINE GPIDL - GET A PID LIST
;CALL	MOVEI	T1,JOB NUMBER
;	PUSHJ	P,GPIDL
;RETURN	CPOPJ			;NO PIDS AVAILABLE
;	CPOPJ1			;PID LIST STARTS AT MSGREC+2
;				;RETURNS THE FIRST PID OF THE PID LIST IN T1
GPIDL:				;ENTRY POINT
	MOVEM	T1,MSGSND+.IPCS1;STORE THE JOB NUMBER
	MOVEI	T1,.IPCSP	;GET THE FUNCTION
	MOVEM	T1,MSGSND+.IPCS0;STORE THE FUNCTION
	SETZM	PAKSND+.IPCFS	;CLEAR SENDER
	SKIPA	T1,.+1		;FIND THE PID OF IPCC
	%IPCCP
	GETTAB	T1,		;GET THE PID
	  POPJ	P,		;FATAL ERROR
	MOVEM	T1,PAKSND+.IPCFR;STORE THE RECEIVER PID (IPCCP)
	SKIPA	T1,.+1		;LOAD THE MESSAGE POINTER
	XWD	^D8,MSGSND	;..
	MOVEM	T1,PAKSND+.IPCFP	;STORE THE POINTER
	SETZB	T1,MSGSND+2	;CLEAR THE FLAGS
	SKIPA	T2,.+1		;CLEAR THE REST OF MSGSND TO 0
	MSGSND+2,,MSGSND+3
	BLT	T2,MSGSND+7
	PUSHJ	P,SNDIPC	;SEND
	  POPJ	P,		;FATAL
GPDL2:	PUSHJ	P,SNOOZ		;WAIT FOR RESPONSE
	TRNN	T1,IP.CFV	;PAGE MODE
	JRST	GPDL3		;NO, GOT A PACKET
	PUSHJ	P,PAGJNK	;READ JUNK PAGE
	JRST	GPDL2		;TRY AGAIN
GPDL3:	SKIPA	T1,.+1		;MESSAGE POINTER
	XWD	^D8,MSGREC
	MOVEM	T1,PAKREC+.IPCFP;STORE THE POINTER
	SETZ	T1,		;CLEAR THE FLAGS
	PUSHJ	P,RECIPC	;READ THE PACKET
	  JRST	GPDL2			;TRY AGAIN
	HRRZ	T1,MSGREC+.IPCS0	;GET THE FUNCTION
	CAIE	T1,.IPCSP	;PID LIST REQUEST
	JRST	GPDL2		;WAIT FOR ANOTHER RESPONSE
	SKIPE	T1,MSGREC+.IPCS2;GET THE PID
	AOS	(P)		;GOOD EXIT ATLEAST ONE PID
	POPJ	P,		;NO PIDS
;SUBROUTINE GETPID - GET A PID
;CALL	PUSHJ	P,GETPID
;RETURN	CPOPJ			;ALWAYS PID IN T1 & STORED IN PIDLCM

GETPID:	MOVE	T2,PIDMCP##	;HERE IF A DEBUGGING MPP
	MOVEM	T2,MSGSND+.IPCS1
	MOVEI	T1,.IPCII	;MAKE A PID FOR US
	MOVEM	T1,MSGSND+.IPCS0;STORE THE FUNCTION CODE
	SKIPA	T1,.+1		;GET PART ONE OF THE NAME
	ASCII	/MPP(#/
	MOVEM	T1,MSGSND+.IPCS2	;STORE THE NAME
	SKIPA	T4,.+1		;LOAD AN OUTPUT POINTER
	POINT	7,MSGSND+.IPCS2+1
	PJOB	T1,		;GET THE JOB NUMBER
	IDIVI	T1,12		;CONVERT TO DECIMAL
	PUSH	P,T2		;SAVE THE LOW ORDER DIGIT
	IDIVI	T1,12		;AND AGAIN
	MOVEI	T1,"0"(T1)	;CONVERT TO ASCII
	IDPB	T1,T4		;STORE
	MOVEI	T1,"0"(T2)	;NEXT
	IDPB	T1,T4		;STORE
	POP	P,T1
	MOVEI	T1,"0"(T1)	;TO ASCII
	IDPB	T1,T4		;STORE
	MOVEI	T1,")"		;CLOSEING
	IDPB	T1,T4		;STORE
	SKIPA	T1,.+1		;LOAD MESSAGE POINTER
	XWD	^D8,MSGSND
	MOVEM	T1,PAKSND+.IPCFP;STOE THE POINTER
	SETZM	PAKSND+.IPCFS	;CLEAR SENDER
	SETZB	T1,PAKSND+.IPCFR;CLEAR RECEIVER AND FLAGS
	PUSHJ	P,SNDIPC	;SEND THE MESSAGE
	JRST	LCMFTL		;FATAL NO SYSINFO
GETPD1:	PUSHJ	P,SNOOZ		;WAIT FOR A RESPONSE
	TLNN	T1,IP.CFV	;PAGE MODE
	JRST	GETPD2		;NO,CONTINUE
	PUSHJ	P,PAGJNK	;YES, EAT THE PAGE
	JRST	GETPD1		;TRY AGAIN
GETPD2:	ANDI	T1,IP.CFC	;ISOLATE THE FUNCTION CODE
	CAIN	T1,<.IPCCF>B32	;FROM INFO
	JRST	GETPD3		;YES CONTINUE
	PUSHJ	P,PAKJNK	;EAT THE JUNK PACKET
	JRST	GETPD1		;TRY AGAIN
GETPD3:	SKIPA	T1,.+1		;MESSAGE POINTER
	XWD	^D8,MSGREC
	MOVEM	T1,PAKREC+.IPCFP;STORE THE POINTER
	SETZ	T1,		;CLEAR THE FLAGS
	PUSHJ	P,RECIPC	;READ THE PACKET
	  JRST	GETPD1		;TRY AGAIN
	HRRZ	T1,MSGREC+.IPCS0;GET THE FUNCTION CODE
	CAIE	T1,.IPCII	;MAKE PID
	JRST	GETPD1		;TRY AGAIN
	MOVE	T1,MSGREC+.IPCS1;YES,GET THE PID
	MOVEM	T1,PIDLCM	;STORE OUT PID
	POPJ	P,		;RETURN
	END