1 /* $NetBSD: intr.h,v 1.7 2006/06/17 12:44:52 rjs Exp $ */ 2 3 /*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Charles M. Hannum. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _IBMNWS_INTR_H_ 40 #define _IBMNWS_INTR_H_ 41 42 /* Interrupt priority `levels'. */ 43 #define IPL_NONE 9 /* nothing */ 44 #define IPL_SOFTCLOCK 8 /* software clock interrupt */ 45 #define IPL_SOFTNET 7 /* software network interrupt */ 46 #define IPL_BIO 6 /* block I/O */ 47 #define IPL_NET 5 /* network */ 48 #define IPL_SOFTSERIAL 4 /* software serial interrupt */ 49 #define IPL_TTY 3 /* terminal */ 50 #define IPL_VM 3 /* memory allocation */ 51 #define IPL_AUDIO 2 /* audio */ 52 #define IPL_CLOCK 1 /* clock */ 53 #define IPL_HIGH 1 /* everything */ 54 #define IPL_SERIAL 0 /* serial */ 55 #define NIPL 10 56 57 /* Interrupt sharing types. */ 58 #define IST_NONE 0 /* none */ 59 #define IST_PULSE 1 /* pulsed */ 60 #define IST_EDGE 2 /* edge-triggered */ 61 #define IST_LEVEL 3 /* level-triggered */ 62 63 #ifndef _LOCORE 64 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS 65 #include <powerpc/softintr.h> 66 #endif 67 68 /* 69 * Interrupt handler chains. intr_establish() inserts a handler into 70 * the list. The handler is called with its (single) argument. 71 */ 72 struct intrhand { 73 int (*ih_fun)(void *); 74 void *ih_arg; 75 u_long ih_count; 76 struct intrhand *ih_next; 77 int ih_level; 78 int ih_irq; 79 }; 80 81 #include <sys/device.h> 82 struct intrsource { 83 int is_type; 84 int is_level; 85 int is_hwirq; 86 int is_mask; 87 struct intrhand *is_hand; 88 struct evcnt is_ev; 89 char is_source[16]; 90 }; 91 92 int splraise(int); 93 int spllower(int); 94 void softintr(int); 95 96 void do_pending_int(void); 97 98 void init_intr(void); 99 void init_intr_ivr(void); 100 101 void enable_intr(void); 102 void disable_intr(void); 103 104 void *intr_establish(int, int, int, int (*)(void *), void *); 105 void intr_disestablish(void *); 106 107 void softnet(int); 108 void softserial(void); 109 int isa_intr(void); 110 void isa_intr_mask(int); 111 void isa_intr_clr(int); 112 void isa_setirqstat(int, int, int); 113 114 extern int imen; 115 extern int imask[]; 116 extern struct intrhand *intrhand[]; 117 extern vaddr_t prep_intr_reg; 118 119 #define ICU_LEN 32 120 extern struct intrsource intrsources[ICU_LEN]; 121 122 #define IRQ_SLAVE 2 123 #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE) 124 #define I8259_INTR_NUM 16 125 126 #define PREP_INTR_REG 0xbffff000 127 #define INTR_VECTOR_REG 0xff0 128 129 #define SINT_CLOCK 0x20000000 130 #define SINT_NET 0x40000000 131 #define SINT_SERIAL 0x80000000 132 #define SPL_CLOCK 0x00000001 133 #define SINT_MASK (SINT_CLOCK|SINT_NET|SINT_SERIAL) 134 135 #define CNT_SINT_NET 29 136 #define CNT_SINT_CLOCK 30 137 #define CNT_SINT_SERIAL 31 138 #define CNT_CLOCK 0 139 140 #define splbio() splraise(imask[IPL_BIO]) 141 #define splnet() splraise(imask[IPL_NET]) 142 #define spltty() splraise(imask[IPL_TTY]) 143 #define splclock() splraise(imask[IPL_CLOCK]) 144 #define splvm() splraise(imask[IPL_VM]) 145 #define splaudio() splraise(imask[IPL_AUDIO]) 146 #define splserial() splraise(imask[IPL_SERIAL]) 147 #define splstatclock() splclock() 148 #define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK]) 149 #define splsoftclock() splraise(imask[IPL_SOFTCLOCK]) 150 #define splsoftnet() splraise(imask[IPL_SOFTNET]) 151 #define splsoftserial() splraise(imask[IPL_SOFTSERIAL]) 152 153 #define spllpt() spltty() 154 155 #define setsoftclock() softintr(SINT_CLOCK); 156 #define setsoftnet() softintr(SINT_NET); 157 #define setsoftserial() softintr(SINT_SERIAL); 158 159 #define splhigh() splraise(imask[IPL_HIGH]) 160 #define splsched() splhigh() 161 #define spllock() splhigh() 162 #define splx(x) spllower(x) 163 #define spl0() spllower(0) 164 165 #define CLKF_BASEPRI(pri) ((pri) != 0) 166 167 #endif /* !_LOCORE */ 168 169 #endif /* !_IBMNWS_INTR_H_ */ 170