4 * @brief Common Driver Code Manager (CDCM) header file.
6 * @author Georgievskiy Yury, Alain Gagnaire. CERN AB/CO.
8 * @date Created on 31/05/2006
10 * This is a CDCM header file which holds all major definitions of the CDCM
12 * Many thanks to Julian Lewis and Nicolas de Metz-Noblat.
16 #ifndef _CDCM_DRVR_H_INCLUDE_
17 #define _CDCM_DRVR_H_INCLUDE_
27 #include <linux/version.h>
28 #include <linux/kernel.h>
29 #include <linux/module.h>
31 //#include <linux/config.h>
34 #include <config/modversions.h>
37 #include <linux/string.h>
38 #include <linux/errno.h>
39 #include <linux/sched.h>
40 #include <linux/signal.h>
41 #include <linux/timer.h>
42 #include <linux/interrupt.h>
43 #include <linux/pci.h>
44 #include <linux/tty.h>
45 #include <linux/tty_flip.h>
46 #include <linux/serial.h>
47 #include <linux/major.h>
48 #include <linux/fcntl.h>
49 #include <linux/ptrace.h>
50 #include <linux/ioport.h> /* for request_region */
52 #include <linux/slab.h>
53 #include <linux/netdevice.h>
54 #include <linux/vmalloc.h>
55 #include <linux/init.h>
56 #include <asm/serial.h>
57 #include <linux/delay.h> /* for loops_per_jiffy */
58 #include <linux/poll.h> /* for POLLIN, etc. */
59 #include <asm/system.h>
60 #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */
63 #include <asm/bitops.h>
64 #include <asm/types.h>
65 #include <linux/termios.h>
66 #include <linux/workqueue.h>
67 #include <linux/hdlc.h>
68 #include <linux/kthread.h>
70 #include "cdcmInfoT.h" /* for 'cdcm_hdr_t' type */
71 #include "drvr_dbg_prnt.h"
73 #define kkprintf printk
74 #define cprintf printk
77 /*! @name device alive level in the CDCM environment
81 ALIVE_DEAD
= 0x0, //!< device is dead
82 ALIVE_ALLOC
= 1<<0, //!< structure is allocated
83 ALIVE_CDEV
= 1<<1, //!< cdev is registered
84 ALIVE_THRDS
= 1<<2, //!< threads are running
85 ALIVE_FULL
= (~0) //!< all is done
90 /*! @name CDCM-tune flags
94 CDCMFLG_NOUSREP
= 1<<0, //!< don't execute user entry points
95 CDCMFLG_ALL
= (~0) //!< all are set
100 /*! @name timer handling mechanism
103 #define MAX_CDCM_TIMERS 16
104 typedef struct _cdcmTimer
{
105 pid_t ct_on
; /**< on/off flag
106 0 - timer is not used, else
107 tid - who is using this timer */
108 struct timer_list ct_timer
; //!<
109 int (*ct_uf
)(void*); //!< user function
110 char *ct_arg
; //!< user arg
114 /* ioctl operation information */
115 #define DIR_NONE (1 << 0) /* no params */
116 #define DIR_READ (1 << 1) /* read params */
117 #define DIR_WRITE (1 << 2) /* write params */
118 #define DIR_RW (DIR_READ | DIR_WRITE) /* both write and read params */
119 typedef struct _cdcmIoctl
{
120 int direction
; /* DIR_READ or DIR_WRITE from user point of view */
121 int size
; /* data size in bytes */
126 /* process descr, currently using the driver */
128 struct task_struct
*cdcm_task
; //!< id
133 /*! @name Used to describe VME devices
137 unsigned int vd_virt_addr
; //!< virtual address
138 unsigned int vd_phys_addr
; //!< physical address
139 unsigned int vd_len
; //!< size of the mapped memory
140 unsigned int vd_am
; //!< address modifier
145 /*! @name description of each module, handled by CDCM
148 struct cdcm_dev_info
{
149 struct list_head di_list
; //!< device linked list
150 struct pci_dev
*di_pci
; //!< PCI device pointer
151 struct vme_dev
*di_vme
; //!< VME device pointer
152 devAlive_t di_alive
; //!< alive level
154 /* Thread Stuff. TODO.
155 struct list_head di_thr_list; //!< thread list head
156 int di_thr_croak; //!< batch thread suicide
157 struct completion di_thr_c; //!< thread syncronization
161 #define drm_node_s cdcm_dev_info
164 /* general CDCM statics table */
165 typedef struct _cdcmStatics
{
166 struct list_head cdcm_dev_list
; /**< controlled device list head
167 described by cdcm_dev_info */
168 char *cdcm_st
; //!< statics table, returned by install entry point
169 char *cdcm_mn
; //!< module name provided by the user
170 cdcm_hdr_t
*cdcm_hdr
; //!< header passed from the user space
171 int cdcm_major
; //!< driver major number
173 dbgipl_t cdcm_ipl
; //!< CDCM Information Printout Level
174 struct list_head cdcm_thr_list_head
; /* thread list */
175 //struct list_head cdcm_proc_list_head; /* process list */
176 cdcmt_t cdcm_timer
[MAX_CDCM_TIMERS
]; /* timers */
177 struct list_head cdcm_sem_list_head
; /* semaphore list */
178 cdcmflg_t cdcm_flags
; /* bitset flags */
179 int cdcm_isdg
; /* this is a driverGen driver */
182 /* TODO. Initialize cdcmStatT */
183 /* cdcmStatT - global statics table defined in cdcmDrvr.c module */
198 #endif /* _CDCM_DRVR_H_INCLUDE_ */