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