h17951
s 00273/00000/00000
d D 1.1 80/05/15 14:27:14 lcd 1 0
e
u
sunix
lcd
U
t
T
I 1
#

#include "globals.h"
#include <stdio.h>

/*
 *	ppt.c:	PPT support 
 */

CONST	char	*_S_ppt		"%W%";
	char	*pptnam		"ppt";

#define	entrySize	12L

VAR	long	pptadr;
	long	adrppt;
	long	pptsiz;
	integer	entcnt;



/*
 *	pptinit: intialize ppt module
 */

PROCEDURE pptinit()

BEGIN	getladdr( pptnam, &pptadr, &pptsiz );
END

/*
 *	prppt: print out ppt entry
 */

PROCEDURE prppt( pptent )

CONST	integer	pptent[6];

BEGIN	VAR	integer	devent[4];
		long	devadr;
		boolean	devpd;

	devpd = ( pptent[4] == 0177777 );

	IF devpd
	THEN	devadr = pptent[5]&0177777L;
		dadjust( &devadr );
		rdBlock( devadr, 8, devent );
	END;

	printf( "p.sp\t%7o", pptent[0] );

	IF devpd
	THEN	printf("\t\tv.sp\t%7o\n", devent[0] );
	ELSE	putchar( eoln );
	END;

	printf( "p.par\t%7o", pptent[1] );

	IF devpd
	THEN	printf("\t\tv.par\t%7o\n", devent[1] );
	ELSE	putchar( eoln );
	END;

	printf( "p.pdr\t%7o", pptent[2] );

	IF devpd
	THEN	printf("\t\tv.pdr\t%7o\n", devent[2] );
	ELSE	putchar( eoln );
	END;

	printf( "p.sc\t%7o", pptent[3] );

	IF devpd
	THEN	printf("\t\tv.pd\t%7o\n", devent[3] );
	ELSE	putchar( eoln );
	END;

	printf( "p.rank\t%7o\n", pptent[4] );
	printf( "p.veca\t%7o\n", pptent[5] );

	inc( entcnt );

	IF ( entcnt MOD 3 ) == 0
	THEN	WHILE getchar() != eoln DO END;
	END;
END

/*
 *	pptdis: ppt display
 */

PROCEDURE pptdis( from, to )

CONST	long	from;
	long	to;

BEGIN	VAR	long	stpadr;
		long	svaddr;
		integer	pptent[6];

	svaddr = addr;

	adrppt = ( from*entrySize ) + pptadr;

	stpadr = ( ( to+1L )*entrySize ) + pptadr;

	printf("%lo to %lo\n", adrppt, stpadr );

	IF ( adrppt < pptadr ) OR
	   ( stpadr > pptadr+pptsiz )
	THEN	printf("?\n");
	ELSE	IF adrppt < stpadr
		THEN	LOOP	rdBlock( adrppt, 12, pptent );
	
				prppt( pptent );

				adrppt = adrppt + entrySize;

				WHEN stpadr == adrppt DO EXIT;

				printf("-------------\n");
			END;
		END;
	END;

	addr = svaddr;
END


/*
 *	ppt: print out ppt
 */

PROCEDURE ppt()

BEGIN	VAR	long	begn;
		long	stop;

	entcnt = 0;

	getnum( &begn );

	IF begn == -1L
	THEN	begn = 0L;
		stop = 0L;
	ELSE	getnum( &stop );

		IF stop == -1L
		THEN	stop = 0L;
		END;
		
		stop = stop + begn;
	END;

	pptdis( begn, stop );
END

/*
 *	paradr: convert par, pdr, and data address into physical address
 */

PROCEDURE paradr( par, pdr, addrs )

CONST	integer	par;
	integer	pdr;
VAR	long	*addrs;

BEGIN	VAR	long	naddr;
		long	tpdr;

	naddr = par&0177777L;
	naddr = naddr*64L;

	IF ( *addrs >= 0140000L ) AND
	   ( *addrs < 0160000L )
	THEN	*addrs = *addrs-0140000L;

	ELSE	tpdr = pdr&0177777L;
		tpdr = ( tpdr >> 8 )&0177L;
		tpdr = tpdr*64L;
		*addrs = *addrs+tpdr;
	END;

	*addrs = *addrs + naddr;
END


/*
 *	stack: print out stack information
 */

PROCEDURE stack()

BEGIN	VAR	long	addr1;
		long	addr2;
		long	index;
		integer	pptent[6];

	getnum( &index );

	IF index == -1L
	THEN	printf("?\n");

	ELSE	index = index+pptadr;

		IF ( index < pptadr ) OR
		   ( index > pptadr+pptsiz )
		THEN	printf("?\n");

		ELSE	rdBlock( index, 12, pptent );

			getnum( &addr1 );

			IF addr1 == -1L
			THEN	addr1 = 0L;
			END;

			paradr( pptent[1], pptent[2], &addr1 );

			getnum( &addr2 );

			IF addr2 == -1L
			THEN	addr2 = 0L;
			END;

			addr2 = addr2+addr1;

			display( addr1, addr2 );
			addr = addr2;
		END;
	END;
END

/*
 *	sgnal: print out signal queues
 */

PROCEDURE sgnal()

BEGIN	VAR	char	word[ MAXLINELENGTH ];
		long	addrs;
		integer	pptent[6];

	entcnt = 0;

	IF getnw( word, &addrs )
	THEN	getaddr( word, &addrs );
	ELSE	dadjust( &addrs );
	END;

	rdBlock( addrs, 2, pptent );

	addrs = pptent[0]&0177777L;
	dadjust( &addrs );

	LOOP	WHEN ( addrs < pptadr ) OR
		     ( addrs >= pptadr+pptsiz) 
		DO	printf("?\n");
		EXIT;
		
		rdBlock( addrs, 12, pptent );

		prppt( pptent );

		WHEN pptent[3] == 0 DO EXIT;

		printf("-------------\n");

		addrs = pptent[3]&0177777L;
		dadjust( &addrs );
	END;
END
E 1
