4
* Written by Oron Peled <oron@actcom.co.il>
5
* Copyright (C) 2004-2006, Xorcom
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.
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.
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.
25
#include "xpp_version.h"
29
#include <linux/kernel.h>
30
#include <linux/version.h>
34
/* This is to enable user-space programs to include this. */
38
typedef uint32_t __u32;
42
#define DBG(fmt, ...) printf("DBG: %s: " fmt, __FUNCTION__, ## __VA_ARGS__)
43
#define INFO(fmt, ...) printf("INFO: " fmt, ## __VA_ARGS__)
44
#define NOTICE(fmt, ...) printf("NOTICE: " fmt, ## __VA_ARGS__)
45
#define ERR(fmt, ...) printf("ERR: " fmt, ## __VA_ARGS__)
48
struct list_head { struct list_head *next; struct list_head *prev; };
52
#define PACKED __attribute__((packed))
54
#define ALL_LINES ((lineno_t)-1)
56
#ifndef BIT /* added in 2.6.24 */
57
#define BIT(i) (1UL << (i))
59
#define BIT_SET(x,i) ((x) |= BIT(i))
60
#define BIT_CLR(x,i) ((x) &= ~BIT(i))
61
#define IS_SET(x,i) (((x) & BIT(i)) != 0)
62
#define BITMASK(i) (((u64)1 << (i)) - 1)
64
#define MAX_PROC_WRITE 100 /* Largest buffer we allow writing our /proc files */
65
#define CHANNELS_PERXPD 32 /* Depends on xpp_line_t and protocol fields */
67
#define MAX_SPANNAME 20 /* From zaptel.h */
68
#define MAX_SPANDESC 40 /* From zaptel.h */
69
#define MAX_CHANNAME 40 /* From zaptel.h */
71
#define XPD_NAMELEN 10 /* must be <= from maximal workqueue name */
72
#define XPD_DESCLEN 20
73
#define XBUS_NAMELEN 20 /* must be <= from maximal workqueue name */
74
#define XBUS_DESCLEN 40
77
#define UNIT_BITS 3 /* Bit for Astribank unit number */
78
#define SUBUNIT_BITS 3 /* Bit for Astribank subunit number */
80
#define MAX_UNIT (1 << UNIT_BITS) /* 1 FXS + 3 FXS/FXO | 1 BRI + 3 FXS/FXO */
81
#define MAX_SUBUNIT (1 << SUBUNIT_BITS) /* 8 port BRI */
84
* Compile time sanity checks
86
#if MAX_UNIT > BIT(UNIT_BITS)
87
#error "MAX_UNIT too large"
90
#if MAX_SUBUNIT > BIT(SUBUNIT_BITS)
91
#error "MAX_SUBUNIT too large"
94
#define MAX_XPDS (MAX_UNIT*MAX_SUBUNIT)
96
#define VALID_XPD_NUM(x) ((x) < MAX_XPDS && (x) >= 0)
98
#define CHAN_BITS 5 /* 0-31 for E1 */
101
typedef unsigned char byte;
104
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
105
#define KMEM_CACHE_T kmem_cache_t
107
#define KMEM_CACHE_T struct kmem_cache
110
#define KZALLOC(size, gfp) my_kzalloc(size, gfp)
111
#define KZFREE(p) do { \
112
memset((p), 0, sizeof(*(p))); \
116
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
122
typedef struct xbus xbus_t;
123
typedef struct xpd xpd_t;
124
typedef struct xframe xframe_t;
125
typedef struct xpacket xpacket_t;
126
typedef struct xops xops_t;
127
typedef __u32 xpp_line_t; /* at most 31 lines for E1 */
128
typedef byte lineno_t;
129
typedef byte xportno_t;
131
#define PORT_BROADCAST 255