1 /* $NetBSD: intr.h,v 1.6 2005/11/23 13:00:51 nonaka Exp $ */ 2 3 /* 4 * Copyright 2001 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed for the NetBSD Project by 20 * Wasabi Systems, Inc. 21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22 * or promote products derived from this software without specific prior 23 * written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 /* 39 * Copyright (C) 1995-1997 Wolfgang Solfrank. 40 * Copyright (C) 1995-1997 TooLs GmbH. 41 * All rights reserved. 42 * 43 * Redistribution and use in source and binary forms, with or without 44 * modification, are permitted provided that the following conditions 45 * are met: 46 * 1. Redistributions of source code must retain the above copyright 47 * notice, this list of conditions and the following disclaimer. 48 * 2. Redistributions in binary form must reproduce the above copyright 49 * notice, this list of conditions and the following disclaimer in the 50 * documentation and/or other materials provided with the distribution. 51 * 3. All advertising materials mentioning features or use of this software 52 * must display the following acknowledgement: 53 * This product includes software developed by TooLs GmbH. 54 * 4. The name of TooLs GmbH may not be used to endorse or promote products 55 * derived from this software without specific prior written permission. 56 * 57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 67 */ 68 69 #ifndef _MACHINE_INTR_H_ 70 #define _MACHINE_INTR_H_ 71 72 /* Interrupt priority "levels". */ 73 #define IPL_NONE 0 /* nothing */ 74 #define IPL_SOFT 1 /* generic software interrupts */ 75 #define IPL_SOFTCLOCK 2 /* software clock interrupt */ 76 #define IPL_SOFTNET 3 /* software network interrupt */ 77 #define IPL_BIO 4 /* block I/O */ 78 #define IPL_NET 5 /* network */ 79 #define IPL_SOFTSERIAL 6 /* software serial interrupt */ 80 #define IPL_TTY 7 /* terminals */ 81 #define IPL_VM 8 /* memory allocation */ 82 #define IPL_AUDIO 9 /* audio device */ 83 #define IPL_CLOCK 10 /* clock interrupt */ 84 #define IPL_HIGH 11 /* everything */ 85 #define IPL_SERIAL 12 /* serial device */ 86 87 #define NIPL 13 88 89 /* Interrupt sharing types. */ 90 #define IST_NONE 0 /* none */ 91 #define IST_PULSE 1 /* pulsed */ 92 #define IST_EDGE 2 /* edge-triggered */ 93 #define IST_LEVEL 3 /* level-triggered */ 94 95 #ifdef _KERNEL 96 #ifndef _LOCORE 97 #define CLKF_BASEPRI(frame) ((frame)->pri == IPL_NONE) 98 99 struct clockframe; 100 101 extern int imask[]; 102 extern long ticks_per_intr; 103 extern volatile u_long lasttb; 104 105 struct machvec { 106 int (*mvec_splraise)(int); 107 int (*mvec_spllower)(int); 108 void (*mvec_splx)(int); 109 void (*mvec_setsoft)(int); 110 void (*mvec_clock_return)(struct clockframe *, int, long); 111 void *(*mvec_intr_establish)(int, int, int, int (*)(void *), void *); 112 void (*mvec_intr_disestablish)(void *); 113 }; 114 115 extern struct machvec machine_interface; 116 117 #define _splraise(x) ((*machine_interface.mvec_splraise)(x)) 118 #define _spllower(x) ((*machine_interface.mvec_spllower)(x)) 119 #define splx(x) ((*machine_interface.mvec_splx)(x)) 120 #define setsoftintr(x) ((*machine_interface.mvec_setsoft)(x)) 121 #define clock_return(x, y, z) ((*machine_interface.mvec_clock_return)(x, y, z)) 122 #define intr_establish(irq, lvl, ist, func, arg) \ 123 ((*machine_interface.mvec_intr_establish)((irq), (lvl), (ist), \ 124 (func), (arg))) 125 #define intr_disestablish(cookie) \ 126 ((*machine_interface.mvec_intr_disestablish)((cookie))) 127 128 #define splhigh() _splraise(imask[IPL_HIGH]) 129 #define splsoft() _splraise(imask[IPL_SOFT]) 130 #define splsoftclock() _splraise(imask[IPL_SOFTCLOCK]) 131 #define splsoftnet() _splraise(imask[IPL_SOFTNET]) 132 #define splbio() _splraise(imask[IPL_BIO]) 133 #define splnet() _splraise(imask[IPL_NET]) 134 #define spltty() _splraise(imask[IPL_TTY]) 135 #define splvm() _splraise(imask[IPL_VM]) 136 #define splaudio() _splraise(imask[IPL_AUDIO]) 137 #define splclock() _splraise(imask[IPL_CLOCK]) 138 #define splserial() _splraise(imask[IPL_SERIAL]) 139 140 #define splstatclock() splclock() 141 142 #define spl0() _spllower(imask[IPL_NONE]) 143 #define spllowersoftclock() _spllower(imask[IPL_SOFTCLOCK]) 144 145 #define splsched() splhigh() 146 #define spllock() splhigh() 147 148 #define setsoftnet() setsoftintr(IPL_SOFTNET) 149 #define setsoftclock() setsoftintr(IPL_SOFTCLOCK) 150 151 /* 152 * Software interrupt support. 153 */ 154 155 #define SI_SOFT 0 /* for IPL_SOFT */ 156 #define SI_SOFTCLOCK 1 /* for IPL_SOFTCLOCK */ 157 #define SI_SOFTNET 2 /* for IPL_SOFTNET */ 158 #define SI_SOFTSERIAL 3 /* for IPL_SOFTSERIAL */ 159 160 #define SI_NQUEUES 4 161 162 #define SI_QUEUENAMES { \ 163 "generic", \ 164 "clock", \ 165 "net", \ 166 "serial", \ 167 } 168 169 #endif /* _LOCORE */ 170 #endif /* _KERNEL */ 171 172 #endif /* _MACHINE_INTR_H_ */ 173