46 int initcam(
const char * fname,
const char *bdir)
53 char edt_devname[256];
61 static char *debug_env = NULL;
81 strcpy(cfgname, fname);
220 if (debug_env == NULL
221 && ((debug_env = (
char *) getenv(
"PDVDEBUG")) != NULL)
222 && *debug_env !=
'0')
223 pdv_debug = atoi(debug_env);
230 level = edt_msg_default_level();
232 if ((verbose > 1) && (pdv_debug < verbose))
235 if ((!verbose) && (!pdv_debug))
241 level |= EDTAPP_MSG_INFO_1;
242 level |= PDVLIB_MSG_INFO_1;
243 level |= PDVLIB_MSG_WARNING;
244 level |= PDVLIB_MSG_FATAL;
247 level |= EDTAPP_MSG_INFO_2;
249 level |= PDVLIB_MSG_INFO_2;
252 edt_msg_set_level(edt_msg_default_handle(), level);
254 edt_msg_set_name(edt_msg_default_handle(), logname);
260 pdv_setdebug(NULL, pdv_debug);
266 if ((dd_p = pdv_alloc_dependent()) == NULL)
268 edt_msg(PDVLIB_MSG_FATAL,
"alloc_dependent FAILED -- exiting\n");
276 ret = pdv_readcfg_emb(cfgname, dd_p, &edtinfo);
280 if (pdv_readcfg(cfgname, dd_p, &edtinfo) != 0)
282 edt_msg(PDVLIB_MSG_FATAL,
"readcfg FAILED -- exiting\n");
287 strcpy(dd_p->rbtfile,
"_SKIPPED_");
292 unit = edt_parse_unit_channel(unitstr, edt_devname,
"pdv", &channel);
293 edt_msg(EDTAPP_MSG_INFO_1,
"opening %s unit %d....\n", edt_devname, unit);
294 if ((edt_p = edt_open_channel(edt_devname, unit, channel)) == NULL)
296 sprintf(errstr,
"edt_open(%s%d)", edt_devname, unit);
301 if (edt_p->devid == PDVFOI_ID)
303 #ifdef _FOI_SUPPORTED
304 pdv_initcam_set_rci(edt_p, channel) ;
306 edt_msg(EDTAPP_MSG_FATAL,
"FOI not supported after pkg v4.1.5.9\n");
312 if (pdv_initcam(edt_p, dd_p, unit, &edtinfo, cfgname, bitdir,
315 edt_msg(EDTAPP_MSG_FATAL,
"initcam failed. Run with '-V' to see complete debugging output\n");
321 edt_msg(EDTAPP_MSG_FATAL,
"done\n");
331 #define edt_swab32(x) \
334 (((u_int)(x) & (u_int)0x000000ffUL) << 24) | \
335 (((u_int)(x) & (u_int)0x0000ff00UL) << 8) | \
336 (((u_int)(x) & (u_int)0x00ff0000UL) >> 8) | \
337 (((u_int)(x) & (u_int)0xff000000UL) >> 24) )) \
342 u_int tracebuf[EDT_TRACESIZE];
346 void print_hex(u_char *buf,
int count);
347 void print_ascii(
char *buf);
352 int i, unit = 0, report = 0, debug = -1, quiet = 0;
355 char edt_devname[100];
357 int test_timestamp = 0 ;
362 int set_solaris_dma_mode = 0;
363 int solaris_dma_mode = 0;
364 int set_umem_lock_mode = 0;
365 int umem_lock_mode = 0;
374 int process_isr = -1;
375 int do_process_isr = 0;
377 int multi_done = 0x1234;
378 int check_openmask = 0 ;
380 int use_kernel_buffers = -1;
381 int do_kernel_buffers = 0;
382 int use_persistent_buffers = 0;
385 int set_fv_done = -1;
388 int lock_on_value = 0;
392 u_int trace_state = 0;
393 u_int trace_regs_enable = 0;
407 int direct_coupled = 0;
414 use_kernel_buffers = -1;
415 else if (kbuff[0] ==
'c')
416 use_kernel_buffers = EDT_COPY_KBUFS;
417 else if (kbuff[0] ==
'm')
418 use_kernel_buffers = EDT_MMAP_KBUFS;
420 use_kernel_buffers = 0;
422 if (isdigit(kbuff[0]))
423 use_kernel_buffers = strtol(kbuff,0,0);
425 if (kbuff[0] && (kbuff[1] ==
'p'))
427 use_persistent_buffers = 1;
428 use_kernel_buffers |= EDT_PERSISTENT_KBUFS;
430 do_kernel_buffers = 1;
639 unit = edt_parse_unit(unitstr, edt_devname, EDT_INTERFACE);
643 if ((edt_p = edt_open_channel(edt_devname, unit, channel)) == NULL)
647 sprintf(str,
"%s%d_%d", edt_devname, unit, channel);
652 else if ((edt_p = edt_open(edt_devname, unit)) == NULL)
656 sprintf(str,
"%s%d", edt_devname, unit);
661 if (trace_regs_enable)
663 edt_trace_regs_enable(edt_p, trace_reg);
667 edt_set_trace_regs(edt_p, trace_reg, trace_state);
673 edt_dma_info tmpinfo ;
674 tmpmask = edt_get_dma_info(edt_p, &tmpinfo) ;
675 printf(
"dma info mask %08x used %08x alloc %08x active %08x\n",
679 tmpinfo.active_dma) ;
686 edt_ioctl(edt_p, EDTS_TEST_LOCK_ON, &lock_on_value);
694 if (edt_ioctl(edt_p, P53S_RESET, &arg) == -1)
695 perror(
"edt_ioctl(P53S_RESET)");
700 if (edt_ioctl(edt_p, P53S_RESET, &arg) == -1)
701 perror(
"edt_ioctl(P53S_RESET)");
706 printf(
"setting direct_coupled\n");
708 printf(
"setting transformer_coupled\n");
709 if (edt_ioctl(edt_p, P53S_COUPLED, &direct_coupled) == -1)
710 perror(
"edt_ioctl(P53S_DIRECT)");
717 printf(
"setting read timeout to %d ms\n", mstimeout);
718 edt_set_rtimeout(edt_p, mstimeout);
719 edt_set_wtimeout(edt_p, mstimeout);
724 edt_ioctl(edt_p, EDTS_PROCESS_ISR, &process_isr);
725 printf(
"Process ISR state = %d\n", process_isr);
729 if (multi_done != 0x1234)
734 edt_ioctl(edt_p, EDTG_MULTI_DONE,&multi_done);
735 printf(
"multi done = %d\n", multi_done);
737 printf(
"setting multi done = %d\n", multi_done);
738 edt_ioctl(edt_p, EDTS_MULTI_DONE, &multi_done);
742 if (do_kernel_buffers)
746 if (use_kernel_buffers != -1)
748 printf(
"Setting to %d\n",
750 old_state = edt_set_kernel_buffers(edt_p,use_kernel_buffers);
751 printf(
"old_state = %d\n", old_state);
754 old_state = edt_get_kernel_buffers(edt_p);
755 use_persistent_buffers = edt_get_persistent_buffers(edt_p);
757 printf(
"Use Kernel buffers is %s %s\n", (old_state == 0)?
758 "off":(old_state == 2)?
"mmapped":
"copy",
759 (use_persistent_buffers)?
"(persistent)":
"");
765 edt_set_max_buffers(edt_p,max_buffers);
766 printf(
"Max Buffers = %d\n", edt_get_max_buffers(edt_p));
773 edt_version_string version;
774 edt_version_string build;
776 edt_get_driver_version(edt_p,version,
sizeof(version));
777 edt_get_driver_buildid(edt_p,build,
sizeof(version));
779 printf(
"\n%s%d: Driver version %s \n Build %s\n",
789 i = edt_get_debug(edt_p);
791 printf(
"\n%s%d: current debug %d type %d\n", edt_devname, unit, i,
792 edt_get_drivertype(edt_p));
796 for(i = 0 ; i < 4 ; i++)
798 edt_ref_tmstamp(edt_p,i) ;
803 if (set_fv_done != -1)
806 i = (set_fv_done)?1:0;
807 edt_ioctl(edt_p,EDTS_FVAL_DONE,&i);
808 if (set_fv_done == 1)
809 edt_reg_and(edt_p,PDV_UTIL3,~PDV_TRIGINT);
814 (void) edt_set_debug(edt_p, debug);
816 printf(
"%s%d: new debug %d\n", edt_devname, unit, debug);
819 edt_dump_registers(edt_p, debug);
821 printf(
"xfer %d bytes\n", edt_get_bytecount(edt_p));
826 mapsize = edt_get_mappable_size(edt_p);
830 printf(
"Second memory space size = 0x%x bytes\n", mapsize);
838 edt_trace(edt_p, stdout, FALSE, (wait_trace)?0:1, NULL, 0);
856 sg_args.desc = EDT_SGLIST_SIZE;
857 sg_args.value = sgbuf;
858 edt_ioctl(edt_p, EDTG_SGINFO, &sg_args);
859 sg_size = (u_int) sg_args.value;
861 sg_args.desc = EDT_SGLIST_VIRTUAL;
862 sg_args.value = sgbuf;
863 edt_ioctl(edt_p, EDTG_SGINFO, &sg_args);
864 sg_virtual = (u_int) sg_args.value;
866 sg_args.desc = EDT_SGLIST_PHYSICAL;
867 sg_args.value = sgbuf;
868 edt_ioctl(edt_p, EDTG_SGINFO, &sg_args);
869 sg_physical = (u_int) sg_args.value;
871 sg_args.desc = EDT_SGTODO_SIZE;
872 sg_args.value = sgbuf;
873 edt_ioctl(edt_p, EDTG_SGINFO, &sg_args);
874 todo_size = (u_int) sg_args.value;
876 sg_args.desc = EDT_SGTODO_VIRTUAL;
877 sg_args.value = sgbuf;
878 edt_ioctl(edt_p, EDTG_SGINFO, &sg_args);
879 todo_virtual = (u_int) sg_args.value;
881 sg_args.desc = EDT_SGTODO_FIRST_SG;
882 sg_args.value = sgbuf;
883 edt_ioctl(edt_p, EDTG_SGINFO, &sg_args);
884 first_sg = (u_int) sg_args.value;
886 printf(
"todo size 0x%x addr %x\n", todo_size, todo_virtual);
887 printf(
"sg size 0x%x viraddr %x physaddr %x first_sg %x\n",
888 sg_size, sg_virtual, sg_physical, first_sg);
891 todo_list = (u_int *) malloc(todo_size);
892 sg_list = (u_int *) malloc(sg_size);
896 printf(
"return to read todo list: ");
898 printf(
"todo list %p\n", todo_list);
899 edt_ioctl(edt_p, EDTG_SGTODO, todo_list);
901 printf(
"todo_list:\n");
902 printf(
"todo size %x\n", todo_size);
903 printf(
"return to continue");
905 for (ii = 0; ii < todo_size / 8; ii++)
907 printf(
"%08x %08x\n", *ptr, *(ptr + 1));
913 buf_args sg_getargs ;
914 sg_getargs.addr = (uint64_t) ((
unsigned long) sg_list) ;
915 sg_getargs.size = sg_size ;
916 sg_getargs.index = sgbuf ;
917 printf(
"return to read sg list: %x at %p",sg_size,sg_list);
919 edt_ioctl(edt_p, EDTG_SGLIST, &sg_getargs);
921 printf(
"sg list:\n");
922 if (edt_little_endian())
923 for (ii = 0; ii < sg_size / 8; ii++)
925 printf(
"%08x %08x\n", *ptr, *(ptr + 1));
929 for (ii = 0; ii < sg_size / 8; ii++)
931 printf(
"%08x %08x\n", edt_swab32(*ptr), edt_swab32(*(ptr + 1)));
938 printf(
"return to test sg list: ");
940 log_list = (u_int *) malloc(1024 * 8);
941 for (i = 7; i >= 0; i--)
943 log_list[i * 2] = 1024 * (1024 / 8) * i ;
944 log_list[i * 2 + 1] = 1024 * (1024 / 8) ;
946 edt_set_sglist(edt_p, 0, log_list, 8) ;
960 stat = edt_reg_read(edt_p, PCD_STAT);
961 bytenum = (stat & (SSDIO_BYTECNT_MSK)) >> SSDIO_BYTECNT_SHFT;
962 printf(
"stat %02x next strobe ", stat);
963 if (stat & SSDIO_LAST_BIT)
964 printf(
"will fill byte to start filling %d\n", bytenum);
966 printf(
"filling byte %d\n", bytenum);
967 tmp = edt_reg_read(edt_p, PCD_FUNCT);
968 printf(
"return to strobe: ");
970 edt_reg_write(edt_p, PCD_FUNCT, tmp & ~SSDIO_STROBE);
971 edt_reg_write(edt_p, PCD_FUNCT, tmp | SSDIO_STROBE);
978 cnt = edt_get_bytecount(edt_p);
979 cfg = edt_reg_read(edt_p, EDT_DMA_CFG);
980 printf(
"0x%x tranferred fifo %d cfg %08x\n",
981 cnt, (cfg & EDT_FIFO_CNT) >> EDT_FIFO_SHIFT, cfg);
982 printf(
"return to clock fifo: ");
984 edt_reg_write(edt_p, EDT_DMA_INTCFG, cfg | EDT_WRITE_STROBE);
996 bcount = edt_get_bytecount(edt_p);
997 printf(
"xfer %d (0x%x) bytes\n", bcount, bcount);
998 bcount = edt_get_bufbytecount(edt_p,&buf);
999 printf(
"xfer %d (0x%x) bytes buf %x\n", bcount, bcount,buf);
1002 if (set_solaris_dma_mode)
1004 edt_ioctl(edt_p, EDTS_SOLARIS_DMA_MODE, &solaris_dma_mode);
1006 if (set_umem_lock_mode)
1008 edt_ioctl(edt_p, EDTS_UMEM_LOCK, &umem_lock_mode);
1020 print_hex(u_char *buf,
int count)
1025 for (i=0; i<count; i++)
1026 printf(
"%02x%s", buf[i], i == count-1?
">":
" ");
1031 print_ascii(
char *buf)
1036 for (i=0; i<strlen(buf); i++)
1038 if (buf[i] >=
' ' && buf[i] <=
'~')
1039 printf(
"%c", buf[i]);
1040 else if (buf[i] ==
'\t')
1042 else if (buf[i] ==
'\n')
1044 else if (buf[i] ==
'\r')
int setdebug(const char *kbuff)
A local version of setdebug.
Declarations for some utility functions pertaining to the EDT framegrabber PCI card.
int initcam(const char *fname, const char *bdir)
A local version of initcam.