Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.1
      1 /*	$NetBSD: intr.h,v 1.1 2004/10/13 23:28:36 gavan Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2001, 2003 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed for the NetBSD Project by
     20  *	Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 #ifndef	_IYONIX_INTR_H_
     39 #define	_IYONIX_INTR_H_
     40 
     41 #ifdef _KERNEL
     42 
     43 /* Interrupt priority "levels". */
     44 #define	IPL_NONE	0	/* nothing */
     45 #define	IPL_SOFT	1	/* generic software interrupts */
     46 #define	IPL_SOFTCLOCK	2	/* software clock interrupt */
     47 #define	IPL_SOFTNET	3	/* software network interrupt */
     48 #define	IPL_BIO		4	/* block I/O */
     49 #define	IPL_NET		5	/* network */
     50 #define	IPL_SOFTSERIAL	6	/* software serial interrupt */
     51 #define	IPL_TTY		7	/* terminals */
     52 #define	IPL_VM		8	/* memory allocation */
     53 #define	IPL_AUDIO	9	/* audio device */
     54 #define	IPL_CLOCK	10	/* clock interrupt */
     55 #define	IPL_STATCLOCK	11	/* statistics clock interrupt */
     56 #define	IPL_HIGH	12	/* everything */
     57 #define	IPL_SERIAL	13	/* serial device */
     58 
     59 #define	NIPL		14
     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 #define IST_LEVEL_LOW	 IST_LEVEL
     68 #define IST_LEVEL_HIGH   4
     69 #define IST_EDGE_FALLING IST_EDGE
     70 #define IST_EDGE_RISING  5
     71 #define IST_EDGE_BOTH    6
     72 
     73 #define	__NEWINTR	/* enables new hooks in cpu_fork()/cpu_switch() */
     74 
     75 #ifndef _LOCORE
     76 
     77 #include <sys/device.h>
     78 #include <sys/queue.h>
     79 
     80 #if defined(_LKM)
     81 
     82 int	_splraise(int);
     83 int	_spllower(int);
     84 void	splx(int);
     85 void	_setsoftintr(int);
     86 
     87 #else	/* _LKM */
     88 
     89 #include "opt_arm_intr_impl.h"
     90 
     91 #if defined(ARM_INTR_IMPL)
     92 
     93 /*
     94  * Each board needs to define the following functions:
     95  *
     96  * int	_splraise(int);
     97  * int	_spllower(int);
     98  * void	splx(int);
     99  * void	_setsoftintr(int);
    100  *
    101  * These may be defined as functions, static __inline functions, or macros,
    102  * but there must be a _spllower() and splx() defined as functions callable
    103  * from assembly language (for cpu_switch()).  However, since it's quite
    104  * useful to be able to inline splx(), you could do something like the
    105  * following:
    106  *
    107  * in <boardtype>_intr.h:
    108  * 	static __inline int
    109  *	boardtype_splx(int spl)
    110  *	{...}
    111  *
    112  *	#define splx(nspl)	boardtype_splx(nspl)
    113  *	...
    114  * and in boardtype's machdep code:
    115  *
    116  *	...
    117  *	#undef splx
    118  *	int
    119  *	splx(int spl)
    120  *	{
    121  *		return boardtype_splx(spl);
    122  *	}
    123  */
    124 
    125 #include ARM_INTR_IMPL
    126 
    127 #else /* ARM_INTR_IMPL */
    128 
    129 #error ARM_INTR_IMPL not defined.
    130 
    131 #endif	/* ARM_INTR_IMPL */
    132 
    133 #endif /* _LKM */
    134 
    135 #define	splhigh()	_splraise(IPL_HIGH)
    136 #define	splsoft()	_splraise(IPL_SOFT)
    137 #define	splsoftclock()	_splraise(IPL_SOFTCLOCK)
    138 #define	splsoftnet()	_splraise(IPL_SOFTNET)
    139 #define	splbio()	_splraise(IPL_BIO)
    140 #define	splnet()	_splraise(IPL_NET)
    141 #define	spltty()	_splraise(IPL_TTY)
    142 #define	splvm()		_splraise(IPL_VM)
    143 #define	splaudio()	_splraise(IPL_AUDIO)
    144 #define	splclock()	_splraise(IPL_CLOCK)
    145 #define	splstatclock()	_splraise(IPL_STATCLOCK)
    146 #define	splserial()	_splraise(IPL_SERIAL)
    147 
    148 #define	spl0()		_spllower(IPL_NONE)
    149 #define	spllowersoftclock() _spllower(IPL_SOFTCLOCK)
    150 
    151 #define	splsched()	splhigh()
    152 #define	spllock()	splhigh()
    153 
    154 /* Use generic software interrupt support. */
    155 #include <arm/softintr.h>
    156 
    157 #endif /* ! _LOCORE */
    158 
    159 #endif /* _KERNEL */
    160 
    161 #endif	/* _IYONIX_INTR_H_ */
    162