1 /*
2 * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved.
3 *
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.
12 *
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.
24 *
25 *---------------------------------------------------------------------------
26 *
27 * i4b_global.h - i4b global include file
28 * --------------------------------------
29 *
30 * $FreeBSD: releng/5.3/sys/i4b/include/i4b_global.h 132199 2004-07-15 08:26:07Z phk $
31 *
32 * last edit-date: [Sun Mar 17 09:55:26 2002]
33 *
34 *---------------------------------------------------------------------------*/
35
36 #ifndef _I4B_GLOBAL_H_
37 #define _I4B_GLOBAL_H_
38
39 /*---------------------------------------------------------------------------*
40 * hiding OS differences in the kernel
41 *---------------------------------------------------------------------------*/
42
43 #if defined(__FreeBSD__) && __FreeBSD__ >= 5
44 /*
45 * Deprecated LKM interface.
46 */
47 #include <sys/module.h>
48 #define PSEUDO_SET(sym, name) \
49 static int name ## _modevent(module_t mod, int type, void *data) \
50 { \
51 void (*initfunc)(void *) = (void (*)(void *))data; \
52 switch (type) { \
53 case MOD_LOAD: \
54 /* printf(#name " module load\n"); */ \
55 initfunc(NULL); \
56 break; \
57 case MOD_UNLOAD: \
58 printf(#name " module unload - not possible for this module type\n"); \
59 return EINVAL; \
60 default: \
61 return EOPNOTSUPP; \
62 } \
63 return 0; \
64 } \
65 static moduledata_t name ## _mod = { \
66 #name, \
67 name ## _modevent, \
68 (void *)sym \
69 }; \
70 DECLARE_MODULE(name, name ## _mod, SI_SUB_PSEUDO, SI_ORDER_ANY)
71 #endif
72
73 /*---------------*/
74 /* time handling */
75 /*---------------*/
76
77 #include <sys/param.h>
78
79 #define TIMEOUT_FUNC_T timeout_t *
80 #define SECOND time_second
81 #define MICROTIME(x) getmicrotime(&(x))
82
83 /*----------------*/
84 /* timer handling */
85 /*----------------*/
86
87 #define START_TIMER(XHANDLE, XF, XSC, XTIME) XHANDLE = timeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XTIME)
88 #define STOP_TIMER(XHANDLE, XF, XSC) untimeout((TIMEOUT_FUNC_T)XF, (void*)XSC, XHANDLE)
89
90 /*---------------------------------------------------------------------------*
91 * misc globally used things in the kernel
92 *---------------------------------------------------------------------------*/
93
94 /* timer states */
95
96 #define TIMER_IDLE 1 /* a timer is running */
97 #define TIMER_ACTIVE 2 /* a timer is idle */
98
99 /* priority */
100 #define I4BPRI (PSOCK + 1)
101
102 /* i4b's spl */
103
104 #define SPLI4B() splimp() /* spl for i4b */
105
106 /* critial code region handling macros */
107
108 #define CRIT_VAR int _svd_spl_ /* declare variable */
109 #define CRIT_BEG _svd_spl_ = SPLI4B() /* save spl */
110 #define CRIT_END splx(_svd_spl_) /* restore spl */
111
112 /* definitions for the STATUS indications L1 -> L2 -> L3 */
113
114 #define STI_ATTACH 0 /* attach at boot time */
115 #define STI_L1STAT 1 /* layer 1 status */
116 #define STI_L2STAT 2 /* layer 2 status */
117 #define STI_TEIASG 3 /* TEI assignments */
118 #define STI_PDEACT 4 /* Layer 1 T4 expired = persistent deactivation */
119 #define STI_NOL1ACC 5 /* no outgoing L1 access possible */
120
121 /* definitions for the COMMAND requests L3 -> L2 -> L1 */
122
123 #define CMR_DOPEN 0 /* daemon opened /dev/i4b */
124 #define CMR_DCLOSE 1 /* daemon closed /dev/i4b */
125 #define CMR_SETTRACE 2 /* set D-channel and B-channel trace */
126 #define CMR_GCST 3 /* get chipset statistics */
127 #define CMR_CCST 4 /* clear chipset statistics */
128
129 #endif /* _I4B_GLOBAL_H_ */
Cache object: 37b715391251fcb2184e59089d61ea57
|