Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.32
      1  1.32  uebayasi /*	$NetBSD: intr.h,v 1.32 2008/10/01 02:44:14 uebayasi 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.29        ad #define	IPL_SOFTCLOCK	1	/* generic software interrupts */
     33  1.29        ad #define	IPL_SOFTBIO	1	/* clock software interrupts */
     34  1.29        ad #define	IPL_SOFTNET	2	/* network software interrupts */
     35  1.29        ad #define	IPL_SOFTSERIAL	2	/* serial software interrupts */
     36  1.29        ad #define	IPL_VM		3	/* Memory allocation */
     37  1.29        ad #define	IPL_SCHED	4	/* Disable clock interrupts. */
     38  1.29        ad #define	IPL_HIGH	4	/* Disable all interrupts. */
     39  1.29        ad #define NIPL		5
     40   1.1     soren 
     41   1.1     soren /* Interrupt sharing types. */
     42   1.1     soren #define IST_NONE	0	/* none */
     43   1.1     soren #define IST_PULSE	1	/* pulsed */
     44   1.1     soren #define IST_EDGE	2	/* edge-triggered */
     45   1.1     soren #define IST_LEVEL	3	/* level-triggered */
     46   1.1     soren 
     47   1.3     soren #ifdef _KERNEL
     48   1.1     soren #ifndef _LOCORE
     49   1.5     soren 
     50  1.30        ad #include <sys/evcnt.h>
     51   1.5     soren #include <mips/cpuregs.h>
     52  1.27   tsutsui #include <mips/locore.h>
     53   1.1     soren 
     54  1.29        ad #define SPLVM		(MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1 | \
     55  1.29        ad 			MIPS_INT_MASK_1 | MIPS_INT_MASK_2 | \
     56  1.29        ad 			MIPS_INT_MASK_3 | MIPS_INT_MASK_4)
     57  1.29        ad #define SPLSCHED	(SPLVM | MIPS_INT_MASK_5)
     58  1.29        ad 
     59   1.1     soren #define spl0()          (void)_spllower(0)
     60   1.1     soren #define splx(s)         (void)_splset(s)
     61  1.29        ad #define splvm()		_splraise(SPLVM)
     62  1.29        ad #define splsched()	_splraise(SPLSCHED)
     63  1.29        ad #define splhigh()       _splraise(MIPS_INT_MASK)
     64   1.1     soren 
     65  1.15   tsutsui #define splsoftclock()	_splraise(MIPS_SOFT_INT_MASK_0)
     66  1.29        ad #define splsoftbio()	_splraise(MIPS_SOFT_INT_MASK_0)
     67  1.15   tsutsui #define splsoftnet()	_splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
     68  1.15   tsutsui #define splsoftserial()	_splraise(MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
     69  1.15   tsutsui 
     70  1.24      yamt typedef int ipl_t;
     71  1.24      yamt typedef struct {
     72  1.24      yamt 	int _spl;
     73  1.24      yamt } ipl_cookie_t;
     74  1.24      yamt 
     75  1.24      yamt ipl_cookie_t makeiplcookie(ipl_t);
     76  1.24      yamt 
     77  1.24      yamt static inline int
     78  1.24      yamt splraiseipl(ipl_cookie_t icookie)
     79  1.24      yamt {
     80  1.24      yamt 
     81  1.24      yamt 	return _splraise(icookie._spl);
     82  1.24      yamt }
     83  1.24      yamt 
     84  1.31   tsutsui #define NCPU_INT	6
     85  1.31   tsutsui #define NICU_INT	16
     86  1.31   tsutsui 
     87  1.15   tsutsui struct cobalt_intrhand {
     88  1.15   tsutsui 	LIST_ENTRY(cobalt_intrhand) ih_q;
     89  1.15   tsutsui 	int (*ih_func)(void *);
     90  1.15   tsutsui 	void *ih_arg;
     91  1.31   tsutsui 	int ih_irq;
     92  1.19   tsutsui 	int ih_cookie_type;
     93  1.15   tsutsui #define	COBALT_COOKIE_TYPE_CPU	0x1
     94  1.15   tsutsui #define	COBALT_COOKIE_TYPE_ICU	0x2
     95  1.15   tsutsui };
     96  1.15   tsutsui 
     97  1.15   tsutsui #include <mips/softintr.h>
     98  1.15   tsutsui 
     99  1.31   tsutsui void intr_init(void);
    100  1.15   tsutsui void *cpu_intr_establish(int, int, int (*)(void *), void *);
    101  1.15   tsutsui void *icu_intr_establish(int, int, int, int (*)(void *), void *);
    102  1.15   tsutsui void cpu_intr_disestablish(void *);
    103  1.15   tsutsui void icu_intr_disestablish(void *);
    104   1.1     soren 
    105   1.3     soren #endif /* !_LOCORE */
    106  1.32  uebayasi #endif /* _KERNEL */
    107  1.14   tsutsui 
    108  1.14   tsutsui #endif	/* !_COBALT_INTR_H_ */
    109