Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.23.4.1
      1  1.23.4.1     yamt /*	$NetBSD: intr.h,v 1.23.4.1 2006/09/23 08:52:19 yamt Exp $	*/
      2       1.6    soren 
      3       1.6    soren /*
      4       1.6    soren  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
      5       1.6    soren  *
      6       1.6    soren  * Redistribution and use in source and binary forms, with or without
      7       1.6    soren  * modification, are permitted provided that the following conditions
      8       1.6    soren  * are met:
      9       1.6    soren  * 1. Redistributions of source code must retain the above copyright
     10       1.6    soren  *    notice, this list of conditions, and the following disclaimer.
     11       1.6    soren  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.6    soren  *    notice, this list of conditions and the following disclaimer in the
     13       1.6    soren  *    documentation and/or other materials provided with the distribution.
     14       1.6    soren  *
     15       1.6    soren  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16       1.6    soren  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17       1.6    soren  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18       1.6    soren  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19       1.6    soren  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20       1.6    soren  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21       1.6    soren  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22       1.6    soren  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23       1.6    soren  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24       1.6    soren  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25       1.6    soren  * SUCH DAMAGE.
     26       1.6    soren  */
     27       1.1    soren 
     28      1.14  tsutsui #ifndef	_COBALT_INTR_H_
     29      1.14  tsutsui #define	_COBALT_INTR_H_
     30      1.14  tsutsui 
     31       1.1    soren #define	IPL_NONE	0	/* Disable only this interrupt. */
     32  1.23.4.1     yamt #define	IPL_SOFT	1	/* generic software interrupts */
     33  1.23.4.1     yamt #define	IPL_SOFTSERIAL	2	/* serial software interrupts */
     34  1.23.4.1     yamt #define	IPL_SOFTNET	3	/* network software interrupts */
     35  1.23.4.1     yamt #define	IPL_SOFTCLOCK	4	/* clock software interrupts */
     36  1.23.4.1     yamt #define	IPL_BIO		5	/* Disable block I/O interrupts. */
     37  1.23.4.1     yamt #define	IPL_NET		6	/* Disable network interrupts. */
     38  1.23.4.1     yamt #define	IPL_TTY		7	/* Disable terminal interrupts. */
     39  1.23.4.1     yamt #define	IPL_SERIAL	IPL_TTY	/* Disable serial hardware interrupts. */
     40  1.23.4.1     yamt #define	IPL_VM		8	/* Memory allocation */
     41  1.23.4.1     yamt #define	IPL_CLOCK	9	/* Disable clock interrupts. */
     42  1.23.4.1     yamt #define	IPL_STATCLOCK	10	/* Disable profiling interrupts. */
     43  1.23.4.1     yamt #define	IPL_HIGH	11	/* Disable all interrupts. */
     44  1.23.4.1     yamt #define	IPL_SCHED	IPL_HIGH
     45  1.23.4.1     yamt #define	IPL_LOCK	IPL_HIGH
     46  1.23.4.1     yamt #define NIPL		12
     47       1.1    soren 
     48       1.1    soren /* Interrupt sharing types. */
     49       1.1    soren #define IST_NONE	0	/* none */
     50       1.1    soren #define IST_PULSE	1	/* pulsed */
     51       1.1    soren #define IST_EDGE	2	/* edge-triggered */
     52       1.1    soren #define IST_LEVEL	3	/* level-triggered */
     53       1.1    soren 
     54      1.15  tsutsui /* Soft interrupt numbers. */
     55  1.23.4.1     yamt #define	SI_SOFT		0	/* generic software interrupts */
     56  1.23.4.1     yamt #define	SI_SOFTSERIAL	1	/* serial software interrupts */
     57  1.23.4.1     yamt #define	SI_SOFTNET	2	/* network software interrupts */
     58  1.23.4.1     yamt #define	SI_SOFTCLOCK	3	/* clock software interrupts */
     59      1.15  tsutsui 
     60  1.23.4.1     yamt #define	SI_NQUEUES	4
     61  1.23.4.1     yamt 
     62  1.23.4.1     yamt #define	SI_QUEUENAMES {							\
     63      1.15  tsutsui 	"misc",								\
     64      1.15  tsutsui 	"serial",							\
     65      1.15  tsutsui 	"net",								\
     66      1.15  tsutsui 	"clock",							\
     67      1.15  tsutsui }
     68       1.5    soren 
     69       1.3    soren #ifdef _KERNEL
     70       1.1    soren #ifndef _LOCORE
     71       1.5    soren 
     72      1.20  tsutsui #include <sys/device.h>
     73       1.5    soren #include <mips/cpuregs.h>
     74       1.1    soren 
     75      1.18  tsutsui int  _splraise(int);
     76      1.18  tsutsui int  _spllower(int);
     77      1.18  tsutsui int  _splset(int);
     78      1.18  tsutsui int  _splget(void);
     79      1.18  tsutsui void _splnone(void);
     80      1.18  tsutsui void _setsoftintr(int);
     81      1.18  tsutsui void _clrsoftintr(int);
     82       1.1    soren 
     83       1.1    soren #define splhigh()       _splraise(MIPS_INT_MASK)
     84       1.1    soren #define spl0()          (void)_spllower(0)
     85       1.1    soren #define splx(s)         (void)_splset(s)
     86      1.15  tsutsui #define SPLSOFT		(MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1)
     87      1.15  tsutsui #define SPLBIO		(SPLSOFT | MIPS_INT_MASK_4)
     88      1.15  tsutsui #define SPLNET		(SPLBIO | MIPS_INT_MASK_1 | MIPS_INT_MASK_2)
     89      1.15  tsutsui #define SPLTTY		(SPLNET | MIPS_INT_MASK_3)
     90      1.15  tsutsui #define SPLCLOCK	(SPLTTY | MIPS_INT_MASK_0 | MIPS_INT_MASK_5)
     91      1.15  tsutsui #define splbio()	_splraise(SPLBIO)
     92      1.15  tsutsui #define splnet()	_splraise(SPLNET)
     93      1.15  tsutsui #define spltty()	_splraise(SPLTTY)
     94      1.17  tsutsui #define spllpt()	spltty()
     95      1.15  tsutsui #define splserial()	_splraise(SPLTTY)
     96      1.15  tsutsui #define splclock()	_splraise(SPLCLOCK)
     97       1.9  thorpej #define splvm()		splclock()
     98      1.15  tsutsui #define splstatclock()	splclock()
     99       1.3    soren #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_0)
    100       1.7  thorpej 
    101       1.7  thorpej #define	splsched()	splhigh()
    102       1.8  thorpej #define	spllock()	splhigh()
    103       1.1    soren 
    104      1.15  tsutsui #define splsoft()	_splraise(MIPS_SOFT_INT_MASK_0)
    105      1.15  tsutsui #define splsoftclock()	_splraise(MIPS_SOFT_INT_MASK_0)
    106      1.15  tsutsui #define splsoftnet()	_splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    107      1.15  tsutsui #define splsoftserial()	_splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
    108      1.15  tsutsui 
    109  1.23.4.1     yamt typedef int ipl_t;
    110  1.23.4.1     yamt typedef struct {
    111  1.23.4.1     yamt 	int _spl;
    112  1.23.4.1     yamt } ipl_cookie_t;
    113  1.23.4.1     yamt 
    114  1.23.4.1     yamt ipl_cookie_t makeiplcookie(ipl_t);
    115  1.23.4.1     yamt 
    116  1.23.4.1     yamt static inline int
    117  1.23.4.1     yamt splraiseipl(ipl_cookie_t icookie)
    118  1.23.4.1     yamt {
    119  1.23.4.1     yamt 
    120  1.23.4.1     yamt 	return _splraise(icookie._spl);
    121  1.23.4.1     yamt }
    122  1.23.4.1     yamt 
    123      1.15  tsutsui struct cobalt_intrhand {
    124      1.15  tsutsui 	LIST_ENTRY(cobalt_intrhand) ih_q;
    125      1.15  tsutsui 	int (*ih_func)(void *);
    126      1.15  tsutsui 	void *ih_arg;
    127      1.21  tsutsui 	int ih_type;
    128      1.19  tsutsui 	int ih_cookie_type;
    129      1.15  tsutsui #define	COBALT_COOKIE_TYPE_CPU	0x1
    130      1.15  tsutsui #define	COBALT_COOKIE_TYPE_ICU	0x2
    131      1.20  tsutsui 
    132      1.20  tsutsui 	struct evcnt ih_evcnt;
    133      1.20  tsutsui 	char ih_evname[32];
    134      1.15  tsutsui };
    135      1.15  tsutsui 
    136      1.15  tsutsui #include <mips/softintr.h>
    137      1.15  tsutsui 
    138      1.15  tsutsui void *cpu_intr_establish(int, int, int (*)(void *), void *);
    139      1.15  tsutsui void *icu_intr_establish(int, int, int, int (*)(void *), void *);
    140      1.15  tsutsui void cpu_intr_disestablish(void *);
    141      1.15  tsutsui void icu_intr_disestablish(void *);
    142      1.21  tsutsui void icu_init(void);
    143       1.1    soren 
    144       1.3    soren #endif /* !_LOCORE */
    145       1.1    soren #endif /* _LOCORE */
    146      1.14  tsutsui 
    147      1.14  tsutsui #endif	/* !_COBALT_INTR_H_ */
    148