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