Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / netisdn / i4b_global.h
blobfa29280d6cb3023b7b585b4c155a27f2334cbc1e
1 /*
2 * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
25 *---------------------------------------------------------------------------
27 * i4b_global.h - i4b global include file
28 * --------------------------------------
30 * $Id: i4b_global.h,v 1.8 2007/10/14 23:44:49 martin Exp $
32 * $FreeBSD$
34 * last edit-date: [Thu Aug 24 12:38:50 2000]
36 *---------------------------------------------------------------------------*/
38 #ifndef _NETISDN_I4B_GLOBAL_H_
39 #define _NETISDN_I4B_GLOBAL_H_
41 /*---------------------------------------------------------------------------*
42 * hiding OS differences in the kernel
43 *---------------------------------------------------------------------------*/
45 /*---------------*/
46 /* time handling */
47 /*---------------*/
49 #ifdef __FreeBSD__
50 #include <sys/param.h>
52 #if defined(__FreeBSD_version) && __FreeBSD_version >= 400000 && __FreeBSD_version < 400011
53 #error "Unsupported FreeBSD-current version,"
54 #error "you need a FreeBSD-current >= 400011"
55 #endif
57 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
59 #define TIMEOUT_FUNC_T timeout_t *
60 #define SECOND time_second
61 #define MICROTIME(x) getmicrotime(&(x))
63 #else /* FreeBSD < 3 */
65 #define TIMEOUT_FUNC_T timeout_func_t
66 #define SECOND time.tv_sec
67 #define MICROTIME(x) microtime(&(x))
69 #endif /* >= 3 */
70 #endif /* __FreeBSD__ */
72 #if defined(__NetBSD__) /* after timecounter merge */
74 #define TIMEOUT_FUNC_T void *
75 #define SECOND time_uptime
76 #define MICROTIME(x) getmicrotime(&(x))
78 #endif /* __NetBSD__ */
80 #if defined (__OpenBSD__) || defined(__bsdi__)
82 #define TIMEOUT_FUNC_T void *
83 #define SECOND time.tv_sec
84 #define MICROTIME(x) microtime(&(x))
86 #endif /* __OpenBSD__ */
88 /*----------------*/
89 /* timer handling */
90 /*----------------*/
92 #if defined(__NetBSD__)
94 #if __NetBSD_Version__ >= 104230000
95 #define START_TIMER(XHANDLE, XF, XSC, XTIME) callout_reset(&XHANDLE, XTIME, (TIMEOUT_FUNC_T)XF, (void*)XSC)
96 #define STOP_TIMER(XHANDLE, XF, XSC) callout_stop(&XHANDLE)
97 #else
98 #define START_TIMER(XHANDLE, XF, XSC, XTIME) timeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XTIME)
99 #define STOP_TIMER(XHANDLE, XF, XSC) untimeout((TIMEOUT_FUNC_T)XF, (void*)XSC)
100 #endif
102 #else
103 #define START_TIMER(XHANDLE, XF, XSC, XTIME) XHANDLE = timeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XTIME)
104 #ifdef __FreeBSD__
105 #define STOP_TIMER(XHANDLE, XF, XSC) untimeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XHANDLE)
106 #else
107 #define STOP_TIMER(XHANDLE, XF, XSC) untimeout((TIMEOUT_FUNC_T)XF, (void*)XSC)
108 #endif
109 #endif
111 /*----------------------*/
112 /* poll/select handling */
113 /*----------------------*/
115 #if (defined(__FreeBSD__) && \
116 (!defined(__FreeBSD_version) || (__FreeBSD_version < 300001))) \
117 || defined (__OpenBSD__) || defined(__bsdi__)
118 #define OS_USES_SELECT
119 #else
120 #define OS_USES_POLL
121 #endif
123 /*---------------------------------------------------------------------------*
124 * misc globally used things in the kernel
125 *---------------------------------------------------------------------------*/
127 /* timer states */
129 #define TIMER_IDLE 1 /* a timer is running */
130 #define TIMER_ACTIVE 2 /* a timer is idle */
132 /* definitions for the STATUS indications L1 -> L2 -> L3 */
134 #define STI_ATTACH 0 /* attach at boot time */
135 #define STI_L1STAT 1 /* layer 1 status */
136 #define STI_L2STAT 2 /* layer 2 status */
137 #define STI_TEIASG 3 /* TEI assignments */
138 #define STI_PDEACT 4 /* Layer 1 T4 expired = persistent deactivation */
139 #define STI_NOL1ACC 5 /* no outgoing L1 access possible */
141 /* definitions for the COMMAND requests L3 -> L2 -> L1 */
143 #define CMR_DOPEN 0 /* daemon opened /dev/i4b */
144 #define CMR_DCLOSE 1 /* daemon closed /dev/i4b */
145 #define CMR_SETTRACE 2 /* set D-channel and B-channel trace */
146 #define CMR_GCST 3 /* get chipset statistics */
147 #define CMR_CCST 4 /* clear chipset statistics */
148 #define CMR_SETLEDS 5 /* set LEDs (if available) */
150 /* param for CMR_SETLEDS: */
151 #define CMRLEDS_TEI 1 /* this controller has a TEI */
152 #define CMRLEDS_B0 2 /* first B channel is in use */
153 #define CMRLEDS_B0_IN 4 /* first B channel handles an incoming call */
154 #define CMRLEDS_B1 8 /* second B channel is in use */
155 #define CMRLEDS_B1_IN 16 /* second B channel handles an incoming call */
157 #endif /* !_NETISDN_I4B_GLOBAL_H_ */