intr.h revision 1.6
11.6Srjs/* $NetBSD: intr.h,v 1.6 2006/05/09 18:02:32 rjs Exp $ */ 21.1Smatt 31.1Smatt/*- 41.1Smatt * Copyright (c) 1998 The NetBSD Foundation, Inc. 51.1Smatt * All rights reserved. 61.1Smatt * 71.1Smatt * This code is derived from software contributed to The NetBSD Foundation 81.1Smatt * by Charles M. Hannum. 91.1Smatt * 101.1Smatt * Redistribution and use in source and binary forms, with or without 111.1Smatt * modification, are permitted provided that the following conditions 121.1Smatt * are met: 131.1Smatt * 1. Redistributions of source code must retain the above copyright 141.1Smatt * notice, this list of conditions and the following disclaimer. 151.1Smatt * 2. Redistributions in binary form must reproduce the above copyright 161.1Smatt * notice, this list of conditions and the following disclaimer in the 171.1Smatt * documentation and/or other materials provided with the distribution. 181.1Smatt * 3. All advertising materials mentioning features or use of this software 191.1Smatt * must display the following acknowledgement: 201.1Smatt * This product includes software developed by the NetBSD 211.1Smatt * Foundation, Inc. and its contributors. 221.1Smatt * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Smatt * contributors may be used to endorse or promote products derived 241.1Smatt * from this software without specific prior written permission. 251.1Smatt * 261.1Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Smatt * POSSIBILITY OF SUCH DAMAGE. 371.1Smatt */ 381.1Smatt 391.1Smatt#ifndef _IBMNWS_INTR_H_ 401.1Smatt#define _IBMNWS_INTR_H_ 411.1Smatt 421.1Smatt/* Interrupt priority `levels'. */ 431.1Smatt#define IPL_NONE 9 /* nothing */ 441.1Smatt#define IPL_SOFTCLOCK 8 /* software clock interrupt */ 451.1Smatt#define IPL_SOFTNET 7 /* software network interrupt */ 461.1Smatt#define IPL_BIO 6 /* block I/O */ 471.1Smatt#define IPL_NET 5 /* network */ 481.1Smatt#define IPL_SOFTSERIAL 4 /* software serial interrupt */ 491.1Smatt#define IPL_TTY 3 /* terminal */ 501.1Smatt#define IPL_IMP 3 /* memory allocation */ 511.1Smatt#define IPL_AUDIO 2 /* audio */ 521.1Smatt#define IPL_CLOCK 1 /* clock */ 531.1Smatt#define IPL_HIGH 1 /* everything */ 541.1Smatt#define IPL_SERIAL 0 /* serial */ 551.1Smatt#define NIPL 10 561.1Smatt 571.1Smatt/* Interrupt sharing types. */ 581.1Smatt#define IST_NONE 0 /* none */ 591.1Smatt#define IST_PULSE 1 /* pulsed */ 601.1Smatt#define IST_EDGE 2 /* edge-triggered */ 611.1Smatt#define IST_LEVEL 3 /* level-triggered */ 621.1Smatt 631.1Smatt#ifndef _LOCORE 641.6Srjs#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS 651.6Srjs#include <powerpc/softintr.h> 661.6Srjs#endif 671.1Smatt 681.1Smatt/* 691.1Smatt * Interrupt handler chains. intr_establish() inserts a handler into 701.1Smatt * the list. The handler is called with its (single) argument. 711.1Smatt */ 721.1Smattstruct intrhand { 731.1Smatt int (*ih_fun)(void *); 741.1Smatt void *ih_arg; 751.1Smatt u_long ih_count; 761.1Smatt struct intrhand *ih_next; 771.1Smatt int ih_level; 781.1Smatt int ih_irq; 791.1Smatt}; 801.1Smatt 811.6Srjs#include <sys/device.h> 821.6Srjsstruct intrsource { 831.6Srjs int is_type; 841.6Srjs int is_level; 851.6Srjs int is_hwirq; 861.6Srjs int is_mask; 871.6Srjs struct intrhand *is_hand; 881.6Srjs struct evcnt is_ev; 891.6Srjs char is_source[16]; 901.6Srjs}; 911.6Srjs 921.6Srjsint splraise(int); 931.6Srjsint spllower(int); 941.6Srjsvoid softintr(int); 951.6Srjs 961.1Smattvoid do_pending_int(void); 971.1Smatt 981.1Smattvoid init_intr(void); 991.1Smattvoid init_intr_ivr(void); 1001.1Smatt 1011.1Smattvoid enable_intr(void); 1021.1Smattvoid disable_intr(void); 1031.1Smatt 1041.1Smattvoid *intr_establish(int, int, int, int (*)(void *), void *); 1051.1Smattvoid intr_disestablish(void *); 1061.1Smatt 1071.1Smattvoid softnet(int); 1081.1Smattvoid softserial(void); 1091.1Smattint isa_intr(void); 1101.1Smattvoid isa_intr_mask(int); 1111.1Smattvoid isa_intr_clr(int); 1121.1Smattvoid isa_setirqstat(int, int, int); 1131.1Smatt 1141.1Smattextern int imen; 1151.1Smattextern int imask[]; 1161.1Smattextern struct intrhand *intrhand[]; 1171.1Smattextern vaddr_t prep_intr_reg; 1181.1Smatt 1191.6Srjs#define ICU_LEN 32 1201.6Srjsextern struct intrsource intrsources[ICU_LEN]; 1211.1Smatt 1221.1Smatt#define IRQ_SLAVE 2 1231.1Smatt#define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE) 1241.1Smatt#define I8259_INTR_NUM 16 1251.1Smatt 1261.1Smatt#define PREP_INTR_REG 0xbffff000 1271.1Smatt#define INTR_VECTOR_REG 0xff0 1281.1Smatt 1291.1Smatt#define SINT_CLOCK 0x20000000 1301.1Smatt#define SINT_NET 0x40000000 1311.1Smatt#define SINT_SERIAL 0x80000000 1321.1Smatt#define SPL_CLOCK 0x00000001 1331.1Smatt#define SINT_MASK (SINT_CLOCK|SINT_NET|SINT_SERIAL) 1341.1Smatt 1351.1Smatt#define CNT_SINT_NET 29 1361.1Smatt#define CNT_SINT_CLOCK 30 1371.1Smatt#define CNT_SINT_SERIAL 31 1381.1Smatt#define CNT_CLOCK 0 1391.1Smatt 1401.1Smatt#define splbio() splraise(imask[IPL_BIO]) 1411.1Smatt#define splnet() splraise(imask[IPL_NET]) 1421.1Smatt#define spltty() splraise(imask[IPL_TTY]) 1431.1Smatt#define splclock() splraise(imask[IPL_CLOCK]) 1441.1Smatt#define splvm() splraise(imask[IPL_IMP]) 1451.1Smatt#define splaudio() splraise(imask[IPL_AUDIO]) 1461.1Smatt#define splserial() splraise(imask[IPL_SERIAL]) 1471.1Smatt#define splstatclock() splclock() 1481.1Smatt#define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK]) 1491.1Smatt#define splsoftclock() splraise(imask[IPL_SOFTCLOCK]) 1501.1Smatt#define splsoftnet() splraise(imask[IPL_SOFTNET]) 1511.1Smatt#define splsoftserial() splraise(imask[IPL_SOFTSERIAL]) 1521.1Smatt 1531.1Smatt#define spllpt() spltty() 1541.1Smatt 1551.6Srjs#define setsoftclock() softintr(SINT_CLOCK); 1561.6Srjs#define setsoftnet() softintr(SINT_NET); 1571.6Srjs#define setsoftserial() softintr(SINT_SERIAL); 1581.1Smatt 1591.1Smatt#define splhigh() splraise(imask[IPL_HIGH]) 1601.1Smatt#define splsched() splhigh() 1611.1Smatt#define spllock() splhigh() 1621.1Smatt#define splx(x) spllower(x) 1631.1Smatt#define spl0() spllower(0) 1641.1Smatt 1651.1Smatt#define CLKF_BASEPRI(pri) ((pri) != 0) 1661.1Smatt 1671.1Smatt#endif /* !_LOCORE */ 1681.1Smatt 1691.1Smatt#endif /* !_IBMNWS_INTR_H_ */ 170