⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpmtest.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
shmem_test8k(passes)    int             passes;{    int             pass, error1 = 0, error2 = 0, i, hung_count = 0;    unsigned short  readback, data[BLOCK_SIZE_2];    short          *ptr;    for (pass = 1; pass <= passes; pass++) {	/* write data to shared memory */	ptr = (short *) &gp1_shmem[0x1000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    data[i] = (short) random();	    *ptr++ = data[i];	}	if (simulate_error == TEST4_VERIFY_ERROR ||	    simulate_error == TEST4_PATH_ERROR) {	    ptr = (short *) &gp1_shmem[0x1010];	    readback = *ptr;	    *ptr = readback + 1;	}	gp1_shmem[0] = 0x800;		       /* set semaphore */	hung_count = 0;	do {				       /* readback the just-written					        * data */	    ptr = (short *) &gp1_shmem[0x1000];	    for (i = 0; i < BLOCK_SIZE_2; i++) {		readback = *ptr++;		if (readback != data[i] && simulate_error != TEST4_PATH_ERROR) {		    error1++;		    errors++;		    sprintf(msg,"data compare error on memory verify, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.", i + 0x1000, data[i], readback, test);		    send_message(-TEST4_VERIFY_ERROR, ERROR, msg);		}	    }	    if (++hung_count == HUNG_STATE) {		errors++;		sprintf(msg, "the graphics processor hung, test %d.", test);		send_message(-TEST4_HUNG_ERROR, ERROR, msg);	    }	}				       /* semaphore reset ?? */	while (gp1_shmem[0] != 0 || simulate_error == TEST4_HUNG_ERROR);	/* readback the data passed through the GP */	ptr = (short *) &gp1_shmem[0x2000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    readback = *ptr++;	    if (readback != data[i]) {		error2++;		errors++;		sprintf(msg,"data compare error, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.",		    i + 0x2000, data[i], readback, test);		send_message(-TEST4_PATH_ERROR, ERROR, msg);	    }	}    }    return (error1 + error2);}/* function to read shmem contents (prom -> shmem) and test checksum */test_prom(){    int             i, checksum = 0;    unsigned short  readback;    int             error = 0;    /* ensure time for GP to move prom contents to shared memory */    sleep(2);    /* compute and check checksum */    for (i = 0; i < PROM_SIZE - 1; i++) {	checksum += gp1_shmem[i];	checksum &= 0xffff;    }    readback = gp1_shmem[PROM_SIZE - 1];    if (simulate_error == CHECKSUM_ERROR)	readback++;    if (((unsigned short) checksum) == readback) {	send_message(0, VERBOSE, "CHECKSUM MATCH; value= %x", checksum);    } else {	error++;	errors++;	send_message(-CHECKSUM_ERROR, ERROR, "checksum incorrect, \		checksum exp = 0x%x, checksum actual = 0x%x, test %d.",		checksum, readback, test);    }    return (error);}/* function to test vme-readable status flags */test_sflag(){    int             pass, passes = 32, error1 = 0, error2 = 0, error3 = 0;    int             i, hung_count = 0;    unsigned short  readback, data[BLOCK_SIZE_2];    short          *ptr;    unsigned short  sflag4, sflag8;    if (quick_test)	passes = 1;    for (pass = 1; pass <= passes; pass++) {	/*	 * Mask off the last four bits of pass number and (ones) complement	 * them. This should equal the state of the Viewing Processor and	 * Painting Processor status flags	 */	sflag4 = 0xf - (pass & 0xf);	sflag8 = (sflag4 << 4) + sflag4;	readback = gp1_base[GP1_STATUS_REG] & 0xff;	if (simulate_error == STATUS_ERROR)	    readback++;	if (sflag8 != readback) {	    error3++;	    errors++;	    sprintf(msg, 	  "status incorrect, exp = 0x%x, actual = 0x%x, test %d.",		sflag8, readback, test);	    send_message(-STATUS_ERROR, ERROR, msg);	}	/* write data to shared memory */	ptr = (short *) &gp1_shmem[0x1000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    data[i] = (short) random();	    *ptr++ = data[i];	}	if (simulate_error == TEST5_VERIFY_ERROR ||	    simulate_error == TEST5_PATH_ERROR) {	    ptr = (short *) &gp1_shmem[0x1010];	    readback = *ptr;	    *ptr = readback + 1;	}	gp1_shmem[0] = 0x800;		       /* set semaphore */	hung_count = 0;	/*	 * readback the just-written data until the GP is done moving the	 * data	 */	do {	    ptr = (short *) &gp1_shmem[0x1000];	    for (i = 0; i < BLOCK_SIZE_2; i++) {		readback = *ptr++;		if (readback != data[i] && simulate_error != TEST5_PATH_ERROR) {		    error1++;		    errors++;		    sprintf(msg,"data compare error on memory verify, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.", i + 0x1000, data[i], readback, test);		    send_message(-TEST5_VERIFY_ERROR, ERROR, msg);		}	    }	    if (++hung_count == HUNG_STATE) {		errors++;		sprintf(msg, 		    "the graphics processor hung, test %d.", test);		send_message(-TEST5_HUNG_ERROR, ERROR, msg);	    }	}				       /* semaphore reset ?? */	while (gp1_shmem[0] != 0 || simulate_error == TEST5_HUNG_ERROR);	/* readback the data passed through the GP by the microcode */	ptr = (short *) &gp1_shmem[0x2000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    readback = *ptr++;	    if (readback != data[i]) {		error2++;		errors++;		sprintf(msg,"data compare error, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.",		    i + 0x2000, data[i], readback, test);		send_message(-TEST5_PATH_ERROR, ERROR, msg);	    }	}    }    return (error1 + error2 + error3);}/* * function to write an integer to/from the vme bus by making it into two * 16-bit pieces of data. This solves the VME bus error problem encountered * on the Sun4 architecture */move_int(p1, p2)    register short *p1, *p2;{    *p1++ = *p2++;    *p1 = *p2;}/* function to test shmem -> ... -> shmem with graphics buffer microcode */shmem_testgb(){    int             pass, passes = 256, error1 = 0, error2 = 0, i, hung_count = 0;    int             gbaddr;    unsigned short  readback, data[BLOCK_SIZE_2];    short          *ptr;    int            *ptr_gbaddr;    if (quick_test)	passes = 1;    ptr_gbaddr = (int *) &gp1_shmem[2];    for (pass = 1; pass <= passes; pass++) {	/* 256 = 1 Megaword divided by 4k words */	/* write data to shared memory */	ptr = (short *) &gp1_shmem[0x1000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    data[i] = (short) random();	    *ptr++ = data[i];	}	gbaddr = 0x1000 * (pass - 1);	move_int(ptr_gbaddr, &gbaddr);	/* *ptr_gbaddr = gbaddr; */	if (simulate_error == TEST6_VERIFY_ERROR ||	    simulate_error == TEST6_PATH_ERROR) {	    ptr = (short *) &gp1_shmem[0x1010];	    readback = *ptr;	    *ptr = readback + 1;	}	gp1_shmem[0] = 0x800;		       /* set semaphore */	hung_count = 0;	/*	 * readback the just-written data until the GP is done moving the	 * data	 */	do {	    ptr = (short *) &gp1_shmem[0x1000];	    for (i = 0; i < BLOCK_SIZE_2; i++) {		readback = *ptr++;		if (readback != data[i] && simulate_error != TEST6_PATH_ERROR) {		    error1++;		    errors++;		    sprintf(msg,"data compare error on memory verify, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.", i + 0x1000, data[i], readback, test);		    send_message(-TEST6_VERIFY_ERROR, ERROR, msg);		}	    }	    if (++hung_count == HUNG_STATE) {		errors++;		sprintf(msg, "the graphics processor hung, test %d.", test);		send_message(-TEST6_HUNG_ERROR, ERROR, msg);	    }	}				       /* semaphore reset ?? */	while (gp1_shmem[0] != 0 || simulate_error == TEST6_HUNG_ERROR);	/* readback the data passed through the GP by the microcode */	ptr = (short *) &gp1_shmem[0x2000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    readback = *ptr++;	    if (readback != data[i]) {		error2++;		errors++;		sprintf(msg,"data compare error, word address = 0x%x, gb address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.", i + 0x2000, i + gbaddr, data[i], readback, test);		send_message(-TEST6_PATH_ERROR, ERROR, msg);	    }	}    }    return (error1 + error2);}/* * function to test shmem -> ... -> shmem microcode using interrupt flag as * reset semaphore instead of shared memory location 0 */shmem_iflag(passes)    int             passes;{    int             pass, error1 = 0, error2 = 0, error3 = 0, i, hung_count = 0;    unsigned short  readback, data[BLOCK_SIZE_2];    short          *ptr;    /* ensure interrupt enable is turned off */    if (simulate_error == INT1_ERROR)	gp1_base[GP1_CONTROL_REG] = 0x0100;    else	gp1_base[GP1_CONTROL_REG] = 0x0200;    if ((gp1_base[GP1_STATUS_REG] & 0x4000) != 0) {	errors++;	sprintf(msg, "interrupt cannot be disabled, test %d.", test);	send_message(-INT1_ERROR, ERROR, msg);    }    for (pass = 1; pass <= passes; pass++) {	/* write data to shared memory */	ptr = (short *) &gp1_shmem[0x1000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    data[i] = (short) random();	    *ptr++ = data[i];	}	if (simulate_error == TEST7_VERIFY_ERROR ||	    simulate_error == TEST7_PATH_ERROR) {	    ptr = (short *) &gp1_shmem[0x1010];	    readback = *ptr;	    *ptr = readback + 1;	}	gp1_shmem[0] = 0;		       /* reset semaphore for VP */	gp1_shmem[0] = 0x800;		       /* set semaphore */	hung_count = 0;	/*	 * readback the just-written data until the GP is done moving the	 * data	 */	do {	    ptr = (short *) &gp1_shmem[0x1000];	    for (i = 0; i < BLOCK_SIZE_2; i++) {		readback = *ptr++;		if (readback != data[i] && simulate_error != TEST7_PATH_ERROR) {		    error1++;		    errors++;		    sprintf(msg,"data compare error on memory verify, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.", i + 0x1000, data[i], readback, test);		    send_message(-TEST7_VERIFY_ERROR, ERROR, msg);		}	    }	    if (++hung_count == HUNG_STATE) {		errors++;		sprintf(msg, "the graphics processor hung, test %d.", test);		send_message(-TEST7_HUNG_ERROR, ERROR, msg);	    }	}	/* semaphore (int flag) reset? ? */	while ((gp1_base[GP1_STATUS_REG] & 0x8000) == 0 ||	       simulate_error == TEST7_HUNG_ERROR);	/* reset interrupt flag (the PP semaphore) */	if (simulate_error == INT2_ERROR)	    gp1_base[GP1_CONTROL_REG] = 0x0000;	else	    gp1_base[GP1_CONTROL_REG] = 0x8000;	/* did the interrupt flag reset */	if ((gp1_base[GP1_STATUS_REG] & 0x8000) != 0) {	    error3++;	    errors++;	    sprintf(msg, "interrupt flag did not reset, test %d.", test);	    send_message(-INT2_ERROR, ERROR, msg);	}	/* readback the data passed through the GP by the microcode */	ptr = (short *) &gp1_shmem[0x2000];	for (i = 0; i < BLOCK_SIZE_2; i++) {	    readback = *ptr++;	    if (readback != data[i]) {		error2++;		errors++;		sprintf(msg,"data compare error, word address = 0x%x, exp = 0x%x, actual = 0x%x, test %d.",		    i + 0x2000, data[i], readback, test);		send_message(-TEST7_PATH_ERROR, ERROR, msg);	    }	}    }    return (error1 + error2 + error3);}gp1_open(){    int             i, p;    int             align;    caddr_t         gpm;    extern char    *malloc();    if (simulate_error == VME24_NOT_OPEN)	strcpy(file_name, "/dev/vme24.invalid");    else	strcpy(file_name, "/dev/vme24");    if ((gp1_fd = open(file_name, O_RDWR)) < 0) {	perror(perror_msg);	sprintf(msg, "Couldn't open file '%s'.", file_name);	send_message(-VME24_NOT_OPEN, FATAL, msg);    }    align = getpagesize();    if ((allocp = malloc(VME_GP1SIZE + align)) == 0 ||	simulate_error == NO_MALLOC) {	perror(perror_msg);	send_message(-NO_MALLOC, FATAL, "Couldn't allocate address space.");    }    p = ((int) allocp + align - 1) & ~(align - 1);    if (((i = (int)mmap(p, VME_GP1SIZE, PROT_READ|PROT_WRITE,        MAP_SHARED|MAP_FIXED, gp1_fd, VME_GP1BASE)) == -1) ||        (i != p) ||	simulate_error == NO_MAP) {	perror(perror_msg);	send_message(-NO_MAP, FATAL, "Couldn't map the graphics processor.");    }    gp1_base = (short *) p;    gpm = (caddr_t) (p + GP1_SHMEM_OFFSET);    gp1_shmem = (short *) gpm;}gp1_close(){    if (gp1_base) {	close(gp1_fd);	free(allocp);	gp1_base = 0;    }}gp1_reset(){    gp1_hwreset();    gp1_swreset();}gp1_hwreset(){    gp1_base[GP1_CONTROL_REG] = GP1_CR_CLRIF | GP1_CR_INT_DISABLE |	GP1_CR_RESET;    gp1_base[GP1_CONTROL_REG] = 0;}gp1_swreset(){    register int   *shmem = (int *) gp1_shmem;    register short  i;    int             x = 0x800000FF;    int             y = 0;    i = 133;    while (--i) {	move_int(shmem, &y);    }    move_int(&gp1_shmem[10], &x);    /* *((int *)&gp1_shmem[10]) = 0x800000FF; */}gp1_load(filename)    char           *filename;{    FILE           *fp;    u_short         tadd, nlines;    u_short         ucode[4096 * 4];    int             nwords;    register u_short *ptr;    register short *gp1_ucode;    strcpy(SD, "./");    if (exec_by_sundiag) {	if (simulate_error == UFILE_NOT_OPEN)	    strcat(SD, "no.ucode");	else	    strcat(SD, filename);    }    else 	strcat(SD, filename);    if ((fp = fopen(SD, "r")) == NULL) 	send_message(-UFILE_NOT_OPEN, FATAL, 		"Couldn't open microcode file '%s'.", SD);    gp1_ucode = &gp1_base[GP1_UCODE_DATA_REG];    while (fread(&tadd, sizeof(tadd), 1, fp) == 1) {	/* starting microcode address */	gp1_base[GP1_UCODE_ADDR_REG] = tadd;	fread(&nlines, sizeof(nlines), 1, fp);	/* number of microcode lines  */	while (nlines > 0) {	    nwords = (nlines > 4096) ? 4096 : nlines;	    nlines -= nwords;	    fread(ucode, sizeof(u_short), 4 * nwords, fp);	    for (ptr = ucode; nwords > 0; nwords--) {		*gp1_ucode = *ptr++;		*gp1_ucode = *ptr++;		*gp1_ucode = *ptr++;		*gp1_ucode = *ptr++;	    }	}    }    fclose(fp);}gp1_vp_start(cont_flag)    int             cont_flag;{    register short *gp1_cntrl = &gp1_base[GP1_CONTROL_REG];    *gp1_cntrl = 0;    if (cont_flag)	*gp1_cntrl = GP1_CR_VP_CONT;    else	*gp1_cntrl = GP1_CR_VP_STRT0 | GP1_CR_VP_CONT;}gp1_vp_halt(){    register short *gp1_cntrl = &gp1_base[GP1_CONTROL_REG];    *gp1_cntrl = 0;    *gp1_cntrl = GP1_CR_VP_HLT;}gp1_pp_start(cont_flag)    int             cont_flag;{    register short *gp1_cntrl = &gp1_base[GP1_CONTROL_REG];    *gp1_cntrl = 0;    if (cont_flag)	*gp1_cntrl = GP1_CR_PP_CONT;    else	*gp1_cntrl = GP1_CR_PP_STRT0 | GP1_CR_PP_CONT;}gp1_pp_halt(){    register short *gp1_cntrl = &gp1_base[GP1_CONTROL_REG];    *gp1_cntrl = 0;    *gp1_cntrl = GP1_CR_PP_HLT;}int process_gpmtest_args (argv, arrcount)char	*argv[];int	arrcount;{    if (argv[arrcount][0] == 'e') {        simulate_error = atoi(&argv[arrcount][1]);        if (simulate_error > 0 && simulate_error < END_ERROR)            return (TRUE);     }    else if (strcmp(argv[arrcount], "gb") == 0)         num_of_tests += GB_TESTS;    else if (strcmp(argv[arrcount], "ppprom") == 0)         ppprom_flag = TRUE;    else	return (FALSE);    return (TRUE);}/******************************* Dummy code to satisfy libtest.a********************************/clean_up(){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -