1 /********************************************************/
3 /* VME control of TrueTime VME-SG sync gen card */
4 /* and TrueTime GPS-VME receiver card */
5 /* Version for 700 series HPUX 9.0 */
6 /* Richard E.Schmidt, US Naval Observatory, Washington */
8 /********************************************************/
14 #if defined(REFCLOCK) && defined(CLOCK_GPSVME)
18 #include <sys/types.h>
21 #include <sys/ioctl.h>
22 #include <sys/types.h>
24 #include <sys/sysmacros.h>
25 #include <sys/rtprio.h> /* for rtprio */
26 #include <sys/lock.h> /* for plock */
27 #include "/etc/conf/machine/vme2.h"
28 #include "/etc/conf/h/io.h"
33 unsigned short *greg[NREGS];
34 struct vme2_map_addr ma; /* memory mapped structure */
35 int fd; /* file descriptor for VME */
46 struct vme2_io_testx tx;
49 #define VME_START_ADDR 0x00000 /* Starting address in A16N VME Space */
50 #define VMESIZE 0xFF /* 256 bytes of A16N space length */
53 To create the HP9000/700 series device file, /dev/vme2:
54 mknod /dev/vme2 c 44 0x0; chmod 600 /dev/vme2
56 Then must create /etc/vme.CFG and run /etc/vme_config and reboot.
58 if ((fd = open (filename, O_RDWR)) < 0) {
59 printf("ERROR: VME bus adapter open failed. errno:%d\n",
62 printf("ENODEV. Is driver in kernel? vme2 in dfile?\n");
66 tx.card_type = VME_A16;
67 tx.vme_addr = VME_START_ADDR;
68 tx.width = SHORT_WIDE;
70 if(ioctl(fd, VME2_IO_TESTR, &tx)) {
71 printf("ioctl to test VME space failed. Errno: %d\n",
76 printf("io_testr failed internal error %d\n",tx.error);
77 if(tx.access_result < 0) {
78 printf("io_testr failed\n");
82 /* If successful mmap the device */
83 /* NOW MAP THE CARD */
84 ma.card_type = VME_A16;
85 ma.vme_addr = VME_START_ADDR;
88 if(ioctl(fd, VME2_MAP_ADDR, &ma)) {
89 printf("ioctl to map VME space failed. Errno: %d\n",
94 printf("ioctl to map VME failed\n");
105 if(ioctl(fd, VME2_UNMAP_ADDR, &ma))
106 printf("ioctl to unmap VME space failed. Errno: %d\n",
116 /* set up address offsets */
118 gps_base = map_vme (GPS_VME);
120 /* offsets from base address: */
122 greg[0] = (unsigned short *)gps_base + GFRZ1;
123 greg[1] = (unsigned short *)gps_base + GUFRZ1;
124 greg[2] = (unsigned short *)gps_base + GREG1A;
125 greg[3] = (unsigned short *)gps_base + GREG1B;
126 greg[4] = (unsigned short *)gps_base + GREG1C;
127 greg[5] = (unsigned short *)gps_base + GREG1D;
128 greg[6] = (unsigned short *)gps_base + GREG1E;
133 #else /* not (REFCLOCK && CLOCK_GPSVME) */
135 #endif /* not (REFCLOCK && CLOCK_GPSVME) */