# include # include "mult.h" unsigned int testad = 0; /* address of the last 4k memory in system */ rwalk() /* test rec. reg. walk-test */ { int a,b,i; error = rwalk; puts("\n****** recieve walk-test on port #"); putdec(group); puts(" ******\n\n"); in(TBASE); for( i=a=1; i<10; ++i) { base = SBASE; tran(a); base = TBASE; if((b = rec()) > 0xff) terflg(); else if(b != a) waler(a,b); /* test with inverted a */ base = SBASE; tran((~a & 0xff)); base = TBASE; if((b = rec()) > 0xff) terflg(); else if(b != (~a & 0xff)) waler((~a & 0xff),b); a = a << 1 & 0xff; } if(erflg == 0 && verflg == 0) puts("passes the recieve walk-test !\n"); } waler(a,b) /* prints walk error */ { puts("port #"); putdec(group); puts(" failed the walk-test !\nword "); putbin(a); puts(" came through as "); putbin(b); putc('\n'); terflg(); } bitest() /* test all bit lengths 5, 6, 7, 8, */ { int i,err; error = bitest; puts("\n****** testing different word lengths on port #"); putdec(group); puts("******\n\n"); in(SBASE); /* clear port */ in(TBASE); /* clear port */ for(i= 5; i < 9; ++i) { wrdsze = i; base = TBASE; setparm(); err = 0; err = ckparm(); base = SBASE; setparm(); if(err |= ckparm() > 0xff) { puts("failed to set word length to "); putdec(i); puts(" bits !\n\n"); terflg(); } else walktest(i); } if(erflg == 0 && verflg == 0) puts("passes word length test !\n\n"); } walktest(s) /* walk bits and with mask for right length */ int s; { int a,b,i,mask; switch(s) { case 5 : mask = 0x1f; break; case 6 : mask = 0x3f; break; case 7 : mask = 0x7f; break; case 8 : mask = 0xff; break; } for( i = a = 1; i < 9 ; ++i) { base = TBASE; tran(a); base = SBASE; if((b = rec()) > 0xff) terflg(); if(b != (a & mask)) walker(a,(a & mask),b); /* test with inverted bits */ base = TBASE; tran(~a); base = SBASE; if((b = rec()) > 0xff) terflg(); if(b != (~a & mask)) walker((~a & 0xff),(~a & mask),b); a = (a << 1 & 0xff); } } walker(a,b,c) /* failure for word length walk test */ int a,b,c; { puts("port #"); putdec(group); puts(" failed the word length test !\nword "); putbin(a); puts(" should have come through as "); putbin(b); puts(" but came through as "); putbin(c); putc('\n'); terflg(); } parytest() /* test parity of serial ports */ { int err,b; error = parytest; puts("\n\n****** testing parity on port #"); putdec(group); puts(" ******\n\n"); parity = 'y'; eoparty = 'e'; if(bothset() > 0xff) /* set both to even parity */ { puts("failed to set parity correctly\n"); terflg(); } else /* check for good even parity check */ { base = TBASE; tran(0xa5); base = SBASE; if(rece() != 1) { puts("port #"); putdec(group); puts(" failed to transmit even parity\n"); terflg(); } base = SBASE; tran(0xa5); /* check to see if it can recieve even parity */ base = TBASE; if(rece() != 1) { puts("port #"); putdec(group); puts(" failed to recieve even parity!\n"); terflg(); } eoparty = 'o'; if(bothset() > 0xff) /* set to odd parity */ { puts("failed to set odd parity!\n"); terflg(); } else /* check for odd parity transmit */ { base = TBASE; tran(0xa5); base = SBASE; if(rece() != 1) { puts("port #"); putdec(group); puts(" failed to transmit odd parity!\n"); terflg(); } base = SBASE; tran(0xa5); base = TBASE; if(rece() != 1) /* check for odd parity recieve */ { puts("port #"); putdec(group); puts(" failed to recieve odd parity!\n"); terflg(); } } /* parity error check */ eoparty = 'e'; setparm(); if(ckparm() > 0xff) { puts("failed to set to even parity!\n"); terflg(); } else { tran(0xa5); base = SBASE; if(rece() != 5) { puts("port #"); putdec(group); puts(" failed to detect parity error!\n"); terflg(); } tran(0xa5); base = TBASE; if(rece() != 5) { puts("port #"); putdec(group); puts(" failed to send odd parity!\n"); terflg(); } } eoparty = 'o'; setparm(); b = ckparm(); base = SBASE; eoparty = 'e'; setparm(); if(b |= ckparm() > 0xff) { puts("failed to set parity!\n"); terflg(); } else /* reverse parities on both boards */ { tran(0xa5); base = TBASE; if(rece() != 5) { puts("port #"); putdec(group); puts(" failed to detect odd parity error!\n"); terflg(); } tran(0xa5); base = SBASE; if(rece() != 5) { puts("port #"); putdec(group); puts(" failed to send even parity!\n"); terflg(); } } } if(erflg == 0 && verflg == 0) puts("passes parity test !\n"); } ovtest() /* over flow test */ { int i,b; puts("\n\n****** overflow test on port #"); putdec(group); puts(" ******\n\n"); error = ovtest; base = SBASE; tran(53); /* output once */ tran(53); /* output again without inputting */ for( i = 0; i < 1000; ++i) /* delay loop */ ; base = TBASE; b = rece(); if(b != 3) { puts("\n didn't overflow on port #"); putdec(group); putc('\n'); terflg(); } else if(erflg == 0 && verflg == 0) puts("passes over flow test !\n"); } rece() /* inputs the status word */ { int i,status; for( i=0; i<10000 ; ++i) { if((status = (in(base+5) & 0xf)) & 1 == 1) break; } in(base); /* clear recieve reg. */ return(status); } bgsel() /* select groups on both boards */ { base = SBASE; groupsel(); base = TBASE; groupsel(); } /* parallel port test */ partest() { error = partest; puts("\n******parallel ports are being tested******\n\n"); functs &= 0xcf; group = 0; bgsel(); /* select group 0 both boards */ out(SBASE,0); /* select port 0 input to non-test bd. */ out((SBASE+1),0); /* clear port 1 on non-test bd. */ out(TBASE,0); /* clear port 0 on test bd. */ out((TBASE+1),0); /* clear port 1 on test bd. */ if(in(SBASE) != 0) { puts("the printer port won't disable from the test board !\n"); terflg(); } else { functs |= 0x20; /* turn on the printer outputs */ bgsel(); pinwalk(); /* printer port input walk-test */ poutwalk(0); /* printer port 0 output walk-test */ out(SBASE,1); /* select port 1 on test board */ poutwalk(1); /* printer port 1 output walk-test */ out(SBASE,2); /* select restore bit on test board */ if(in(SBASE) & 1) /* if the restore bit isn't high */ { puts("the restore bit isn't high on test board\n"); terflg(); } functs |= 0x10; /* turn the restore bit low */ bgsel(); if(in(SBASE) & 1 == 0) /* if the restore bit isn't low */ { puts("the restore bit isn't low on test board\n"); terflg(); } } functs &= 0xcf; /* turn off printer ports and restore bit */ bgsel(); if(erflg == 0 && verflg == 0) puts("passes the parallel port test !\n\n"); } bothset() /* set both parameters up */ { int err; base = TBASE; setparm(); err = ckparm(); base = SBASE; setparm(); err |= ckparm(); return(err); } pinwalk() /* printer port input walk-test */ { int a,b,i; for(i = a = 1; i < 10; i++) { out((SBASE+1),a); b = ~in(TBASE) & 0xff; if(b != a) pwerr(a,b); /* test inverted walk-test also */ out((SBASE+1),(~a & 0xff)); b = (~in(TBASE) & 0xff); if(b != (~a & 0xff)) pwerr(~a & 0xff,b); a = a << 1 & 0xff; } if(erflg == 0 && verflg == 0) puts("passes parallel input walk-test on port #0 !\n\n"); } /* error for input walk-test */ pwerr(a,b) int a,b; { puts("parallel port failed the input walk-test\n"); puts("word "); putbin(a); puts(" came through as word "); putbin(b); puts("\n\n"); terflg(); } /* parallel port output walk-test */ poutwalk(z) int z; { int a,b,i; for(i = a = 1 ; i < 10; ++i) { out(TBASE+z,a); b = ~in(SBASE) & 0xff; if(b != a) poerr(a,b); /* test with inverted bits */ out(TBASE+z,~a & 0xff); b = (~in(SBASE) & 0xff); if(b != (~a & 0xff)) poerr(~a & 0xff,b); a = a << 1 & 0xff; } if(erflg == 0 && verflg == 0) { puts("passes parallel output walk-test on port #"); putdec(z); puts("\n\n"); } } /* parallel port error for output walk-test */ poerr(a,b) int a,b; { puts("parallel port failed the output walk-test\n"); puts("word "); putbin(a); puts(" came through as word "); putbin(b); puts("\n\n"); terflg(); } testram() /* should test ram here returns to cp/m */ { int a,b,i; unsigned char *mem; mem = testad; /* mem points to mem 0xftestad */ a = 1; /* initialize a */ *mem = a; /* memory should be bank disabled */ if(*mem == a) { puts("Memory is enabled when it should be disabled by bank "); puts("select!\n"); terflg(); } out(TBASE+7,4); /* bank select memory */ for( i=0 ; i<8; ++i) { *mem = a; b = *mem; if(b != (a & 0xff)) { puts("memory fails walk-bit test at first location\n"); puts("word "); putbin(a); puts(" came through as word "); putbin(b); putc('\n'); memerr(); break; } a <<= 1; } for( i=0; i < 256; ++i) /* test one full page of memory */ *(mem+i) = i; /* store data in page */ for( i=0; i < 256; ++i) { b = *(mem+i); if(b != i) /* test for correct data */ { puts("memory fails test at location #"); putdec(i); puts("\nword "); putbin(i); puts(" read as word "); putbin(b); putc('\n'); memerr(); } } for( i=0 ; i < 16; ++i) *(mem+(i * 256)) = i; /* store data */ for( i=0; i < 16; ++i) { b = *(mem +(i * 256)); if( b != i) { puts("memory fails on page #"); putdec(i); puts(" \nword "); putbin(i); puts(" read as word "); putbin(b); putc('\n'); memerr(); } } if(erflg == 0 && verflg == 0) puts("passes memory test !\n"); oldtask(); } memerr() /* memory error reset mem addr */ { oldtask(); /* reset memory map */ terflg(); } finadd() /* locates the last 4k memory to use */ { int *a,b; a = 6; /* address of storage location of top of ram */ b = *a; /* b = addr of the last memory in system */ b &= 0xf000; /* mask out lower 12 bits from addr */ b -= 0x1000; /* subtract 4k from addr */ testad = b; /* store in external variable */ if(testad < 0xb000) /* if cp/m isn't big enough */ { puts("\n cp/m isn't big enough!!!!"); fatal(); } } memchng() /* maps page testad to page ftestad */ { int (*restore)(); unsigned char *mem,*pc; mem = (testad >> 12) * 2 + 0x220; /* addr of byte in vmap */ *mem = 0xfc; /* set new map byte */ *(mem+0x400) = 0xfc; /* set real map byte */ pc = 0x15; /* program counter for task 1 */ *pc = (unsigned) testram & 0xff; *(pc+1) = (unsigned) testram / 0x100; /* store addr of testram */ restore = 0x815; /* addr to restore task 1 */ (*restore)(); /* return to task 1 at testram */ } memtest() /* enters task 0 then jumps to memchng */ { int (*task)(); unsigned char taskchng[5]; puts("\n\n****** testing memory ******\n\n"); error = memtest; taskchng[0] = 0x76; /* machine code halt */ taskchng[1] = 0x76; /* machine code halt (traps into mon.) */ taskchng[2] = 0xc3; /* machine code jump */ taskchng[3] = (unsigned)(memchng) & 0xff; /* low addr of jump */ taskchng[4] = (unsigned)(memchng) / 0x100; /* high addr of jump */ task = taskchng; (*task)(); } endtest() /* after ram test is done , map is fixed return here */ { } unchng() /* restore map to original setup */ { int (*restore)(); unsigned char *mem,*pc; mem = (testad >> 12) * 2 + 0x220; /* addr of byte in vmap */ *mem = (testad >> 12); /* set new map byte */ *(mem+0x400) = (testad >> 12); /* set real map byte */ pc = 0x15; /* program counter for task 1 */ *pc = (unsigned) endtest & 0xff; *(pc+1) = (unsigned) endtest / 0x100; /* store addr of testram */ restore = 0x815; /* addr to restore task 1 */ (*restore)(); /* return to task 1 at testram */ } oldtask() /* enters task 0 then jumps to memchng */ { int (*task)(); unsigned char taskchng[5]; taskchng[0] = 0x76; /* machine code halt */ taskchng[1] = 0x76; /* machine code halt (traps into mon.) */ taskchng[2] = 0xc3; /* machine code jump */ taskchng[3] = (unsigned)(unchng) & 0xff; /* low addr of jump */ taskchng[4] = (unsigned)(unchng) / 0x100; /* high addr of jump */ task = taskchng; (*task)(); } control() /* test the control signals of the ace */ { error = control; puts("\n****** testing the control signals on port #"); putdec(group); puts(" ******\n"); out(SBASE+7,0); /* select group 0 */ out(SBASE,0xff); /* set all bits high */ out(SBASE+7,group); /* reset group select */ in(TBASE+6); /* clear all delta bits */ ctos(); /* test clear to send */ dsr(); /* test data set ready */ if(group != 3) /* port three doesn't have rts */ rtos(); /* test request to send */ dtrt(); /* test data terminal ready */ rcd(); /* test received carrier detect */ } ctos() /* test clear to send */ { int b ; static char *msg[]={ "delta clear to send didn't change state during clear to send test\n", "delta data set ready changed state on clear to send test\n", "delta ring indicator should not fail.(not used) during clear to send test\n", "delta recieved carrier detect changed on clear to send test\n", "clear to send isn't high during clear to send test\n", "data set ready isn't low during clear to send test\n", "ring indicate should never fail (not used) during clear to send test\n", "recieved carrier detect isn't low during clear to send test\n" }; if(group != 3) /* if group equals 3 then special */ { out(SBASE+4,2); /* set clear to send bit */ b = in(TBASE+6) ^ 0x11; /* did cts and dcts go high */ if(b != 0) /* did it match what was expected */ conerr(b,msg); /* print error message */ out(SBASE+4,0); /* clear control lines */ in(TBASE+6); /* to clear delta bit */ b = in(TBASE+6) & 1; /* did delta cts clear */ if(b != 0) /* if not print error */ { puts("delta clear to send would not reset\n"); terflg(); } } else { out(SBASE+7,0x20); /* set group 0 and enable parallel */ out(SBASE,0xff); /* set all bits high */ in(TBASE+6); /* reset any bits that changed */ out(SBASE,0xdf); /* set cts bit */ b = in(TBASE+6) ^ 0x11; /* did cts and dcts go high */ if(b != 0) /* did it match what was expected */ conerr(b,msg); /* print error message */ out(SBASE,0xff); /* clear control lines */ out(SBASE+7,3); /* select group three */ in(TBASE+6); /* to clear delta bit */ b = in(TBASE+6) & 1; /* did delta cts clear */ if(b != 0) /* if not print error */ { puts("delta clear to send would not reset\n"); terflg(); } } if(erflg == 0 && verflg == 0) puts("passes clear to send test!\n"); } dsr() /* data set ready test */ { int b; static char *msg2[] ={ "delta clear to send changed during data set ready test\n", "delta data set ready didn't change state during data set ready test\n", "delta ring indicator should never occur ( not used)\n", "delta recieved carrier detect changed during data set ready test\n", "clear to send wasn't low during data set ready test\n", "data set ready didn't go high during test\n", "ring indicate should never occur (not used)\n", "recieved carrier detect wasn't low during data set ready test\n" }; out(SBASE+4,1); /* set data set ready line */ b = in(TBASE+6) ^ 0x22; /* did the reg get set ok */ if(b != 0) conerr(b,msg2); /* print proper error messages */ out(SBASE+4,0); /* clear control lines */ in(TBASE+6); /* to clear delta bit */ b = in(TBASE+6) & 2; /* see if delta bit reset */ if(b != 0) { puts("delta data set ready won't reset\n"); terflg(); } if(erflg == 0 && verflg == 0) puts("passes data set ready test!\n"); } rcd() /* recieved carrier detect */ { int b,i; static char *msg3[] ={ "delta clear to send changed during received carrier test\n", "delta data set ready changed during received carrier test\n", "delta ring indicator should never occur ( not used )\n", "delta received carrier detect didn't change during received carrier test\n", "clear to send was high during received carrier test\n", "data set ready was high during received carrier test\n", "ring indicator was high during received carrier test\n", "received carrier detect wasn't high during received carrier test\n" }; i = group; /* get group number in i */ switch(i) { case 1: i = 0xfb; /* byte to output for right rcd bit */ break; case 2: i = 0xf7; /* byte to output for right rcd bit */ break; case 3: i = 0xef; /* byte to output for right rcd bit */ break; } out(SBASE+7,0x20); /* set non-test bd to group 0 */ out(SBASE,i); /* output rcd bit low to port 0 */ b = in(TBASE+6) ^ 0x88; /* did it match what was expected */ if(b != 0) /* if not print error msg */ conerr(b,msg3); out(SBASE,0xff); /* clear all bits */ out(SBASE+7,group); /* reselect group */ b = in(TBASE+6) & 0x4; /* did delta rcd bit reset */ if(b != 0) /* if not print error */ { puts("delta recieved carrier detect wouldn't reset\n"); terflg(); } if(erflg == 0 && verflg == 0) puts("passes received carrier detect test!\n"); } rtos() /* test request to send line */ { int b; out(TBASE+4,02); /* set rts high */ b = in(SBASE+6) & 0x11; /* mask out unwanted bits */ if(b != 0x11) { puts("failed to request to send test!\n"); terflg(); } else if(erflg == 0 && verflg == 0) puts("passes request to send test!\n"); } dtrt() /* data terminal ready test */ { int b; out(TBASE+4,01); /* set dtr bit high */ b = in(SBASE+6) & 0x22; /* mask out unwanted bits */ if(b != 0x22) { puts("failed data terminal ready test!\n"); terflg(); } else if(erflg == 0 && verflg == 0) puts("passes data terminal ready test!\n"); } conerr(b,pmsg) /* print error msgs for xor against known value */ int b; char *pmsg[]; { int a,i; for(i=0; i < 8 ; ++i) { a = (b >> i) & 1; /* leave test bit in b0 */ if(a) /* is a = 1 */ puts(pmsg[i]); /* print proper msg */ } terflg(); }