source: drsdaq/VME/struck/sis1100/V2.02/test.orig/check_3100_path.c@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 2.2 KB
Line 
1/*
2 * $ZEL$
3 */
4
5#include "test_3100.h"
6
7int
8init_path(struct path* path)
9{
10 path->type=-1;
11 path->p=-1;
12 path->mapsize=0;
13 path->map=0;
14
15 path->p=open(path->name, O_RDWR, 0);
16 if (path->p<0) {
17 printf("open \"%s\": %s\n", path->name, strerror(errno));
18 return -1;
19 }
20 if (ioctl(path->p, SIS1100_DEVTYPE, &path->type)<0) {
21 printf("ioctl(%s, SIS1100_DEVTYPE): %s\n",
22 path->name, strerror(errno));
23 return -1;
24 }
25
26#ifdef SIS1100_DRIVERVERSION
27 {
28 int version;
29 if (ioctl(path->p, SIS1100_DRIVERVERSION, &version)<0) {
30 printf("ioctl(%s, SIS1100_DRIVERVERSION):\n %s\n",
31 path->name, strerror(errno));
32 if (MAJORVERSION>1) {
33 printf(" Major version does not match; path cannot be used\n");
34 return -1;
35 }
36 } else {
37 path->majorversion=(version>>16)&0xffff;
38 path->minorversion=version&0xffff;
39 printf("%s: driverversion is %d.%d\n",
40 path->name,
41 path->majorversion,
42 path->minorversion);
43 if (path->majorversion!=MAJORVERSION) {
44 printf("Major version does not match; path cannot be used\n");
45 return -1;
46 }
47 }
48 }
49#else
50 if (MAJORVERSION>1) {
51 printf(" Major version does not match; path cannot be used\n");
52 return -1;
53 }
54#endif
55
56 switch (path->type) {
57 case sis1100_subdev_remote:
58 printf("%s is <REMOTE>\n", path->name);
59 break;
60 case sis1100_subdev_ram:
61 printf("%s is RAM\n", path->name);
62 break;
63#if MAJORVERSION >= 2
64 case sis1100_subdev_ctrl:
65 printf("%s is CTRL\n", path->name);
66 break;
67#endif
68 case sis1100_subdev_dsp:
69 printf("%s is DSP\n", path->name);
70 break;
71 default:
72 printf("init_path: %s has unknown type %d\n",
73 path->name, path->type);
74 return -1;
75 }
76 return 0;
77}
78
79int
80done_path(struct path* path)
81{
82 if (path->map) {
83 if (munmap((u_int32_t*)path->map, path->mapsize)<0)
84 printf("munmap(%s): %s\n",
85 path->name, strerror(errno));
86 }
87 if (path->p>=0) close(path->p);
88 return 0;
89}
90
Note: See TracBrowser for help on using the repository browser.