intr.h revision 1.14
11.14Sad/*	$NetBSD: intr.h,v 1.14 2007/12/03 15:33:33 ad Exp $	*/
21.1Ssimonb
31.1Ssimonb/*-
41.1Ssimonb * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
51.1Ssimonb * All rights reserved.
61.1Ssimonb *
71.1Ssimonb * This code is derived from software contributed to The NetBSD Foundation
81.1Ssimonb * by Jason R. Thorpe.
91.1Ssimonb *
101.1Ssimonb * Redistribution and use in source and binary forms, with or without
111.1Ssimonb * modification, are permitted provided that the following conditions
121.1Ssimonb * are met:
131.1Ssimonb * 1. Redistributions of source code must retain the above copyright
141.1Ssimonb *    notice, this list of conditions and the following disclaimer.
151.1Ssimonb * 2. Redistributions in binary form must reproduce the above copyright
161.1Ssimonb *    notice, this list of conditions and the following disclaimer in the
171.1Ssimonb *    documentation and/or other materials provided with the distribution.
181.1Ssimonb * 3. All advertising materials mentioning features or use of this software
191.1Ssimonb *    must display the following acknowledgement:
201.1Ssimonb *	This product includes software developed by the NetBSD
211.1Ssimonb *	Foundation, Inc. and its contributors.
221.1Ssimonb * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Ssimonb *    contributors may be used to endorse or promote products derived
241.1Ssimonb *    from this software without specific prior written permission.
251.1Ssimonb *
261.1Ssimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Ssimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Ssimonb * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Ssimonb * POSSIBILITY OF SUCH DAMAGE.
371.1Ssimonb */
381.1Ssimonb
391.1Ssimonb#ifndef _EVBMIPS_INTR_H_
401.8Ssimonb#define	_EVBMIPS_INTR_H_
411.1Ssimonb
421.1Ssimonb#include <sys/device.h>
431.1Ssimonb#include <sys/lock.h>
441.1Ssimonb#include <sys/queue.h>
451.1Ssimonb
461.1Ssimonb#define	IPL_NONE	0	/* disable only this interrupt */
471.14Sad#define	IPL_SOFTCLOCK	1	/* software interrupts */
481.14Sad#define	IPL_SOFTBIO	1	/* software interrupts */
491.14Sad#define	IPL_SOFTNET	2	/* software interrupts */
501.14Sad#define	IPL_SOFTSERIAL	2	/* software interrupts */
511.14Sad#define	IPL_VM		3
521.14Sad#define	IPL_SCHED	4
531.14Sad#define	IPL_HIGH	4
541.1Ssimonb
551.14Sad#define	_IPL_N		5	/* max IPL + 1 */
561.1Ssimonb
571.14Sad#define	_IPL_SI0_FIRST	IPL_SOFTCLOCK
581.14Sad#define	_IPL_SI0_LAST	IPL_SOFTBIO
591.1Ssimonb
601.1Ssimonb#define	_IPL_SI1_FIRST	IPL_SOFTNET
611.1Ssimonb#define	_IPL_SI1_LAST	IPL_SOFTSERIAL
621.1Ssimonb
631.1Ssimonb#define	IST_UNUSABLE	-1	/* interrupt cannot be used */
641.1Ssimonb#define	IST_NONE	0	/* none (dummy) */
651.1Ssimonb#define	IST_PULSE	1	/* pulsed */
661.1Ssimonb#define	IST_EDGE	2	/* edge-triggered */
671.1Ssimonb#define	IST_LEVEL	3	/* level-triggered */
681.8Ssimonb#define	IST_LEVEL_HIGH	4	/* level triggered, active high */
691.8Ssimonb#define	IST_LEVEL_LOW	5       /* level triggered, active low */
701.1Ssimonb
711.1Ssimonb#ifdef	_KERNEL
721.1Ssimonb
731.12Stsutsui#include <mips/locore.h>
741.12Stsutsui
751.7Sgdamoreextern const uint32_t ipl_sr_bits[_IPL_N];
761.1Ssimonb
771.1Ssimonb#define	spl0()		(void) _spllower(0)
781.1Ssimonb#define	splx(s)		(void) _splset(s)
791.1Ssimonb
801.1Ssimonb#define	splsoft()	_splraise(ipl_sr_bits[IPL_SOFT])
811.1Ssimonb
821.10Syamttypedef int ipl_t;
831.10Syamttypedef struct {
841.10Syamt	ipl_t _sr;
851.10Syamt} ipl_cookie_t;
861.10Syamt
871.10Syamtstatic inline ipl_cookie_t
881.10Syamtmakeiplcookie(ipl_t ipl)
891.10Syamt{
901.10Syamt
911.10Syamt	return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]};
921.10Syamt}
931.10Syamt
941.10Syamtstatic inline int
951.10Syamtsplraiseipl(ipl_cookie_t icookie)
961.10Syamt{
971.10Syamt
981.10Syamt	return _splraise(icookie._sr);
991.10Syamt}
1001.6Syamt
1011.6Syamt#include <sys/spl.h>
1021.6Syamt
1031.1Ssimonbstruct evbmips_intrhand {
1041.1Ssimonb	LIST_ENTRY(evbmips_intrhand) ih_q;
1051.1Ssimonb	int (*ih_func)(void *);
1061.1Ssimonb	void *ih_arg;
1071.1Ssimonb	int ih_irq;
1081.1Ssimonb};
1091.1Ssimonb
1101.5Stsutsui#include <mips/softintr.h>
1111.1Ssimonb
1121.1Ssimonbvoid	evbmips_intr_init(void);
1131.1Ssimonbvoid	intr_init(void);
1141.7Sgdamorevoid	evbmips_iointr(uint32_t, uint32_t, uint32_t, uint32_t);
1151.1Ssimonbvoid	*evbmips_intr_establish(int, int (*)(void *), void *);
1161.1Ssimonbvoid	evbmips_intr_disestablish(void *);
1171.1Ssimonb#endif /* _KERNEL */
1181.1Ssimonb#endif /* ! _EVBMIPS_INTR_H_ */
119