Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.8
      1 /*	$NetBSD: intr.h,v 1.8 2007/12/03 15:33:47 ad 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_SOFTCLOCK	1	/* software clock interrupt */
     46 #define	IPL_SOFTBIO	2	/* generic software interrupts */
     47 #define	IPL_SOFTNET	3	/* software network interrupt */
     48 #define	IPL_SOFTSERIAL	4	/* software serial interrupt */
     49 #define	IPL_VM		5	/* memory allocation */
     50 #define	IPL_SCHED	6	/* scheduler */
     51 #define	IPL_HIGH	6	/* everything */
     52 
     53 #define	NIPL		7
     54 
     55 /* Interrupt sharing types. */
     56 #define	IST_NONE	0	/* none */
     57 #define	IST_PULSE	1	/* pulsed */
     58 #define	IST_EDGE	2	/* edge-triggered */
     59 #define	IST_LEVEL	3	/* level-triggered */
     60 
     61 #define IST_LEVEL_LOW	 IST_LEVEL
     62 #define IST_LEVEL_HIGH   4
     63 #define IST_EDGE_FALLING IST_EDGE
     64 #define IST_EDGE_RISING  5
     65 #define IST_EDGE_BOTH    6
     66 
     67 #define	__NEWINTR	/* enables new hooks in cpu_fork()/cpu_switch() */
     68 
     69 #ifndef _LOCORE
     70 
     71 #if defined(_LKM)
     72 
     73 int	_splraise(int);
     74 int	_spllower(int);
     75 void	splx(int);
     76 void	_setsoftintr(int);
     77 
     78 #else	/* _LKM */
     79 
     80 #include "opt_arm_intr_impl.h"
     81 
     82 #if defined(ARM_INTR_IMPL)
     83 
     84 /*
     85  * Each board needs to define the following functions:
     86  *
     87  * int	_splraise(int);
     88  * int	_spllower(int);
     89  * void	splx(int);
     90  * void	_setsoftintr(int);
     91  *
     92  * These may be defined as functions, static inline functions, or macros,
     93  * but there must be a _spllower() and splx() defined as functions callable
     94  * from assembly language (for cpu_switch()).  However, since it's quite
     95  * useful to be able to inline splx(), you could do something like the
     96  * following:
     97  *
     98  * in <boardtype>_intr.h:
     99  * 	static inline int
    100  *	boardtype_splx(int spl)
    101  *	{...}
    102  *
    103  *	#define splx(nspl)	boardtype_splx(nspl)
    104  *	...
    105  * and in boardtype's machdep code:
    106  *
    107  *	...
    108  *	#undef splx
    109  *	int
    110  *	splx(int spl)
    111  *	{
    112  *		return boardtype_splx(spl);
    113  *	}
    114  */
    115 
    116 #include ARM_INTR_IMPL
    117 
    118 #else /* ARM_INTR_IMPL */
    119 
    120 #error ARM_INTR_IMPL not defined.
    121 
    122 #endif	/* ARM_INTR_IMPL */
    123 
    124 #endif /* _LKM */
    125 
    126 typedef uint8_t ipl_t;
    127 typedef struct {
    128 	ipl_t _ipl;
    129 } ipl_cookie_t;
    130 
    131 static inline ipl_cookie_t
    132 makeiplcookie(ipl_t ipl)
    133 {
    134 
    135 	return (ipl_cookie_t){._ipl = ipl};
    136 }
    137 
    138 static inline int
    139 splraiseipl(ipl_cookie_t icookie)
    140 {
    141 
    142 	return _splraise(icookie._ipl);
    143 }
    144 
    145 #define	spl0()		_spllower(IPL_NONE)
    146 
    147 #include <sys/spl.h>
    148 
    149 #include <arm/softintr.h>
    150 
    151 #endif /* ! _LOCORE */
    152 
    153 #endif /* _KERNEL */
    154 
    155 #endif	/* _IYONIX_INTR_H_ */
    156