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