File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / demand / cp.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v12b, v121, HEAD
Power 6/32 Unix version 1.2b

/*	Console Processor Interface 	*/
/*	Tahoe version, Nov. 1982	*/

/****************************************/
/*					*/
/*	Reduced DCB layout for byte	*/
/*	communication.			*/
/*					*/
/****************************************/

asm(".set CPMDCB,21");
asm(".set DC_OFF,2");
asm(".set DC_ON,1");
asm(".set DCR,27");
asm(".set PDCS,28");
asm(".set CTL_SW,0x41b");  /* Addr of switches to turn on Cache, MME, Fault */
long tmp_lw;


#define	CPBUFLEN 200		/* Output buffer length */
struct	cphdr
{
	char	cp_unit;	/* Done bit & unit # */
	char	cp_comm;	/* Command */
	short	cp_count;	/* Counter (when relevant) */
};

struct	cpdcb_o			/* Output structure */
{
	struct	cphdr	cp_hdr;
	char	cp_buf[CPBUFLEN]; /* Buffer for output or 'stty' */
};

struct	cpdcb_i			/* Structure for input */
{
	struct	cphdr	cp_hdr;
	char	cpi_buf[4]; 	/* Buffer for input */
};

#define	CPDONE	0x80		/* 'Done' bit in cp_unit */
#define	CPTAKE	0x40		/* CP 'ack' to this cpdcb */

		/* Values for 'unit' */
#define	CPUNIT	0		/* The CP itself */
#define	CPCONS	1		/* Console line */
#define	CPREMOT	2		/* Remote line */

		/* Values for 'command' */
#define	CPRESET 0
#define	CPWRITE 1
#define	CPREAD	2
#define	CPSTTY	3
#define	CPBOOT	4


/*	Put a char to CPU2 console */

#define NCHAR	1

long cpbuf_sz = 1;		/* Buffer size   */
long charcnt = 0;
struct cpdcb_o cpout;			/* DCB for output */

asm(".set HISR,0x410");

putchar(c)
{
	cpout.cp_hdr.cp_unit = CPCONS;		/* Reset done bit */
	cpout.cp_hdr.cp_comm = CPWRITE;		/* Set command */
	cpout.cp_buf[charcnt] = c;
	if (cpbuf_sz <=  1) 
		{	/* Char I/O mode */
		cpout.cp_hdr.cp_count = 1;
		cp_poll(c);
		}
	    else
		{
		charcnt++;
		if (((charcnt+1) > cpbuf_sz) || (c == '\n') || (c == '\r'))
			{		/* buffer full, print it */
			charcnt = 0;
			cpout.cp_hdr.cp_count = cpbuf_sz;
			cp_poll(c);
			}
		}
	asm("movl $0,*$HISR");	/* Mask out console xmit int */
}

cp_poll(c)
char c;
{	register long time;

	asm("andl3 *$0x418,$0x8,_tmp_lw");
	if (tmp_lw)	/* Data cache ON */
		asm("mtpr $DC_OFF,$DCR");	/* Turn data cache OFF */
	time = 0x1ff0000;
	asm("movab _cpout,r10");
	asm("andl2 $0xffffff,r10");
	asm("mtpr r10,$CPMDCB");
	tmp_lw = (long)(&cpout.cp_hdr.cp_unit);
	while (time-- && !(cpout.cp_hdr.cp_unit & CPDONE));
	if (!(cpout.cp_hdr.cp_unit & CPDONE)) cp_hlt();	/* Time out */
	if (c== '\n') putchar('\r');
	if (tmp_lw)	/* Data cache was ON */
		asm("mtpr $DC_ON,$DCR");	/* Turn data cache back ON */
}

cp_hlt()
{
	asm("movl $0xeeeeeeee,r0");
	asm("movl $0xeeeeeeee,r1");
	asm("movl $0xeeeeeeee,r2");
	asm("movl $0xeeeeeeee,r3");
	asm("movl $0xeeeeeeee,r4");
	asm("movl $0xeeeeeeee,r5");
	asm("movl $0xeeeeeeee,r6");
	asm("movl $0xeeeeeeee,r7");
	asm("movl $0xeeeeeeee,r8");
	asm("halt");
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.