Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.20
      1  1.20  tsutsui /*	$NetBSD: intr.h,v 1.20 2007/06/17 06:04:29 tsutsui Exp $	*/
      2   1.1   tsubai 
      3  1.13  tsutsui /*-
      4  1.13  tsutsui  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
      5  1.13  tsutsui  * All rights reserved.
      6  1.13  tsutsui  *
      7  1.13  tsutsui  * This code is derived from software contributed to The NetBSD Foundation
      8  1.13  tsutsui  * by Jason R. Thorpe.
      9   1.1   tsubai  *
     10   1.1   tsubai  * Redistribution and use in source and binary forms, with or without
     11   1.1   tsubai  * modification, are permitted provided that the following conditions
     12   1.1   tsubai  * are met:
     13   1.1   tsubai  * 1. Redistributions of source code must retain the above copyright
     14   1.1   tsubai  *    notice, this list of conditions and the following disclaimer.
     15   1.1   tsubai  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1   tsubai  *    notice, this list of conditions and the following disclaimer in the
     17   1.1   tsubai  *    documentation and/or other materials provided with the distribution.
     18   1.1   tsubai  * 3. All advertising materials mentioning features or use of this software
     19   1.1   tsubai  *    must display the following acknowledgement:
     20  1.13  tsutsui  *	This product includes software developed by the NetBSD
     21  1.13  tsutsui  *	Foundation, Inc. and its contributors.
     22  1.13  tsutsui  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.13  tsutsui  *    contributors may be used to endorse or promote products derived
     24  1.13  tsutsui  *    from this software without specific prior written permission.
     25   1.1   tsubai  *
     26  1.13  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.13  tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.13  tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.13  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.13  tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.13  tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.13  tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.13  tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.13  tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.13  tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.13  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1   tsubai  */
     38   1.1   tsubai 
     39   1.1   tsubai #ifndef _MACHINE_INTR_H_
     40   1.1   tsubai #define _MACHINE_INTR_H_
     41   1.1   tsubai 
     42   1.4   tsubai #define IPL_NONE	0	/* disable only this interrupt */
     43  1.13  tsutsui #define IPL_SOFT	1	/* generic software interrupts (SI 0) */
     44  1.13  tsutsui #define IPL_SOFTCLOCK	2	/* clock software interrupts (SI 0) */
     45  1.13  tsutsui #define IPL_SOFTNET	3	/* network software interrupts (SI 1) */
     46  1.13  tsutsui #define IPL_SOFTSERIAL	4	/* serial software interrupts (SI 1) */
     47  1.13  tsutsui #define IPL_BIO		5	/* disable block I/O interrupts */
     48  1.13  tsutsui #define IPL_NET		6	/* disable network interrupts */
     49  1.13  tsutsui #define IPL_TTY		7	/* disable terminal interrupts */
     50  1.18     yamt #define	IPL_LPT		IPL_TTY
     51  1.18     yamt #define	IPL_VM		IPL_TTY
     52  1.13  tsutsui #define IPL_SERIAL	7	/* disable serial hardware interrupts */
     53  1.13  tsutsui #define IPL_CLOCK	8	/* disable clock interrupts */
     54  1.18     yamt #define	IPL_STATCLOCK	IPL_CLOCK
     55  1.18     yamt #define	IPL_SCHED	IPL_CLOCK
     56  1.13  tsutsui #define IPL_HIGH	8	/* disable all interrupts */
     57  1.18     yamt #define	IPL_LOCK	IPL_HIGH
     58  1.13  tsutsui 
     59  1.13  tsutsui #define _IPL_N		9
     60  1.13  tsutsui 
     61  1.13  tsutsui #define _IPL_SI0_FIRST	IPL_SOFT
     62  1.13  tsutsui #define _IPL_SI0_LAST	IPL_SOFTCLOCK
     63  1.13  tsutsui 
     64  1.13  tsutsui #define _IPL_SI1_FIRST	IPL_SOFTNET
     65  1.13  tsutsui #define _IPL_SI1_LAST	IPL_SOFTSERIAL
     66  1.13  tsutsui 
     67  1.18     yamt #define	SI_SOFT		0
     68  1.18     yamt #define	SI_SOFTCLOCK	1
     69  1.18     yamt #define	SI_SOFTNET	2
     70  1.18     yamt #define	SI_SOFTSERIAL	3
     71  1.18     yamt 
     72  1.18     yamt #define	SI_NQUEUES	4
     73  1.18     yamt 
     74  1.18     yamt #define	SI_QUEUENAMES {							\
     75  1.13  tsutsui 	"misc",								\
     76  1.13  tsutsui 	"clock",							\
     77  1.13  tsutsui 	"net",								\
     78  1.13  tsutsui 	"serial",							\
     79  1.13  tsutsui }
     80   1.2   tsubai 
     81   1.4   tsubai #ifdef _KERNEL
     82   1.2   tsubai #ifndef _LOCORE
     83  1.13  tsutsui 
     84  1.12  tsutsui #include <sys/device.h>
     85  1.20  tsutsui #include <mips/locore.h>
     86  1.13  tsutsui 
     87  1.15  tsutsui extern const uint32_t ipl_sr_bits[_IPL_N];
     88   1.2   tsubai 
     89   1.4   tsubai #define spl0()		(void)_spllower(0)
     90   1.4   tsubai #define splx(s)		(void)_splset(s)
     91  1.13  tsutsui 
     92  1.13  tsutsui #define splsoft()	_splraise(ipl_sr_bits[IPL_SOFT])
     93  1.13  tsutsui 
     94  1.18     yamt typedef int ipl_t;
     95  1.18     yamt typedef struct {
     96  1.18     yamt 	ipl_t _sr;
     97  1.18     yamt } ipl_cookie_t;
     98  1.18     yamt 
     99  1.18     yamt static inline ipl_cookie_t
    100  1.18     yamt makeiplcookie(ipl_t ipl)
    101  1.18     yamt {
    102  1.18     yamt 
    103  1.18     yamt 	return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]};
    104  1.18     yamt }
    105  1.18     yamt 
    106  1.18     yamt static inline int
    107  1.18     yamt splraiseipl(ipl_cookie_t icookie)
    108  1.18     yamt {
    109  1.18     yamt 
    110  1.18     yamt 	return _splraise(icookie._sr);
    111  1.18     yamt }
    112  1.18     yamt 
    113  1.18     yamt #include <sys/spl.h>
    114  1.18     yamt 
    115  1.12  tsutsui struct newsmips_intrhand {
    116  1.12  tsutsui 	LIST_ENTRY(newsmips_intrhand) ih_q;
    117  1.12  tsutsui 	struct evcnt intr_count;
    118  1.12  tsutsui 	int (*ih_func)(void *);
    119  1.12  tsutsui 	void *ih_arg;
    120  1.12  tsutsui 	u_int ih_level;
    121  1.12  tsutsui 	u_int ih_mask;
    122  1.12  tsutsui 	u_int ih_priority;
    123  1.12  tsutsui };
    124  1.12  tsutsui 
    125  1.12  tsutsui struct newsmips_intr {
    126  1.12  tsutsui 	LIST_HEAD(,newsmips_intrhand) intr_q;
    127  1.12  tsutsui };
    128   1.1   tsubai 
    129  1.13  tsutsui #include <mips/softintr.h>
    130  1.13  tsutsui 
    131   1.1   tsubai /*
    132   1.1   tsubai  * Index into intrcnt[], which is defined in locore
    133   1.1   tsubai  */
    134  1.13  tsutsui #define SERIAL0_INTR	0
    135  1.13  tsutsui #define SERIAL1_INTR	1
    136  1.13  tsutsui #define SERIAL2_INTR	2
    137  1.13  tsutsui #define LANCE_INTR	3
    138  1.13  tsutsui #define SCSI_INTR	4
    139  1.13  tsutsui #define ERROR_INTR	5
    140  1.13  tsutsui #define HARDCLOCK_INTR	6
    141  1.13  tsutsui #define FPU_INTR	7
    142  1.13  tsutsui #define SLOT1_INTR	8
    143  1.13  tsutsui #define SLOT2_INTR	9
    144  1.13  tsutsui #define SLOT3_INTR	10
    145  1.13  tsutsui #define FLOPPY_INTR	11
    146  1.13  tsutsui #define STRAY_INTR	12
    147   1.1   tsubai 
    148   1.2   tsubai extern u_int intrcnt[];
    149   1.1   tsubai 
    150   1.2   tsubai /* handle i/o device interrupts */
    151  1.13  tsutsui #ifdef news3400
    152  1.16  tsutsui void news3400_intr(uint32_t, uint32_t, uint32_t, uint32_t);
    153  1.13  tsutsui #endif
    154  1.13  tsutsui #ifdef news5000
    155  1.16  tsutsui void news5000_intr(uint32_t, uint32_t, uint32_t, uint32_t);
    156  1.13  tsutsui #endif
    157  1.16  tsutsui extern void (*hardware_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
    158   1.5   tsubai 
    159  1.15  tsutsui extern void (*enable_intr)(void);
    160  1.15  tsutsui extern void (*disable_intr)(void);
    161  1.15  tsutsui extern void (*enable_timer)(void);
    162   1.4   tsubai 
    163   1.2   tsubai #endif /* !_LOCORE */
    164   1.4   tsubai #endif /* _KERNEL */
    165   1.1   tsubai #endif /* _MACHINE_INTR_H_ */
    166