Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.27
      1  1.27      yamt /*	$NetBSD: intr.h,v 1.27 2006/12/21 15:55:24 yamt Exp $	*/
      2   1.2     perry 
      3   1.3  jonathan /*
      4   1.3  jonathan  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
      5   1.3  jonathan  *
      6   1.3  jonathan  * Redistribution and use in source and binary forms, with or without
      7   1.3  jonathan  * modification, are permitted provided that the following conditions
      8   1.3  jonathan  * are met:
      9   1.3  jonathan  * 1. Redistributions of source code must retain the above copyright
     10   1.3  jonathan  *    notice, this list of conditions and the following disclaimer.
     11   1.3  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.3  jonathan  *    notice, this list of conditions and the following disclaimer in the
     13   1.3  jonathan  *    documentation and/or other materials provided with the distribution.
     14   1.3  jonathan  * 3. All advertising materials mentioning features or use of this software
     15   1.3  jonathan  *    must display the following acknowledgement:
     16   1.3  jonathan  *	This product includes software developed by Jonathan Stone for
     17   1.3  jonathan  *      the NetBSD Project.
     18   1.3  jonathan  * 4. The name of the author may not be used to endorse or promote products
     19   1.3  jonathan  *    derived from this software without specific prior written permission.
     20   1.3  jonathan  *
     21   1.3  jonathan  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.3  jonathan  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.3  jonathan  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.3  jonathan  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.3  jonathan  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.3  jonathan  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.3  jonathan  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.3  jonathan  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.3  jonathan  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.3  jonathan  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.3  jonathan  */
     32   1.1  jonathan 
     33   1.1  jonathan #ifndef _PMAX_INTR_H_
     34   1.1  jonathan #define _PMAX_INTR_H_
     35   1.4  jonathan 
     36  1.21  nisimura #include <sys/device.h>
     37  1.21  nisimura #include <sys/lock.h>
     38  1.21  nisimura #include <sys/queue.h>
     39  1.21  nisimura 
     40   1.4  jonathan #define	IPL_NONE	0	/* disable only this interrupt */
     41  1.21  nisimura #define	IPL_SOFT	1	/* generic software interrupts (SI 0) */
     42  1.21  nisimura #define	IPL_SOFTCLOCK	2	/* clock software interrupts (SI 0) */
     43  1.21  nisimura #define	IPL_SOFTNET	3	/* network software interrupts (SI 1) */
     44  1.21  nisimura #define	IPL_SOFTSERIAL	4	/* serial software interrupts (SI 1) */
     45  1.21  nisimura #define	IPL_BIO		5	/* disable block I/O interrupts */
     46  1.21  nisimura #define	IPL_NET		6	/* disable network interrupts */
     47  1.21  nisimura #define	IPL_TTY		7	/* disable terminal interrupts */
     48  1.27      yamt #define	IPL_VM		8
     49  1.27      yamt #define	IPL_SERIAL	IPL_TTY	/* disable serial interrupts */
     50  1.27      yamt #define	IPL_CLOCK	9	/* disable clock interrupts */
     51  1.27      yamt #define	IPL_STATCLOCK	10
     52  1.27      yamt #define	IPL_HIGH	IPL_STATCLOCK /* disable all interrupts */
     53  1.27      yamt #define	IPL_SCHED	IPL_HIGH
     54  1.27      yamt #define	IPL_LOCK	IPL_HIGH
     55   1.4  jonathan 
     56  1.27      yamt #define	_IPL_N		11
     57  1.21  nisimura 
     58  1.21  nisimura #define	_IPL_SI0_FIRST	IPL_SOFT
     59  1.21  nisimura #define	_IPL_SI0_LAST	IPL_SOFTCLOCK
     60  1.21  nisimura 
     61  1.21  nisimura #define	_IPL_SI1_FIRST	IPL_SOFTNET
     62  1.21  nisimura #define	_IPL_SI1_LAST	IPL_SOFTSERIAL
     63  1.21  nisimura 
     64  1.27      yamt /* Soft interrupt numbers. */
     65  1.27      yamt #define	SI_SOFT		0	/* generic software interrupts */
     66  1.27      yamt #define	SI_SOFTSERIAL	1	/* serial software interrupts */
     67  1.27      yamt #define	SI_SOFTNET	2	/* network software interrupts */
     68  1.27      yamt #define	SI_SOFTCLOCK	3	/* clock software interrupts */
     69  1.27      yamt 
     70  1.27      yamt #define	SI_NQUEUES	4
     71  1.27      yamt 
     72  1.27      yamt #define	SI_QUEUENAMES {							\
     73  1.21  nisimura 	"misc",								\
     74  1.27      yamt 	"serial",							\
     75  1.27      yamt 	"net",								\
     76  1.21  nisimura 	"clock",							\
     77  1.21  nisimura }
     78  1.21  nisimura 
     79   1.5  nisimura #ifdef _KERNEL
     80   1.5  nisimura #ifndef _LOCORE
     81   1.5  nisimura 
     82   1.6  nisimura #include <mips/cpuregs.h>
     83   1.6  nisimura 
     84   1.9    simonb int	_splraise __P((int));
     85   1.9    simonb int	_spllower __P((int));
     86   1.9    simonb int	_splset __P((int));
     87   1.9    simonb int	_splget __P((void));
     88   1.9    simonb void	_splnone __P((void));
     89   1.9    simonb void	_setsoftintr __P((int));
     90   1.9    simonb void	_clrsoftintr __P((int));
     91   1.6  nisimura 
     92   1.6  nisimura #define splhigh()	_splraise(MIPS_INT_MASK)
     93   1.6  nisimura #define spl0()		(void)_spllower(0)
     94   1.6  nisimura #define splx(s)		(void)_splset(s)
     95  1.27      yamt #define splbio()	splraiseipl(makeiplcookie(IPL_BIO))
     96  1.27      yamt #define splnet()	splraiseipl(makeiplcookie(IPL_NET))
     97  1.27      yamt #define spltty()	splraiseipl(makeiplcookie(IPL_TTY))
     98  1.27      yamt #define	splserial()	spltty()
     99  1.27      yamt #define splvm()		splraiseipl(makeiplcookie(IPL_VM))
    100  1.27      yamt #define splclock()	splraiseipl(makeiplcookie(IPL_CLOCK))
    101  1.27      yamt #define splstatclock()	splraiseipl(makeiplcookie(IPL_STATCLOCK))
    102   1.8   thorpej #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_0)
    103  1.16   thorpej 
    104  1.16   thorpej #define	splsched()	splhigh()
    105  1.17   thorpej #define	spllock()	splhigh()
    106   1.6  nisimura 
    107  1.27      yamt #define	_SPL_SOFT	MIPS_SOFT_INT_MASK_0
    108  1.27      yamt #define	_SPL_SOFTCLOCK	MIPS_SOFT_INT_MASK_0
    109  1.27      yamt #define	_SPL_SOFTNET	(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    110  1.27      yamt #define	_SPL_SOFTSERIAL	(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    111  1.27      yamt 
    112  1.27      yamt #define splsoft()	_splraise(_SPL_SOFT)
    113  1.27      yamt #define splsoftclock()	_splraise(_SPL_SOFTCLOCK)
    114  1.27      yamt #define splsoftnet()	_splraise(_SPL_SOFTNET)
    115  1.27      yamt #define splsoftserial()	_splraise(_SPL_SOFTSERIAL)
    116  1.27      yamt 
    117  1.27      yamt extern const int *ipl2spl_table;
    118  1.27      yamt 
    119  1.27      yamt typedef int ipl_t;
    120  1.27      yamt typedef struct {
    121  1.27      yamt 	int _spl;
    122  1.27      yamt } ipl_cookie_t;
    123  1.27      yamt 
    124  1.27      yamt ipl_cookie_t makeiplcookie(ipl_t);
    125  1.27      yamt 
    126  1.27      yamt static inline int
    127  1.27      yamt splraiseipl(ipl_cookie_t icookie)
    128  1.27      yamt {
    129  1.27      yamt 
    130  1.27      yamt 	return _splraise(icookie._spl);
    131  1.27      yamt }
    132   1.6  nisimura 
    133   1.6  nisimura /* Conventionals ... */
    134   1.6  nisimura 
    135   1.6  nisimura #define MIPS_SPLHIGH (MIPS_INT_MASK)
    136   1.6  nisimura #define MIPS_SPL0 (MIPS_INT_MASK_0|MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    137   1.6  nisimura #define MIPS_SPL1 (MIPS_INT_MASK_1|MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    138   1.6  nisimura #define MIPS_SPL3 (MIPS_INT_MASK_3|MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    139   1.6  nisimura #define MIPS_SPL_0_1	 (MIPS_INT_MASK_1|MIPS_SPL0)
    140   1.6  nisimura #define MIPS_SPL_0_1_2	 (MIPS_INT_MASK_2|MIPS_SPL_0_1)
    141   1.6  nisimura #define MIPS_SPL_0_1_3	 (MIPS_INT_MASK_3|MIPS_SPL_0_1)
    142   1.6  nisimura #define MIPS_SPL_0_1_2_3 (MIPS_INT_MASK_3|MIPS_SPL_0_1_2)
    143   1.3  jonathan 
    144  1.11    simonb struct intrhand {
    145  1.11    simonb 	int	(*ih_func) __P((void *));
    146  1.11    simonb 	void	*ih_arg;
    147  1.25    simonb 	struct evcnt ih_count;
    148  1.11    simonb };
    149  1.11    simonb extern struct intrhand intrtab[];
    150  1.11    simonb 
    151  1.25    simonb #define SYS_DEV_SCC0	0
    152  1.25    simonb #define SYS_DEV_SCC1	1
    153  1.25    simonb #define SYS_DEV_LANCE	2
    154  1.25    simonb #define SYS_DEV_SCSI	3
    155  1.25    simonb #define SYS_DEV_OPT0	4
    156  1.25    simonb #define SYS_DEV_OPT1	5
    157  1.25    simonb #define SYS_DEV_OPT2	6
    158  1.25    simonb #define SYS_DEV_DTOP	7
    159  1.25    simonb #define SYS_DEV_ISDN	8
    160  1.25    simonb #define SYS_DEV_FDC	9
    161  1.12  nisimura #define SYS_DEV_BOGUS	-1
    162  1.23  nisimura #define MAX_DEV_NCOOKIES 10
    163  1.23  nisimura 
    164  1.15  nisimura 
    165  1.21  nisimura struct pmax_intrhand {
    166  1.21  nisimura 	LIST_ENTRY(pmax_intrhand) ih_q;
    167  1.21  nisimura 	int (*ih_func)(void *);
    168  1.21  nisimura 	void *ih_arg;
    169  1.21  nisimura };
    170  1.21  nisimura 
    171  1.24   tsutsui #include <mips/softintr.h>
    172  1.15  nisimura 
    173  1.21  nisimura extern struct evcnt pmax_clock_evcnt;
    174  1.21  nisimura extern struct evcnt pmax_fpu_evcnt;
    175  1.23  nisimura extern struct evcnt pmax_memerr_evcnt;
    176   1.5  nisimura 
    177  1.25    simonb void intr_init(void);
    178   1.5  nisimura #endif /* !_LOCORE */
    179   1.5  nisimura #endif /* _KERNEL */
    180   1.3  jonathan 
    181  1.10        ad #endif	/* !_PMAX_INTR_H_ */
    182