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

📄 vfctest.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic	char sccsid[] = "@(#)vfctest.c 1.1 92/07/30 Copyright Sun Micro";#endif#include <sys/types.h>#include <stdio.h>#include <sys/fcntl.h>#include <sys/mman.h>#include <signal.h>#include "vfctest_defs.h"#include "vfc_defs.h"#include "vfc_ioctls.h"#include "sdrtns.h"	/* sdrtns.h should always be included */#include "../../../lib/include/libonline.h"#define	DEVICE_NAME	"/dev/vfc0"#define	TOTAL_PASS	1     /* number of test loops */#define ERROR_LIMIT	100   /* max num of errors allowed if run_on_error */int probe_vfcdev(), process_vfc_args(), vfctest_usage();/* VFC-specific globals */u_int *vfc_port1, *vfc_port2;int vfcfd;			/* file-desc for use during test */int vidchk;			/* flag to see if user wants a video chk */int memchk;			/* flag to see if user wants a mem chk */int enggflag;int errors = 0;struct memstrct {  int pixloc;  u_int wpatt;  u_int rpatt;} ;struct memstrct *memerr;static int errnum = 0;static char mesgstr[120];main(argc, argv)     int	argc;     char	*argv[];{  int fd;  versionid = "1.1";  device_name = DEVICE_NAME;  vidchk = TRUE;  memchk = TRUE;  enggflag = FALSE;  /* Sundiag start up call */  test_init(argc, argv, process_vfc_args, vfctest_usage, (char *)NULL);  if (vidchk == FALSE)    send_message(SKIP_ERROR, VERBOSE, "Don't Report on Video Signals");  if (memchk == FALSE)    send_message(SKIP_ERROR, VERBOSE, "Don't test the Field Memory");  if (enggflag == TRUE)    send_message(SKIP_ERROR, VERBOSE, "Engg. Testing/Debug");  if (!exec_by_sundiag)		/* command-line execution in progress */    probe_vfcdev();    run_vfctests(single_pass ? 1 : TOTAL_PASS);	/* start vfc tests */  if (errors > 0)    exit(1);  else    {      clean_up();      test_end();    }}/** * Process_vfc_args() processes vfctest specific args. * Check if the user wants to check the video signals on each port. */process_vfc_args(argv, argindex)char *argv[];int  argindex;{  int match = FALSE;   if (strncmp(argv[argindex], "novideo", 7) == 0) {     vidchk = FALSE;     match = TRUE;   }   if (strncmp(argv[argindex], "nomem", 5) == 0) {     memchk = FALSE;     match = TRUE;   }  if (strncmp(argv[argindex], "vfceng", 6) == 0) {    enggflag = TRUE;    match = TRUE;  }  if (strncmp(argv[argindex], "vfc0", 4) == 0) {	strcpy(device_name, "/dev/vfc0");	match = TRUE;  }	  if (strncmp(argv[argindex], "vfc1", 4) == 0) {	strcpy(device_name, "/dev/vfc1");	match = TRUE;	}	  return (match);}vfctest_usage(){  send_message(SKIP_ERROR, CONSOLE, "vfctest [novideo] [nomem]: \n\ 	novideo = Do not test video section\n\	nomem = Do not test memory section\n");}/*  Since vfc has a loadable-only driver, the open call should *  failed if the board is not installed in the system. */probe_vfcdev(){  int rcode, fd;  rcode = 0;  fd = -1;  /* First check if the driver has been installed */  if (access(device_name, 0) != 0)    rcode = DEV_NOT_ACCESSIBLE;  else    if ((fd = open(device_name, O_RDWR)) == -1)       rcode = DEV_OPEN_ERR;  if (rcode)    errorlog(rcode, "Probe Failed \n");  if (fd > 0)			/* valid fd */    close(fd);  return (0);  }run_vfctests(total_pass)int total_pass;{  int pass = 0;  caddr_t base;  int subcmd;  if ((vfcfd = open(device_name, O_RDWR)) == -1)    errorlog(DEV_OPEN_ERR, "Open Failed \n");  base = mmap(0, 0x8000, PROT_READ | PROT_WRITE, MAP_SHARED, vfcfd, 0x0);  if (base < 0)    errorlog(DEV_MMAP_ERR, "Mmap Failure \n");  /* Obtain pointers to the 2 FRAM banks */  vfc_port1 = (u_int *)((caddr_t) base + 0x5000);  vfc_port2 = (u_int *)((caddr_t) base + 0x7000);  memerr = (struct memstrct *)malloc(sizeof(struct memstrct) * 3000);  while (++pass <= total_pass) {    if (memchk == TRUE) {      subcmd = DIAGMODE;      ioctl(vfcfd, VFCSCTRL, &subcmd); /* put the device in diag-mode */      send_message(SKIP_ERROR, VERBOSE, "Memory Test");      walking_test();	/* walking 1s and 0s test */      unique_test();	/* unique test  */      subcmd = NORMMODE;      ioctl(vfcfd, VFCSCTRL, &subcmd); /* put the board back in Normal mode */    }    if (vidchk == TRUE)      video_report();    if (vidchk || memchk)      send_message(SKIP_ERROR, VERBOSE, "vfctest: Pass = %d, Errors = %d",		   pass, errors);  }  if (!exec_by_sundiag)    printf("vfctest: Errors found = %d \n", errors);  free((struct memstrct *)memerr);  close(vfcfd);}	/* Report on the Video signals at each port */video_report(){  int subcmd, rcode;  int vidport;  for (vidport = 1; vidport <= 3; ++vidport) {    subcmd = STD_NTSC;    rcode = ioctl(vfcfd, VFCSVID, &subcmd);    if (rcode) {      errorlog(SKIP_ERROR, "Failed during NTSC initialisation");      return(0);			/* no use going further */    }    subcmd = vidport;    if (rcode = ioctl(vfcfd, VFCPORTCHG, &subcmd)) {      errorlog(SKIP_ERROR, "Failed to change port");      continue;    }    subcmd = 0;    rcode = ioctl(vfcfd, VFCGVID, &subcmd);        if (rcode == -1) {      errorlog(SKIP_ERROR, "Failed to get video status");      continue;    }        if (debug) {      sprintf(mesgstr,"Video Status from driver = %x \n", subcmd);      send_message(0, DEBUG, mesgstr);    }    send_message(SKIP_ERROR, VERBOSE, "Report on Port %d", vidport);    switch(subcmd) {    case NO_LOCK:      send_message(SKIP_ERROR, VERBOSE, "\tNo Video Signal Detected");      break;    case NTSC_COLOR:      /* We detected NTSC Hlock, so let's try Capture Command */      send_message(SKIP_ERROR, VERBOSE,		   "\tNTSC Color signal detected");      subcmd = CAPTRCMD;      if (ioctl(vfcfd, VFCSCTRL, &subcmd))	errorlog(SKIP_ERROR,		 "NTSC Horz Freq. detected, but Capture Command failed");      else	send_message(SKIP_ERROR, VERBOSE, "Capture Command ok");      break;    case NTSC_NOCOLOR:      /* We detected NTSC Hlock, so let's try Capture Command */      send_message(SKIP_ERROR, VERBOSE,		   "\tNTSC signal detected, but NO color signal confirmation");      subcmd = CAPTRCMD;      if (ioctl(vfcfd, VFCSCTRL, &subcmd))	errorlog(SKIP_ERROR,		 "NTSC Horz Freq. detected, but Capture Command failed");      else	send_message(SKIP_ERROR, VERBOSE, "Capture Command ok");      break;    case PAL_NOCOLOR:      /* We assume that 50 Hz pulses is a PAL signal. Since we had       * initialised for NTSC, we should re-initialise for PAL and       * check for PAL color detected. After that we will try a       * Capture.       */      subcmd = STD_PAL;      if (ioctl(vfcfd, VFCSVID, &subcmd)) {	errorlog(SKIP_ERROR, "Failed during PAL initialisation");	break;      }      subcmd = 0;      if (ioctl(vfcfd, VFCGVID, &subcmd)) {	errorlog(SKIP_ERROR,		 "Failed to get Video Status after PAL initialisation");	break;      }      if (debug) {	sprintf(mesgstr,"Video Status from driver(after PAL init.) = %x \n", subcmd);	send_message(0, DEBUG, mesgstr);      }      if (subcmd == PAL_COLOR)	send_message(SKIP_ERROR, VERBOSE, "\tPAL Color Signal Detected");      else	send_message(SKIP_ERROR, VERBOSE, 	            "\tPAL signal detected, but NO color signal confirmation");      subcmd = CAPTRCMD;      if (ioctl(vfcfd, VFCSCTRL, &subcmd))	errorlog(SKIP_ERROR,		 "PAL Horz. Freq. detected, but Capture Command failed");      else	send_message(SKIP_ERROR, VERBOSE, "Capture Command ok");      break;    default:      errorlog(-VFC_FATAL, "Unknown code returned from analyse_vidstatus\n");    }  }  return (0);}	/* The following routine zaptopmem() takes care of	 * ensuring the top 248 pixels are off-limits to testing.	 */	   zaptopmem (port, op)     u_int *port;     int   op;{  int i;  u_int data;  if (op == WRITE) {    for (i = 1; i <= GARBAGE_PIXELS; ++i)	*port = 0xbad00000;  }  else {    for (i = 1; i <= GARBAGE_PIXELS; ++i)	data = *port;  }  return (0);}walking_test(){  int loop, field;  u_int *taddr;  int retstat;  for (field = 1; field <= 2; ++field) {    if (field == 1)      taddr = vfc_port1;    else      taddr = vfc_port2;    for (loop = 1; loop <= 2; ++loop) {      walking_write(taddr, loop); /* write walking pattern */      /* Now perform the reading ... */      if (enggflag)	{	  /* walking_read(taddr, loop, field, 3); */	}      else	{	  if (walking_read(taddr, loop, field,1) > 0)	/* first loop */	    {	      errnum = 0;	      retstat = walking_read(taddr, loop, field, 2);	      if (retstat == 1)		{

⌨️ 快捷键说明

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