intr.h revision 1.1
11.1Smatt/* 	$NetBSD: intr.h,v 1.1 2001/09/05 04:53:40 matt Exp $	*/
21.1Smatt
31.1Smatt/*
41.1Smatt * Copyright (c) 1997 Mark Brinicombe.
51.1Smatt * All rights reserved.
61.1Smatt *
71.1Smatt * Redistribution and use in source and binary forms, with or without
81.1Smatt * modification, are permitted provided that the following conditions
91.1Smatt * are met:
101.1Smatt * 1. Redistributions of source code must retain the above copyright
111.1Smatt *    notice, this list of conditions and the following disclaimer.
121.1Smatt * 2. Redistributions in binary form must reproduce the above copyright
131.1Smatt *    notice, this list of conditions and the following disclaimer in the
141.1Smatt *    documentation and/or other materials provided with the distribution.
151.1Smatt * 3. All advertising materials mentioning features or use of this software
161.1Smatt *    must display the following acknowledgement:
171.1Smatt *	This product includes software developed by Mark Brinicombe
181.1Smatt *	for the NetBSD Project.
191.1Smatt * 4. The name of the company nor the name of the author may be used to
201.1Smatt *    endorse or promote products derived from this software without specific
211.1Smatt *    prior written permission.
221.1Smatt *
231.1Smatt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
241.1Smatt * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
251.1Smatt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
261.1Smatt * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
271.1Smatt * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
281.1Smatt * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
291.1Smatt * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Smatt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Smatt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Smatt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Smatt * SUCH DAMAGE.
341.1Smatt */
351.1Smatt
361.1Smatt#ifndef _EVBARM_INTR_H_
371.1Smatt#define _EVBARM_INTR_H_
381.1Smatt
391.1Smatt/* Define the various Interrupt Priority Levels */
401.1Smatt
411.1Smatt/* Interrupt Priority Levels are mutually exclusive. */
421.1Smatt
431.1Smatt#define	IPL_NONE	0	/* no interrupts blocked */
441.1Smatt#define	IPL_SOFT	1	/* generic soft interrupts */
451.1Smatt#define	IPL_SOFTCLOCK	2	/* clock soft interrupts */
461.1Smatt#define	IPL_SOFTNET	3	/* network soft interrupts */
471.1Smatt#define	IPL_SOFTSERIAL	4	/* serial soft interrupts */
481.1Smatt#define IPL_BIO		5	/* block I/O */
491.1Smatt#define IPL_NET		6	/* network */
501.1Smatt#define IPL_TTY		7	/* terminal */
511.1Smatt#define IPL_IMP		8	/* memory allocation */
521.1Smatt#define IPL_AUDIO	9	/* audio */
531.1Smatt#define IPL_CLOCK	10	/* clock */
541.1Smatt#define IPL_SERIAL	11	/* serial */
551.1Smatt#define IPL_PERF	12	/* peformance monitoring unit */
561.1Smatt#define IPL_HIGH	13	/* blocks all interrupts */
571.1Smatt
581.1Smatt#define IPL_LEVELS	14
591.1Smatt
601.1Smatt#define	IST_UNUSABLE	-1	/* interrupt cannot be used */
611.1Smatt#define	IST_NONE	0	/* none (dummy) */
621.1Smatt#define	IST_PULSE	1	/* pulsed */
631.1Smatt#define	IST_EDGE	2	/* edge-triggered */
641.1Smatt#define	IST_LEVEL	3	/* level-triggered */
651.1Smatt
661.1Smatt#if defined (_KERNEL) && !defined(_LOCORE)
671.1Smatt#include <sys/queue.h>
681.1Smatt
691.1Smattextern int _splraise(int);
701.1Smattextern int _spllower(int);
711.1Smattextern int _splget(int);
721.1Smattextern int _splset(int);
731.1Smattextern int _splnone(void);
741.1Smattextern int _softintrset(int);
751.1Smattextern int _softintrclr(int);
761.1Smatt
771.1Smatt#define	splsoftclock()		_splraise(IPL_SOFTCLOCK)
781.1Smatt#define	splsoftnet()		_splraise(IPL_SOFTNET)
791.1Smatt#define	splsoftserial()		_splraise(IPL_SOFTSERIAL)
801.1Smatt#define	splbio()		_splraise(IPL_BIO)
811.1Smatt#define	splnet()		_splraise(IPL_NET)
821.1Smatt#define	spltty()		_splraise(IPL_TTY)
831.1Smatt#define	splvm()			_splraise(IPL_IMP)
841.1Smatt#define	splaudio()		_splraise(IPL_AUDIO)
851.1Smatt#define	splclock()		_splraise(IPL_CLOCK)
861.1Smatt#define	splserial()		_splraise(IPL_SERIAL)
871.1Smatt#define	splhigh()		_splraise(IPL_HIGH)
881.1Smatt#define	spl0()			(void) _splnone()
891.1Smatt#define	splx(s)			(void) _splset(s)
901.1Smatt
911.1Smatt#define	spllock()		splhigh()
921.1Smatt#define	splsched()		splclock()
931.1Smatt#define	splstatclock()		splclock()
941.1Smatt
951.1Smatt#define	spllowersoftclock()	_spllower(IPL_SOFTCLOCK)
961.1Smatt
971.1Smatt#define	setsoftclock()		_softintrset(IPL_SOFTCLOCK)
981.1Smatt#define	setsoftnet()		_softintrset(IPL_SOFTNET)
991.1Smatt#define	setsoftserial()		_softintrset(IPL_SOFTSERIAL)
1001.1Smatt
1011.1Smattstruct intrsource {
1021.1Smatt	void *is_cookie;
1031.1Smatt	LIST_ENTRY(evbarm_intrsource) is_link;
1041.1Smatt	void *(*is_establish)(void *, int, int, int (*)(void *), void *);
1051.1Smatt	void (*is_disestablish)(void *, void *);
1061.1Smatt
1071.1Smatt	void (*is_setmask)(int);
1081.1Smatt};
1091.1Smatt
1101.1Smatt#define	intr_establish(src, irq, type, func, arg) \
1111.1Smatt	(((src)->is_establish)((src)->is_cookie, irq, type, func, arg))
1121.1Smatt#define	intr_disestablish(src, ih) \
1131.1Smatt	(((src)->is_disestablish)((src)->is_cookie, ih))
1141.1Smatt#endif	/* _KERNEL */
1151.1Smatt
1161.1Smatt#endif	/* _EVBARM_INTR_H */
117