intr.h revision 1.16
11.16Sthorpej/*	$NetBSD: intr.h,v 1.16 1999/08/05 18:08:11 thorpej Exp $	*/
21.2Sscottr
31.2Sscottr/*
41.2Sscottr * Copyright (C) 1997 Scott Reynolds
51.2Sscottr * All rights reserved.
61.2Sscottr *
71.2Sscottr * Redistribution and use in source and binary forms, with or without
81.2Sscottr * modification, are permitted provided that the following conditions
91.2Sscottr * are met:
101.2Sscottr * 1. Redistributions of source code must retain the above copyright
111.2Sscottr *    notice, this list of conditions and the following disclaimer.
121.2Sscottr * 2. Redistributions in binary form must reproduce the above copyright
131.2Sscottr *    notice, this list of conditions and the following disclaimer in the
141.2Sscottr *    documentation and/or other materials provided with the distribution.
151.6Sscottr * 3. The name of the author may not be used to endorse or promote products
161.2Sscottr *    derived from this software without specific prior written permission.
171.2Sscottr *
181.2Sscottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
191.2Sscottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
201.2Sscottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
211.2Sscottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
221.2Sscottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
231.2Sscottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
241.2Sscottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
251.2Sscottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
261.2Sscottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
271.2Sscottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
281.2Sscottr */
291.1Sscottr
301.1Sscottr#ifndef _MAC68K_INTR_H_
311.1Sscottr#define _MAC68K_INTR_H_
321.1Sscottr
331.16Sthorpej#include <machine/psl.h>
341.16Sthorpej
351.1Sscottr#ifdef _KERNEL
361.1Sscottr
371.1Sscottr/* spl0 requires checking for software interrupts */
381.1Sscottr
391.15Sthorpej/*
401.15Sthorpej * This array contains the appropriate PSL_S|PSL_IPL? values
411.15Sthorpej * to raise interrupt priority to the requested level.
421.15Sthorpej */
431.15Sthorpejextern unsigned short mac68k_ipls[];
441.15Sthorpej
451.15Sthorpej#define	MAC68K_IPL_SOFT		0
461.15Sthorpej#define	MAC68K_IPL_BIO		1
471.15Sthorpej#define	MAC68K_IPL_NET		2
481.15Sthorpej#define	MAC68K_IPL_TTY		3
491.15Sthorpej#define	MAC68K_IPL_IMP		4
501.15Sthorpej#define	MAC68K_IPL_AUDIO	5
511.15Sthorpej#define	MAC68K_IPL_SERIAL	6
521.15Sthorpej#define	MAC68K_IPL_CLOCK	7
531.15Sthorpej#define	MAC68K_IPL_STATCLOCK	8
541.15Sthorpej#define	MAC68K_IPL_SCHED	9
551.15Sthorpej#define	MAC68K_IPL_HIGH		10
561.15Sthorpej#define	MAC68K_NIPLS		11
571.15Sthorpej
581.4Sscottr/* These spl calls are _not_ to be used by machine-independent code. */
591.4Sscottr#define	spladb()	splhigh()
601.4Sscottr#define	splzs()		splserial()
611.7Sbriggs
621.7Sbriggs/*
631.1Sscottr * These should be used for:
641.1Sscottr * 1) ensuring mutual exclusion (why use processor level?)
651.1Sscottr * 2) allowing faster devices to take priority
661.1Sscottr *
671.1Sscottr * Note that on the Mac, most things are masked at spl1, almost
681.1Sscottr * everything at spl2, and everything but the panic switch and
691.1Sscottr * power at spl4.
701.1Sscottr */
711.16Sthorpej#define	spllowersoftclock() spl1()
721.16Sthorpej#define	splsoftclock()	_splraise(mac68k_ipls[MAC68K_IPL_SOFT])
731.15Sthorpej#define	splsoftnet()	_splraise(mac68k_ipls[MAC68K_IPL_SOFT])
741.15Sthorpej#define	spltty()	_splraise(mac68k_ipls[MAC68K_IPL_TTY])
751.15Sthorpej#define	splbio()	_splraise(mac68k_ipls[MAC68K_IPL_BIO])
761.15Sthorpej#define	splnet()	_splraise(mac68k_ipls[MAC68K_IPL_NET])
771.15Sthorpej#define	splimp()	_splraise(mac68k_ipls[MAC68K_IPL_IMP])
781.15Sthorpej#define	splaudio()	_splraise(mac68k_ipls[MAC68K_IPL_AUDIO])
791.15Sthorpej#define	splclock()	_splraise(mac68k_ipls[MAC68K_IPL_CLOCK])
801.15Sthorpej#define	splstatclock()	_splraise(mac68k_ipls[MAC68K_IPL_STATCLOCK])
811.15Sthorpej#define	splsched()	_splraise(mac68k_ipls[MAC68K_IPL_SCHED])
821.15Sthorpej#define	splserial()	_splraise(mac68k_ipls[MAC68K_IPL_SERIAL])
831.4Sscottr#define	splhigh()	spl7()
841.1Sscottr
851.1Sscottr/* watch out for side effects */
861.1Sscottr#define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
871.1Sscottr
881.1Sscottr/*
891.1Sscottr * simulated software interrupt register
901.1Sscottr */
911.1Sscottrextern volatile u_int8_t ssir;
921.1Sscottr
931.1Sscottr#define	SIR_NET		0x01
941.1Sscottr#define	SIR_CLOCK	0x02
951.1Sscottr#define	SIR_SERIAL	0x04
961.3Sscottr#define SIR_DTMGR	0x08
971.8Sscottr#define SIR_ADB		0x10
981.1Sscottr
991.1Sscottr#define	siron(mask)	\
1001.14Skleink	__asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
1011.1Sscottr#define	siroff(mask)	\
1021.14Skleink	__asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
1031.1Sscottr
1041.1Sscottr#define	setsoftnet()	siron(SIR_NET)
1051.1Sscottr#define	setsoftclock()	siron(SIR_CLOCK)
1061.1Sscottr#define	setsoftserial()	siron(SIR_SERIAL)
1071.3Sscottr#define	setsoftdtmgr()	siron(SIR_DTMGR)
1081.8Sscottr#define	setsoftadb()	siron(SIR_ADB)
1091.9Sscottr
1101.9Sscottr/* intr.c */
1111.13Sscottrvoid	intr_init __P((void));
1121.9Sscottrvoid	intr_establish __P((int (*)(void *), void *, int));
1131.9Sscottrvoid	intr_disestablish __P((int));
1141.11Sscottrvoid	intr_dispatch __P((int));
1151.1Sscottr
1161.1Sscottr/* locore.s */
1171.1Sscottrint	spl0 __P((void));
1181.1Sscottr#endif /* _KERNEL */
1191.1Sscottr
1201.1Sscottr#endif /* _MAC68K_INTR_H_ */
121