1 #ifndef _<mod_name>_<drvr_type>_H_INCLUDE_
2 #define _<mod_name>_<drvr_type>_H_INCLUDE_
8 #include <kern_proto.h>
11 #include <sys/types.h>
14 #include <sys/ioctl.h>
19 #include <proto_int.h>
31 #include <ces/vmelib.h> /* for 'pdparam_xxx' structure */
39 #include "<dg_free_fmt>/vme_am.h" /* for VMEbus Address Modifier Codes */
40 #include "<dg_free_fmt>/ServiceRegIoctl.h"
41 #include "<dg_free_fmt>/ModuleHeader.h"
43 #if defined(__linux__) && defined (__KERNEL__)
45 #define sel poll_table_struct /* for select entry point */
46 /* only for Linux kernel */
47 #include <cdcm/cdcm.h>
48 #include "<dg_free_fmt>/swab-extra-linux.h"
52 #if defined(__LYNXOS) || defined (__KERNEL__)
53 /* to be able to use CDCM utils inside the driver */
54 #include <cdcm/cdcmBoth.h>
57 /* Provides debug information printing. */
58 #define DBG_BEG(f_nm) \
60 if (s->info->debugFlag & DBGIOCTL) { \
61 swait(&sem_drvr, SEM_SIGIGNORE); /* lock calling thread */ \
62 cprintf("(pid %d) (tid %d) %s() ", getpid(), st_getstid(), f_nm); \
66 /* information about the address that will be read/write */
67 #define DBG_ADDR(ra, idx, en) \
69 if (s->info->debugFlag & DBGIOCTL) { \
70 unsigned addr = (unsigned)ra; \
71 cprintf("[(elIdx %d) (elAm %d) @ 0x%x] ", idx, (int)en, addr); \
75 /* ioctl completion tag */
78 if (s->info->debugFlag & DBGIOCTL) { \
79 cprintf(" - OK.\n"); \
80 ssignal(&sem_drvr); /* wake up waiting thread */ \
84 /* ioctl completion tag */
87 if (s->info->debugFlag & DBGIOCTL) { \
88 cprintf(" - FAIL.\n"); \
89 ssignal(&sem_drvr); /* wake up waiting thread */ \
93 /* start timing measurements. Different in case of Lynx/Linux */
96 #define START_TIME_STAT() \
98 if (s->info->debugFlag & DBGTIMESTAT) { \
99 /* because of the spatial locality reference phenomenon, fill in cache \
100 memory so that it will keep recently accessed values (in our case \
101 it is 'nanotime' sys function stuff), thus trying to avoid additional \
102 time loss induced by cache miss. \
103 Normally, '__builtin_prefetch' gcc function should be used to minimize \
104 cache-miss latency by moving data into a cache before it is accessed. \
105 But with currently used Lynx gcc (version 2.95.3 20010323 (Lynx) as \
106 of 24.04.06) it's not possible, as it's probably not supported. \
107 For more info see gcc 4.0.1 reference manual at: \
108 http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Other-Builtins.html#Other-Builtins \
109 So let's wait until newer gcc will be installed and then try the new \
111 GlobStartN = nanotime(&GlobStartS); \
113 /* wait for the better times to implement... */ \
114 /*__builtin_prefetch(&GlobStartN, 1, 1); */ \
116 /* now we can start real timing measurements */ \
117 GlobStartN = nanotime(&GlobStartS); \
123 #define START_TIME_STAT() \
124 if (s->info->debugFlag & DBGTIMESTAT) getnstimeofday(&_t_beg)
126 #endif /* defined __Lynx__ */
128 /* printout measured time statistics */
129 #define FINISH_TIME_STAT() \
131 if (s->info->debugFlag & DBGTIMESTAT) { \
132 unsigned int retN; /* for timing measurements */ \
133 retN = ComputeTime(GlobTimeStatS); \
135 cprintf("Done in %s\n", GlobTimeStatS); \
137 cprintf("Done in %dns (%s)\n", retN, GlobTimeStatS); \
142 #define <mod_name>_MAX_NUM_CARDS 21 /* VME crates have 21 slots max */
144 /* <mod_name> module ioctl numbers */
145 #define <mod_name>_IOCTL_MAGIC '<dg_char>'
147 #define <mod_name>_IO(nr) _IO(<mod_name>_IOCTL_MAGIC, nr)
148 #define <mod_name>_IOR(nr,sz) _IOR(<mod_name>_IOCTL_MAGIC, nr, sz)
149 #define <mod_name>_IOW(nr,sz) _IOW(<mod_name>_IOCTL_MAGIC, nr, sz)
150 #define <mod_name>_IOWR(nr,sz) _IOWR(<mod_name>_IOCTL_MAGIC, nr, sz)