File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / mem / monitor.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:30:16 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

		/* 	constant definitions for program		*/
#define LINE	  80
#define CRTN      0x0d
#define EOL       '.'
#define INTSIZE   8
#define msg1	"\n**************** Memory Test (R1.2) ****************"
#define msg2	"\n  TEST		TITLE"
#define msg3	"\n   0		Execute tests 1 - 6"
#define msg4	"\n   1		Marching patterns"
#define msg5	"\n   2		Unique address"
#define msg6	"\n   3		Adjacent cell disturbance"
#define msg7	"\n   4		ECC single bit error correct"
#define msg8	"\n   5		ECC single bit (data) error detection"
#define msg9	"\n   6		ECC single bit (check) error detection"
#define	NL	'\012'
#define MAX_TST		6	/* Max. no of subtests */
#include "definitions"

extern long maxmem,count,tstmsk,endprog,nonstop;
extern  long loop_flg,hlt_flg,prt_flg,test_no;
extern struct	OPTIONS OPTIONS;
long abend,abmax;
int bitbl[8] = { 1,2,4,8,16,32,64,128};

monitor()
{	
	int number;
	long startadd,endadd;
	long debug,debuga,debugb,debugc;
	prt_flg = loop_flg = 0;
	abend = endprog;
	abmax = maxmem;
	/**********************************************************
	If the header option was set, output test header and report
	memory size as calculated in init.x, also indicate brd type
	**********************************************************/
	if (OPTIONS.header) {
	  writes(msg1);			
	  writes("\n\nMemory size = "); 
	  writed(maxmem); writes(" bytes;");
	  if (OPTIONS.mixed)
		writes(" 20 Mb mixed configuration option selected\n");
	  else  {
		if (OPTIONS.fourmb)
			writes(" 4mb memory board option selected\n");
		else
			writes(" 1mb memory board option selected\n");
		}
			    }
	if ( test_no > MAX_TST ) {
		writes("\n invalid test number: must be 0 or 1-6");
		gettest(); }
	if (!OPTIONS.diagmode) {
		endprog = abend;
		maxmem = abmax;
		}
	/*************************************************************
	If the diagnostic mode flag is set, query user for parameters.
	Output the ending address of the memory program and max memory
	address.  Check the validity of the start and ending addresses 
	entered by the user.
	*************************************************************/
	if (OPTIONS.diagmode) {			
		writes("\nminimum memory address is ");writeh(endprog);
		writes("\n\nmaximum memory address is ");writeh(maxmem);
start:		writes("\n\nenter starting memory address : ");
		startadd = gethex();
		if (startadd >= endprog){ 
		    endprog = startadd;
		    }
		else{
		    writes("\nthe starting address must be >= "); 
	    	    writeh(endprog);	
		    goto start;
		    }
end:		writes("\n\nenter ending memory address : ");
		endadd = gethex();
		if (endadd > startadd && endadd <= maxmem){
		    maxmem = endadd;
		    }
		else{
		    writes("\nthe ending address must be > "); 
		    writeh(startadd);
		    writes(" and <= ");
		    writeh(maxmem);
		    goto end;
		    }	
		}
	/***************************************************************
	If the selected test was 0 then set tstmsk to run all tests.
	Else set tstmsk to the selected test.	
	***************************************************************/
	if (!test_no) tstmsk = 1|2|4|8|16|32;		
		else {
			number = test_no;		
			tstmsk = bitbl[--number];
	      	}
	if (OPTIONS.err_msg) prt_flg =1;
	if (OPTIONS.loop_err) loop_flg =1; 
		else hlt_flg = 1;
}
		/**************************************************** 
		This routine gets the user input and validates it, if
		an invalid response is made the user will be queried 
		again.
		****************************************************/
gettest()
{
int valid;
char c;
valid = 1;
while(valid){
	writes("\n\nenter test number or '?' for help : ");
	c = readc();
	switch(c){
		case '0':
			test_no = 0;
			valid = 0;
			break;
		case '1':
			test_no = 1;
			valid = 0;
			break;
		case '2':
			test_no = 2;
			valid = 0;
			break;
		case '3':
			test_no = 3;
			valid = 0;
			break;
		case '4':
			test_no = 4;
			valid = 0;
			break;
		case '5':
			test_no = 5;
			valid = 0;
			break;
		case '6':
			test_no = 6;
			valid = 0;
			break;
		case '?':
			tsthelp();
			break;
		default:
			writes("  invalid test number");
			break; }
	}
return;
}
	/*********************************************************
	This routine just outputs the test numbers and description
	to the user
	*********************************************************/
tsthelp()
{
writes("\n");writes(msg2);writes(msg3);writes(msg4);writes(msg5);
writes(msg6);writes(msg7);writes(msg8);writes(msg9);
return;
}
	/**********************************************************
	Hex input routine, call fill and validates the characters
	in the character buffer. Then returns the HEX value back to 
	the calling routine.
	**********************************************************/
gethex() 
{
	char s[LINE];
	int k[1],i,n;
	n=0x0;
	fill(s,k);			/* Fill s[] */ 
	for (i=0;i<k[0];++i) {
         if (s[i] >= 'a' && s[i] <= 'f')
	 n=0x10*n+s[i]-'W';
	 if (s[i] >= 'A' && s[i] <= 'F')
	 n=0x10*n+s[i]-'7';
	 if (s[i] >= '0' && s[i] <= '9')
	 n=0x10*n+s[i]-'0';
	 if ((s[i] < '0' ) || (s[i] > '9' && s[i] < 'A') || (s[i]  > 'F' 
	     && s[i] < 'a') || (s[i] > 'f')) 
	 {
	 writes("\nInvalid hex digit: "); writec(s[i]); writes(" (ignored)");
	 }
	}
	return(n);
}
	/****************************************************
	This routine fills a character buffer with characters
	that are input on the console.
	****************************************************/
fill(s,k)
char s[];
int k[];
{
	char c;
	int i;
	k[0]=0;
	for (i=0;(c=readc())!=CRTN;++i)
	{
	if (k[0]>LINE - 1) break;
	if (c==EOL)        break;
	s[i]=c;
	++k[0];
	}
}

unix.superglobalmegacorp.com

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