intr.h revision 1.19
11.19Sdyoung/*	$NetBSD: intr.h,v 1.19 2003/06/25 00:03:13 dyoung Exp $	*/
21.1Stsubai
31.3Smycroft/*-
41.3Smycroft * Copyright (c) 1998 The NetBSD Foundation, Inc.
51.3Smycroft * All rights reserved.
61.3Smycroft *
71.3Smycroft * This code is derived from software contributed to The NetBSD Foundation
81.3Smycroft * by Charles M. Hannum.
91.1Stsubai *
101.1Stsubai * Redistribution and use in source and binary forms, with or without
111.1Stsubai * modification, are permitted provided that the following conditions
121.1Stsubai * are met:
131.1Stsubai * 1. Redistributions of source code must retain the above copyright
141.1Stsubai *    notice, this list of conditions and the following disclaimer.
151.1Stsubai * 2. Redistributions in binary form must reproduce the above copyright
161.1Stsubai *    notice, this list of conditions and the following disclaimer in the
171.1Stsubai *    documentation and/or other materials provided with the distribution.
181.1Stsubai * 3. All advertising materials mentioning features or use of this software
191.1Stsubai *    must display the following acknowledgement:
201.3Smycroft *        This product includes software developed by the NetBSD
211.3Smycroft *        Foundation, Inc. and its contributors.
221.3Smycroft * 4. Neither the name of The NetBSD Foundation nor the names of its
231.3Smycroft *    contributors may be used to endorse or promote products derived
241.3Smycroft *    from this software without specific prior written permission.
251.1Stsubai *
261.3Smycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.3Smycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.3Smycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.3Smycroft * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.3Smycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.3Smycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.3Smycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.3Smycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.3Smycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.3Smycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.3Smycroft * POSSIBILITY OF SUCH DAMAGE.
371.1Stsubai */
381.1Stsubai
391.4Stsubai#ifndef _MACPPC_INTR_H_
401.4Stsubai#define _MACPPC_INTR_H_
411.18Smartin
421.19Sdyoung#ifdef _KERNEL_OPT
431.18Smartin#include "opt_multiprocessor.h"
441.19Sdyoung#endif
451.1Stsubai
461.1Stsubai/* Interrupt priority `levels'. */
471.1Stsubai#define	IPL_NONE	9	/* nothing */
481.1Stsubai#define	IPL_SOFTCLOCK	8	/* timeouts */
491.1Stsubai#define	IPL_SOFTNET	7	/* protocol stacks */
501.1Stsubai#define	IPL_BIO		6	/* block I/O */
511.1Stsubai#define	IPL_NET		5	/* network */
521.1Stsubai#define	IPL_SOFTSERIAL	4	/* serial */
531.1Stsubai#define	IPL_TTY		3	/* terminal */
541.17Sthorpej#define	IPL_VM		3	/* memory allocation */
551.1Stsubai#define	IPL_AUDIO	2	/* audio */
561.1Stsubai#define	IPL_CLOCK	1	/* clock */
571.1Stsubai#define	IPL_HIGH	1	/* everything */
581.1Stsubai#define	IPL_SERIAL	0	/* serial */
591.1Stsubai#define	NIPL		10
601.1Stsubai
611.1Stsubai/* Interrupt sharing types. */
621.1Stsubai#define	IST_NONE	0	/* none */
631.1Stsubai#define	IST_PULSE	1	/* pulsed */
641.1Stsubai#define	IST_EDGE	2	/* edge-triggered */
651.1Stsubai#define	IST_LEVEL	3	/* level-triggered */
661.1Stsubai
671.1Stsubai#ifndef _LOCORE
681.1Stsubai
691.1Stsubai/*
701.1Stsubai * Interrupt handler chains.  intr_establish() inserts a handler into
711.1Stsubai * the list.  The handler is called with its (single) argument.
721.1Stsubai */
731.1Stsubaistruct intrhand {
741.1Stsubai	int	(*ih_fun) __P((void *));
751.1Stsubai	void	*ih_arg;
761.1Stsubai	struct	intrhand *ih_next;
771.1Stsubai	int	ih_level;
781.1Stsubai	int	ih_irq;
791.1Stsubai};
801.1Stsubai
811.14Smattvoid softnet __P((int));
821.13Smattvoid softserial __P((void));
831.1Stsubai
841.9Stsubaiint splraise __P((int));
851.9Stsubaiint spllower __P((int));
861.9Stsubaivoid splx __P((int));
871.9Stsubaivoid softintr __P((int));
881.1Stsubai
891.9Stsubaiextern volatile int astpending, tickspending;
901.1Stsubaiextern int imask[];
911.1Stsubai
921.6Stsubai#define ICU_LEN		64
931.1Stsubai
941.1Stsubai/* Soft interrupt masks. */
951.1Stsubai#define SIR_CLOCK	28
961.1Stsubai#define SIR_NET		29
971.1Stsubai#define SIR_SERIAL	30
981.1Stsubai#define SPL_CLOCK	31
991.1Stsubai
1001.1Stsubai/*
1011.1Stsubai * Hardware interrupt masks
1021.1Stsubai */
1031.1Stsubai#define splbio()	splraise(imask[IPL_BIO])
1041.1Stsubai#define splnet()	splraise(imask[IPL_NET])
1051.1Stsubai#define spltty()	splraise(imask[IPL_TTY])
1061.1Stsubai#define	splaudio()	splraise(imask[IPL_AUDIO])
1071.1Stsubai#define splclock()	splraise(imask[IPL_CLOCK])
1081.1Stsubai#define splstatclock()	splclock()
1091.1Stsubai#define	splserial()	splraise(imask[IPL_SERIAL])
1101.2Sis
1111.2Sis#define spllpt()	spltty()
1121.1Stsubai
1131.1Stsubai/*
1141.1Stsubai * Software interrupt masks
1151.1Stsubai *
1161.1Stsubai * NOTE: splsoftclock() is used by hardclock() to lower the priority from
1171.1Stsubai * clock to softclock before it calls softclock().
1181.1Stsubai */
1191.5Sthorpej#define	spllowersoftclock() spllower(imask[IPL_SOFTCLOCK])
1201.5Sthorpej#define	splsoftclock()	splraise(imask[IPL_SOFTCLOCK])
1211.1Stsubai#define	splsoftnet()	splraise(imask[IPL_SOFTNET])
1221.1Stsubai#define	splsoftserial()	splraise(imask[IPL_SOFTSERIAL])
1231.1Stsubai
1241.1Stsubai/*
1251.1Stsubai * Miscellaneous
1261.1Stsubai */
1271.17Sthorpej#define splvm()		splraise(imask[IPL_VM])
1281.1Stsubai#define	splhigh()	splraise(imask[IPL_HIGH])
1291.7Sthorpej#define	splsched()	splhigh()
1301.8Sthorpej#define	spllock()	splhigh()
1311.1Stsubai#define	spl0()		spllower(0)
1321.1Stsubai
1331.1Stsubai#define	setsoftclock()	softintr(SIR_CLOCK)
1341.1Stsubai#define	setsoftnet()	softintr(SIR_NET)
1351.1Stsubai#define	setsoftserial()	softintr(SIR_SERIAL)
1361.1Stsubai
1371.4Stsubaiextern long intrcnt[];
1381.4Stsubai
1391.4Stsubai#define CNT_IRQ0	0
1401.4Stsubai#define CNT_CLOCK	64
1411.4Stsubai#define CNT_SOFTCLOCK	65
1421.4Stsubai#define CNT_SOFTNET	66
1431.4Stsubai#define CNT_SOFTSERIAL	67
1441.4Stsubai
1451.15Schs#ifdef MULTIPROCESSOR
1461.15Schs#define MACPPC_IPI_HALT		0x0001
1471.15Schs#define MACPPC_IPI_FLUSH_FPU	0x0002
1481.15Schs#define MACPPC_IPI_FLUSH_VEC	0x0004
1491.1Stsubai
1501.11Stsubaistruct cpu_info;
1511.15Schsvoid macppc_send_ipi(volatile struct cpu_info *, u_long);
1521.11Stsubai#endif
1531.11Stsubai
1541.11Stsubai#endif /* _LOCORE */
1551.11Stsubai
1561.11Stsubai#endif /* _MACPPC_INTR_H_ */
157