intr.h revision 1.19
1/* $NetBSD: intr.h,v 1.19 2003/06/25 00:03:13 dyoung 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 _MACPPC_INTR_H_ 40#define _MACPPC_INTR_H_ 41 42#ifdef _KERNEL_OPT 43#include "opt_multiprocessor.h" 44#endif 45 46/* Interrupt priority `levels'. */ 47#define IPL_NONE 9 /* nothing */ 48#define IPL_SOFTCLOCK 8 /* timeouts */ 49#define IPL_SOFTNET 7 /* protocol stacks */ 50#define IPL_BIO 6 /* block I/O */ 51#define IPL_NET 5 /* network */ 52#define IPL_SOFTSERIAL 4 /* serial */ 53#define IPL_TTY 3 /* terminal */ 54#define IPL_VM 3 /* memory allocation */ 55#define IPL_AUDIO 2 /* audio */ 56#define IPL_CLOCK 1 /* clock */ 57#define IPL_HIGH 1 /* everything */ 58#define IPL_SERIAL 0 /* serial */ 59#define NIPL 10 60 61/* Interrupt sharing types. */ 62#define IST_NONE 0 /* none */ 63#define IST_PULSE 1 /* pulsed */ 64#define IST_EDGE 2 /* edge-triggered */ 65#define IST_LEVEL 3 /* level-triggered */ 66 67#ifndef _LOCORE 68 69/* 70 * Interrupt handler chains. intr_establish() inserts a handler into 71 * the list. The handler is called with its (single) argument. 72 */ 73struct intrhand { 74 int (*ih_fun) __P((void *)); 75 void *ih_arg; 76 struct intrhand *ih_next; 77 int ih_level; 78 int ih_irq; 79}; 80 81void softnet __P((int)); 82void softserial __P((void)); 83 84int splraise __P((int)); 85int spllower __P((int)); 86void splx __P((int)); 87void softintr __P((int)); 88 89extern volatile int astpending, tickspending; 90extern int imask[]; 91 92#define ICU_LEN 64 93 94/* Soft interrupt masks. */ 95#define SIR_CLOCK 28 96#define SIR_NET 29 97#define SIR_SERIAL 30 98#define SPL_CLOCK 31 99 100/* 101 * Hardware interrupt masks 102 */ 103#define splbio() splraise(imask[IPL_BIO]) 104#define splnet() splraise(imask[IPL_NET]) 105#define spltty() splraise(imask[IPL_TTY]) 106#define splaudio() splraise(imask[IPL_AUDIO]) 107#define splclock() splraise(imask[IPL_CLOCK]) 108#define splstatclock() splclock() 109#define splserial() splraise(imask[IPL_SERIAL]) 110 111#define spllpt() spltty() 112 113/* 114 * Software interrupt masks 115 * 116 * NOTE: splsoftclock() is used by hardclock() to lower the priority from 117 * clock to softclock before it calls softclock(). 118 */ 119#define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK]) 120#define splsoftclock() splraise(imask[IPL_SOFTCLOCK]) 121#define splsoftnet() splraise(imask[IPL_SOFTNET]) 122#define splsoftserial() splraise(imask[IPL_SOFTSERIAL]) 123 124/* 125 * Miscellaneous 126 */ 127#define splvm() splraise(imask[IPL_VM]) 128#define splhigh() splraise(imask[IPL_HIGH]) 129#define splsched() splhigh() 130#define spllock() splhigh() 131#define spl0() spllower(0) 132 133#define setsoftclock() softintr(SIR_CLOCK) 134#define setsoftnet() softintr(SIR_NET) 135#define setsoftserial() softintr(SIR_SERIAL) 136 137extern long intrcnt[]; 138 139#define CNT_IRQ0 0 140#define CNT_CLOCK 64 141#define CNT_SOFTCLOCK 65 142#define CNT_SOFTNET 66 143#define CNT_SOFTSERIAL 67 144 145#ifdef MULTIPROCESSOR 146#define MACPPC_IPI_HALT 0x0001 147#define MACPPC_IPI_FLUSH_FPU 0x0002 148#define MACPPC_IPI_FLUSH_VEC 0x0004 149 150struct cpu_info; 151void macppc_send_ipi(volatile struct cpu_info *, u_long); 152#endif 153 154#endif /* _LOCORE */ 155 156#endif /* _MACPPC_INTR_H_ */ 157