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