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 #define KMEM_CACHE_T struct kmem_cache
107
108 #define KZALLOC(size, gfp) my_kzalloc(size, gfp)
109 #define KZFREE(p) \
110 do { \
111 memset((p), 0, sizeof(*(p))); \
112 kfree(p); \
113 } while (0);
114
115 #define DEVICE_ATTR_READER(name, dev, buf) \
116 ssize_t name(struct device *dev, \
117 struct device_attribute *attr, char *buf)
118 #define DEVICE_ATTR_WRITER(name, dev, buf, count) \
119 ssize_t name(struct device *dev, \
120 struct device_attribute *attr, \
121 const char *buf, size_t count)
122 #define DRIVER_ATTR_READER(name, drv, buf) \
123 ssize_t name(struct device_driver *drv, char * buf)
124
125 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
126 #define SET_PROC_DIRENTRY_OWNER(p) \
127 do { \
128 (p)->owner = THIS_MODULE; \
129 } while (0);
130 #else
131 #define SET_PROC_DIRENTRY_OWNER(p) do { } while (0);
132 #endif
133
134 #else
135 typedef int bool;
136 #endif /* ifdef __KERNEL__ */
137 typedef struct xbus xbus_t;
138 typedef struct xpd xpd_t;
139 typedef struct xframe xframe_t;
140 typedef struct xpacket xpacket_t;
141 typedef __u32 xpp_line_t; /* at most 31 lines for E1 */
142 typedef __u8 lineno_t;
143 typedef __u8 xportno_t;
144
145 #define PORT_BROADCAST 255
146
147 #endif /* XDEFS_H */