Debian Codegraph @

drivers/dahdi/xpp/xdefs.h

raw symbols SCIP
1 #ifndef XDEFS_H
2 #define XDEFS_H
3 /*
4 * Written by Oron Peled <[email protected]>
5 * Copyright (C) 2004-2006, Xorcom
6 *
7 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25 #ifdef __KERNEL__
26
27 #include <linux/kernel.h>
28 #include <linux/version.h>
29
30 #else
31
32 /* This is to enable user-space programs to include this. */
33
34 #include <stdint.h>
35 typedef uint8_t __u8;
36 typedef uint32_t __u32;
37
38 #include <stdio.h>
39
40 #define DBG(fmt, ...) printf("DBG: %s: " fmt, __func__, ## __VA_ARGS__)
41 #define INFO(fmt, ...) printf("INFO: " fmt, ## __VA_ARGS__)
42 #define NOTICE(fmt, ...) printf("NOTICE: " fmt, ## __VA_ARGS__)
43 #define ERR(fmt, ...) printf("ERR: " fmt, ## __VA_ARGS__)
44 #define __user
45
46 struct list_head {
47 struct list_head *next;
48 struct list_head *prev;
49 };
50
51 #endif
52
53 #define PACKED __attribute__((packed))
54
55 #define ALL_LINES ((lineno_t)-1)
56
57 #ifndef BIT /* added in 2.6.24 */
58 #define BIT(i) (1UL << (i))
59 #endif
60 #define BIT_SET(x, i) ((x) |= BIT(i))
61 #define BIT_CLR(x, i) ((x) &= ~BIT(i))
62 #define IS_SET(x, i) (((x) & BIT(i)) != 0)
63 #define BITMASK(i) (((u64)1 << (i)) - 1)
64
65 #define MAX_PROC_WRITE 100 /* Longest write allowed to our /proc files */
66 #define CHANNELS_PERXPD 32 /* Depends on xpp_line_t and protocol fields */
67
68 #define MAX_SPANNAME 20 /* From dahdi/kernel.h */
69 #define MAX_SPANDESC 40 /* From dahdi/kernel.h */
70 #define MAX_CHANNAME 40 /* From dahdi/kernel.h */
71
72 #define XPD_NAMELEN 10 /* must be <= from maximal workqueue name */
73 #define XPD_DESCLEN 20
74 #define XBUS_NAMELEN 20 /* must be <= from maximal workqueue name */
75 #define XBUS_DESCLEN 40
76 #define LABEL_SIZE 20
77
78 #define UNIT_BITS 3 /* Bit for Astribank unit number */
79 #define SUBUNIT_BITS 3 /* Bit for Astribank subunit number */
80
81 /* 1 FXS + 3 FXS/FXO | 1 BRI + 3 FXS/FXO */
82 #define MAX_UNIT (1 << UNIT_BITS)
83 #define MAX_SUBUNIT (1 << SUBUNIT_BITS) /* 8 port BRI */
84
85 /*
86 * Compile time sanity checks
87 */
88 #if MAX_UNIT > BIT(UNIT_BITS)
89 #error "MAX_UNIT too large"
90 #endif
91
92 #if MAX_SUBUNIT > BIT(SUBUNIT_BITS)
93 #error "MAX_SUBUNIT too large"
94 #endif
95
96 #define MAX_XPDS (MAX_UNIT*MAX_SUBUNIT)
97
98 #define VALID_XPD_NUM(x) ((x) < MAX_XPDS && (x) >= 0)
99
100 #define CHAN_BITS 5 /* 0-31 for E1 */
101
102 typedef char *charp;
103 #ifdef __KERNEL__
104
105 /* Kernel versions... */
106 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
107 #define KMEM_CACHE_T kmem_cache_t
108 #else
109 #define KMEM_CACHE_T struct kmem_cache
110 #endif
111
112 #define KZALLOC(size, gfp) my_kzalloc(size, gfp)
113 #define KZFREE(p) \
114 do { \
115 memset((p), 0, sizeof(*(p))); \
116 kfree(p); \
117 } while (0);
118
119 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
120 #define DEVICE_ATTR_READER(name, dev, buf) \
121 ssize_t name(struct device *dev, \
122 struct device_attribute *attr, char *buf)
123 #define DEVICE_ATTR_WRITER(name, dev, buf, count) \
124 ssize_t name(struct device *dev, \
125 struct device_attribute *attr, \
126 const char *buf, size_t count)
127 #else
128 #define DEVICE_ATTR_READER(name, dev, buf) \
129 ssize_t name(struct device *dev, char *buf)
130 #define DEVICE_ATTR_WRITER(name, dev, buf, count) \
131 ssize_t name(struct device *dev, const char *buf, size_t count)
132 #endif
133 #define DRIVER_ATTR_READER(name, drv, buf) \
134 ssize_t name(struct device_driver *drv, char * buf)
135
136 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
137 #define SET_PROC_DIRENTRY_OWNER(p) \
138 do { \
139 (p)->owner = THIS_MODULE; \
140 } while (0);
141 #else
142 #define SET_PROC_DIRENTRY_OWNER(p) do { } while (0);
143 #endif
144
145 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
146 /* Also don't define this for later RHEL >= 5.2. */
147 #if defined(RHEL_RELEASE_CODE) && defined(RHEL_RELEASE_VERSION)
148 #if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5, 3)
149 typedef int bool;
150 #endif
151 #else
152 typedef int bool;
153 #endif
154 #endif
155 #else
156 typedef int bool;
157 #endif
158 typedef struct xbus xbus_t;
159 typedef struct xpd xpd_t;
160 typedef struct xframe xframe_t;
161 typedef struct xpacket xpacket_t;
162 typedef __u32 xpp_line_t; /* at most 31 lines for E1 */
163 typedef __u8 lineno_t;
164 typedef __u8 xportno_t;
165
166 #define PORT_BROADCAST 255
167
168 #endif /* XDEFS_H */